| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
BufferedReader and BufferedWriter cannot be used to determine local
files. For example, users can implement CustomFile to operate on OSS
files, and then use BufferedReader(CustomFile) to achieve the buffered
effect. But fileno method can do it.
|
|
|
|
|
| |
Note that unfortunately, compat does expose _inspect as well,
so the import remains (just the definition place moves).
|
|
|
|
|
| |
The submoudle numpy.compat._pep440 is removed from the default import of
numpy to reduce the import time. See #22061
|
|
|
|
|
|
|
|
| |
LooseVersion is provided by Python distutils, which is going away in
3.12. This PR vendors _pep440 from scipy and uses it as a replacement.
Numpy distutils is not touched, replacing LooseVersion in that package
was considered too risky, and numpy distutils will need to go away when
Python distutils does.
|
|
|
|
|
|
|
| |
`load_module` is deprecated since python 3.4 and will be removed in python 3.12.
Use `exec_module` instead. Provide a convenience function in `distutils.misc_utils`
instead of `npy_load_module` from `compat.py3k`.
|
|
|
| |
* Remove unnecessary imports and minor fixes
|
| |
|
|
|
|
| |
`Path` can now never be none, and `PurePath` is not used and not in `__all__`.
|
|
|
|
|
| |
Since we no longer support Python 3.5 and below, this code is unreachable.
As with the rest of `py3k.py`, we leave behind the aliases to prevent breaking downstream code.
|
| |
|
|\
| |
| | |
MAINT: cleanup compat.py3k.py
|
| | |
|
|/
|
|
|
|
|
| |
Inheriting from object was necessary for Python 2 compatibility to use
new-style classes. In Python 3, this is unnecessary as there are no
old-style classes.
Dropping the object is more idiomatic Python.
|
|
|
|
|
| |
As numpy is Python 3 only, these import statements are now unnecessary
and don't alter runtime behavior.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
The pickle module was being imported from numpy.core.numeric. It was
defined there in order to use pickle5 when available in Python3 and
cpickle in Python2. The numpy.compat module seems a better place for
that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Use list comprehension
* More list comprehension migration
* Revert key copying in dict
* A few more fixes
* More reverts
* Use dict comprehension
* Fix dict comprehension
* Address review comments
* More review comments
* Fix for empty unpacking of zip(*
* Revert zip(* unpacking altogether
* Fix dict copying
* More simplifications
|
| |
|
| |
|
|
|
|
|
| |
That function is nose specific and has not worked since `__init__` files
were added to the tests directories.
|
|
|
|
|
| |
These tests were not included in the `setup.py` file and consequently
not available in the installed numpy for testing.
|
|
|
|
|
|
|
|
| |
This allows pytest to run with duplicate test file names. Note that
`python <path-to-test-file>` no longer works with this change, nor will
a simple `pytest numpy`, because numpy is imported from the numpy
repository. However, `python runtests.py` and `>>> numpy.test()` are
still available.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
Use the full module path when importing importlib.machinery for use in the
npy_load_module function. Just importing importlib is not sufficient in certain
cases, for example Python 3.4.
closes #8147
|
|
|
|
| |
f2py.compile (issue #7683)
|
| |
|
| |
|
|
|
|
|
| |
Some newer *.py files are missing the `from __future__` boilerplate
that helps assure Python2 and Python3 compatibility.
|
|
|
|
|
| |
allows passing flags like --pdb to test files
also add call to files where its missing
|
| |
|
|
|
|
|
|
|
|
|
| |
The `getargspec` needed to import the disassembler to support parsing
tuple arguments. Since numpy never uses those, the corresponding code
is deleted and an TypeError raised if such arguments are encountered.
Also fix the unused formatargs function so it does not require the
string module.
|
| |
|
| |
|
|
|
|
|
|
|
| |
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long
and will need to be broken at some point. OTOH, some lines were already
too long and need to be broken at some point. Now seems as good a time
as any to do this with open PRs at a minimum.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Python 3 removes the builtin types from the types module. The types
fixer replaces such references with the builtin types where possible
and also takes care of some special cases:
types.TypeNone <- type(None)
types.NotImplementedType <- type(NotImplemented)
types.EllipsisType <- type(Ellipsis)
The only two tricky substitutions are
types.StringType <- bytes
types.LongType <- int
These are fixed up to support both Python 3 and Python 2 code by
importing the long and bytes types from numpy.compat.
Closes #3240.
|
|
|
|
|
|
|
|
|
|
|
| |
The basestring class is not defined in Python 3 and the fixer replaces
it with str. In order to have a common code base we define basestring in
numpy/compat/py3k.py to be str when the Python version is >= 3,
otherwise basestring and import it where needed. That works for most
cases, but there are a few files where the version dependent define
needs to be in the file.
Closes #3042.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Python 3 `map` is an iterator while in Python 2 it returns a list.
The simple fix applied by the fixer is to inclose all instances of map
with `list(...)`. This is not needed in all cases, and even where
appropriate list comprehensions may be preferred for their clarity.
Consequently, this patch attempts to use list comprehensions where it
makes sense.
When the mapped function has two arguments there is another problem that
can arise. In Python 3 map stops execution when the shortest argument
list is exhausted, while in Python 2 it stops when the longest argument
list is exhausted. Consequently the two argument case might need special
care. However, we have been running Python3 converted versions of numpy
since 1.5 without problems, so it is probably not something that affects
us.
Closes #3068
|
|
|
|
|
|
|
| |
Add `print_function` to all `from __future__ import ...` statements
and use the python3 print function syntax everywhere.
Closes #3078.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|\
| |
| | |
2to3: Put `from __future__ import division` in every python file.
|
| |
| |
| |
| |
| |
| |
| |
| | |
This should be harmless, as we already are division clean. However,
placement of this import takes some care. In the future a script
can be used to append new features without worry, at least until
such time as it exceeds a single line. Having that ability will
make it easier to deal with absolute imports and printing updates.
|
|/
|
|
|
| |
Replaces old style `f.im_func` and `f.im_class` method attributes
with `f.__func__` and `f.__class__`. Closes #3070.
|
|
|
|
|
| |
This replaces the `b.func_xxxx` with newer `__xxxx__` attribute names
For example, `f.__name__` replaces `f.func_name`
|
|
|
|
|
|
|
|
|
| |
This removes files and code supporting scons builds. After this change
numpy will only support builds using distutils or bento. The removal of
scons has been discussed on the list several times and a decision has been
made that scons support is no longer needed. This was originally discussed
for numpy 1.7 and because the distutils and bento methods are still
available we are skipping the usual deprecation period.
|
|
|
|
|
|
|
| |
When an array is created from a sequence of numeric (boolean, int, float,
complex) and string (bytes, str, unicode) values, the resulting array type
is string, but only the string values were being used to choose the string
length, leading to truncation of data.
|
| |
|