summaryrefslogtreecommitdiff
path: root/numpy/__init__.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #14882 from eric-wieser/6103-alias-__getattr__-deprecationSebastian Berg2020-06-161-17/+61
|\ | | | | DEP: Deprecate aliases of builtin types in python 3.7+
| * DEP: Deprecate aliases of builtin types in python 3.7+Eric Wieser2020-06-121-17/+61
| | | | | | | | | | | | | | | | This: * Makes accessing these attributes emit a deprecation warning * Removes them from `dir(numpy)`, so as not to emit warnings for user of `inspect.getmembers` These aliases are a continual source of confusion for beginners, and are still often used by accident by experts.
* | DOC,ENH: extend error message when Accelerate is detectedmattip2020-05-311-5/+4
|/
* DEP: Deprecate `numpy.dual`.Warren Weckesser2020-05-041-1/+3
| | | | | | Add a deprecation warning in the `numpy.dual` module, and remove the use of `numpy.dual` from the few places where it is used in the numpy code.
* Merge pull request #15769 from seberg/hugepages-allow-togglingMatti Picus2020-05-031-0/+21
|\ | | | | ENH: Allow toggling madvise hugepage and fix default
| * Fixup: Implement suggestions by MattiSebastian Berg2020-04-281-1/+1
| |
| * ENH: Allow toggling madvise hugepage and fix defaultSebastian Berg2020-03-171-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | By default this disables madvise hugepage on kernels before 4.6, since we expect that these typically see large performance regressions when using hugepages due to slow defragementation code presumably fixed by: https://github.com/torvalds/linux/commit/7cf91a98e607c2f935dbcc177d70011e95b8faff This adds support to set the behaviour at startup time through the ``NUMPY_MADVISE_HUGEPAGE`` environment variable. Fixes gh-15545
* | MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-261-2/+1
|/ | | | | types (#15816) Cleanup from the dropping of python 2
* MAINT: Test during import to detect bugs with Accelerate(MacOS) LAPACK (#15695)Rakesh Vasudevan2020-03-151-0/+32
| | | | | | | * TST: Test during import to detect bugs with Accelerate(MacOS) LAPACK fixes #15647 * Pipeline update for Accelerate(MacOS) testing
* FIXME -> NOTE: more precise language in comment.Ross Barnowski2020-03-011-2/+2
| | | | Reference multiple relevant discussions on GH
* MAINT: Added comment pointing FIXME to relevant PR.Ross Barnowski2020-03-011-0/+1
| | | | | | | Clarifies a FIXME comment in numpy/__init__.py by referencing relevant discussion in issue tracker. Closes #15668.
* MAINT: dir(numpy) returned duplicate "testing" (gh-15425)SanthoshBala182020-01-271-1/+1
| | | | | Modified __dir__() to remove duplicate "Tester/Testing" attribute. Also added a test to verify this. Closes gh-15383
* MAINT/DOC: Remove use of old Python __builtin__, now known as builtinsMike Taves2020-01-241-5/+2
|
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-031-2/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* BUG: Remove builtins from __all__Eric Wieser2019-11-121-2/+6
| | | | | | | | This was introduced in 3ca0eb1136102ff01bcc171f53c106326fa4445b, due to an incorrect implementation of `__dir__` (fixed in the previous commit). It was never released, so this is not a breaking change. In that commit, `from numpy import *` would reset all the builtins to their defaults, and set `unicode = str`, `long = int`.
* BUG: Fix np.__dir__ to correctly handle new propertiesEric Wieser2019-11-111-1/+1
| | | | | | | | | | Previously this would fail, but only on python 3.7+ ``` np.new_member = 1 assert 'new_member' in dir(np) ``` While this isn't something we support anyway, it certainly wasn't intentional.
* DOC: add some comments to explain namespace cleanup in numpy/__init__.pyRalf Gommers2019-09-191-0/+4
| | | | [ci skip]
* MAINT: add missing 'Arrayterator' to `numpy.lib.__all__`Ralf Gommers2019-09-191-0/+6
| | | | | | | Also finish the TODO about figuring out which np.lib.<submodule>'s are public. This is a giant mess ...
* BUG: Fix format statement associated with AttributeError.Warren Weckesser2019-09-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | Before this fix, a reference such as `numpy.wxyz` produced an incorrect error message because of the invalid format specifiers in the error message string: >>> import numpy >>> numpy.wxyz Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/.../numpy/__init__.py", line 206, in __getattr__ "module %s has no attribute $s".format(__name__, attr)) AttributeError: module %s has no attribute $s After the fix: >>> import numpy >>> numpy.wxyz Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/.../numpy/__init__.py", line 206, in __getattr__ "{!r}".format(__name__, attr)) AttributeError: module 'numpy' has no attribute 'wxyz'
* MAINT: Lazy import testing on python >=3.7 (#14097)Mark Harfouche2019-08-221-3/+31
| | | | | On new python versions, the module level `__getattr__` can be used to import testing and Tester only when needed (at no speed cost, except for the first time import). Since most users never use testing, this avoids an expensive import.
* MAINT: cleanup getlimit global varsAllan Haldane2018-10-091-1/+1
|
* MAINT: delay initialization of getlimits (circular imports)Allan Haldane2018-10-091-0/+2
| | | | | | | getlimits previously called numpy code before all of numpy was loaded, which often causes circular import issues. This delays getlimits init. Fixes #12063
* DEP: Remove np.pkgload, which was deprecated in 1.10Eric Wieser2018-08-121-10/+1
| | | | | | | | Attempts to use this on either cpython27 or cpython35, in either a shell or a script, gives: NameError: name '__path__' is not defined Perhaps I'm calling it wrong, but it might just be broken.
* ignore cython warnings in initJeremy Manning2018-07-291-0/+5
|
* DOC: extend sanity check messagemattip2018-07-041-1/+3
|
* MAINT: Move add_newdocs into core, since it only adds docs to those piecesEric Wieser2018-07-021-3/+1
|
* MAINT: Move pytesttester outside of np.testing, to avoid creating ↵Eric Wieser2018-07-021-1/+1
| | | | | | | | unnecessary import dependencies pytesttester is used by every single subpackage, so making it depend on np.testing just creates cyclic dependencies that can lead to circular imports Relates to #11457
* HTTP -> HTTPS, and other linkrot fixesMike Toews2018-06-161-2/+2
|
* MAINT: add sanity-checks to be run at import timePauli Virtanen2018-05-271-0/+25
| | | | This checks for potential BLAS issues, which are useful to catch early.
* TST: Update modules `test` to PytestTester.Charles Harris2018-04-041-11/+9
| | | | | | | | Numpy can now be tested using the standard `python -c"import numpy; numpy.test()"` construct.
* MAINT: Remove "bench" from testing modules `__init__`s.Charles Harris2018-03-311-1/+0
| | | | | The "bench" testing with the old bench files is no longer supported. These days we use `runtests.py` and `asv`.
* MAINT: Rearrange files in numpy/testing module.Charles Harris2017-07-041-3/+3
| | | | | | | | | | | | | | | | | The aim here is to separate out the nose dependent files prior to adding pytest support. This could be done by adding new files to the general numpy/testing directory, but I felt that it was to have the relevant files separated out as it makes it easier to completely remove nose dependencies when needed. Many places were accessing submodules in numpy/testing directly, and in some cases incorrectly. That presented a backwards compatibility problem. The solution adapted here is to have "dummy" files whose contents will depend on whether of not pytest is active. That way the module looks the same as before from the outside. In the case of numpy itself, direct accesses have been fixed. Having proper `__all__` lists in the submodules helped in that.
* DOC: change Numpy to NumPy in dosctrings and commentsPierre de Buyl2016-09-061-2/+2
| | | | The strings in error messages were left untouched
* BUG: Make sure numpy globals keep identity after reload.Charles Harris2016-08-161-50/+8
| | | | | | | | | | | | 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 #7844.
* BUG: Raise RuntimeError when reloading numpy is attempted.Charles Harris2016-07-201-9/+18
| | | | | | | | | | There seems to be little use in reloading numpy as any changed modules that are imported into numpy would need to be reloaded first in order to see any changes. Furthermore, reloading causes problems as global classes defined in numpy/__init__.py change their identity. Hence we raise a RuntimeError when an attempt to reload numpy is made. Closes #7844.
* ENH: platform-specific install hook to change initMatthew Brett2016-03-071-0/+3
| | | | | | Give hook to allow platform-specific installs to modify the initialization of numpy. Particular use-case is to allow check for SSE2 on Windows when shipping with ATLAS wheel.
* [TST] Refactor new raise_warnings logic for subpackage test suitesNathaniel J. Smith2015-12-301-6/+4
|
* [FIX] fix NoseTester's raise_warning defaultNathaniel J. Smith2015-12-291-2/+6
| | | | | | | | | | | | | | | | Our test-runner's raise_warning mode traditionally has varied depending on whether we have a development or release version of numpy: for development versions we raise on warnings, and for release versions we don't. This is all very sensible... *if* you're running numpy's test suite. But our test-runner is also used by other packages like scipy, and it doesn't make sense for scipy's raise_warning mode to vary depending on whether *numpy* is a development or release version. (It should vary depending on whether the scipy-under-test is a development or release version.) So this commit moves the numpy-version-dependent raise_warning logic out of the generic NoseTester class and into numpy-specific code. (See scipy/scipy#5609 for more discussion.)
* MAINT: add a warning filter for possible "ndarray size changed" Cython noise.Ralf Gommers2015-04-051-0/+1
| | | | | See gh-432 for details. Motivation for adding this now is the discussion on gh-5343.
* ENH: _NoValue class at top-level to test kwargsMatthew Brett2015-03-151-0/+10
| | | | | | | | | | Add _NoValue class at top level to make it possible to detect when non-default values got passed to a keyword argument, as in: def func(a, b=np._NoValue): if b is not np._NoValue: warnings.warn("Argument b is deprecated", DeprecationWarning)
* Update __init__.pyCameron Bates2014-04-261-1/+1
| | | interpreter is misspelled
* DEP: Deprecate numpy.rankSebastian Berg2014-04-221-1/+14
| | | | | | | This function is commonly confused with numpy.linalg.matrix_rank and exists itself only for history reasons. Closes gh-4616
* MAINT: Make useless imports of oldnumeric and numarray safe.Charles Harris2013-09-281-0/+6
| | | | | | | The oldnumeric and numarray packages were removed in numpy 1.9, but some packages, e.g. scipy, import them even though they are not used. This defines both to the string 'removed' in numpy/__init__.py, which avoids an import error.
* STY: Giant whitespace cleanup.Charles Harris2013-08-181-1/+0
| | | | Now is as good a time as any with open PR's at a low.
* DEP: Deprecate the oldnumeric and numarray modules.Charles Harris2013-06-101-1/+14
| | | | | | | | | The numarray and oldnumeric modules are deprecated. This is a bit tricky as raising a DeprecationWarning on import causes an error when tests are run. To deal with that, a ModuleDeprecationWarning class is added to numpy and NoseTester is modified to ignore that warning during testing. Closes #2905
* 2to3: Apply unicode fixer.Charles Harris2013-04-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | The unicode fixer strips the u from u'hi' and converts the unicode type to str. The first won't work for Python 2 and instead we replace the u prefix with the sixu function borrowed from the six compatibility package. That function calls the unicode constructor with the 'unicode_escape' encoder so that the many tests using escaped unicode characters like u'\u0900' will be handled correctly. That makes the sixu function a bit different from the asunicode function currently in numpy.compat and also provides a target that can be converted back to the u prefix when support for Python 3.2 is dropped. Python 3.3 reintroduced the u prefix for compatibility. The unicode fixer also replaces 'unicode' with 'str' as 'unicode' is no longer a builtin in Python 3. For code compatibility, 'unicode' is defined either as 'str' or 'unicode' in numpy.compat so that checks like if isinstance(x, unicode): ... will work properly for all python versions. Closes #3089.
* 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-131-2/+3
| | | | | | | | | | | | | | | | | | | The numliterals fixer replaces the old style octal number like '01' by '0o1' removes the 'L' suffix. Octal values were previously mistakenly specified in some dates, those uses have been corrected by removing the leading zeros. Simply Removing the 'L' suffix should not be a problem, but in some testing code it looks neccesary, so in those places the Python long constructor is used instead. The 'long' type is no longer defined in Python 3. Because we need to have it defined for Python 2 it is added to numpy/compat/np3k.py where it is defined as 'int' for Python 3 and 'long' for Python 2. The `long` fixer then needs to be skipped so that it doesn't undo the good work. Closes #3074, #3067.
* 2to3: Apply `print` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Apply `imports` fixer.Charles Harris2013-04-021-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The `imports` fixer deals with the standard packages that have been renamed, removed, or methods that have moved. cPickle -- removed, use pickle commands -- removed, getoutput, getstatusoutput moved to subprocess urlparse -- removed, urlparse moved to urllib.parse cStringIO -- removed, use StringIO or io.StringIO copy_reg -- renamed copyreg _winreg -- renamed winreg ConfigParser -- renamed configparser __builtin__ -- renamed builtins In the case of `cPickle`, it is imported as `pickle` when python < 3 and performance may be a consideration, but otherwise plain old `pickle` is used. Dealing with `StringIO` is a bit tricky. There is an `io.StringIO` function in the `io` module, available since Python 2.6, but it expects unicode whereas `StringIO.StringIO` expects ascii. The Python 3 equivalent is then `io.BytesIO`. What I have done here is used BytesIO for anything that is emulating a file for testing purposes. That is more explicit than using a redefined StringIO as was done before we dropped support for Python 2.4 and 2.5. Closes #3180.
* 2to3: Use absolute imports.Charles Harris2013-03-281-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172