109109import sys
110110import warnings
111111
112- # Disallow reloading numpy. Doing that does nothing to change previously
113- # loaded modules, which would need to be reloaded separately, but it does
114- # change the identity of the warnings and sentinal classes defined below
115- # with dire consequences when checking for identity.
116- if '_is_loaded' in globals ():
117- raise RuntimeError ('Reloading numpy is not supported' )
118- _is_loaded = True
119-
120-
121- # Define some global warnings and the _NoValue sentinal. Defining them here
122- # means that their identity will change if numpy is reloaded, hence if that is
123- # to be allowed they should be moved into their own, non-reloadable module.
124- # Note that these should be defined (or imported) before the other imports.
125- class ModuleDeprecationWarning (DeprecationWarning ):
126- """Module deprecation warning.
127-
128- The nose tester turns ordinary Deprecation warnings into test failures.
129- That makes it hard to deprecate whole modules, because they get
130- imported by default. So this is a special Deprecation warning that the
131- nose tester will let pass without making tests fail.
132-
133- """
134- pass
135-
136-
137- class VisibleDeprecationWarning (UserWarning ):
138- """Visible deprecation warning.
139-
140- By default, python will not show deprecation warnings, so this class
141- can be used when a very visible warning is helpful, for example because
142- the usage is most likely a user bug.
143-
144- """
145- pass
146-
147-
148- class _NoValue :
149- """Special keyword value.
150-
151- This class may be used as the default value assigned to a deprecated
152- keyword in order to check if it has been given a user defined value.
153- """
154- pass
155-
156-
157- # oldnumeric and numarray were removed in 1.9. In case some packages import
158- # but do not use them, we define them here for backward compatibility.
159- oldnumeric = 'removed'
160- numarray = 'removed'
161-
112+ from ._globals import ModuleDeprecationWarning , VisibleDeprecationWarning
113+ from ._globals import _NoValue
162114
163115# We first need to detect if we're being called as part of the numpy setup
164116# procedure itself in a reliable manner.
@@ -177,6 +129,7 @@ class _NoValue:
177129 its source directory; please exit the numpy source tree, and relaunch
178130 your python interpreter from there."""
179131 raise ImportError (msg )
132+
180133 from .version import git_revision as __git_revision__
181134 from .version import version as __version__
182135
@@ -239,3 +192,8 @@ def pkgload(*packages, **options):
239192 warnings .filterwarnings ("ignore" , message = "numpy.dtype size changed" )
240193 warnings .filterwarnings ("ignore" , message = "numpy.ufunc size changed" )
241194 warnings .filterwarnings ("ignore" , message = "numpy.ndarray size changed" )
195+
196+ # oldnumeric and numarray were removed in 1.9. In case some packages import
197+ # but do not use them, we define them here for backward compatibility.
198+ oldnumeric = 'removed'
199+ numarray = 'removed'
0 commit comments