-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle structured dtype in labeled_comprehension (#66)
* Type cast record values in `labeled_comprehension` Make sure that type casting within `labeled_comprehension` and associated utility functions handles record (a.k.a. structured) values in addition to typical scalar types. * Scalar arrays in _labeled_comprehension_delayed Instead of squeezing NumPy arrays into scalars when returning results from `_labeled_comprehension_delayed`, actually just return NumPy 0-D scalar arrays. These behave a little better in some cases (e.g. when a function returns a scalar array). * Use 1-D singleton array in `labeled_comprehension` To better handle structured type values that might be returned from the custom user function, coerce all results returned by `labeled_comprehension` into 1-D singleton arrays. As Dask Arrays seem to do a better job of handling structured types when they have some shape to them, this addresses returning structured types. * Adjust `labeled_comprehension` result handling Preallocate an array to store the result in `_labeled_comprehension_delayed`. Makes sure that writing into the `default` value doesn't happen by accident. Also makes sure that only scalar values are handled from custom user functions. As not enforcing these constraints may result in the computation breaking later in more confusing ways, explicit handling of them in `_labeled_comprehension_delayed` should point out to the user where they may have gone wrong. * Test `labeled_comprehension` with structured types Include a test using `labeled_comprehension` with structured dtypes.
- Loading branch information
Showing
3 changed files
with
77 additions
and
6 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