Repository navigation
Conversation
| [(20, 20), (4, 5)], | ||
| ]) | ||
| @pytest.mark.parametrize("invert", [True, False]) | ||
| def test_isin_rand(seed, low, high, elements_shape, elements_chunks, |
There was a problem hiding this comment.
I need to skip these tests for old versions of NumPy.
There was a problem hiding this comment.
Seems reasonable (especially given isin was introduced in NumPy 1.13).
There should be some pytest.skip or @pytest.mark.skipif lines floating around that can be used.
jakirkham
left a comment
There was a problem hiding this comment.
Thanks @shoyer. Have been meaning to do this for a while. Guess you beat me to it. ;)
Looks pretty good. Had some questions about how test_elements factors into the result shape and a couple minor comments. Otherwise seems fine.
| @wraps(getattr(np, 'isin', None)) | ||
| def isin(element, test_elements, assume_unique=False, invert=False): | ||
| element = asarray(element) | ||
| test_elements = asarray(test_elements) |
There was a problem hiding this comment.
Are we ok with this as far as other libraries (e.g. xarray) are concerned?
There was a problem hiding this comment.
I think so? test_elements is just a set of elements to test against.
There was a problem hiding this comment.
FWIW I'm ok with it if you are. Was just reminded of issue ( #2912 ).
| d1 = da.from_array(a1, chunks=elements_chunks) | ||
|
|
||
| a2 = rng.randint(low, high, size=elements_shape) - 5 | ||
| d2 = da.from_array(a2, chunks=elements_chunks) |
There was a problem hiding this comment.
Should these be test_shape and test_chunks?
| @wraps(getattr(np, 'isin', None)) | ||
| def isin(element, test_elements, assume_unique=False, invert=False): | ||
| element = asarray(element) | ||
| test_elements = asarray(test_elements) |
There was a problem hiding this comment.
On a different point, it looks like NumPy's isin flattens the test_elements array first. This might simplify some of the chunk handling below and in the kernel function. Thoughts on doing this here?
There was a problem hiding this comment.
I don't see a major advantage to doing this. The logic would be slightly simpler (only one dimension to keep track of), but reshaping might be slightly expensive if lots of chunks need to move around.
|
|
||
| - Add ``piecewise`` for Dask Arrays (:pr:`3350`) `John A Kirkham`_ | ||
| - Fix handling of ``nan`` in ``broadcast_shapes`` (:pr:`3356`) `John A Kirkham`_ | ||
| - Add `isin` for dask arrays. `Stephan Hoyer`_ |
There was a problem hiding this comment.
Guessing you were waiting to see what number it would give you. ;)
| element, element_axes, | ||
| test_elements, test_axes, | ||
| adjust_chunks={axis: lambda _: 1 for axis in test_axes}, | ||
| dtype=np.bool_, |
There was a problem hiding this comment.
Slight preference for np.bool8 or bool if that's ok.
There was a problem hiding this comment.
These are all basically equivalent, so sure.
|
The build failure looks totally unrelated: |
|
Yeah, that's a known issue ( #3345 ) on |
|
Thanks @shoyer. |
| isclose | ||
| iscomplex | ||
| isfinite | ||
| isin |
There was a problem hiding this comment.
Missed that we didn't have an autofunction line with isin. Fixing with PR ( #3364 ).
I added a section to the indexing docs showing how to use `isin` with `where` to do idnexing. Adding support for older numpy turned out to be pretty easy, so I added a copy of np.isin in npcompat. This PR also makes use of dask.array.isin, so that we can support a dask array properly as the second argument: dask/dask#3363
* isin: better docs, support older numpy and use dask.array.isin. I added a section to the indexing docs showing how to use `isin` with `where` to do idnexing. Adding support for older numpy turned out to be pretty easy, so I added a copy of np.isin in npcompat. This PR also makes use of dask.array.isin, so that we can support a dask array properly as the second argument: dask/dask#3363 * lint * more lint * yet more lint
flake8 daskdocs/source/changelog.rstfor all changesand one of the
docs/source/*-api.rstfiles for new API