-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hw6 #13
base: main
Are you sure you want to change the base?
Hw6 #13
Conversation
Test/TestsHw6.fs
Outdated
if Single.IsFinite(a) && Single.IsFinite(b) then | ||
abs (a - b) < epsilon | ||
elif Single.IsNaN(a) && Single.IsNaN(b) then | ||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А нельзя ли вот жто всё в одно логическое выражение записать?
Test/TestsHw6.fs
Outdated
elif Single.IsPositiveInfinity(a) && Single.IsPositiveInfinity(b) then | ||
true | ||
else | ||
false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Точно через форматтер гоняли?
Test/TestsHw6.fs
Outdated
member _.floatTest(tree: MyTree<float32>) = | ||
let treeList = MyTree.treeToList (MyTree.map id tree) | ||
let list = MyTree.treeToList tree | ||
Assert.True(List.forall2 (fun a b -> areAlmostEqual a b 1e-10f) list treeList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
При id есть погрешность?
Test/TestsHw6.fs
Outdated
let sum acc value = value + acc | ||
let actsum = MyTree.fold sum 0f tree | ||
let expsum = List.fold (fun x acc -> sum acc x) 0f (MyTree.treeToList tree) | ||
//Assert.True(areAlmostEqual actsum expsum 1e-10f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лишние комментарии?
|
||
[<Property>] | ||
member _.floatFoldTest(tree: MyTree<float32>) = | ||
let sum acc value = value + acc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавьте тесты, которые покажут, что с ассоциативностью и фолдами всё хорошо.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неплохо, но нужно провреить ещё и ассоциативность поэлементных операций.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если я правильно понял, то это проверка ассоциативности map-а?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нет. Речь именно про fold с операциями с различной ассоциативностью.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошо, сейчас поправлю
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Т.е., нужно проверить ассоциативность функции sum которую я написал?
И всё же, как проверить, что с операциями типа деления всё нормально? |
Сделал 6 домашку. Написал тип MyTree, где дерево может иметь произвольное количество сыновей с помощью библиотеки FsharpPlus. Также к этому типу были написаны map, fold, foldBack и height. Они были также протестированы с помощью свойств.