Skip to content

Releases: numpy/numpy

v1.12.0b1

17 Nov 05:08
v1.12.0b1
Compare
Choose a tag to compare

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

NumPy 1.12.0 Release Notes


This release supports Python 2.7 and 3.4 - 3.6.

Highlights

  • Order of operations in np.einsum now can 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.

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:

  1. If user does not provide keepdims, no keyword is passed to the underlying
    method.
  2. 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.

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 originial 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 polynomi...
Read more