-
Notifications
You must be signed in to change notification settings - Fork 557
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
ENH: add copy=None to CoordinateSequence.__array__ #2053
base: main
Are you sure you want to change the base?
Conversation
Thanks! I had noted this as a TODO item in #1972, but didn't yet get to it (and didn't expect our CI to fail for it, but so this is a good reminder ;)) Ideally we would honor the |
I had a play with various copy=True/False/None versions, and it all seems minor impact, mostly because CoordinateSequence objects aren't really used as separate objects. Each A simple implementation would be: def __array__(self, dtype=None, copy=None):
if copy:
return self._coords.copy()
return self._coords then tested (somewhere): def test_coords_array():
coord_seq = point.coords
assert np.array(coord_seq) is not np.array(coord_seq)
assert np.array(coord_seq, copy=False) is np.array(coord_seq, copy=False)
assert np.array(coord_seq, copy=True) is not np.array(coord_seq, copy=True) |
Pull Request Test Coverage Report for Build 9087673717Details
💛 - Coveralls |
Hmm, yes, it depends on how you interpret the CoordinateSequence object. Is that just a wrapper around an already materialized numpy array Because in the former case, you can indeed say that Now, since this CoordinateSequence class is a separate object from the Geometry objects, it might be that the former interpretation is the only viable one. |
From The |
Recent CI failures have picked up a recent NumPy 2.0 change, noted in the migration guide under "Adapting to changes in the copy keyword".
A simple fix appears to be to simply add
copy=None
to the__array__
signature. This value is not used by the method.Here is an example failure:
Note that test failures with macos in this PR are unrelated.