-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. #11788
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
It is a harmless. You can either ignore it or go back to 1.14.5. Will be fixed in the upcoming 1.15.1 |
@mattip Maybe it's best to edit the stackoverflow question with details about the issue with 1.15 if it would appear there this topic would have not been created. The question there is the first search result of google regarding the error. |
I'm running 1.15.1, and getting the error still :-( I'm running 1.1.5.1 fron conda-forge on OS-X, with python2.7, if that's relevant. I'm also making heavy use of Cython -- maybe it's .pyd files are out of date?? |
NOTE: I'm running Cython code compiled against an older numpy -- maybe that's the issue?? |
You shouldn't get those. Are you clearing the warning filters somewhere? It's this one in numpy's main
|
What pytest version? |
I have noticed a lot more warnings in other contexts as well -- so maybe pytest changed its defaults. But should numpy be putting out this warning at all? @rgommers -- I'm not doing anything (myself) about warnings -- but maybe pytest is? But why is numpy set to ignore a warning that it itself raises??? |
Long story, the warning comes from Cython and the Cython devs don't want to turn it off. Hence we filter it in Your warning filters get reset somewhere, that must be the cause. Maybe a new pytest release. |
Anyway, this is definitely fixed in 1.15.1, so closing. If you find it's a |
For the "why" - see cython/cython#2498. From the positive feedback to a possible solution in this comment, there is hope it might get solved. |
Matti, that isn't the problem with this warning, what is happening is that the C struct has been changed across numpy versions. That is back compatible if the new members are added to the end of the structure, because extension module compiled again earlier numpy versions will never access them. However, cython will complain if numpy reports a structure size different than it was for the numpy that the code was generated against. See #5343 for that added member. |
For clarity for future readers, and to make sure I understand the issue, here's a summary: let's see if I have this right Problem:
cython is also (or is this the cause) still using a oder, deprecated numpy API (which leads to a bunch of warnings at compile time) -- updating that is under discussion. Solutions:
NOTE: that PEP 565 recommends that test runners do not suppress warnings: https://www.python.org/dev/peps/pep-0565/#recommended-filter-settings-for-test-runners -- makes some sense, there is a lot that you don't want to see at runtime that you probably should see when you run your tests -- at least by default. Final note: if anyone with good pytest and warnings foo can post a way to suppress this particular warning, that would be much appreciated :-) |
@charris: thanks for the explanation -- I wonder if Cython could check to see if the struct is smaller than it was, rather than just different -- then you'd only get the warning when it really mattered! I guess that's a suggestion for the cython folks -CHB |
@ChrisBarker-NOAA I think there is something like that in the code. I don't recall exactly, but you can find the relevant code in the Cython generated C if you are willing to wade through that. |
just checking: are you sure? that's a long doc page, and it's not clear to me that pytest really changed. did you find a difference in behavior with an older version? The relevant discussion on the Cython tracker is cython/cython#2221. |
Two things are involved.
Pytest will change so that the command line overrides pytests.ini, probably in the 3.9 series. |
Thanks @charris. That does not sound like a good change. NumPy only has control over its own
or am I missing something? |
I think pytest is doing the right thing -- there is a warning raised, it should be up to the test framework, and the user to determine what warnings they want see. The idea of numpy (or any package) suppressing warnings that are raised by other code seems pretty dangerous to me. I can see why it seems like the right thing to do in this case, but not in general. (now that I think about it, scipy has cython generated code -- so this is going to come up there) Frankly, it's a cython issue -- it's raising a warning that it shouldn't. Until someone gets around to fixing it in cython, I think we'll have to live with it. And since I don't have the time to try to make a PR for cython, I know I'll have to live with it. At least if googling will quickly let people know that don't have to sorry about it -- then we're OK. -CHB |
@charris is correct that this not cython/cython#2498, rather cython/cython#2221. |
Well, it's debatable. The Cython devs are saying that the check and warning are useful to them sometimes. It's just never useful for numpy. They really should give us a better option to disable it though.
I don't think that's right. Packages should certainly be able to decide which of the warnings that come from their own code or from code below them in the stack should be suppressed. Say we have a user that writes some code that uses, e.g., |
I think there is no good answer with Python's warning system. For example: " If numpy or pandas devs decide that a warning from numpy is never relevant, there is zero reason to let a seaborn user see it. " absolutely -- but the warning doesn't necessarily come from numpy -- in fact, does it ever? numpy used some cython code (yes?) -- but then it gets compiled all together -- so there would never be a numpy version mis-match, would there? In my case, I'm getting the warning when I run the tests on my "gridded" package, which is pure-python, but depends on (also mine) cell_tree2d package, which is written in cython, and depends on numpy. So should the numpy project be able to dictate what warnings are seen from my code? In this case, it's all pretty numpy-focused, but doesn't seem like a good policy to build into Python or pytest. The core problem here is that the numpy devs and the cython devs disagree about how useful this warning is. But if it's useful for Cython developers (and i can sure see how it could be), it seems to me that it should be something that can be turned on and off at cython-compile time. -CHB |
okay:) let me rephrase: the warning is caused by numpy (because it decided to increase the size of
cython/cython#2221 seems to be converging on a solution |
Fixed in cython/cython#2627 and merged for the upcoming cython release. |
Late response here, but |
Hi! I have added this part into my code shown as follows
While the warning is still there, how can I eliminate it? |
Assuming "your code" is something you are compiling with cython; Cython 0.29, released only recently, should not generate this warning. Can you try upgrading? |
Upgrade to numy 1.15.2 could solve the problem. |
upgrading to numpy-1.15.4 did not fix it. BTW, I am currently using cypython-0.29.2 |
@ebo This issue is closed. Please open a new one with details about how you are obtaining the packages and the exact error message you are getting. Chances are it is a problem not with NumPy itself rather with something interacting with NumPy, and we need to know what that something is. |
Note that the message changed in Cython 0.29, it should now print |
Hi, I got the warning after importing the following packages: Maybe this helps in figuring out where the issue is caused. My warning is: |
I am using 1.19 and still getting it. |
@advhscmoe please open a new issue and paste the entire traceback. This issue is closed. |
I went to requirements.txt and added this changes |
I'm running
Python 3.5.2
andnumpy 1.15.0
I'm seeing:
According to this stackoverflow question I shouldn't see this warring as it was silence since
numpy 1.8
Why do I see it? and does it means anything?
The text was updated successfully, but these errors were encountered: