Skip to content

Conversation

@JLVarjo
Copy link
Contributor

@JLVarjo JLVarjo commented Nov 13, 2024

This PR fixes some function names that were deprecated in NumPy 2.0.

@reneeotten
Copy link

@jjhelmus it would be great to get these fixes in (perhaps check the complete code base with $ ruff check path/to/code/ --select NPY201 as an additional check). Right now because numpy is not pinned to a version <2 in setup.py things break.

@JLVarjo
Copy link
Contributor Author

JLVarjo commented Nov 27, 2024

@reneeotten Thanks for the tip, ruff check found one more function name which is removed in NumPy >2.0, this is now pushed. BTW, the code should be still compatible with NumPy 1.26 after this PR, as all these renamed functions were already available in that version.

@kaustubhmote
Copy link
Collaborator

Thanks for submitting these changes. Unfortunately, the change from recfromtxt to genfromtxt will break the code in several places which need to read in strings, as the default data type is float. All calls to genfromtxt should set the kwarg dtype=None. This will make sure that the existing code still works. There are still some changes in the output record array generated by these two functions, so each example needs to be tested individually to see that it does not affect the output.

@JLVarjo
Copy link
Contributor Author

JLVarjo commented Jan 22, 2025

Added dtype to every genfromtxt call where it was missing. Any better now? I'm sorry I'm unable to test nmrglue thoroughly as I don't have most of the test data.

@kaustubhmote
Copy link
Collaborator

As I suspected, this does break some of the examples that relied on accessing elements from a record array instead of a the new array object. I will try and fix the test data story before attempting to review this again. #87

@reneeotten
Copy link

As I suspected, this does break some of the examples that relied on accessing elements from a record array instead of a the new array object. I will try and fix the test data story before attempting to review this again. #87

I understand that some of the examples might not work after this change, but isn't that better than having the whole package defunct with NumPy v2. You are not restricting NumPy to the 1.x branch in the dependency declaration so everyone installing this will likely do so in an environment with NumPy v2.x by now. So I would really suggest to merge this PR, release a new version, and then work on examples whenever time permits.

@reneeotten
Copy link

NumPy v2 has been released well over a year by now. The changes in this PR are required to work with that version. Your own test-suite fails in the current state because you don't restrict numpy to v1 branch; I would say it's time to get the package compatible with NumPy v2 and worry about the possibility of old examples not working anymore later.

@jjhelmus could you please weigh in on this? Thanks!

@lcnittl
Copy link

lcnittl commented Dec 5, 2025

Fully agree with @reneeotten — and thanks to all maintainers (foremost @jjhelmus) and contributors for keeping this excellent package moving forward. nmrglue has been invaluable to the community, and it’s great to see continued attention to modernization.

The current dependency on NumPy 1 is becoming a real constraint. NumPy 1.x does not support Python 3.13 (and certainly won’t support 3.14), so updating the requirement to NumPy 2.x is essentially a prerequisite for enabling the project to adopt newer Python versions. Aligning with the modern NumPy API would significantly help future-proof the package and ease integration for downstream users.

@jjhelmus
Copy link
Owner

I'm going to merge this change now that CI is set up and this fixes the tests in the nmrglue folder that were broken without this change.

The changes this makes related to examples and the tests in the tests directory can be fixed after this is merged.

@jjhelmus jjhelmus merged commit 5685a3e into jjhelmus:master Dec 23, 2025
5 checks passed
kaustubhmote added a commit to kaustubhmote/nmrglue that referenced this pull request Dec 29, 2025
kaustubhmote added a commit to kaustubhmote/nmrglue that referenced this pull request Dec 29, 2025
kaustubhmote added a commit to kaustubhmote/nmrglue that referenced this pull request Dec 29, 2025
…re either failing, or are slow, or have external dependencies (corrected after jjhelmus#224)
kaustubhmote added a commit to kaustubhmote/nmrglue that referenced this pull request Dec 30, 2025
…re either failing, or are slow, or have external dependencies (corrected after jjhelmus#224)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants