forked from scipy/scipy
-
Notifications
You must be signed in to change notification settings - Fork 0
Address more comments #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2315,7 +2315,6 @@ def test_grey_erosion01(self, xp): | |
[5, 5, 3, 3, 1]])) | ||
|
||
@skip_xp_backends("jax.numpy", reason="output array is read-only.") | ||
@skip_xp_backends("dask.array", reason="output array is read-only.") | ||
@xfail_xp_backends("cupy", reason="https://github.com/cupy/cupy/issues/8398") | ||
def test_grey_erosion01_overlap(self, xp): | ||
|
||
|
@@ -2521,6 +2520,8 @@ def test_white_tophat01(self, xp): | |
tmp = ndimage.grey_opening(array, footprint=footprint, | ||
structure=structure) | ||
expected = array - tmp | ||
# array created by xp.zeros is non-writeable for dask | ||
# and jax | ||
output = xp.zeros(array.shape, dtype=array.dtype) | ||
ndimage.white_tophat(array, footprint=footprint, | ||
structure=structure, output=output) | ||
|
@@ -2574,6 +2575,8 @@ def test_white_tophat04(self, xp): | |
structure = xp.asarray(structure) | ||
|
||
# Check that type mismatch is properly handled | ||
# This output array is read-only for dask and jax | ||
# TODO: investigate why for dask? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this makes no sense to me. |
||
output = xp.empty_like(array, dtype=xp.float64) | ||
ndimage.white_tophat(array, structure=structure, output=output) | ||
|
||
|
@@ -2588,6 +2591,7 @@ def test_black_tophat01(self, xp): | |
tmp = ndimage.grey_closing(array, footprint=footprint, | ||
structure=structure) | ||
expected = tmp - array | ||
# This output array is read-only for dask and jax | ||
lithomas1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
output = xp.zeros(array.shape, dtype=array.dtype) | ||
ndimage.black_tophat(array, footprint=footprint, | ||
structure=structure, output=output) | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not true. All arrays are non-writeabla for jax. All arrays are writeable for dask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r.e. writeability, I am not referring to the mutability of the original dask array, but the numpy array created from the dask array with np.asarray.
MRE
I'll remove the jax comment (and I'll raise an issue on scipy to disallow the
output
keyword for jax since it looks like there's no way to make that work).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's because the chunks of
a
are broadcasted, and so isa_np
unless it's a concatenation of chunks.Broadcasted arrays are read-only as the whole thing is only 8 bytes in size.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole idea of having an
output=
parameter makes no sense if you are going to convert it to numpy.This makes sense:
This does not:
In the second example, even without the broadcasting issue you're facing, the
output
item that the user is holding will remain completely blank, unless np.asarray returns a view of the original memory. which, for dask, can never be.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that
np.asarray(output, copy=False)
will not crash, while it should. This is a bug in Dask.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense.
I'll put in a separate PR to the main scipy repo disabling the output kwarg for jax (to keep the diff down here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI dask/dask#11697