-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Numpy 1.25 now has min and max on __all__ (from numpy import *) #24229
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
Comments
Thanks for the clear report on this @e-carlin. I think we can filter For 2.0 I'd much prefer to keep things as they are now in If you could file bug reports against the dependencies you are having problems with, that would be helpful. Also, this tool to automatically replace all |
@rgommers yes, for backporting I it seemed to make sense (btw. PR welcome). TBH, I am not sure I am worried about keeping th |
The public names defined by a module are determined by checking the module’s namespace for a variable named There are a few different ways to try and determine public API, rather than a one-and-only way - but checking So now that we're finally going to have a clear public/private split, we should not carry weird hacks but have it be correct in my opinion. |
Well, but "public names" there refers explicitly to those exported by |
I don't think that is true. For introspection tooling for example, So I would say that all these dunder attributes/methods have clearly defined meanings and expectations, and a major release is as good a time as any to fix them. Especially if the fix was already made, I don't really want to see it reverted because some old packages with bad habits relied on the technically incorrect contents. In a more general way, there are many other things in
I will try to do that today. |
OK, I am sure it can be annoying, just not sure about it being worth too much churn. OTOH, it took a few weeks for an issue, so maybe it isn't that much churn. |
This is a workaround for breakage in downstream packages that do `from numpy import *`, see numpygh-24229. Note that there are other builtins that are contained in `__all__`: ``` >>> for s in dir(builtins): ... if s in np.__all__: ... print(s) ... all any divmod sum ``` Those were already there before the change in 1.25.0, and can stay. The downstream code should be fixed before the numpy 2.0 release. Closes numpygh-24229
I checked all builtins, and Let's see if more complaints come in, but I'd say it's been 5 weeks already indeed, so anything relevant should have noticed by now - and issues should then be filed to get those fixed. |
👍 to keeping everything in |
Closing, reverted for 1.25 (and thus 1.26) and unless there proofs to be more disruption I expect we will keep it in main, so libraries failing here will have to be fixed. |
Thanks all for the quick response and fix! I'll start working on submitting patches to our dependencies in anticipation of v2.0 |
Uh oh!
There was an error while loading. Please reload this page.
Describe the issue:
This isn't exactly a bug per se but a surprise after updating to 1.25. So let me know if this should be moved elsewhere.
In 1.25
from numpy import *
brings in names likemin
andmax
which override the builtinmin
andmax
.The specific case that lead to our failure was in a dependency we use. This is the import and this is the use of min.
To fix I initially tried patching the dependency (warp) in our build system with
from builtins import *
after thefrom numpy import *
. But, warp also doesfrom gist import *
which also does afrom numpy import *
. I could patch the dependency of a dependency but I’m wondering if there is a better "upstream" fix.I believe this is the change that caused the bug.
It looks like some thought has already been given to builtin names and
from numpy import *
(here and here).I’m wondering if removing builtin names from
__all__
or at least removing min and max is something you all are open to considering?Reproduce the code example:
Error message:
One specific example is this
An example you can more easily run is
Runtime information:
1.24.0
1.25.1
Context for the issue:
As stated above, dependencies we use do
from numpy import *
which caused breakage in numpy 1.25. This went undetected until our CD caught it during a release (issue).A cursory look at our production image reveals a few packages that could have problems:
A search on github reveals 5.8k results that use
from numpy import *
followed by a use ofmin
ormax
. Justfrom numpy import *
has 39.7k results.I know your docs say not to use
from numpy import *
and as a general rule of thumb it is frowned on (ex Google python style guide). I personally use qualified imports but, as evidence from the searches, many people don't follow this advice.I realize those searches are imperfect and won't cause a break in all cases. But, I think the use of
from numpy import *
could be widespread enough that care needs to be put into what is brought in when doing so.I don't know what the "best" fix is. It may just be I need to patch the dependencies I use. But, I wanted to float the problem out to get your thoughts.
Thanks for your time.
The text was updated successfully, but these errors were encountered: