Repository navigation
Mandatory dtypes on dask-array - #1755
Conversation
- Make known `dtype` mandatory for all `dask.array.Array` objects - Still need to add inference to map_blocks/atop/reduction as needed.
- dtype must be specified to atop, due to difficulty of inference - infer dtype in elemwise and map_blocks
|
This could use a review. A summary of the changes:
Note that I still need to add some (direct) tests for the inference bits, but am waiting on feedback on the overall approach before doing that. |
|
I think we can add |
mrocklin
left a comment
There was a problem hiding this comment.
A cursory look through this seems good to me, although I haven't thoroughly reviewed the tricky atop inference bits.
| def _nonempty_data(x): | ||
| if isinstance(x, Array): | ||
| return np.ones((1,) * x.ndim, dtype=x.dtype) | ||
| return x |
There was a problem hiding this comment.
Does this work with struct dtypes?
There was a problem hiding this comment.
Yes, it just writes int/float/str 1s in all fields.
I'd slightly in favor of keeping them separate. The number of places where we emulate an operation in dask.array is very small, and the implementation is simple. In most cases array/dataframe are not mixable, so sharing the functionality seems less important to me. |
|
I would also be in favor of keeping This approach does seems pretty sensible. I'm pleased to see how easy it was to make dtypes mandatory. For dtype inference in |
I thought about that, but am not happy with that approach for a few reasons:
Overall, I'm comfortable saying that |
|
I agree, it's not too much trouble to ask for an output dtype in most cases. On Mon, Nov 7, 2016 at 10:32 AM, Jim Crist [email protected] wrote:
|
|
I think this is good to go now. |
Cased by changed in dask#1755 Fixes 6278
Cased by changed in #1755 Fixes 6278
Cased by changed in dask#1755 Fixes 6278
Previously
dask.arrayallowed known dtype to be optional, computing it dynamically as needed. This proved to be difficult to reason about, leading to unexpected computation (#1718). As done in #1422, we remove the optional dtype, falling back to inference if dtype isn't specified (if possible).dtypemandatory for alldask.array.ArrayobjectsFixes #1718