| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In Python3 `dict.items()`, `dict.keys()`, and `dict.values()` are
iterators. This causes problems when a list is needed so the 2to3 fixer
explicitly constructs a list when is finds on of those functions.
However, that is usually not necessary, so a lot of the work here has
been cleaning up those places where the fix is not needed. The big
exception to that is the `numpy/f2py/crackfortran.py` file. The code
there makes extensive use of loops that modify the contents of the
dictionary being looped through, which raises an error. That together
with the obscurity of the code in that file made it safest to let the
`dict` fixer do its worst.
Closes #3050.
|
|\ \
| |/
|/| |
MAINT: Cleanup some imports involving reduce.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Because reduce has been available in functools since Python 2.6 we
can get rid of the version checks we currently have before we import
it.
Also removes some reduce related skips in tools/py3tool.py. We were
already skipping the reduce fixer so this has no effect other than
cleaning up the code.
|
|/
|
|
|
|
|
| |
Add `print_function` to all `from __future__ import ...` statements
and use the python3 print function syntax everywhere.
Closes #3078.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In python3 range is an iterator and `xrange` has been removed. This has
two consequence for code:
1) Where a list is needed `list(range(...))` must be used.
2) `xrange` must be replaced by `range`
Both of these changes also work in python2 and this patch makes both.
There are three places fixed that do not need it, but I left them in
so that the result would be `xrange` clean.
Closes #3092
|
|
|
|
|
|
|
|
| |
I'm not sure this is the right fix, but test_closing_fid need to check
that garbage collection will close a file that goes through a bunch of
openings followed by dropping the reference. So the fix is to ignore
warnings during the test. I'd just ignore ResourceWarning, but it does
not look to be a built in warning in Python 2.7.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Example: except ValueError,msg: -> except ValueError as msg:
|
|
|
|
|
|
|
|
| |
This broke when function_base._nannop tried to fill a boolean array with
integer zeros, raising a 'safe_casting' error. It looks like nanargmax and
nanargmin would also break, and were probably incorrect for booleans in any
case. The fix is not to use fill values for boolean and integer dtypes.
Previously that was only done for the integer dtypes.
|
| |
|
|
|
|
|
| |
Fix ndindex for 0-d arrays.
Add tests for tuple arguments to ndindex
|
| |
|
| |
|
|
|
|
|
|
| |
The behavior of in1d is not really defined here, but it should
be at least consistent over different execution branches. This is
what it has been for most usages.
|
|
|
|
|
|
|
|
|
| |
There was a regression introduced by the speed improvement in
commit 6441c2a. This fixes it, and generally ravels the arrays for
np.in1d. However it can be argued that at least the first array should
not be ravelled in the future.
Fixes "Issue gh-2755"
|
|
|
|
|
| |
This switches us back to the behaviour seen in numpy 1.6 and earlier,
which it turns out that scikit-learn (and probably others) relied on.
|
| |
|
| |
|
| |
|
| |
|
|\
| |
| | |
BF bug #808
|
| |
| |
| |
| |
| |
| |
| | |
the argument passed to be used as the item to be insterted, and a list was
passed as the positions. This was fixed by simply duplicating the item to
be inserted so that it was a list of equal length and then control was
passed to the already exsisting code to handel this case
|
|\ \
| | |
| | | |
Meshgrid enhancements (>2-D, sparse grids, matrix indexing)
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| |/
|/|
| |
| | |
(test_io.TestSavezLoad)
|
|\ \
| | |
| | | |
BUG: make genfromtxt work with comments=None. Closes Github issue 329.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Small arrays are sorted with insertion sort, which is a stable
sort. Consequently larger arrays are needed to check that the
sort used is properly stable.
The test was also refactored to make it more compact.
|
|/ / |
|
| |
| |
| |
| |
| | |
otherwise zipfile of python3 gets confused to receive bytes for the header
whenever handle is opened for a text (unicode) file
|
| | |
|
| | |
|
|\ \
| | |
| | | |
ENH: Add kwarg support for vectorize (tickets #2100, #1156, and #1487) (clean)
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This is a substantial rewrite of vectorize to remove all introspection and
caching behaviour. This greatly simplifies the logic of the code, and allows
for much more generalized behaviour, simultaneously fixing tickets #1156,
#1487, and #2100. There will probably be a performance hit because caching is
no longer used (but should be able to be reinstated if needed).
As vectorize is a convenience function with poor performance in general,
perhaps this is okay. Rather than trying to inspect the function to determine
the number of arguments, defaults, and argument names, we just use the
arguments passed on the call to determine the behaviour on each call.
All tests pass and code is fully covered
Fixes:
Ticket #2100: kwarg support for vectorize
- API: Optional excluded argument to exclude some args from vectorization.
- Added documentation, examples, and coverage tests
- Added additional coverage test and base case for functions with no args
- Factored original behaviour into _vectorize_call
- Some minor documentation and error message corrections
Ticket #1156: Support vectorizing over instance methods
- No longer an issue since everything is determined by the call.
Ticket: #1487: result depends on execution order
- No longer caching, so the behaviour is as was expected.
ENH: Simple cache for vectorize
- Added simple cache to prevent vectorize from calling pyfunc twice on the first
argument when determining the output types and added regression test.
- Added documentation for excluded positional arguments.
- Documentation cleanups.
- Cleaned up variable names.
ENH: Performance improvements for backward compatibility of vectorize.
After some simple profiling, I found that the wrapping used to
support the caching of the previous commit wasted more time than
it saved, so I added a flag to allow the user to toggle. Moral:
caching makes sense only if the function is expensive and is off
by default.
I also compared performance with the original vectorize and opted
for keeping a cache of _ufunc if otypes is specified and there are
no kwargs/excluded vars. This case is easy to implement, and allows
users to reproduce (almost) the old performance characteristics if
needed. (The new version is about 5% slower in this case).
It would be much more complicated to add a similar cache in the case
where kwargs are used, and since a wrapper is used here, the
performance gain would be negligible (profiling showed that wrapping
was a more significant slowdown than the extra call to frompyfunc).
- API: Added cache kwarg which allows the user to toggle caching
of the first result.
- DOC: Added Notes section with a discussion of performance and a
warning that vectorize should not be used for performance.
- Added private _ufunc member to implement old-style of cache for
special case with no kwargs, excluded, and with otypes specified.
- Modified test case.
Partially address ticket #1982
- I tried to use hasattr(outputs, '__len__') rather than
isinstance(outputs, tuple) in order to allow for functions to return
lists. This, however, means that strings will get vectorized over
each character which breaks previous behaviour. Keeping old
behaviour for now.
|
| | |
| | |
| | |
| | | |
behavior.
|
|/ / |
|
| |
| |
| |
| |
| | |
The ipmt function was also fixed to handle broadcasting. The tests
were improved and extended to cover the broadcasting capability.
|
| |
| |
| |
| |
| | |
Fix incorrect python version checks in test_print.py.
Fix missing build_err_msg import and wrong variable in test_io.py.
|
| | |
|
|\ \
| | |
| | | |
ENH: Give digitize left or right open interval option
|
| | | |
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The various padding functions are exposed as options to a public 'pad'
function. Example:
pad(a, 5, mode='mean')
Current modes are 'constant', 'edge', 'linear_ramp', 'maximum', 'mean',
'median', 'minimum', 'reflect', 'symmetric', 'wrap', and <function>
This commit includes unit tests and doctests and is based on feature
request ticket #655.
|