8000 BUG: Make sure numpy globals keep identity after reload. by charris · Pull Request #7941 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Make sure numpy globals keep identity after reload. #7941

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

Merged
merged 1 commit into from
Aug 20, 2016

Conversation

charris
Copy link
Member
@charris charris commented Aug 16, 2016

Given that pandas, matplotlib, and astropy all reload numpy, the preferred solution of raising and error when a reload is attempted is too draconian. This PR takes the approach of making numpy reload safer by moving the needed globals into their own _globals.py module from which they can be imported when numpy reloads. Unless _globals.py itself is reloaded, not just imported from, the identity of the globals will remain intact.

@charris charris added this to the 1.11.2 release milestone Aug 16, 2016
@charris charris force-pushed the fix-numpy-reload-again branch from 45803b9 to 5b12784 Compare August 16, 2016 00:15
@charris charris changed the title Fix numpy reload again BUG: Make sure numpy globals keep identity after reload. Aug 16, 2016
]


# Disallow reloading numpy. Doing that does nothing to change previously
Copy link
Contributor

Choose a reason for hiding this comment

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

Update comment here to say disallow reloading _globals

@mhvk
Copy link
Contributor
mhvk commented Aug 16, 2016

This looks good to me. Only thing to do would seem to be to update the comments in the new _globals file to reflect that it is only that one that cannot be reloaded.

Reloading currently causes problems because global classes defined in
numpy/__init__.py change their identity (a is b) after reload. The
solution taken here is to move those classes to a new non-reloadable
module numpy/_globals and import them into numpy from there.

Classes moved are ModuleDeprecationWarning, VisibleDeprecationWarning,
and _NoValue.

Closes numpy#7844.
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.

2 participants
0