-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add argmin/max_skipnan and indexed_fold_skipnan (#33)
* Implement argmin_skipnan * Implement argmax_skipnan * Loosen the rule for argmin max related methods * Make returning code clearer * Add quickcheck for argmin_skipnan, argmax_skipnan * Use `fold` instead of `for` * Add indexed_fold_skipnan to MaybeNanExt * Impl argmin/max_skipnan using indexed_fold_skipnan * Fix argmin/max_skipnan quickcheck tests The old tests were incorrect because `min`/`max` return `None` when there are *any* NaN values (or the array is empty), while `argmin/max_skipnan` should return `None` only when *all* the values are NaNs (or the array is empty). This wasn't caught earlier because the `quickcheck::Arbitrary` implementation for `f32` generates only finite values. To make sure the behavior with NaN values is properly tested, the element type in the test has been changed to `Option<i32>`. * Replace min/max.map with if for clarity * Add () to make the match clearer
- Loading branch information
1 parent
7df0728
commit d838ee7
Showing
3 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters