Skip to content

Conversation

@arunkannawadi
Copy link
Contributor

This PR makes ngmix compatible with numpy>=2 and numpy<2.

The recommended method is to replace np.array(..., copy=False) with np.asarray link. However, given the necessity of ndmin which is not available in asarray, I took the scipy approach here.

This adds a shim similar to scipy that sets copy=False in numpy < 2 and
copy=None otherwise.
When the input variable ``val`` may be of type np.int32. This forces an
implicit casting of ``fval``, and when it is equal to or exceed 2**31,
an OverflowError is raised. This explicit casting prevents this error.
With numpy<2, bitwise_and does not operate on uint64 dtype objects.
Given that the range of fval is within the range of uint32, casting to
uint32 suffices. If the input value has more bits, they will be not used
anyway regardless of the casting as long as fval is limited to 2**31.
@beckermr
Copy link
Collaborator

@esheldon comments here or shall we merge?

@esheldon
Copy link
Owner

Arun are you still making additions?

@arunkannawadi
Copy link
Contributor Author

Nope, I don't have any more to add unless there are requests. Could you also please cut a release after merging this?

@esheldon
Copy link
Owner

Sure, can you make a comment in CHANGES.txt with a short explanation?

@arunkannawadi
Copy link
Contributor Author

arunkannawadi commented Mar 24, 2025

I shall, but I also notice that changes from #246 have not made it into a release yet. I will let you comment on that. With that included, would it bump up the minor version, right? (this PR alone should bump the patch version I think)

@esheldon
Copy link
Owner

I'll add notes for that. I'll do the version bump when I make my changes.

@esheldon
Copy link
Owner

Thanks Arun and Matt

@esheldon esheldon merged commit 4ae49b2 into esheldon:master Mar 24, 2025
@esheldon
Copy link
Owner

v2.4.0 is released

@arunkannawadi
Copy link
Contributor Author

Thank you, Erin!

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