Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@da-woods
Copy link
Contributor

In #5820 (comment) @mattip suggests that Cython providing slightly different Numpy includes is a source of confusing error messages.

They've been in Numpy for a reasonable length of time now, so it's probably time to drop Cython's copy. It'll hopefully avoid people raising issues about Cython's copy too.

In cython#5820 (comment)
@mattip suggests that Cython providing slightly different Numpy
includes is a source of confusing error messages.

They've been in Numpy for a reasonable length of time now, so it's
probably time to drop Cython's copy. It'll hopefully avoid people
raising issues about Cython's copy too.
@da-woods
Copy link
Contributor Author

The one issue seems to be that Numpy don't seem to have adopted the math.pxd file in the Numpy directory. I can find quite a few people using it, including Numpy themselves (https://github.com/numpy/numpy/blob/605e34577affa99fd49bbb6156843953b81d92b8/numpy/random/_common.pyx#L8) so unless I'm missing something, we may not be in a position to remove it

@mattip
Copy link
Contributor

mattip commented Nov 18, 2023

aargh. Sorry, we seem to have missed that: see numpy/numpy#25177. I guess Cython could drop the __init__.pxd file for now.

@mattip
Copy link
Contributor

mattip commented Nov 19, 2023

CI is passing other than the PyPy trashcan test, skipped in #5832.

@mattip
Copy link
Contributor

mattip commented Jan 17, 2024

About numpy.math.pxd:

@rgommers commented on elsewhere that perhaps the bettter solution is for cython to drop the file:

... [W]hat bothers me the most here is that the selection of functions included makes little sense. How would a user know what's in this namespace without trial and error?

It may be better for Cython to simply deprecate the numpy.math namespace and tell users to prefer libc.math and that if they have a specific issue to work around libc issues, simply do this in their own code:

cdef extern from "numpy/npy_math.h" nogil:
  # replace copysign with the function of interest here
  double copysign "npy_copysign"(double, double)

@mattip
Copy link
Contributor

mattip commented Jan 17, 2024

Is there any indication that numpy/math.pxd is in use?

@da-woods
Copy link
Contributor Author

Is there any indication that numpy/math.pxd is in use?

Looks like Scipy and Pandas both use it (just for NaN/INFINITY constants). scikit-learn looks to have used it until 2023 but it's probably been removed. A bunch of smaller projects also look to use it. I suspect not for anything irreplaceable, but I'm reluctant to cause that much disruption deliberately.

@rgommers
Copy link
Contributor

The SciPy usage was one very recently introduced line that I missed - I just opened a PR to remove it again. Pandas main branch looks clean too, no usages.

I think it would be good to at least approve the deprecation, conditional on code findable with GitHub code search being cleaned up first. Now that Cython 3 is kind of a "fresh" start with many much more disruptive changes than this one, it'd be nice to get rid of this.

@mattip
Copy link
Contributor

mattip commented Jan 31, 2024

I think this PR could be merged as-is. The use of math.pxd is a separate problem, and a little harder to solve, so separating the concerns and merging this would at least solve the immediate problem of duplicate files in two different repos.

@da-woods da-woods added this to the 3.1 milestone Jan 31, 2024
@da-woods da-woods merged commit a6cef74 into cython:master Jan 31, 2024
@da-woods da-woods deleted the drop-numpy-includes branch January 31, 2024 21:31
@da-woods
Copy link
Contributor Author

Yeah I think I agree with this conclusion. I'll merge this for 3.1.

I mostly agree that we should drop numpy.math too. I'll make another PR for that but won't merge it unilaterally.

da-woods added a commit to da-woods/cython that referenced this pull request Jan 31, 2024
See discussion in cython#5842.
This file was in Numpy until faily recently so dropping it is
potentially breaking. However, it'd still be nice to remove it
so putting it up for review.
@da-woods da-woods mentioned this pull request Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants