This is a bugfix release for problems found in 1.13.0. The major changes are
fixes for the new memory overlap detection and temporary elision as well as
reversion of the removal of the boolean binary - operator. Users of 1.13.0
should upgrade.
Thr Python versions supported are 2.7 and 3.4 - 3.6. Note that the Python 3.6
wheels available from PIP are built against 3.6.1, hence will not work when
used with 3.6.0 due to Python bug 29943_. NumPy 1.13.2 will be released shortly
after Python 3.6.2 is out to fix that problem. If you are using 3.6.0 the
workaround is to upgrade to 3.6.1 or use an earlier Python version.
A total of 19 pull requests were merged for this release.
9240 DOC: BLD: fix lots of Sphinx warnings/errors.
9255 Revert "DEP: Raise TypeError for subtract(bool, bool)."
9261 BUG: don't elide into readonly and updateifcopy temporaries for...
9262 BUG: fix missing keyword rename for common block in numpy.f2py
9263 BUG: handle resize of 0d array
9267 DOC: update f2py front page and some doc build metadata.
9299 BUG: Fix Intel compilation on Unix.
9317 BUG: fix wrong ndim used in empty where check
9319 BUG: Make extensions compilable with MinGW on Py2.7
9339 BUG: Prevent crash if ufunc doc string is null
9340 BUG: umath: un-break ufunc where= when no out= is given
9371 DOC: Add isnat/positive ufunc to documentation
9372 BUG: Fix error in fromstring function from numpy.core.records...
9373 BUG: ')' is printed at the end pointer of the buffer in numpy.f2py.
9374 DOC: Create NumPy 1.13.1 release notes.
9376 BUG: Prevent hang traversing ufunc userloop linked list
9377 DOC: Use x1 and x2 in the heaviside docstring.
9378 DOC: Add $PARAMS to the isnat docstring
9379 DOC: Update the 1.13.1 release notes
Contributors
A total of 12 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Andras Deak +
Bob Eldering +
Charles Harris
Daniel Hrisca +
Eric Wieser
Joshua Leahy +
Julian Taylor
Michael Seifert
Pauli Virtanen
Ralf Gommers
Roland Kaufmann
Warren Weckesser
=========================
1.13.0
==========================
This release supports Python 2.7 and 3.4 - 3.6.
Highlights
Operations like a + b + c will reuse temporaries on some platforms,
resulting in less memory use and faster execution.
Inplace operations check if inputs overlap outputs and create temporaries
to avoid problems.
New __array_ufunc__ attribute provides improved ability for classes to
override default ufunc behavior.
New np.block function for creating blocked arrays.
New functions
New np.positive ufunc.
New np.divmod ufunc provides more efficient divmod.
New np.isnat ufunc tests for NaT special values.
New np.heaviside ufunc computes the Heaviside function.
New np.isin function, improves on in1d.
New np.block function for creating blocked arrays.
New PyArray_MapIterArrayCopyIfOverlap added to NumPy C-API.
See below for details.
Deprecations
Calling np.fix, np.isposinf, and np.isneginf with f(x, y=out)
is deprecated - the argument should be passed as f(x, out=out), which
matches other ufunc-like interfaces.
Use of the C-API NPY_CHAR type number deprecated since version 1.7 will
now raise deprecation warnings at runtime. Extensions built with older f2py
versions need to be recompiled to remove the warning.
np.ma.argsort, np.ma.minimum.reduce, and np.ma.maximum.reduce
should be called with an explicit axis argument when applied to arrays with
more than 2 dimensions, as the default value of this argument (None) is
inconsistent with the rest of numpy (-1, 0, and 0, respectively).
np.ma.MaskedArray.mini is deprecated, as it almost duplicates the
functionality of np.MaskedArray.min. Exactly equivalent behaviour
can be obtained with np.ma.minimum.reduce.
The single-argument form of np.ma.minimum and np.ma.maximum is
deprecated. np.maximum. np.ma.minimum(x) should now be spelt
np.ma.minimum.reduce(x), which is consistent with how this would be done
with np.minimum.
Calling ndarray.conjugate on non-numeric dtypes is deprecated (it
should match the behavior of np.conjugate, which throws an error).
Calling expand_dims when the axis keyword does not satisfy
-a.ndim - 1 <= axis <= a.ndim, where a is the array being reshaped,
is deprecated.
Future Changes
Assignment between structured arrays with different field names will change
in NumPy 1.14. Previously, fields in the dst would be set to the value of the
identically-named field in the src. In numpy 1.14 fields will instead be
assigned 'by position': The n-th field of the dst will be set to the n-th
field of the src array. Note that the FutureWarning raised in NumPy 1.12
incorrectly reported this change as scheduled for NumPy 1.13 rather than
NumPy 1.14.
Build System Changes
numpy.distutils now automatically determines C-file dependencies with
GCC compatible compilers.
Compatibility notes
Error type changes
numpy.hstack() now throws ValueError instead of IndexError when
input is empty.
Functions taking an axis argument, when that argument is out of range, now
throw np.AxisError instead of a mixture of IndexError and
ValueError. For backwards compatibility, AxisError subclasses both of
these.
Tuple object dtypes
Support has been removed for certain obscure dtypes that were unintentionally
allowed, of the form (old_dtype, new_dtype), where either of the dtypes
is or contains the object dtype. As an exception, dtypes of the form
(object, [('name', object)]) are still supported due to evidence of
existing use.
DeprecationWarning to error
See Changes section for more detail.
partition, TypeError when non-integer partition index is used.
NpyIter_AdvancedNew, ValueError when oa_ndim == 0 and op_axes is NULL
negative(bool_), TypeError when negative applied to booleans.
subtract(bool_, bool_), TypeError when subtracting boolean from boolean.
Previously bool(dtype) would fall back to the default python
implementation, which checked if len(dtype) > 0. Since dtype objects
implement __len__ as the number of record fields, bool of scalar dtypes
would evaluate to False, which was unintuitive. Now bool(dtype) == True
for all dtypes.
__getslice__ and __setslice__ are no longer needed in ndarray subclasses
When subclassing np.ndarray in Python 2.7, it is no longer necessary to
implement __*slice__ on the derived class, as __*item__ will intercept
these calls correctly.
Any code that did implement these will work exactly as before. Code that
invokesndarray.__getslice__ (e.g. through super(...).__getslice__) will
now issue a DeprecationWarning - .__getitem__(slice(start, end)) should be
used instead.
Indexing MaskedArrays/Constants with ... (ellipsis) now returns MaskedArray
This behavior mirrors that of np.ndarray, and accounts for nested arrays in
MaskedArrays of object dtype, and ellipsis combined with other forms of
indexing.
C API changes
GUfuncs on empty arrays and NpyIter axis removal
It is now allowed to remove a zero-sized axis from NpyIter. Which may mean
that code removing axes from NpyIter has to add an additional check when
accessing the removed dimensions later on.
The largest followup change is that gufuncs are now allowed to have zero-sized
inner dimensions. This means that a gufunc now has to anticipate an empty inner
dimension, while this was never possible and an error raised instead.
For most gufuncs no change should be necessary. However, it is now possible
for gufuncs with a signature such as (..., N, M) -> (..., M) to return
a valid result if N=0 without further wrapping code.
PyArray_MapIterArrayCopyIfOverlap added to NumPy C-API
Similar to PyArray_MapIterArray but with an additional copy_if_overlap
argument. If copy_if_overlap != 0, checks if input has memory overlap with
any of the other arrays and make copies as appropriate to avoid problems if the
input is modified during the iteration. See the documentation for more complete
documentation.
New Features
__array_ufunc__ added
This is the renamed and redesigned __numpy_ufunc__. Any class, ndarray
subclass or not, can define this method or set it to None in order to
override the behavior of NumPy's ufuncs. This works quite similarly to Python's
__mul__ and other binary operation routines. See the documentation for a
more detailed description of the implementation and behavior of this new
option. The API is provisional, we do not yet guarantee backward compatibility
as modifications may be made pending feedback. See the NEP and
documentation for more details.
This ufunc corresponds to unary +, but unlike + on an ndarray it will raise
an error if array values do not support numeric operations.
New divmod ufunc
This ufunc corresponds to the Python builtin divmod, and is used to implement
divmod when called on numpy arrays. np.divmod(x, y) calculates a result
equivalent to (np.floor_divide(x, y), np.remainder(x, y)) but is
approximately twice as fast as calling the functions separately.
np.isnat ufunc tests for NaT special datetime and timedelta values
The new ufunc np.isnat finds the positions of special NaT values
within datetime and timedelta arrays. This is analogous to np.isnan.
np.heaviside ufunc computes the Heaviside function
The new function np.heaviside(x, h0) (a ufunc) computes the Heaviside
function:
.. code::
{ 0 if x < 0,
heaviside(x, h0) = { h0 if x == 0,
{ 1 if x > 0.
np.block function for creating blocked arrays
Add a new block function to the current stacking functions vstack,
hstack, and stack. This allows concatenation across multiple axes
simultaneously, with a similar syntax to array creation, but where elements
can themselves be arrays. For instance::
While primarily useful for block matrices, this works for arbitrary dimensions
of arrays.
It is similar to Matlab's square bracket notation for creating block matrices.
isin function, improving on in1d
The new function isin tests whether each element of an N-dimensonal
array is present anywhere within a second array. It is an enhancement
of in1d that preserves the shape of the first array.
Temporary elision
On platforms providing the backtrace function NumPy will try to avoid
creating temporaries in expression involving basic numeric types.
For example d = a + b + c is transformed to d = a + b; d += c which can
improve performance for large arrays as less memory bandwidth is required to
perform the operation.
axes argument for unique
In an N-dimensional array, the user can now choose the axis along which to look
for duplicate N-1-dimensional elements using numpy.unique. The original
behaviour is recovered if axis=None (default).
np.gradient now supports unevenly spaced data
Users can now specify a not-constant spacing for data.
In particular np.gradient can now take:
A single scalar to specify a sample distance for all dimensions.
N scalars to specify a constant sample distance for each dimension.
i.e. dx, dy, dz, ...
N arrays to specify the coordinates of the values along each dimension of F.
The length of the array must match the size of the corresponding dimension
Any combination of N scalars/arrays with the meaning of 2. and 3.
This means that, e.g., it is now possible to do the following::
Support for returning arrays of arbitrary dimensions in apply_along_axis
Previously, only scalars or 1D arrays could be returned by the function passed
to apply_along_axis. Now, it can return an array of any dimensionality
(including 0D), and the shape of this array replaces the axis of the array
being iterated over.
.ndim property added to dtype to complement .shape
For consistency with ndarray and broadcast, d.ndim is a shorthand
for len(d.shape).
Support for tracemalloc in Python 3.6
NumPy now supports memory tracing with tracemalloc_ module of Python 3.6 or
newer. Memory allocations from NumPy are placed into the domain defined by
numpy.lib.tracemalloc_domain.
Note that NumPy allocation will not show up in tracemalloc_ of earlier Python
versions.
NumPy may be built with relaxed stride checking debugging
Setting NPY_RELAXED_STRIDES_DEBUG=1 in the environment when relaxed stride
checking is enabled will cause NumPy to be compiled with the affected strides
set to the maximum value of npy_intp in order to help detect invalid usage of
the strides in downstream projects. When enabled, invalid usage often results
in an error being raised, but the exact type of error depends on the details of
the code. TypeError and OverflowError have been observed in the wild.
It was previously the case that this option was disabled for releases and
enabled in master and changing between the two required editing the code. It is
now disabled by default but can be enabled for test builds.
Improvements
Ufunc behavior for overlapping inputs
Operations where ufunc input and output operands have memory overlap
produced undefined results in previous NumPy versions, due to data
dependency issues. In NumPy 1.13.0, results from such operations are
now defined to be the same as for equivalent operations where there is
no memory overlap.
Operations affected now make temporary copies, as needed to eliminate
data dependency. As detecting these cases is computationally
expensive, a heuristic is used, which may in rare cases result to
needless temporary copies. For operations where the data dependency
is simple enough for the heuristic to analyze, temporary copies will
not be made even if the arrays overlap, if it can be deduced copies
are not necessary. As an example,np.add(a, b, out=a) will not
involve copies.
To illustrate a previously undefined operation::
>>> x = np.arange(16).astype(float)
>>> np.add(x[1:], x[:-1], out=x[1:])
In NumPy 1.13.0 the last line is guaranteed to be equivalent to::
A similar operation with simple non-problematic data dependence is::
>>> x = np.arange(16).astype(float)
>>> np.add(x[1:], x[:-1], out=x[:-1])
It will continue to produce the same results as in previous NumPy
versions, and will not involve unnecessary temporary copies.
The change applies also to in-place binary operations, for example::
>>> x = np.random.rand(500, 500)
>>> x += x.T
This statement is now guaranteed to be equivalent to x[...] = x + x.T,
whereas in previous NumPy versions the results were undefined.
Partial support for 64-bit f2py extensions with MinGW
Extensions that incorporate Fortran libraries can now be built using the free
MinGW toolset, also under Python 3.5. This works best for extensions that only
do calculations and uses the runtime modestly (reading and writing from files,
for instance). Note that this does not remove the need for Mingwpy; if you make
extensive use of the runtime, you will most likely run into issues. Instead,
it should be regarded as a band-aid until Mingwpy is fully functional.
Extensions can also be compiled using the MinGW toolset using the runtime
library from the (moveable) WinPython 3.4 distribution, which can be useful for
programs with a PySide1/Qt4 front-end.
Performance improvements for packbits and unpackbits
The functions numpy.packbits with boolean input and numpy.unpackbits have
been optimized to be a significantly faster for contiguous data.
Fix for PPC long double floating point information
In previous versions of NumPy, the finfo function returned invalid
information about the double double_ format of the longdouble float type
on Power PC (PPC). The invalid values resulted from the failure of the NumPy
algorithm to deal with the variable number of digits in the significand
that are a feature of PPC long doubles. This release by-passes the failing
algorithm by using heuristics to detect the presence of the PPC double double
format. A side-effect of using these heuristics is that the finfo
function is faster than previous releases.
Subclasses of ndarray with no repr specialization now correctly indent
their data and type lines.
More reliable comparisons of masked arrays
Comparisons of masked arrays were buggy for masked scalars and failed for
structured arrays with dimension higher than one. Both problems are now
solved. In the process, it was ensured that in getting the result for a
structured array, masked fields are properly ignored, i.e., the result is equal
if all fields that are non-masked in both are equal, thus making the behaviour
identical to what one gets by comparing an unstructured masked array and then
doing .all() over some axis.
np.matrix with booleans elements can now be created using the string syntax
np.matrix failed whenever one attempts to use it with booleans, e.g.,
np.matrix('True'). Now, this works as expected.
More linalg operations now accept empty vectors and matrices
All of the following functions in np.linalg now work when given input
arrays with a 0 in the last two dimensions: det, slogdet, pinv,
eigvals, eigvalsh, eig, eigh.
Bundled version of LAPACK is now 3.2.2
NumPy comes bundled with a minimal implementation of lapack for systems without
a lapack library installed, under the name of lapack_lite. This has been
upgraded from LAPACK 3.0.0 (June 30, 1999) to LAPACK 3.2.2 (June 30, 2010). See
the LAPACK changelogs_ for details on the all the changes this entails.
While no new features are exposed through numpy, this fixes some bugs
regarding "workspace" sizes, and in some places may use faster algorithms.
reduce of np.hypot.reduce and np.logical_xor allowed in more cases
This now works on empty arrays, returning 0, and can reduce over multiple axes.
Previously, a ValueError was thrown in these cases.
Better repr of object arrays
Object arrays that contain themselves no longer cause a recursion error.
Object arrays that contain list objects are now printed in a way that makes
clear the difference between a 2d object array, and a 1d object array of lists.
Changes
argsort on masked arrays takes the same default arguments as sort
By default, argsort now places the masked values at the end of the sorted
array, in the same way that sort already did. Additionally, the
end_with argument is added to argsort, for consistency with sort.
Note that this argument is not added at the end, so breaks any code that
passed fill_value as a positional argument.
average now preserves subclasses
For ndarray subclasses, numpy.average will now return an instance of the
subclass, matching the behavior of most other NumPy functions such as mean.
As a consequence, also calls that returned a scalar may now return a subclass
array scalar.
array == None and array != None do element-wise comparison
Previously these operations returned scalars False and True respectively.
np.equal, np.not_equal for object arrays ignores object identity
Previously, these functions always treated identical objects as equal. This had
the effect of overriding comparison failures, comparison of objects that did
not return booleans, such as np.arrays, and comparison of objects where the
results differed from object identity, such as NaNs.
Boolean indexing changes
Boolean array-likes (such as lists of python bools) are always treated as
boolean indexes.
Boolean scalars (including python True) are legal boolean indexes and
never treated as integers.
Boolean indexes must match the dimension of the axis that they index.
Boolean indexes used on the lhs of an assignment must match the dimensions of
the rhs.
Boolean indexing into scalar arrays return a new 1-d array. This means that
array(1)[array(True)] gives array([1]) and not the original array.
np.random.multivariate_normal behavior with bad covariance matrix
It is now possible to adjust the behavior the function will have when dealing
with the covariance matrix by using two new keyword arguments:
tol can be used to specify a tolerance to use when checking that
the covariance matrix is positive semidefinite.
check_valid can be used to configure what the function will do in the
presence of a matrix that is not positive semidefinite. Valid options are
ignore, warn and raise. The default value, warn keeps the
the behavior used on previous releases.
assert_array_less compares np.inf and -np.inf now
Previously, np.testing.assert_array_less ignored all infinite values. This
is not the expected behavior both according to documentation and intuitively.
Now, -inf < x < inf is considered True for any real number x and all
other cases fail.
assert_array_ and masked arrays assert_equal hide less warnings
Some warnings that were previously hidden by the assert_array_
functions are not hidden anymore. In most cases the warnings should be
correct and, should they occur, will require changes to the tests using
these functions.
For the masked array assert_equal version, warnings may occur when
comparing NaT. The function presently does not handle NaT or NaN
specifically and it may be best to avoid it at this time should a warning
show up due to this change.
offset attribute value in memmap objects
The offset attribute in a memmap object is now set to the
offset into the file. This is a behaviour change only for offsets
greater than mmap.ALLOCATIONGRANULARITY.
np.real and np.imag return scalars for scalar inputs
Previously, np.real and np.imag used to return array objects when
provided a scalar input, which was inconsistent with other functions like
np.angle and np.conj.
The polynomial convenience classes cannot be passed to ufuncs
The ABCPolyBase class, from which the convenience classes are derived, sets
__array_ufun__ = None in order of opt out of ufuncs. If a polynomial
convenience class instance is passed as an argument to a ufunc, a TypeError
will now be raised.
Output arguments to ufuncs can be tuples also for ufunc methods
For calls to ufuncs, it was already possible, and recommended, to use an
out argument with a tuple for ufuncs with multiple outputs. This has now
been extended to output arguments in the reduce, accumulate, and
reduceat methods. This is mostly for compatibility with __array_ufunc;
there are no ufuncs yet that have more than one output.
==========================
1.12.1
==========================
NumPy 1.12.1 supports Python 2.7 and 3.4 - 3.6 and fixes bugs and regressions
found in NumPy 1.12.0. In particular, the regression in f2py constant parsing
is fixed. Wheels for Linux, Windows, and OSX can be found on pypi,
Bugs Fixed
BUG: Fix wrong future nat warning and equiv type logic error...
BUG: Fix wrong masked median for some special cases
DOC: Place np.average in inline code
TST: Work around isfinite inconsistency on i386
BUG: Guard against replacing constants without '_' spec in f2py.
BUG: Fix mean for float 16 non-array inputs for 1.12
BUG: Fix calling python api with error set and minor leaks for...
BUG: Make iscomplexobj compatible with custom dtypes again
BUG: Fix undefined behaviour induced by bad __array_wrap__
BUG: Fix MaskedArray.setitem
BUG: PPC64el machines are POWER for Fortran in f2py
BUG: Look up methods on MaskedArray in _frommethod
BUG: Remove extra digit in binary_repr at limit
BUG: Fix deepcopy regression for empty arrays.
BUG: Fix ma.median for empty ndarrays
==========================
1.12.0
==========================
This release supports Python 2.7 and 3.4 - 3.6.
Highlights
The NumPy 1.12.0 release contains a large number of fixes and improvements, but
few that stand out above all others. That makes picking out the highlights
somewhat arbitrary but the following may be of particular interest or indicate
areas likely to have future consequences.
Order of operations in np.einsum can now be optimized for large speed improvements.
New signature argument to np.vectorize for vectorizing with core dimensions.
The keepdims argument was added to many functions.
New context manager for testing warnings
Support for BLIS in numpy.distutils
Much improved support for PyPy (not yet finished)
Dropped Support
Support for Python 2.6, 3.2, and 3.3 has been dropped.
Added Support
Support for PyPy 2.7 v5.6.0 has been added. While not complete (nditer
updateifcopy is not supported yet), this is a milestone for PyPy's
C-API compatibility layer.
Build System Changes
Library order is preserved, instead of being reordered to match that of
the directories.
Deprecations
Assignment of ndarray object's data attribute
Assigning the 'data' attribute is an inherently unsafe operation as pointed
out in gh-7083. Such a capability will be removed in the future.
Unsafe int casting of the num attribute in linspace
np.linspace now raises DeprecationWarning when num cannot be safely
interpreted as an integer.
Insufficient bit width parameter to binary_repr
If a 'width' parameter is passed into binary_repr that is insufficient to
represent the number in base 2 (positive) or 2's complement (negative) form,
the function used to silently ignore the parameter and return a representation
using the minimal number of bits needed for the form in question. Such behavior
is now considered unsafe from a user perspective and will raise an error in the
future.
Future Changes
In 1.13 NAT will always compare False except for NAT != NAT,
which will be True. In short, NAT will behave like NaN
In 1.13 np.average will preserve subclasses, to match the behavior of most
other numpy functions such as np.mean. In particular, this means calls which
returned a scalar may return a 0-d subclass object instead.
Multiple-field manipulation of structured arrays
In 1.13 the behavior of structured arrays involving multiple fields will change
in two ways:
First, indexing a structured array with multiple fields (eg,
arr[['f1', 'f3']]) will return a view into the original array in 1.13,
instead of a copy. Note the returned view will have extra padding bytes
corresponding to intervening fields in the original array, unlike the copy in
1.12, which will affect code such as arr[['f1', 'f3']].view(newdtype).
Second, for numpy versions 1.6 to 1.12 assignment between structured arrays
occurs "by field name": Fields in the destination array are set to the
identically-named field in the source array or to 0 if the source does not have
a field::
>>> a = np.array([(1,2),(3,4)], dtype=[('x', 'i4'), ('y', 'i4')])
>>> b = np.ones(2, dtype=[('z', 'i4'), ('y', 'i4'), ('x', 'i4')])
>>> b[:] = a
>>> b
array([(0, 2, 1), (0, 4, 3)],
dtype=[('z', '<i4'), ('y', '<i4'), ('x', '<i4')])
In 1.13 assignment will instead occur "by position": The Nth field of the
destination will be set to the Nth field of the source regardless of field
name. The old behavior can be obtained by using indexing to reorder the fields
before
assignment, e.g., b[['x', 'y']] = a[['y', 'x']].
Compatibility notes
DeprecationWarning to error
Indexing with floats raises IndexError,
e.g., a[0, 0.0].
Indexing with non-integer array_like raises IndexError,
e.g., a['1', '2']
Indexing with multiple ellipsis raises IndexError,
e.g., a[..., ...].
Non-integers used as index values raise TypeError,
e.g., in reshape, take, and specifying reduce axis.
FutureWarning to changed behavior
np.full now returns an array of the fill-value's dtype if no dtype is
given, instead of defaulting to float.
np.average will emit a warning if the argument is a subclass of ndarray,
as the subclass will be preserved starting in 1.13. (see Future Changes)
power and ** raise errors for integer to negative integer powers
The previous behavior depended on whether numpy scalar integers or numpy
integer arrays were involved.
For arrays
Zero to negative integer powers returned least integral value.
Both 1, -1 to negative integer powers returned correct values.
The remaining integers returned zero when raised to negative integer powers.
For scalars
Zero to negative integer powers returned least integral value.
Both 1, -1 to negative integer powers returned correct values.
The remaining integers sometimes returned zero, sometimes the
correct float depending on the integer type combination.
All of these cases now raise a ValueError except for those integer
combinations whose common type is float, for instance uint64 and int8. It was
felt that a simple rule was the best way to go rather than have special
exceptions for the integer units. If you need negative powers, use an inexact
type.
Relaxed stride checking is the default
This will have some impact on code that assumed that F_CONTIGUOUS and
C_CONTIGUOUS were mutually exclusive and could be set to determine the
default order for arrays that are now both.
The np.percentile 'midpoint' interpolation method fixed for exact indices
The 'midpoint' interpolator now gives the same result as 'lower' and 'higher' when
the two coincide. Previous behavior of 'lower' + 0.5 is fixed.
keepdims kwarg is passed through to user-class methods
numpy functions that take a keepdims kwarg now pass the value
through to the corresponding methods on ndarray sub-classes. Previously the
keepdims keyword would be silently dropped. These functions now have
the following behavior:
If user does not provide keepdims, no keyword is passed to the underlying
method.
Any user-provided value of keepdims is passed through as a keyword
argument to the method.
This will raise in the case where the method does not support a
keepdims kwarg and the user explicitly passes in keepdims.
The following functions are changed: sum, product,
sometrue, alltrue, any, all, amax, amin,
prod, mean, std, var, nanmin, nanmax,
nansum, nanprod, nanmean, nanmedian, nanvar,
nanstd
bitwise_and identity changed
The previous identity was 1, it is now -1. See entry in Improvements for
more explanation.
ma.median warns and returns nan when unmasked invalid values are encountered
Similar to unmasked median the masked median ma.median now emits a Runtime
warning and returns NaN in slices where an unmasked NaN is present.
Greater consistancy in assert_almost_equal
The precision check for scalars has been changed to match that for arrays. It
is now::
abs(actual - desired) < 1.5 * 10**(-decimal)
Note that this is looser than previously documented, but agrees with the
previous implementation used in assert_array_almost_equal. Due to the
change in implementation some very delicate tests may fail that did not
fail before.
NoseTester behaviour of warnings during testing
When raise_warnings="develop" is given, all uncaught warnings will now
be considered a test failure. Previously only selected ones were raised.
Warnings which are not caught or raised (mostly when in release mode)
will be shown once during the test cycle similar to the default python
settings.
assert_warns and deprecated decorator more specific
The assert_warns function and context manager are now more specific
to the given warning category. This increased specificity leads to them
being handled according to the outer warning settings. This means that
no warning may be raised in cases where a wrong category warning is given
and ignored outside the context. Alternatively the increased specificity
may mean that warnings that were incorrectly ignored will now be shown
or raised. See also the new suppress_warnings context manager.
The same is true for the deprecated decorator.
C API
No changes.
New Features
Writeable keyword argument for as_strided
np.lib.stride_tricks.as_strided now has a writeable
keyword argument. It can be set to False when no write operation
to the returned array is expected to avoid accidental
unpredictable writes.
axes keyword argument for rot90
The axes keyword argument in rot90 determines the plane in which the
array is rotated. It defaults to axes=(0,1) as in the original function.
Generalized flip
flipud and fliplr reverse the elements of an array along axis=0 and
axis=1 respectively. The newly added flip function reverses the elements of
an array along any given axis.
np.count_nonzero now has an axis parameter, allowing
non-zero counts to be generated on more than just a flattened
array object.
BLIS support in numpy.distutils
Building against the BLAS implementation provided by the BLIS library is now
supported. See the [blis] section in site.cfg.example (in the root of
the numpy repo or source distribution).
Hook in numpy/__init__.py to run distribution-specific checks
Binary distributions of numpy may need to run specific hardware checks or load
specific libraries during numpy initialization. For example, if we are
distributing numpy with a BLAS library that requires SSE2 instructions, we
would like to check the machine on which numpy is running does have SSE2 in
order to give an informative error.
Add a hook in numpy/__init__.py to import a numpy/_distributor_init.py
file that will remain empty (bar a docstring) in the standard numpy source,
but that can be overwritten by people making binary distributions of numpy.
New nanfunctions nancumsum and nancumprod added
Nan-functions nancumsum and nancumprod have been added to
compute cumsum and cumprod by ignoring nans.
np.interp can now interpolate complex values
np.lib.interp(x, xp, fp) now allows the interpolated array fp
to be complex and will interpolate at complex128 precision.
New polynomial evaluation function polyvalfromroots added
The new function polyvalfromroots evaluates a polynomial at given points
from the roots of the polynomial. This is useful for higher order polynomials,
where expansion into polynomial coefficients is inaccurate at machine
precision.
New array creation function geomspace added
The new function geomspace generates a geometric sequence. It is similar
to logspace, but with start and stop specified directly:
geomspace(start, stop) behaves the same as
logspace(log10(start), log10(stop)).
New context manager for testing warnings
A new context manager suppress_warnings has been added to the testing
utils. This context manager is designed to help reliably test warnings.
Specifically to reliably filter/ignore warnings. Ignoring warnings
by using an "ignore" filter in Python versions before 3.4.x can quickly
result in these (or similar) warnings not being tested reliably.
The context manager allows to filter (as well as record) warnings similar
to the catch_warnings context, but allows for easier specificity.
Also printing warnings that have not been filtered or nesting the
context manager will work as expected. Additionally, it is possible
to use the context manager as a decorator which can be useful when
multiple tests give need to hide the same warning.
New masked array functions ma.convolve and ma.correlate added
These functions wrapped the non-masked versions, but propagate through masked
values. There are two different propagation modes. The default causes masked
values to contaminate the result with masks, but the other mode only outputs
masks if there is no alternative.
New float_power ufunc
The new float_power ufunc is like the power function except all
computation is done in a minimum precision of float64. There was a long
discussion on the numpy mailing list of how to treat integers to negative
integer powers and a popular proposal was that the __pow__ operator should
always return results of at least float64 precision. The float_power
function implements that option. Note that it does not support object arrays.
np.loadtxt now supports a single integer as usecol argument
Instead of using usecol=(n,) to read the nth column of a file
it is now allowed to use usecol=n. Also the error message is
more user friendly when a non-integer is passed as a column index.
Improved automated bin estimators for histogram
Added 'doane' and 'sqrt' estimators to histogram via the bins
argument. Added support for range-restricted histograms with automated
bin estimation.
np.roll can now roll multiple axes at the same time
The shift and axis arguments to roll are now broadcast against each
other, and each specified axis is shifted accordingly.
The __complex__ method has been implemented for the ndarrays
Calling complex() on a size 1 array will now cast to a python
complex.
pathlib.Path objects now supported
The standard np.load, np.save, np.loadtxt, np.savez, and similar
functions can now take pathlib.Path objects as an argument instead of a
filename or open file object.
New bits attribute for np.finfo
This makes np.finfo consistent with np.iinfo which already has that
attribute.
New signature argument to np.vectorize
This argument allows for vectorizing user defined functions with core
dimensions, in the style of NumPy's
:ref:generalized universal functions<c-api.generalized-ufuncs>. This allows
for vectorizing a much broader class of functions. For example, an arbitrary
distance metric that combines two vectors to produce a scalar could be
vectorized with signature='(n),(n)->()'. See np.vectorize for full
details.
Emit py3kwarnings for division of integer arrays
To help people migrate their code bases from Python 2 to Python 3, the
python interpreter has a handy option -3, which issues warnings at runtime.
One of its warnings is for integer division::
$ python -3 -c "2/3"
-c:1: DeprecationWarning: classic int division
In Python 3, the new integer division semantics also apply to numpy arrays.
With this version, numpy will emit a similar warning::
$ python -3 -c "import numpy as np; np.array(2)/np.array(3)"
-c:1: DeprecationWarning: numpy: classic int division
numpy.sctypes now includes bytes on Python3 too
Previously, it included str (bytes) and unicode on Python2, but only str
(unicode) on Python3.
Improvements
bitwise_and identity changed
The previous identity was 1 with the result that all bits except the LSB were
masked out when the reduce method was used. The new identity is -1, which
should work properly on twos complement machines as all bits will be set to
one.
Generalized Ufuncs will now unlock the GIL
Generalized Ufuncs, including most of the linalg module, will now unlock
the Python global interpreter lock.
Caches in np.fft are now bounded in total size and item count
The caches in np.fft that speed up successive FFTs of the same length can no
longer grow without bounds. They have been replaced with LRU (least recently
used) caches that automatically evict no longer needed items if either the
memory size or item count limit has been reached.
Improved handling of zero-width string/unicode dtypes
Fixed several interfaces that explicitly disallowed arrays with zero-width
string dtypes (i.e. dtype('S0') or dtype('U0'), and fixed several
bugs where such dtypes were not handled properly. In particular, changed
ndarray.__new__ to not implicitly convert dtype('S0') to
dtype('S1') (and likewise for unicode) when creating new arrays.
Integer ufuncs vectorized with AVX2
If the cpu supports it at runtime the basic integer ufuncs now use AVX2
instructions. This feature is currently only available when compiled with GCC.
Order of operations optimization in np.einsum
np.einsum now supports the optimize argument which will optimize the
order of contraction. For example, np.einsum would complete the chain dot
example np.einsum(‘ij,jk,kl->il’, a, b, c) in a single pass which would
scale like N^4; however, when optimize=Truenp.einsum will create
an intermediate array to reduce this scaling to N^3 or effectively
np.dot(a, b).dot(c). Usage of intermediate tensors to reduce scaling has
been applied to the general einsum summation notation. See np.einsum_path
for more details.
quicksort has been changed to an introsort
The quicksort kind of np.sort and np.argsort is now an introsort which
is regular quicksort but changing to a heapsort when not enough progress is
made. This retains the good quicksort performance while changing the worst case
runtime from O(N^2) to O(N*log(N)).
ediff1d improved performance and subclass handling
The ediff1d function uses an array instead on a flat iterator for the
subtraction. When to_begin or to_end is not None, the subtraction is performed
in place to eliminate a copy operation. A side effect is that certain
subclasses are handled better, namely astropy.Quantity, since the complete
array is created, wrapped, and then begin and end values are set, instead of
using concatenate.
Improved precision of ndarray.mean for float16 arrays
The computation of the mean of float16 arrays is now carried out in float32 for
improved precision. This should be useful in packages such as Theano
where the precision of float16 is adequate and its smaller footprint is
desirable.
Changes
All array-like methods are now called with keyword arguments in fromnumeric.py
Internally, many array-like methods in fromnumeric.py were being called with
positional arguments instead of keyword arguments as their external signatures
were doing. This caused a complication in the downstream 'pandas' library
that encountered an issue with 'numpy' compatibility. Now, all array-like
methods in this module are called with keyword arguments instead.
Operations on np.memmap objects return numpy arrays in most cases
Previously operations on a memmap object would misleadingly return a memmap
instance even if the result was actually not memmapped. For example,
arr + 1 or arr + arr would return memmap instances, although no memory
from the output array is memmapped. Version 1.12 returns ordinary numpy arrays
from these operations.
Also, reduction of a memmap (e.g. .sum(axis=None) now returns a numpy
scalar instead of a 0d memmap.
stacklevel of warnings increased
The stacklevel for python based warnings was increased so that most warnings
will report the offending line of the user code instead of the line the
warning itself is given. Passing of stacklevel is now tested to ensure that
new warnings will receive the stacklevel argument.
This causes warnings with the "default" or "module" filter to be shown once
for every offending user code line or user module instead of only once. On
python versions before 3.4, this can cause warnings to appear that were falsely
ignored before, which may be surprising especially in test suits.
1.11.3
==========================
Numpy 1.11.3 fixes a bug that leads to file corruption when very large files
opened in append mode are used in ndarray.tofile. It supports Python
versions 2.6 - 2.7 and 3.2 - 3.5. Wheels for Linux, Windows, and OS X can be
found on PyPI.
Contributors to maintenance/1.11.3
A total of 2 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Charles Harris
Pavel Potocek +
Pull Requests Merged
8341 <https://github.com/numpy/numpy/pull/8341>__: BUG: Fix ndarray.tofile large file corruption in append mode.
8346 <https://github.com/numpy/numpy/pull/8346>__: TST: Fix tests in PR 8341 for NumPy 1.11.x
=========================
1.11.2
==========================
Numpy 1.11.2 supports Python 2.6 - 2.7 and 3.2 - 3.5. It fixes bugs and
regressions found in Numpy 1.11.1 and includes several build related
improvements. Wheels for Linux, Windows, and OS X can be found on PyPI.
Pull Requests Merged
Fixes overridden by later merges and release notes updates are omitted.
7736 BUG: Many functions silently drop 'keepdims' kwarg.
7738 ENH: Add extra kwargs and update doc of many MA methods.
8005 BLD: Remove __NUMPY_SETUP__ from builtins at end of setup.py.
8010 MAINT: Remove leftover imp module imports.
8020 BUG: Fix return of np.ma.count if keepdims is True and axis is None.
8024 BUG: Fix numpy.ma.median.
8031 BUG: Fix np.ma.median with only one non-masked value.
8044 BUG: Fix bug in NpyIter buffering with discontinuous arrays.
==========================
1.11.1
==========================
Numpy 1.11.1 supports Python 2.6 - 2.7 and 3.2 - 3.5. It fixes bugs and
regressions found in Numpy 1.11.0 and includes several build related
improvements. Wheels for Linux, Windows, and OSX can be found on pypi.
Fixes Merged
7506 BUG: Make sure numpy imports on python 2.6 when nose is unavailable.
7530 BUG: Floating exception with invalid axis in np.lexsort.
7608 BUG: linalg.norm(): Don't convert object arrays to float.
7638 BLD: Correct C compiler customization in system_info.py.
7654 BUG: ma.median of 1d array should return a scalar.
7656 BLD: Remove hardcoded Intel compiler flag -xSSE4.2.
7660 BUG: Temporary fix for str(mvoid) for object field types.
7665 BUG: Fix incorrect printing of 1D masked arrays.
7670 BUG: Correct initial index estimate in histogram.
7671 BUG: Boolean assignment no GIL release when transfer needs API.
7676 BUG: Fix handling of right edge of final histogram bin.
7680 BUG: Fix np.clip bug NaN handling for Visual Studio 2015.
7724 BUG: Fix segfaults in np.random.shuffle.
7731 MAINT: Change mkl_info.dir_env_var from MKL to MKLROOT.
7737 BUG: Fix issue on OS X with Python 3.x, npymath.ini not installed.
==========================
1.11.0
==========================
This release supports Python 2.6 - 2.7 and 3.2 - 3.5 and contains a number
of enhancements and improvements. Note also the build system changes listed
below as they may have subtle effects.
No Windows (TM) binaries are provided for this release due to a broken
toolchain. One of the providers of Python packages for Windows (TM) is your
best bet.
Highlights
Details of these improvements can be found below.
The datetime64 type is now timezone naive.
A dtype parameter has been added to randint.
Improved detection of two arrays possibly sharing memory.
Automatic bin size estimation for np.histogram.
Speed optimization of A A.T and dot(A, A.T).
New function np.moveaxis for reordering array axes.
Build System Changes
Numpy now uses setuptools for its builds instead of plain distutils.
This fixes usage of install_requires='numpy' in the setup.py files of
projects that depend on Numpy (see gh-6551). It potentially affects the way
that build/install methods for Numpy itself behave though. Please report any
unexpected behavior on the Numpy issue tracker.
Bento build support and related files have been removed.
Single file build support and related files have been removed.
Future Changes
The following changes are scheduled for Numpy 1.12.0.
Support for Python 2.6, 3.2, and 3.3 will be dropped.
Relaxed stride checking will become the default. See the 1.8.0 release
notes for a more extended discussion of what this change implies.
The behavior of the datetime64 "not a time" (NaT) value will be changed
to match that of floating point "not a number" (NaN) values: all
comparisons involving NaT will return False, except for NaT != NaT which
will return True.
Indexing with floats will raise IndexError,
e.g., a[0, 0.0].
Indexing with non-integer array_like will raise IndexError,
e.g., a['1', '2']
Indexing with multiple ellipsis will raise IndexError,
e.g., a[..., ...].
Non-integers used as index values will raise TypeError,
e.g., in reshape, take, and specifying reduce axis.
In a future release the following changes will be made.
The rand function exposed in numpy.testing will be removed. That
function is left over from early Numpy and was implemented using the
Python random module. The random number generators from numpy.random
should be used instead.
The ndarray.view method will only allow c_contiguous arrays to be
viewed using a dtype of different size causing the last dimension to
change. That differs from the current behavior where arrays that are
f_contiguous but not c_contiguous can be viewed as a dtype type of
different size causing the first dimension to change.
Slicing a MaskedArray will return views of both data and mask.
Currently the mask is copy-on-write and changes to the mask in the slice do
not propagate to the original mask. See the FutureWarnings section below for
details.
Compatibility notes
datetime64 changes
In prior versions of NumPy the experimental datetime64 type always stored
times in UTC. By default, creating a datetime64 object from a string or
printing it would convert from or to local time::
old behavior
>>>> np.datetime64('2000-01-01T00:00:00')
numpy.datetime64('2000-01-01T00:00:00-0800') note the timezone offset -08:00
A consensus of datetime64 users agreed that this behavior is undesirable
and at odds with how datetime64 is usually used (e.g., by pandas <http://pandas.pydata.org>__). For most use cases, a timezone naive datetime
type is preferred, similar to the datetime.datetime type in the Python
standard library. Accordingly, datetime64 no longer assumes that input is in
local time, nor does it print local times::
For backwards compatibility, datetime64 still parses timezone offsets, which
it handles by converting to UTC. However, the resulting datetime is timezone
naive::
>>> np.datetime64('2000-01-01T00:00:00-08')
DeprecationWarning: parsing timezone aware datetimes is deprecated;
this will raise an error in the future
numpy.datetime64('2000-01-01T08:00:00')
As a corollary to this change, we no longer prohibit casting between datetimes
with date units and datetimes with time units. With timezone naive datetimes,
the rule for casting from dates to times is no longer ambiguous.
linalg.norm return type changes
The return type of the linalg.norm function is now floating point without
exception. Some of the norm types previously returned integers.
polynomial fit changes
The various fit functions in the numpy polynomial package no longer accept
non-integers for degree specification.
np.dot now raises TypeError instead of ValueError
This behaviour mimics that of other functions such as np.inner. If the two
arguments cannot be cast to a common type, it could have raised a TypeError
or ValueError depending on their order. Now, np.dot will now always
raise a TypeError.
FutureWarning to changed behavior
In np.lib.split an empty array in the result always had dimension
(0,) no matter the dimensions of the array being split. This
has been changed so that the dimensions will be preserved. A
FutureWarning for this change has been in place since Numpy 1.9 but,
due to a bug, sometimes no warning was raised and the dimensions were
already preserved.
% and // operators
These operators are implemented with the remainder and floor_divide
functions respectively. Those functions are now based around fmod and are
computed together so as to be compatible with each other and with the Python
versions for float types. The results should be marginally more accurate or
outright bug fixes compared to the previous results, but they may
differ significantly in cases where roundoff makes a difference in the integer
returned by floor_divide. Some corner cases also change, for instance, NaN
is always returned for both functions when the divisor is zero,
divmod(1.0, inf) returns (0.0, 1.0) except on MSVC 2008, and
divmod(-1.0, inf) returns (-1.0, inf).
C API
Removed the check_return and inner_loop_selector members of
the PyUFuncObject struct (replacing them with reserved slots
to preserve struct layout). These were never used for anything, so
it's unlikely that any third-party code is using them either, but we
mention it here for completeness.
This is my first visit to this fine repo so I have bundled all updates in a single pull request to make things easier for you to merge.
Close this pull request and delete the branch if you want me to start with single pull requests right away
Here's the executive summary:
Updates
Here's a list of all the updates bundled in this pull request. I've added some links to make it easier for you to find all the information you need.
Changelogs
numpy -> 1.13.3