Skip to content
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

Updates for numpy=2. #390

Merged
merged 9 commits into from
May 17, 2024
Merged

Updates for numpy=2. #390

merged 9 commits into from
May 17, 2024

Conversation

erykoff
Copy link
Collaborator

@erykoff erykoff commented May 17, 2024

No description provided.

fitsio/util.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@beckermr beckermr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to somehow get numpy2 into the CI to test the builds. Maybe we wait to merge until numpy2 is official on conda-forge.

@esheldon
Copy link
Owner

what does copy=None mean in the new numpy?

@erykoff
Copy link
Collaborator Author

erykoff commented May 17, 2024

I'll restore the string_ for old numpy on the PR. The new behavior in numpy 2 is that copy is always False as I understand it, and I think they left in copy=None as a way to allow backwards compatibility.

@erykoff
Copy link
Collaborator Author

erykoff commented May 17, 2024

Trying to add py312 and numpy2 to the build matrix. Let's see what happens!

@esheldon
Copy link
Owner

OK, I guess their release notes are out of date

@erykoff
Copy link
Collaborator Author

erykoff commented May 17, 2024

This isn't working:

if numpy.lib.NumpyVersion(numpy.__version__) >= "2.0.0":
    _stypes += (numpy.str_,)
else:
    _stypes += (numpy.string_, numpy.str_,)

@erykoff
Copy link
Collaborator Author

erykoff commented May 17, 2024

It's a dumb rc thing ...

@beckermr
Copy link
Collaborator

@beckermr
Copy link
Collaborator

link is busted

New copy keyword meaning for array and asarray constructors

Now [numpy.array](https://numpy.org/devdocs/reference/generated/numpy.array.html#numpy.array) and [numpy.asarray](https://numpy.org/devdocs/reference/generated/numpy.asarray.html#numpy.asarray) support three values for copy parameter:

None - A copy will only be made if it is necessary.

True - Always make a copy.

False - Never make a copy. If a copy is required a ValueError is raised.

The meaning of False changed as it now raises an exception if a copy is needed.```

@beckermr
Copy link
Collaborator

We specify copies or no copies on purpose so properly pass by reference in places iirc.

@erykoff
Copy link
Collaborator Author

erykoff commented May 17, 2024

So the old numpy1x behavior was copy=False would try to do no copy, but would if it needed? And that is now copy=None I think.

@beckermr
Copy link
Collaborator

Ahhhhhhh yes that's right.

doc string in 1.26:

If true (default), then the object is copied. Otherwise, a copy will only be made if __array__ returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (dtype, order, etc.).

@erykoff
Copy link
Collaborator Author

erykoff commented May 17, 2024

I wonder if all our pushes made the system mad and now won't allocate any nodes for the macos builds ... thoughts?

@beckermr
Copy link
Collaborator

We probably had too many jobs in the queue and just had to wait for the old ones. We should be able to add bit to the GHA to cancel previous jobs.

@erykoff
Copy link
Collaborator Author

erykoff commented May 17, 2024

All tests have passed and I think this is ready.

@esheldon esheldon merged commit 976f025 into esheldon:master May 17, 2024
34 checks passed
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.

3 participants