You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ValueError when using numpy>2.0 related to copy=False keyword usage #32
import pymangle
import numpy as np
LOWZ_S_path = '/Users/raulteixeira/Downloads/mask_DR11v1_LOWZ_South.ply'
lowz_S = pymangle.Mangle(LOWZ_S_path)
good = lowz_S.contains(200, 0)
Error message:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[3], line 7
3 LOWZ_S_path = '[/Users/raulteixeira/Downloads/mask_DR11v1_LOWZ_South.ply](http://localhost:8889/mask_DR11v1_LOWZ_South.ply)'
5 lowz_S = pymangle.Mangle(LOWZ_S_path)
----> 7 good = lowz_S.contains(200, 0)
File [~/miniforge3/envs/mangletest/lib/python3.14/site-packages/pymangle/mangle.py:152](http://localhost:8889/~/miniforge3/envs/mangletest/lib/python3.14/site-packages/pymangle/mangle.py#line=151), in Mangle.contains(self, ra, dec)
137 """
138 Check points against mask, returning 1 if contained 0 if not
139
(...) 149 Array of zeros or ones
150 """
151 # we specify order to force contiguous
--> 152 ra = array(ra, ndmin=1, dtype=longdouble, copy=False, order='C')
153 dec = array(dec, ndmin=1, dtype=longdouble, copy=False, order='C')
154 return super(Mangle, self).contains(ra, dec)
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
Activity
esheldon commentedon Apr 3, 2026
Thanks for the report.
I've got a PR here that fixes this: #33
Want to give it a try?
rbgdet commentedon Apr 3, 2026
Hi, thank you for opening the copy_if_needed branch.
I've gotten an import error
esheldon commentedon Apr 3, 2026
Did you install the code using
pip install .from the code directory, and then try importing from another directory?rbgdet commentedon Apr 3, 2026
Yes, that's how I installed it.
If I open the code from pathtorepo/pymangle/pymangle it works. Issue happened when I was in pathtorepo/pymangle/. I am in the copy_if_needed branch.
esheldon commentedon Apr 3, 2026
I think it is a path issue.
In any case, from the unit tests I think this fixed the problem. I'm going to do a new release today.
rbgdet commentedon Apr 3, 2026
Yes it did! Thank you very much :)