Repository navigation
Drop support for numpy 1.x - #18986
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
Wow, @mhvk , you are brave... If you push https://github.com/astropy/astropy/releases/tag/v8.0.0.dev tag to your fork, I can try to run your PR branch here in https://github.com/astropy/astropy-integration-testing/ and see how many things break. |
neutrinoceros
left a comment
There was a problem hiding this comment.
Here a complete review with a handful of nits, but overall nothing major to report.
| warnings.simplefilter("ignore", category=DeprecationWarning) | ||
| arr.data = self[idx].data.data | ||
| elif sys.getrefcount(arr) > 2: | ||
| if sys.getrefcount(arr) > 2: |
There was a problem hiding this comment.
minor: we could now save one indentation level in what follows by using a single guard clause (if mmap is None or sys.getrefcount(arr) <= 2)
| DTYPES_TEST_INIT = ["?", "b", "i2", "f4", "c8", "S", "U", "O"] + ( | ||
| [ # new in numpy 2 | ||
| np.dtypes.StrDType, # same as "U" | ||
| np.dtypes.BytesDType, # same as "S" | ||
| np.dtypes.StringDType, | ||
| ] | ||
| ) |
There was a problem hiding this comment.
the extra parens are somewhat distracting and can be removed
|
|
||
| if NUMPY_LT_2_4: | ||
| # np.in1d deprecated in not NUMPY_LT_2_0, removed in not NUMPY_LT_24 | ||
| # np.in1d removed in not NUMPY_LT_24 |
There was a problem hiding this comment.
whoops
| # np.in1d removed in not NUMPY_LT_24 | |
| # np.in1d removed in not NUMPY_LT_2_4 |
There was a problem hiding this comment.
Rephrased as text, since it is now a simple if statement so no need for being greppable.
| obj = self.view(np.ndarray) | ||
| else: | ||
| obj = np.array(obj, copy=COPY_IF_NEEDED, subok=True) | ||
| obj = np.array(obj, copy=None, subok=True) |
There was a problem hiding this comment.
for my own culture, is this any different than the following ?
| obj = np.array(obj, copy=None, subok=True) | |
| obj = np.asanyarray(obj, copy=None) |
There was a problem hiding this comment.
It it the same, but the np.array call used to be faster, since np.asanyarray would call np.array... But in trying to proof that, I found it has actually changed: np.asanyarray now is faster: with a plain array as input, which is most likely here, it is 75 vs 85 ns on my laptop, and down to 39 ns after removing copy=None (which is the default for np.asanyarray). So, I'm changing it!
| ) = np.lib._function_base_impl._parse_gufunc_signature( | ||
| ufunc.signature.replace(" ", "") | ||
| ) | ||
| (in_sig, out_sig) = np.lib._function_base_impl._parse_gufunc_signature( |
There was a problem hiding this comment.
parens serve no purpose now
| (in_sig, out_sig) = np.lib._function_base_impl._parse_gufunc_signature( | |
| in_sig, out_sig = np.lib._function_base_impl._parse_gufunc_signature( |
| # a direct dependency in order to set a lower bound for oldest-deps testing | ||
| "jupyter-core>=4.11.2", | ||
| "pandas>=2.0.2", | ||
| "pandas>=2.2.2", # minimum that supports numpy 2.0 |
There was a problem hiding this comment.
same here
| "pandas>=2.2.2", # minimum that supports numpy 2.0 | |
| "pandas>=2.2.2", |
| "pyarrow>=14.0.2", | ||
| "beautifulsoup4>=4.9.3", # imposed by pandas==2.0 | ||
| "h5py>=3.11.0", # older versions are not compatible with numpy 2.0 | ||
| "pyarrow>=16.0", # older versions are not compatible with numpy 2.0 |
There was a problem hiding this comment.
| "pyarrow>=16.0", # older versions are not compatible with numpy 2.0 | |
| "h5py>=3.11.0", | |
| "pyarrow>=16.0", |
| "mpmath>=1.2.1", | ||
| "asdf-astropy>=0.7.0", | ||
| "bottleneck>=1.3.3", | ||
| "bottleneck>=1.4.0", # minimum for numpy 2.0 compatibility |
There was a problem hiding this comment.
| "bottleneck>=1.4.0", # minimum for numpy 2.0 compatibility | |
| "bottleneck>=1.4.0", |
There was a problem hiding this comment.
OK, those are indeed all in one commit, so easy enough to find if needed.
| "pyarrow>=16.0", # minimum for numpy 2.0 support | ||
| "pandas>=2.2.2", # minimum for numpy 2.0 support |
There was a problem hiding this comment.
| "pyarrow>=16.0", # minimum for numpy 2.0 support | |
| "pandas>=2.2.2", # minimum for numpy 2.0 support | |
| "pyarrow>=16.0", | |
| "pandas>=2.2.2", |
|
|
||
| deps = | ||
| numpy125: numpy==1.25.* | ||
| numpy20: numpy==2.0.* |
There was a problem hiding this comment.
I would actually suggest dropping this tox env now; I don't think it's used anywhere and it's not providing much value beyond oldestdeps
There was a problem hiding this comment.
OK, done -- there defintely are more than enough environments as is, and this one has outlived its purpose.
|
Before I reviewed I also pushed a commit to change |
f50b5bc to
e9cf40d
Compare
|
Would it help if I do the mpl384 bump as a standalone PR when I return? |
|
That's already the content of #19115, and yes, it can wait for you :) |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
|
@neutrinoceros , is it possible to take this PR out commits out of #19115 then? mpl upgrade on CircleCI should be completely separable from numpy upgrade. |
|
Indeed. It'll create a couple trivial merge conflict but as long as it helps review, that's fine with me. Done. |
This warning is not specific to this PR, but happens on generally on numpy 2.0 or 2.1 and python 3.10, 3.11 (maybe later too). It was not seen before because CI did not test the relevant combinations.
|
@neutrinoceros - I implemented all your suggestions (all clear improvements), thanks! |
neutrinoceros
left a comment
There was a problem hiding this comment.
Thank you ! I trust you did go through all of them and I don't think I need a second full scan. Approving now !
|
Thanks, merging this... |
This drops support for numpy < 2.0. It is in a few commits:
COPY_IF_NEEDED, since it is now always justNone(lots of changes).EDIT: further commits
5. Bump other dependencies to the minimum needed for numpy >=2.0 support (inferred from numpy/numpy#26191)
6. Silence a weird
RuntimeError(happens on main too with same python/numpy combo; see #18989.In total ~500 lines changed and ~600 lines deleted, i.e., lots of compatibility work-arounds simplified.