Raise NotImplementedError when operating with numpy arrays #294
Raise NotImplementedError when operating with numpy arrays #294mrocklin merged 4 commits intodask:masterfrom
Conversation
|
I should add an |
dask/array/core.py
Outdated
There was a problem hiding this comment.
I'm -1 on changes like this. I personally find the meaning of the list comprehensions to be more evident. However I recognize that this is subjective; I wouldn't object to new code being written this way but prefer it if we don't go out of our way to rewrite existing code.
I suggest adding an extra line ahead of the two list comprehensions with the following check:
if any(isinstance(arg, np.ndarray) for arg in args):
raise NotImplementedError("Dask.array operations only work on dask arrays, not numpy arrays.")This isolates the type checking code from splitting code.
There was a problem hiding this comment.
I rewrote this as one for loop to avoid looping over args three times. But this is really just a micro-optimization so I'll remove it.
|
This is a good start but doesn't fully close #290. Something like this would need to be done in all dask.array functions into which a user might put a numpy.array. This is a great start though that probably solves 60% of the problem. |
|
Or we could add multiple dispatch to NumPy. numpy/numpy#5844 (comment) |
|
@cowlicks |
Raise NotImplementedError when operating with numpy arrays
Closes #290
This also fixes a test which had the numpy array and dask array flipped.