Movatterモバイル変換


[0]ホーム

URL:


SciPy

Release Notes

NumPy 1.15.0 Release Notes

NumPy 1.15.0 is a release with an unusual number of cleanups, many deprecationsof old functions, and improvements to many existing functions. Please read thedetailed descriptions below to see if you are affected.

For testing, we have switched to pytest as a replacement for the no longermaintained nose framework. The old nose based interface remains for downstreamprojects who may still be using it.

The Python versions supported by this release are 2.7, 3.4-3.7. The wheels arelinked with OpenBLAS v0.3.0, which should fix some of the linalg problemsreported for NumPy 1.14.

Highlights

  • NumPy has switched to pytest for testing.
  • A newnumpy.printoptions context manager.
  • Many improvements to the histogram functions.
  • Support for unicode field names in python 2.7.
  • Improved support for PyPy.
  • Fixes and improvements tonumpy.einsum.

New functions

  • numpy.gcd andnumpy.lcm, to compute the greatest common divisor and leastcommon multiple.

  • numpy.ma.stack, thenumpy.stack array-joining function generalized tomasked arrays.

  • numpy.quantile function, an interface topercentile without factors of100

  • numpy.nanquantile function, an interface tonanpercentile withoutfactors of 100

  • numpy.printoptions, a context manager that sets print options temporarilyfor the scope of thewith block:

    >>>withnp.printoptions(precision=2):...print(np.array([2.0])/3)[0.67]
  • numpy.histogram_bin_edges, a function to get the edges of the bins used by ahistogram without needing to calculate the histogram.

  • C functionsnpy_get_floatstatus_barrier andnpy_clear_floatstatus_barrierhave been added to deal with compiler optimization changing the order ofoperations. See below for details.

Deprecations

  • Aliases of builtinpickle functions are deprecated, in favor of theirunaliasedpickle.<func> names:
  • Multidimensional indexing with anything but a tuple is deprecated. This meansthat the index list inind=[slice(None),0];arr[ind] should be changedto a tuple, e.g.,ind=[slice(None),0];arr[tuple(ind)] orarr[(slice(None),0)]. That change is necessary to avoid ambiguity inexpressions such asarr[[[0,1],[0,1]]], currently interpreted asarr[array([0,1]),array([0,1])], that will be interpretedasarr[array([[0,1],[0,1]])] in the future.
  • Imports from the following sub-modules are deprecated, they will be removedat some future date.
    • numpy.testing.utils
    • numpy.testing.decorators
    • numpy.testing.nosetester
    • numpy.testing.noseclasses
    • numpy.core.umath_tests
  • Giving a generator tonumpy.sum is now deprecated. This was undocumentedbehavior, but worked. Previously, it would calculate the sum of the generatorexpression. In the future, it might return a different result. Usenp.sum(np.from_iter(generator)) or the built-in Pythonsum instead.
  • Users of the C-API should callPyArrayResolveWriteBackIfCopy orPyArray_DiscardWritbackIfCopy on any array with theWRITEBACKIFCOPYflag set, before deallocating the array. A deprecation warning will beemitted if those calls are not used when needed.
  • Users ofnditer should use the nditer object as a context manageranytime one of the iterator operands is writeable, so that numpy canmanage writeback semantics, or should callit.close(). A
RuntimeWarning may be emitted otherwise in these cases.
  • Thenormed argument ofnp.histogram, deprecated long ago in 1.6.0,now emits aDeprecationWarning.

Future Changes

  • NumPy 1.16 will drop support for Python 3.4.
  • NumPy 1.17 will drop support for Python 2.7.

Compatibility notes

Compiled testing modules renamed and made private

The following compiled modules have been renamed and made private:

  • umath_tests ->_umath_tests
  • test_rational ->_rational_tests
  • multiarray_tests ->_multiarray_tests
  • struct_ufunc_test ->_struct_ufunc_tests
  • operand_flag_tests ->_operand_flag_tests

Theumath_tests module is still available for backwards compatibility, butwill be removed in the future.

TheNpzFile returned bynp.savez is now acollections.abc.Mapping

This means it behaves like a readonly dictionary, and has a new.values()method andlen() implementation.

For python 3, this means that.iteritems(),.iterkeys() have beendeprecated, and.keys() and.items() now return views and not lists.This is consistent with how the builtindict type changed between python 2and python 3.

Under certain conditions,nditer must be used in a context manager

When using annumpy.nditer with the"writeonly" or"readwrite" flags, thereare some circumstances where nditer doesn’t actually give you a view of thewritable array. Instead, it gives you a copy, and if you make changes to thecopy, nditer later writes those changes back into your actual array. Currently,this writeback occurs when the array objects are garbage collected, which makesthis API error-prone on CPython and entirely broken on PyPy. Therefore,nditer should now be used as a context manager whenever it is usedwith writeable arrays, e.g.,withnp.nditer(...)asit:.... You may alsoexplicitly callit.close() for cases where a context manager is unusable,for instance in generator expressions.

Numpy has switched to using pytest instead of nose for testing

The last nose release was 1.3.7 in June, 2015, and development of that tool hasended, consequently NumPy has now switched to using pytest. The old decoratorsand nose tools that were previously used by some downstream projects remainavailable, but will not be maintained. The standard testing utilities,assert_almost_equal and such, are not be affected by this change except forthe nose specific functionsimport_nose andraises. Those functions arenot used in numpy, but are kept for downstream compatibility.

Numpy no longer monkey-patchesctypes with__array_interface__

Previously numpy added__array_interface__ attributes to all the integertypes fromctypes.

np.ma.notmasked_contiguous andnp.ma.flatnotmasked_contiguous always return lists

This is the documented behavior, but previously the result could be any ofslice, None, or list.

All downstream users seem to check for theNone result fromflatnotmasked_contiguous and replace it with[]. Those callers willcontinue to work as before.

np.squeeze restores old behavior of objects that cannot handle anaxis argument

Prior to version1.7.0,numpy.squeeze did not have anaxis argument andall empty axes were removed by default. The incorporation of anaxisargument made it possible to selectively squeeze single or multiple empty axes,but the old API expectation was not respected because axes could still beselectively removed (silent success) from an object expecting all empty axes tobe removed. That silent, selective removal of empty axes for objects expectingthe old behavior has been fixed and the old behavior restored.

unstructured void array’s.item method now returns a bytes object

.item now returns abytes object instead of a buffer or byte array.This may affect code which assumed the return value was mutable, which is nolonger the case.

copy.copy andcopy.deepcopy no longer turnmasked into an array

Sincenp.ma.masked is a readonly scalar, copying should be a no-op. Thesefunctions now behave consistently withnp.copy().

Multifield Indexing of Structured Arrays will still return a copy

The change that multi-field indexing of structured arrays returns a viewinstead of a copy is pushed back to 1.16. A new methodnumpy.lib.recfunctions.repack_fields has been introduced to help mitigatethe effects of this change, which can be used to write code compatible withboth numpy 1.15 and 1.16. For more information on how to update code to accountfor this future change see the “accessing multiple fields” section of theuser guide.

C API changes

New functionsnpy_get_floatstatus_barrier andnpy_clear_floatstatus_barrier

Functionsnpy_get_floatstatus_barrier andnpy_clear_floatstatus_barrierhave been added and should be used in place of thenpy_get_floatstatus``and``npy_clear_status functions. Optimizing compilers like GCC 8.1 and Clangwere rearranging the order of operations when the previous functions were usedin the ufunc SIMD functions, resulting in the floatstatus flags being checkedbefore the operation whose status we wanted to check was run. See#10339.

Changes toPyArray_GetDTypeTransferFunction

PyArray_GetDTypeTransferFunction now defaults to using user-definedcopyswapn /copyswap for user-defined dtypes. If this causes asignificant performance hit, consider implementingcopyswapn to reflect theimplementation ofPyArray_GetStridedCopyFn. See#10898.* Functionsnpy_get_floatstatus_barrier andnpy_clear_floatstatus_barrier

have been added and should be used in place of thenpy_get_floatstatus``and``npy_clear_status functions. Optimizing compilers like GCC 8.1 and Clangwere rearranging the order of operations when the previous functions wereused in the ufunc SIMD functions, resulting in the floatstatus flags being ‘checked before the operation whose status we wanted to check was run.See#10339.

New Features

np.gcd andnp.lcm ufuncs added for integer and objects types

These compute the greatest common divisor, and lowest common multiple,respectively. These work on all the numpy integer types, as well as thebuiltin arbitrary-precisionDecimal andlong types.

Support for cross-platform builds for iOS

The build system has been modified to add support for the_PYTHON_HOST_PLATFORM environment variable, used bydistutils whencompiling on one platform for another platform. This makes it possible tocompile NumPy for iOS targets.

This only enables you to compile NumPy for one specific platform at a time.Creating a full iOS-compatible NumPy package requires building for the 5architectures supported by iOS (i386, x86_64, armv7, armv7s and arm64), andcombining these 5 compiled builds products into a single “fat” binary.

return_indices keyword added fornp.intersect1d

New keywordreturn_indices returns the indices of the two input arraysthat correspond to the common elements.

np.quantile andnp.nanquantile

Likenp.percentile andnp.nanpercentile, but takes quantiles in [0, 1]rather than percentiles in [0, 100].np.percentile is now a thin wrapperaroundnp.quantile with the extra step of dividing by 100.

Build system

Added experimental support for the 64-bit RISC-V architecture.

Improvements

np.einsum updates

Syncs einsum path optimization tech betweennumpy andopt_einsum. Inparticular, thegreedy path has received many enhancements by @jcmgray. Afull list of issues fixed are:

  • Arbitrary memory can be passed into thegreedy path. Fixes gh-11210.
  • The greedy path has been updated to contain more dynamic programming ideaspreventing a large number of duplicate (and expensive) calls that figure outthe actual pair contraction that takes place. Now takes a few seconds onseveral hundred input tensors. Useful for matrix product state theories.
  • Reworks the broadcasting dot error catching found in gh-11218 gh-10352 to bea bit earlier in the process.
  • Enhances thecan_dot functionality that previous missed an edge case (partof gh-11308).

np.ufunc.reduce and related functions now accept an initial value

np.ufunc.reduce,np.sum,np.prod,np.min andnp.max allnow accept aninitial keyword argument that specifies the value to startthe reduction with.

np.flip can operate over multiple axes

np.flip now accepts None, or tuples of int, in itsaxis argument. Ifaxis is None, it will flip over all the axes.

histogram andhistogramdd functions have moved tonp.lib.histograms

These were originally found innp.lib.function_base. They are stillavailable under their un-scopednp.histogram(dd) names, andto maintain compatibility, aliased atnp.lib.function_base.histogram(dd).

Code that doesfromnp.lib.function_baseimport* will need to be updatedwith the new location, and should consider not usingimport* in future.

histogram will accept NaN values when explicit bins are given

Previously it would fail when trying to compute a finite range for the data.Since the range is ignored anyway when the bins are given explicitly, this errorwas needless.

Note that callinghistogram on NaN values continues to raise theRuntimeWarning s typical of working with nan values, which can be silencedas usual witherrstate.

histogram works on datetime types, when explicit bin edges are given

Dates, times, and timedeltas can now be histogrammed. The bin edges must bepassed explicitly, and are not yet computed automatically.

histogram “auto” estimator handles limited variance better

No longer does an IQR of 0 result inn_bins=1, rather the number of binschosen is related to the data size in this situation.

The edges retuned byhistogram` andhistogramdd now match the data float type

When passednp.float16,np.float32, ornp.longdouble data, thereturned edges are now of the same dtype. Previously,histogram would onlyreturn the same type if explicit bins were given, andhistogram wouldproducefloat64 bins no matter what the inputs.

histogramdd allows explicit ranges to be given in a subset of axes

Therange argument ofnumpy.histogramdd can now containNone values toindicate that the range for the corresponding axis should be computed from thedata. Previously, this could not be specified on a per-axis basis.

The normed arguments ofhistogramdd andhistogram2d have been renamed

These arguments are now calleddensity, which is consistent withhistogram. The old argument continues to work, but the new name should bepreferred.

np.r_ works with 0d arrays, andnp.ma.mr_ works withnp.ma.masked

0d arrays passed to ther_ andmr_ concatenation helpers are now treated asthough they are arrays of length 1. Previously, passing these was an error.As a result,numpy.ma.mr_ now works correctly on themasked constant.

np.ptp accepts akeepdims argument, and extended axis tuples

np.ptp (peak-to-peak) can now work over multiple axes, just likenp.maxandnp.min.

MaskedArray.astype now is identical tondarray.astype

This means it takes all the same arguments, making more code written forndarray work for masked array too.

Enable AVX2/AVX512 at compile time

Change to simd.inc.src to allow use of AVX2 or AVX512 at compile time. Previouslycompilation for avx2 (or 512) with -march=native would still use the SSEcode for the simd functions even when the rest of the code got AVX2.

nan_to_num always returns scalars when receiving scalar or 0d inputs

Previously an array was returned for integer scalar inputs, which isinconsistent with the behavior for float inputs, and that of ufuncs in general.For all types of scalar or 0d input, the result is now a scalar.

np.flatnonzero works on numpy-convertible types

np.flatnonzero now usesnp.ravel(a) instead ofa.ravel(), so itworks for lists, tuples, etc.

np.interp returns numpy scalars rather than builtin scalars

Previouslynp.interp(0.5,[0,1],[10,20]) would return afloat, butnow it returns anp.float64 object, which more closely matches the behaviorof other functions.

Additionally, the special case ofnp.interp(object_array_0d,...) is nolonger supported, asnp.interp(object_array_nd) was never supported anyway.

As a result of this change, theperiod argument can now be used on 0darrays.

Allow dtype field names to be unicode in Python 2

Previouslynp.dtype([(u'name',float)]) would raise aTypeError inPython 2, as only bytestrings were allowed in field names. Now any unicodestring field names will be encoded with theascii codec, raising aUnicodeEncodeError upon failure.

This change makes it easier to write Python 2/3 compatible code usingfrom__future__importunicode_literals, which previously would causestring literal field names to raise a TypeError in Python 2.

Comparison ufuncs acceptdtype=object, overriding the defaultbool

This allows object arrays of symbolic types, which override== and otheroperators to return expressions, to be compared elementwise withnp.equal(a,b,dtype=object).

sort functions acceptkind='stable'

Up until now, to perform a stable sort on the data, the user must do:

>>>np.sort([5,2,6,2,1],kind='mergesort')[1, 2, 2, 5, 6]

because merge sort is the only stable sorting algorithm available inNumPy. However, having kind=’mergesort’ does not make it explicit thatthe user wants to perform a stable sort thus harming the readability.

This change allows the user to specify kind=’stable’ thus clarifyingthe intent.

Do not make temporary copies for in-place accumulation

When ufuncs perform accumulation they no longer make temporary copies becauseof the overlap between input an output, that is, the next element accumulatedis added before the accumulated result is stored in its place, hence theoverlap is safe. Avoiding the copy results in faster execution.

linalg.matrix_power can now handle stacks of matrices

Like other functions inlinalg,matrix_power can now deal with arraysof dimension larger than 2, which are treated as stacks of matrices. As partof the change, to further improve consistency, the name of the first argumenthas been changed toa (fromM), and the exceptions for non-squarematrices have been changed toLinAlgError (fromValueError).

Increased performance inrandom.permutation for multidimensional arrays

permutation uses the fast path inrandom.shuffle for all inputarray dimensions. Previously the fast path was only used for 1-d arrays.

Generalized ufuncs now acceptaxes,axis andkeepdims arguments

One can control over which axes a generalized ufunc operates by passing in anaxes argument, a list of tuples with indices of particular axes. Forinstance, for a signature of(i,j),(j,k)->(i,k) appropriate for matrixmultiplication, the base elements are two-dimensional matrices and these aretaken to be stored in the two last axes of each argument. The correspondingaxes keyword would be[(-2,-1),(-2,-1),(-2,-1)]. If one wanted touse leading dimensions instead, one would pass in[(0,1),(0,1),(0,1)].

For simplicity, for generalized ufuncs that operate on 1-dimensional arrays(vectors), a single integer is accepted instead of a single-element tuple, andfor generalized ufuncs for which all outputs are scalars, the (empty) outputtuples can be omitted. Hence, for a signature of(i),(i)->() appropriatefor an inner product, one could pass inaxes=[0,0] to indicate that thevectors are stored in the first dimensions of the two inputs arguments.

As a short-cut for generalized ufuncs that are similar to reductions, i.e.,that act on a single, shared core dimension such as the inner product exampleabove, one can pass anaxis argument. This is equivalent to passing inaxes with identical entries for all arguments with that core dimension(e.g., for the example above,axes=[(axis,),(axis,)]).

Furthermore, like for reductions, for generalized ufuncs that have inputs thatall have the same number of core dimensions and outputs with no core dimension,one can pass inkeepdims to leave a dimension with size 1 in the outputs,thus allowing proper broadcasting against the original inputs. The location ofthe extra dimension can be controlled withaxes. For instance, for theinner-product example,keepdims=True,axes=[-2,-2,-2] would act on theinner-product example,keepdims=True,axis=-2 would act on theone-but-last dimension of the input arguments, and leave a size 1 dimension inthat place in the output.

float128 values now print correctly on ppc systems

Previously printing float128 values was buggy on ppc, since the specialdouble-double floating-point-format on these systems was not accounted for.float128s now print with correct rounding and uniqueness.

Warning to ppc users: You should upgrade glibc if it is version <=2.23,especially if using float128. On ppc, glibc’s malloc in these version oftenmisaligns allocated memory which can crash numpy when using float128 values.

Newnp.take_along_axis andnp.put_along_axis functions

When used on multidimensional arrays,argsort,argmin,argmax, andargpartition return arrays that are difficult to use as indices.take_along_axis provides an easy way to use these indices to lookup valueswithin an array, so that:

np.take_along_axis(a,np.argsort(a,axis=axis),axis=axis)

is the same as:

np.sort(a,axis=axis)

np.put_along_axis acts as the dual operation for writing to these indiceswithin an array.

NumPy 1.14.5 Release Notes

This is a bugfix release for bugs reported following the 1.14.4 release. Themost significant fixes are:

  • fixes for compilation errors on alpine and NetBSD

The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python3.6 wheels available from PIP are built with Python 3.6.2 and should becompatible with all previous versions of Python 3.6. The source releases werecythonized with Cython 0.28.2 and should work for the upcoming Python 3.7.

Contributors

A total of 1 person contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Charles Harris

Pull requests merged

A total of 2 pull requests were merged for this release.

  • #11274: BUG: Correct use of NPY_UNUSED.
  • #11294: BUG: Remove extra trailing parentheses.

NumPy 1.14.4 Release Notes

This is a bugfix release for bugs reported following the 1.14.3 release. Themost significant fixes are:

  • fixes for compiler instruction reordering that resulted in NaN’s not beingproperly propagated innp.max andnp.min,
  • fixes for bus faults on SPARC and older ARM due to incorrect alignmentchecks.

There are also improvements to printing of long doubles on PPC platforms. Allis not yet perfect on that platform, the whitespace padding is still incorrectand is to be fixed in numpy 1.15, consequently NumPy still fails someprinting-related (and other) unit tests on ppc systems. However, the printedvalues are now correct.

Note that NumPy will error on import if it detects incorrect float32dotresults. This problem has been seen on the Mac when working in the Anacondaenviroment and is due to a subtle interaction between MKL and PyQt5. It is notstrictly a NumPy problem, but it is best that users be aware of it. See thegh-8577 NumPy issue for more information.

The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python3.6 wheels available from PIP are built with Python 3.6.2 and should becompatible with all previous versions of Python 3.6. The source releases werecythonized with Cython 0.28.2 and should work for the upcoming Python 3.7.

Contributors

A total of 7 people contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Allan Haldane
  • Charles Harris
  • Marten van Kerkwijk
  • Matti Picus
  • Pauli Virtanen
  • Ryan Soklaski +
  • Sebastian Berg

Pull requests merged

A total of 11 pull requests were merged for this release.

  • #11104: BUG: str of DOUBLE_DOUBLE format wrong on ppc64
  • #11170: TST: linalg: add regression test for gh-8577
  • #11174: MAINT: add sanity-checks to be run at import time
  • #11181: BUG: void dtype setup checked offset not actual pointer for alignment
  • #11194: BUG: Python2 doubles don’t print correctly in interactive shell.
  • #11198: BUG: optimizing compilers can reorder call to npy_get_floatstatus
  • #11199: BUG: reduce using SSE only warns if inside SSE loop
  • #11203: BUG: Bytes delimiter/comments in genfromtxt should be decoded
  • #11211: BUG: Fix reference count/memory leak exposed by better testing
  • #11219: BUG: Fixes einsum broadcasting bug when optimize=True
  • #11251: DOC: Document 1.14.4 release.

NumPy 1.14.3 Release Notes

This is a bugfix release for a few bugs reported following the 1.14.2 release:

  • np.lib.recfunctions.fromrecords accepts a list-of-lists, until 1.15
  • In python2, float types use the new print style when printing to a file
  • style arg in “legacy” print mode now works for 0d arrays

The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python3.6 wheels available from PIP are built with Python 3.6.2 and should becompatible with all previous versions of Python 3.6. The source releases werecythonized with Cython 0.28.2.

Contributors

A total of 6 people contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Allan Haldane
  • Charles Harris
  • Jonathan March +
  • Malcolm Smith +
  • Matti Picus
  • Pauli Virtanen

Pull requests merged

A total of 8 pull requests were merged for this release.

  • #10862: BUG: floating types should override tp_print (1.14 backport)
  • #10905: BUG: for 1.14 back-compat, accept list-of-lists in fromrecords
  • #10947: BUG: ‘style’ arg to array2string broken in legacy mode (1.14…
  • #10959: BUG: test, fix for missing flags[‘WRITEBACKIFCOPY’] key
  • #10960: BUG: Add missing underscore to prototype in check_embedded_lapack
  • #10961: BUG: Fix encoding regression in ma/bench.py (Issue #10868)
  • #10962: BUG: core: fix NPY_TITLE_KEY macro on pypy
  • #10974: BUG: test, fix PyArray_DiscardWritebackIfCopy…

NumPy 1.14.2 Release Notes

This is a bugfix release for some bugs reported following the 1.14.1 release. The majorproblems dealt with are as follows.

  • Residual bugs in the new array printing functionality.
  • Regression resulting in a relocation problem with shared library.
  • Improved PyPy compatibility.

The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python3.6 wheels available from PIP are built with Python 3.6.2 and should becompatible with all previous versions of Python 3.6. The source releases werecythonized with Cython 0.26.1, which is known tonot support the upcomingPython 3.7 release. People who wish to run Python 3.7 should check out theNumPy repo and try building with the, as yet, unreleased master branch ofCython.

Contributors

A total of 4 people contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Allan Haldane
  • Charles Harris
  • Eric Wieser
  • Pauli Virtanen

Pull requests merged

A total of 5 pull requests were merged for this release.

  • #10674: BUG: Further back-compat fix for subclassed array repr
  • #10725: BUG: dragon4 fractional output mode adds too many trailing zeros
  • #10726: BUG: Fix f2py generated code to work on PyPy
  • #10727: BUG: Fix missing NPY_VISIBILITY_HIDDEN on npy_longdouble_to_PyLong
  • #10729: DOC: Create 1.14.2 notes and changelog.

NumPy 1.14.1 Release Notes

This is a bugfix release for some problems reported following the 1.14.0 release. The majorproblems fixed are the following.

  • Problems with the new array printing, particularly the printing of complexvalues, Please report any additional problems that may turn up.
  • Problems withnp.einsum due to the newoptimized=True default. Somefixes for optimization have been applied andoptimize=False is now thedefault.
  • The sort order innp.unique whenaxis=<some-number> will now alwaysbe lexicographic in the subarray elements. In previous NumPy versions therewas an optimization that could result in sorting the subarrays as unsignedbyte strings.
  • The change in 1.14.0 that multi-field indexing of structured arrays returns aview instead of a copy has been reverted but remains on track for NumPy 1.15.Affected users should read the 1.14.1 Numpy User Guide section“basics/structured arrays/accessing multiple fields” for advice on how tomanage this transition.

The Python versions supported in this release are 2.7 and 3.4 - 3.6. The Python3.6 wheels available from PIP are built with Python 3.6.2 and should becompatible with all previous versions of Python 3.6. The source releases werecythonized with Cython 0.26.1, which is known tonot support the upcomingPython 3.7 release. People who wish to run Python 3.7 should check out theNumPy repo and try building with the, as yet, unreleased master branch ofCython.

Contributors

A total of 14 people contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Allan Haldane
  • Charles Harris
  • Daniel Smith
  • Dennis Weyland +
  • Eric Larson
  • Eric Wieser
  • Jarrod Millman
  • Kenichi Maehashi +
  • Marten van Kerkwijk
  • Mathieu Lamarre
  • Sebastian Berg
  • Simon Conseil
  • Simon Gibbons
  • xoviat

Pull requests merged

A total of 36 pull requests were merged for this release.

  • #10339: BUG: restrict the __config__ modifications to win32
  • #10368: MAINT: Adjust type promotion in linalg.norm
  • #10375: BUG: add missing paren and remove quotes from repr of fieldless…
  • #10395: MAINT: Update download URL in setup.py.
  • #10396: BUG: fix einsum issue with unicode input and py2
  • #10397: BUG: fix error message not formatted in einsum
  • #10398: DOC: add documentation about how to handle new array printing
  • #10403: BUG: Set einsum optimize parameter default toFalse.
  • #10424: ENH: Fix repr of np.record objects to match np.void types #10412
  • #10425: MAINT: Update zesty to artful for i386 testing
  • #10431: REL: Add 1.14.1 release notes template
  • #10435: MAINT: Use ValueError for duplicate field names in lookup (backport)
  • #10534: BUG: Provide a better error message for out-of-order fields
  • #10536: BUG: Resizebytes_ columns in genfromtxt (backport of #10401)
  • #10537: BUG: multifield-indexing adds padding bytes: revert for 1.14.1
  • #10539: BUG: fix np.save issue with python 2.7.5
  • #10540: BUG: Add missing DECREF in Py2 int() cast
  • #10541: TST: Add circleci document testing to maintenance/1.14.x
  • #10542: BUG: complex repr has extra spaces, missing + (1.14 backport)
  • #10550: BUG: Set missing exception after malloc
  • #10557: BUG: In numpy.i, clear CARRAY flag if wrapped buffer is not C_CONTIGUOUS.
  • #10558: DEP: Issue FutureWarning when malformed records detected.
  • #10559: BUG: Fix einsum optimize logic for singleton dimensions
  • #10560: BUG: Fix calling ufuncs with a positional output argument.
  • #10561: BUG: Fix various Big-Endian test failures (ppc64)
  • #10562: BUG: Make dtype.descr error for out-of-order fields.
  • #10563: BUG: arrays not being flattened inunion1d
  • #10607: MAINT: Update sphinxext submodule hash.
  • #10608: BUG: Revert sort optimization in np.unique.
  • #10609: BUG: infinite recursion in str of 0d subclasses
  • #10610: BUG: Align type definition with generated lapack
  • #10612: BUG/ENH: Improve output for structured non-void types
  • #10622: BUG: deallocate recursive closure in arrayprint.py (1.14 backport)
  • #10624: BUG: Correctly identify comma separated dtype strings
  • #10629: BUG: deallocate recursive closure in arrayprint.py (backport…
  • #10630: REL: Prepare for 1.14.1 release.

NumPy 1.14.0 Release Notes

Numpy 1.14.0 is the result of seven months of work and contains a large numberof bug fixes and new features, along with several changes with potentialcompatibility issues. The major change that users will notice are thestylistic changes in the way numpy arrays and scalars are printed, a changethat will affect doctests. See below for details on how to preserve theold style printing when needed.

A major decision affecting future development concerns the schedule fordropping Python 2.7 support in the runup to 2020. The decision has been made tosupport 2.7 for all releases made in 2018, with the last release beingdesignated a long term release with support for bug fixes extending through2019. In 2019 support for 2.7 will be dropped in all new releases. More detailscan be found in the relevantNEP_.

This release supports Python 2.7 and 3.4 - 3.6.

Highlights

  • Thenp.einsum function uses BLAS when possible
  • genfromtxt,loadtxt,fromregex andsavetxt can now handlefiles with arbitrary Python supported encoding.
  • Major improvements to printing of NumPy arrays and scalars.

New functions

  • parametrize: decorator added to numpy.testing
  • chebinterpolate: Interpolate function at Chebyshev points.
  • format_float_positional andformat_float_scientific : formatfloating-point scalars unambiguously with control of rounding and padding.
  • PyArray_ResolveWritebackIfCopy andPyArray_SetWritebackIfCopyBase,new C-API functions useful in achieving PyPy compatibity.

Deprecations

  • Usingnp.bool_ objects in place of integers is deprecated. Previouslyoperator.index(np.bool_) was legal and allowed constructs such as[1,2,3][np.True_]. That was misleading, as it behaved differently fromnp.array([1,2,3])[np.True_].
  • Truth testing of an empty array is deprecated. To check if an array is notempty, usearray.size>0.
  • Callingnp.bincount withminlength=None is deprecated.minlength=0 should be used instead.
  • Callingnp.fromstring with the default value of thesep argument isdeprecated. When that argument is not provided, a broken version ofnp.frombuffer is used that silently accepts unicode strings and – afterencoding them as either utf-8 (python 3) or the default encoding(python 2) – treats them as binary data. If reading binary data isdesired,np.frombuffer should be used directly.
  • Thestyle option of array2string is deprecated in non-legacy printing mode.
  • PyArray_SetUpdateIfCopyBase has been deprecated. For NumPy versions >= 1.14usePyArray_SetWritebackIfCopyBase instead, seeC API changes below formore details.
  • The use ofUPDATEIFCOPY arrays is deprecated, seeC API changes belowfor details. We will not be dropping support for those arrays, but they arenot compatible with PyPy.

Future Changes

  • np.issubdtype will stop downcasting dtype-like arguments.It might be expected thatissubdtype(np.float32,'float64') andissubdtype(np.float32,np.float64) mean the same thing - however, therewas an undocumented special case that translated the former intoissubdtype(np.float32,np.floating), giving the surprising result of True.

    This translation now gives a warning that explains what translation isoccurring. In the future, the translation will be disabled, and the firstexample will be made equivalent to the second.

  • np.linalg.lstsq default forrcond will be changed. Thercondparameter tonp.linalg.lstsq will change its default to machine precisiontimes the largest of the input array dimensions. A FutureWarning is issuedwhenrcond is not passed explicitly.

  • a.flat.__array__() will return a writeable copy ofa whena isnon-contiguous. Previously it returned an UPDATEIFCOPY array whena waswriteable. Currently it returns a non-writeable copy. See gh-7054 for adiscussion of the issue.

  • Unstructured void array’s.item method will return a bytes object. In thefuture, calling.item() on arrays or scalars ofnp.void datatype willreturn abytes object instead of a buffer or int array, the same asreturned bybytes(void_scalar). This may affect code which assumed thereturn value was mutable, which will no longer be the case. AFutureWarning is now issued when this would occur.

Compatibility notes

The mask of a masked array view is also a view rather than a copy

There was a FutureWarning about this change in NumPy 1.11.x. In short, it isnow the case that, when changing a view of a masked array, changes to the maskare propagated to the original. That was not previously the case. This changeaffects slices in particular. Note that this does not yet work properly if themask of the original array isnomask and the mask of the view is changed.See gh-5580 for an extended discussion. The original behavior of having a copyof the mask can be obtained by calling theunshare_mask method of the view.

np.ma.masked is no longer writeable

Attempts to mutate themasked constant now error, as the underlying arraysare marked readonly. In the past, it was possible to get away with:

# emulating a function that sometimes returns np.ma.maskedval=random.choice([np.ma.masked,10])var_arr=np.asarray(val)val_arr+=1# now errors, previously changed np.ma.masked.data

np.ma functions producing``fill_value``s have changed

Previously,np.ma.default_fill_value would return a 0d array, butnp.ma.minimum_fill_value andnp.ma.maximum_fill_value would return atuple of the fields. Instead, all three methods return a structurednp.voidobject, which is what you would already find in the.fill_value attribute.

Additionally, the dtype guessing now matches that ofnp.array - so whenpassing a python scalarx,maximum_fill_value(x) is always the same asmaximum_fill_value(np.array(x)). Previouslyx=long(1) on Python 2violated this assumption.

a.flat.__array__() returns non-writeable arrays whena is non-contiguous

The intent is that the UPDATEIFCOPY array previously returned whena wasnon-contiguous will be replaced by a writeable copy in the future. Thistemporary measure is aimed to notify folks who expect the underlying array bemodified in this situation that that will no longer be the case. The mostlikely places for this to be noticed is when expressions of the formnp.asarray(a.flat) are used, or whena.flat is passed as the outparameter to a ufunc.

np.tensordot now returns zero array when contracting over 0-length dimension

Previouslynp.tensordot raised a ValueError when contracting over 0-lengthdimension. Now it returns a zero array, which is consistent with the behaviourofnp.dot andnp.einsum.

numpy.testing reorganized

This is not expected to cause problems, but possibly something has been leftout. If you experience an unexpected import problem usingnumpy.testinglet us know.

np.asfarray no longer accepts non-dtypes through thedtype argument

This previously would acceptdtype=some_array, with the implied semanticsofdtype=some_array.dtype. This was undocumented, unique across the numpyfunctions, and if used would likely correspond to a typo.

1Dnp.linalg.norm preserves float input types, even for arbitrary orders

Previously, this would promote tofloat64 when arbitrary orders werepassed, despite not doing so under the simple cases:

>>>f32=np.float32([[1,2]])>>>np.linalg.norm(f32,2.0,axis=-1).dtypedtype('float32')>>>np.linalg.norm(f32,2.0001,axis=-1).dtypedtype('float64')  # numpy 1.13dtype('float32')  # numpy 1.14

This change affects onlyfloat32 andfloat16 arrays.

count_nonzero(arr,axis=()) now counts over no axes, not all axes

Elsewhere,axis==() is always understood as “no axes”, butcount_nonzero had a special case to treat this as “all axes”. This wasinconsistent and surprising. The correct way to count over all axes has alwaysbeen to passaxis==None.

__init__.py files added to test directories

This is for pytest compatibility in the case of duplicate test file names inthe different directories. As a result,run_module_suite no longer works,i.e.,python<path-to-test-file> results in an error.

.astype(bool) on unstructured void arrays now callsbool on each element

On Python 2,void_array.astype(bool) would always return an array ofTrue, unless the dtype isV0. On Python 3, this operation would usuallycrash. Going forwards,astype matches the behavior ofbool(np.void),considering a buffer of all zeros as false, and anything else as true.Checks forV0 can still be done witharr.dtype.itemsize==0.

MaskedArray.squeeze never returnsnp.ma.masked

np.squeeze is documented as returning a view, but the masked variant wouldsometimes returnmasked, which is not a view. This has been fixed, so thatthe result is always a view on the original masked array.This breaks any code that usedmasked_arr.squeeze()isnp.ma.masked, butfixes code that writes to the result ofsqueeze().

Renamed first parameter ofcan_cast fromfrom tofrom_

The previous parameter namefrom is a reserved keyword in Python, which madeit difficult to pass the argument by name. This has been fixed by renamingthe parameter tofrom_.

isnat raisesTypeError when passed wrong type

The ufuncisnat used to raise aValueError when it was not passedvariables of typedatetime ortimedelta. This has been changed toraising aTypeError.

dtype.__getitem__ raisesTypeError when passed wrong type

When indexed with a float, the dtype object used to raiseValueError.

User-defined types now need to implement__str__ and__repr__

Previously, user-defined types could fall back to a default implementation of__str__ and__repr__ implemented in numpy, but this has now beenremoved. Now user-defined types will fall back to the python defaultobject.__str__ andobject.__repr__.

Many changes to array printing, disableable with the new “legacy” printing mode

Thestr andrepr of ndarrays and numpy scalars have been changed ina variety of ways. These changes are likely to break downstream user’sdoctests.

These new behaviors can be disabled to mostly reproduce numpy 1.13 behavior byenabling the new 1.13 “legacy” printing mode. This is enabled by callingnp.set_printoptions(legacy="1.13"), or using the newlegacy argument tonp.array2string, asnp.array2string(arr,legacy='1.13').

In summary, the major changes are:

  • For floating-point types:
    • Therepr of float arrays often omits a space previously printedin the sign position. See the newsign option tonp.set_printoptions.
    • Floating-point arrays and scalars use a new algorithm for decimalrepresentations, giving the shortest unique representation. This willusually shortenfloat16 fractional output, and sometimesfloat32 andfloat128 output.float64 should be unaffected. See the newfloatmode option tonp.set_printoptions.
    • Float arrays printed in scientific notation no longer use fixed-precision,and now instead show the shortest unique representation.
    • Thestr of floating-point scalars is no longer truncated in python2.
  • For other data types:
    • Non-finite complex scalars print likenanj instead ofnan*j.
    • NaT values in datetime arrays are now properly aligned.
    • Arrays and scalars ofnp.void datatype are now printed using hexnotation.
  • For line-wrapping:
    • The “dtype” part of ndarray reprs will now be printed on the next lineif there isn’t space on the last line of array output.
    • Thelinewidth format option is now always respected.Therepr orstr of an array will never exceed this, unless a singleelement is too wide.
    • The last line of an array string will never have more elements than earlierlines.
    • An extra space is no longer inserted on the first line if the elements aretoo wide.
  • For summarization (the use of... to shorten long arrays):
    • A trailing comma is no longer inserted forstr.Previously,str(np.arange(1001)) gave'[  0   1   2..., 998 9991000]', which has an extra comma.
    • For arrays of 2-D and beyond, when... is printed on its own line inorder to summarize any but the last axis, newlines are now appended to thatline to match its leading newlines and a trailing space character isremoved.
  • MaskedArray arrays now separate printed elements with commas, alwaysprint the dtype, and correctly wrap the elements of long arrays to multiplelines. If there is more than 1 dimension, the array attributes are nowprinted in a new “left-justified” printing style.
  • recarray arrays no longer print a trailing space before their dtype, andwrap to the right number of columns.
  • 0d arrays no longer have their own idiosyncratic implementations ofstrandrepr. Thestyle argument tonp.array2string is deprecated.
  • Arrays ofbool datatype will omit the datatype in therepr.
  • User-defineddtypes (subclasses ofnp.generic) now need toimplement__str__ and__repr__.

Some of these changes are described in more detail below. If you need to retainthe previous behavior for doctests or other reasons, you may want to dosomething like:

# FIXME: We need the str/repr formatting used in Numpy < 1.14.try:np.set_printoptions(legacy='1.13')exceptTypeError:pass

C API changes

PyPy compatible alternative toUPDATEIFCOPY arrays

UPDATEIFCOPY arrays are contiguous copies of existing arrays, possibly withdifferent dimensions, whose contents are copied back to the original array whentheir refcount goes to zero and they are deallocated. Because PyPy does not userefcounts, they do not function correctly with PyPy. NumPy is in the process ofeliminating their use internally and two new C-API functions,

  • PyArray_SetWritebackIfCopyBase
  • PyArray_ResolveWritebackIfCopy,

have been added together with a complimentary flag,NPY_ARRAY_WRITEBACKIFCOPY. Using the new functionality also requires thatsome flags be changed when new arrays are created, to wit:NPY_ARRAY_INOUT_ARRAY should be replaced byNPY_ARRAY_INOUT_ARRAY2 andNPY_ARRAY_INOUT_FARRAY should be replaced byNPY_ARRAY_INOUT_FARRAY2.Arrays created with these new flags will then have theWRITEBACKIFCOPYsemantics.

If PyPy compatibility is not a concern, these new functions can be ignored,although there will be aDeprecationWarning. If you do wish to pursue PyPycompatibility, more information on these functions and their use may be foundin thec-api documentation and the example inhow-to-extend.

New Features

Encoding argument for text IO functions

genfromtxt,loadtxt,fromregex andsavetxt can now handle fileswith arbitrary encoding supported by Python via the encoding argument.For backward compatibility the argument defaults to the specialbytes valuewhich continues to treat text as raw byte values and continues to pass latin1encoded bytes to custom converters.Using any other value (includingNone for system default) will switch thefunctions to real text IO so one receives unicode strings instead of bytes inthe resulting arrays.

Externalnose plugins are usable bynumpy.testing.Tester

numpy.testing.Tester is now aware ofnose plugins that are outside thenose built-in ones. This allows using, for example,nose-timer likeso:np.test(extra_argv=['--with-timer','--timer-top-n','20']) toobtain the runtime of the 20 slowest tests. An extra keywordtimer wasalso added toTester.test, sonp.test(timer=20) will also report the 20slowest tests.

parametrize decorator added tonumpy.testing

A basicparametrize decorator is now available innumpy.testing. It isintended to allow rewriting yield based tests that have been deprecated inpytest so as to facilitate the transition to pytest in the future. The nosetesting framework has not been supported for several years and looks likeabandonware.

The newparametrize decorator does not have the full functionality of theone in pytest. It doesn’t work for classes, doesn’t support nesting, and doesnot substitute variable names. Even so, it should be adequate to rewrite theNumPy tests.

chebinterpolate function added tonumpy.polynomial.chebyshev

The newchebinterpolate function interpolates a given function at theChebyshev points of the first kind. A newChebyshev.interpolate classmethod adds support for interpolation over arbitrary intervals using the scaledand shifted Chebyshev points of the first kind.

Support for reading lzma compressed text files in Python 3

With Python versions containing thelzma module the text IO functions cannow transparently read from files withxz orlzma extension.

sign option added tonp.setprintoptions andnp.array2string

This option controls printing of the sign of floating-point types, and may beone of the characters ‘-‘, ‘+’ or ‘ ‘. With ‘+’ numpy always prints the sign ofpositive values, with ‘ ‘ it always prints a space (whitespace character) inthe sign position of positive values, and with ‘-‘ it will omit the signcharacter for positive values. The new default is ‘-‘.

This new default changes the float output relative to numpy 1.13. The oldbehavior can be obtained in 1.13 “legacy” printing mode, see compatibilitynotes above.

hermitian option added to``np.linalg.matrix_rank``

The newhermitian option allows choosing between standard SVD based matrixrank calculation and the more efficient eigenvalue based method forsymmetric/hermitian matrices.

threshold andedgeitems options added tonp.array2string

These options could previously be controlled usingnp.set_printoptions, butnow can be changed on a per-call basis as arguments tonp.array2string.

concatenate andstack gained anout argument

A preallocated buffer of the desired dtype can now be used for the output ofthese functions.

Support for PGI flang compiler on Windows

The PGI flang compiler is a Fortran front end for LLVM released by NVIDIA underthe Apache 2 license. It can be invoked by

pythonsetup.pyconfig--compiler=clang--fcompiler=flanginstall

There is little experience with this new compiler, so any feedback from peopleusing it will be appreciated.

Improvements

Numerator degrees of freedom inrandom.noncentral_f need only be positive.

Prior to NumPy 1.14.0, the numerator degrees of freedom needed to be > 1, butthe distribution is valid for values > 0, which is the new requirement.

The GIL is released for allnp.einsum variations

Some specific loop structures which have an accelerated loop versiondid not release the GIL prior to NumPy 1.14.0. This oversight has beenfixed.

Thenp.einsum function will use BLAS when possible and optimize by default

Thenp.einsum function will now callnp.tensordot when appropriate.Becausenp.tensordot uses BLAS when possible, that will speed up execution.By default,np.einsum will also attempt optimization as the overhead issmall relative to the potential improvement in speed.

f2py now handles arrays of dimension 0

f2py now allows for the allocation of arrays of dimension 0. This allowsfor more consistent handling of corner cases downstream.

numpy.distutils supports using MSVC and mingw64-gfortran together

Numpy distutils now supports using Mingw64 gfortran and MSVC compilerstogether. This enables the production of Python extension modules on Windowscontaining Fortran code while retaining compatibility with thebinaries distributed by Python.org. Not all use cases are supported,but most common ways to wrap Fortran for Python are functional.

Compilation in this mode is usually enabled automatically, and can beselected via the--fcompiler and--compiler options tosetup.py. Moreover, linking Fortran codes to static OpenBLAS issupported; by default a gfortran compatible static archiveopenblas.a is looked for.

np.linalg.pinv now works on stacked matrices

Previously it was limited to a single 2d array.

numpy.save aligns data to 64 bytes instead of 16

Saving NumPy arrays in thenpy format withnumpy.save insertspadding before the array data to align it at 64 bytes. Previouslythis was only 16 bytes (and sometimes less due to a bug in the codefor version 2). Now the alignment is 64 bytes, which matches thewidest SIMD instruction set commonly available, and is also the mostcommon cache line size. This makesnpy files easier to use inprograms which open them withmmap, especially on Linux where anmmap offset must be a multiple of the page size.

NPZ files now can be written without using temporary files

In Python 3.6+numpy.savez andnumpy.savez_compressed now writedirectly to a ZIP file, without creating intermediate temporary files.

Better support for empty structured and string types

Structured types can contain zero fields, and string dtypes can contain zerocharacters. Zero-length strings still cannot be created directly, and must beconstructed through structured dtypes:

str0=np.empty(10,np.dtype([('v',str,N)]))['v']void0=np.empty(10,np.void)

It was always possible to work with these, but the following operations arenow supported for these arrays:

  • arr.sort()
  • arr.view(bytes)
  • arr.resize(…)
  • pickle.dumps(arr)

Support fordecimal.Decimal innp.lib.financial

Unless otherwise stated all functions within thefinancial package nowsupport using thedecimal.Decimal built-in type.

Float printing now uses “dragon4” algorithm for shortest decimal representation

Thestr andrepr of floating-point values (16, 32, 64 and 128 bit) arenow printed to give the shortest decimal representation which uniquelyidentifies the value from others of the same type. Previously this was onlytrue forfloat64 values. The remaining float types will now often be shorterthan in numpy 1.13. Arrays printed in scientific notation now also use theshortest scientific representation, instead of fixed precision as before.

Additionally, thestr of float scalars scalars will no longer be truncatedin python2, unlike python2float`s. `np.double scalars now have astrandrepr identical to that of a python3 float.

New functionsnp.format_float_scientific andnp.format_float_positionalare provided to generate these decimal representations.

A new optionfloatmode has been added tonp.set_printoptions andnp.array2string, which gives control over uniqueness and rounding ofprinted elements in an array. The new default isfloatmode='maxprec' withprecision=8, which will print at most 8 fractional digits, or fewer if anelement can be uniquely represented with fewer. A useful new mode isfloatmode="unique", which will output enough digits to specify the arrayelements uniquely.

Numpy complex-floating-scalars with values likeinf*j ornan*j nowprint asinfj andnanj, like the pure-pythoncomplex type.

TheFloatFormat andLongFloatFormat classes are deprecated and shouldboth be replaced byFloatingFormat. SimilarlyComplexFormat andLongComplexFormat should be replaced byComplexFloatingFormat.

void datatype elements are now printed in hex notation

A hex representation compatible with the pythonbytes type is now printedfor unstructurednp.void elements, e.g.,V4 datatype. Previously, inpython2 the raw void data of the element was printed to stdout, or in python3the integer byte values were shown.

printing style forvoid datatypes is now independently customizable

The printing style ofnp.void arrays is now independently customizableusing theformatter argument tonp.set_printoptions, using the'void' key, instead of the catch-allnumpystr key as before.

Reduced memory usage ofnp.loadtxt

np.loadtxt now reads files in chunks instead of all at once which decreasesits memory usage significantly for large files.

Changes

Multiple-field indexing/assignment of structured arrays

The indexing and assignment of structured arrays with multiple fields haschanged in a number of ways, as warned about in previous releases.

First, indexing a structured array with multiple fields, e.g.,arr[['f1','f3']], returns a view into the original array instead of acopy. The returned view will have extra padding bytes corresponding tointervening fields in the original array, unlike the copy in 1.13, which willaffect code such asarr[['f1','f3']].view(newdtype).

Second, assignment between structured arrays will now occur “by position”instead of “by field name”. The Nth field of the destination will be set to theNth field of the source regardless of field name, unlike in numpy versions 1.6to 1.13 in which fields in the destination array were set to theidentically-named field in the source array or to 0 if the source did not havea field.

Correspondingly, the order of fields in a structured dtypes now matters whencomputing dtype equality. For example, with the dtypes

x=dtype({'names':['A','B'],'formats':['i4','f4'],'offsets':[0,4]})y=dtype({'names':['B','A'],'formats':['f4','i4'],'offsets':[4,0]})

the expressionx==y will now returnFalse, unlike before.This makes dictionary based dtype specifications likedtype({'a':('i4',0),'b':('f4',4)}) dangerous in python < 3.6since dict key order is not preserved in those versions.

Assignment from a structured array to a boolean array now raises a ValueError,unlike in 1.13, where it always set the destination elements toTrue.

Assignment from structured array with more than one field to a non-structuredarray now raises a ValueError. In 1.13 this copied just the first field of thesource to the destination.

Using field “titles” in multiple-field indexing is now disallowed, as isrepeating a field name in a multiple-field index.

The documentation for structured arrays in the user guide has beensignificantly updated to reflect these changes.

Integer and Void scalars are now unaffected bynp.set_string_function

Previously, unlike most other numpy scalars, thestr andrepr ofinteger and void scalars could be controlled bynp.set_string_function.This is no longer possible.

0d array printing changed,style arg of array2string deprecated

Previously thestr andrepr of 0d arrays had idiosyncraticimplementations which returnedstr(a.item()) and'array('+repr(a.item())+')' respectively for 0d arraya, unlike both numpyscalars and higher dimension ndarrays.

Now, thestr of a 0d array acts like a numpy scalar usingstr(a[()])and therepr acts like higher dimension arrays usingformatter(a[()]),whereformatter can be specified usingnp.set_printoptions. Thestyle argument ofnp.array2string is deprecated.

This new behavior is disabled in 1.13 legacy printing mode, see compatibilitynotes above.

SeedingRandomState using an array requires a 1-d array

RandomState previously would accept empty arrays or arrays with 2 or moredimensions, which resulted in either a failure to seed (empty arrays) or forsome of the passed values to be ignored when setting the seed.

MaskedArray objects show a more usefulrepr

Therepr of aMaskedArray is now closer to the python code that wouldproduce it, with arrays now being shown with commas and dtypes. Like the otherformatting changes, this can be disabled with the 1.13 legacy printing mode inorder to help transition doctests.

Therepr ofnp.polynomial classes is more explicit

It now shows the domain and window parameters as keyword arguments to makethem more clear:

>>>np.polynomial.Polynomial(range(4))Polynomial([0.,  1.,  2.,  3.], domain=[-1,  1], window=[-1,  1])

NumPy 1.13.3 Release Notes

This is a bugfix release for some problems found since 1.13.1. The mostimportant fixes are for CVE-2017-12852 and temporary elision. Users of earlierversions of 1.13 should upgrade.

The Python versions supported are 2.7 and 3.4 - 3.6. The Python 3.6 wheelsavailable from PIP are built with Python 3.6.2 and should be compatible withall previous versions of Python 3.6. It was cythonized with Cython 0.26.1,which should be free of the bugs found in 0.27 while also being compatible withPython 3.7-dev. The Windows wheels were built with OpenBlas instead ATLAS,which should improve the performance of the linear algebra functions.

The NumPy 1.13.3 release is a re-release of 1.13.2, which suffered from abug in Cython 0.27.0.

Contributors

A total of 12 people contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Allan Haldane
  • Brandon Carter
  • Charles Harris
  • Eric Wieser
  • Iryna Shcherbina +
  • James Bourbeau +
  • Jonathan Helmus
  • Julian Taylor
  • Matti Picus
  • Michael Lamparski +
  • Michael Seifert
  • Ralf Gommers

Pull requests merged

A total of 22 pull requests were merged for this release.

  • #9390 BUG: Return the poly1d coefficients array directly
  • #9555 BUG: Fix regression in 1.13.x in distutils.mingw32ccompiler.
  • #9556 BUG: Fix true_divide when dtype=np.float64 specified.
  • #9557 DOC: Fix some rst markup in numpy/doc/basics.py.
  • #9558 BLD: Remove -xhost flag from IntelFCompiler.
  • #9559 DOC: Removes broken docstring example (source code, png, pdf)…
  • #9580 BUG: Add hypot and cabs functions to WIN32 blacklist.
  • #9732 BUG: Make scalar function elision check if temp is writeable.
  • #9736 BUG: Various fixes to np.gradient
  • #9742 BUG: Fix np.pad for CVE-2017-12852
  • #9744 BUG: Check for exception in sort functions, add tests
  • #9745 DOC: Add whitespace after “versionadded::” directive so it actually…
  • #9746 BUG: Memory leak in np.dot of size 0
  • #9747 BUG: Adjust gfortran version search regex
  • #9757 BUG: Cython 0.27 breaks NumPy on Python 3.
  • #9764 BUG: Ensure_npy_scaled_cexp{,f,l} is defined when needed.
  • #9765 BUG: PyArray_CountNonzero does not check for exceptions
  • #9766 BUG: Fixes histogram monotonicity check for unsigned bin values
  • #9767 BUG: Ensure consistent result dtype of count_nonzero
  • #9771 BUG: MAINT: Fix mtrand for Cython 0.27.
  • #9772 DOC: Create the 1.13.2 release notes.
  • #9794 DOC: Create 1.13.3 release notes.

NumPy 1.13.2 Release Notes

This is a bugfix release for some problems found since 1.13.1. The mostimportant fixes are for CVE-2017-12852 and temporary elision. Users of earlierversions of 1.13 should upgrade.

The Python versions supported are 2.7 and 3.4 - 3.6. The Python 3.6 wheelsavailable from PIP are built with Python 3.6.2 and should be compatible withall previous versions of Python 3.6. The Windows wheels are now builtwith OpenBlas instead ATLAS, which should improve the performance of the linearalgebra functions.

Contributors

A total of 12 people contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Allan Haldane
  • Brandon Carter
  • Charles Harris
  • Eric Wieser
  • Iryna Shcherbina +
  • James Bourbeau +
  • Jonathan Helmus
  • Julian Taylor
  • Matti Picus
  • Michael Lamparski +
  • Michael Seifert
  • Ralf Gommers

Pull requests merged

A total of 20 pull requests were merged for this release.

  • #9390 BUG: Return the poly1d coefficients array directly
  • #9555 BUG: Fix regression in 1.13.x in distutils.mingw32ccompiler.
  • #9556 BUG: Fix true_divide when dtype=np.float64 specified.
  • #9557 DOC: Fix some rst markup in numpy/doc/basics.py.
  • #9558 BLD: Remove -xhost flag from IntelFCompiler.
  • #9559 DOC: Removes broken docstring example (source code, png, pdf)…
  • #9580 BUG: Add hypot and cabs functions to WIN32 blacklist.
  • #9732 BUG: Make scalar function elision check if temp is writeable.
  • #9736 BUG: Various fixes to np.gradient
  • #9742 BUG: Fix np.pad for CVE-2017-12852
  • #9744 BUG: Check for exception in sort functions, add tests
  • #9745 DOC: Add whitespace after “versionadded::” directive so it actually…
  • #9746 BUG: Memory leak in np.dot of size 0
  • #9747 BUG: Adjust gfortran version search regex
  • #9757 BUG: Cython 0.27 breaks NumPy on Python 3.
  • #9764 BUG: Ensure_npy_scaled_cexp{,f,l} is defined when needed.
  • #9765 BUG: PyArray_CountNonzero does not check for exceptions
  • #9766 BUG: Fixes histogram monotonicity check for unsigned bin values
  • #9767 BUG: Ensure consistent result dtype of count_nonzero
  • #9771 BUG, MAINT: Fix mtrand for Cython 0.27.

NumPy 1.13.1 Release Notes

This is a bugfix release for problems found in 1.13.0. The major changes arefixes for the new memory overlap detection and temporary elision as well asreversion of the removal of the boolean binary- operator. Users of 1.13.0should upgrade.

Thr Python versions supported are 2.7 and 3.4 - 3.6. Note that the Python 3.6wheels available from PIP are built against 3.6.1, hence will not work whenused with 3.6.0 due to Python bug29943_. NumPy 1.13.2 will be released shortlyafter Python 3.6.2 is out to fix that problem. If you are using 3.6.0 theworkaround is to upgrade to 3.6.1 or use an earlier Python version.

Pull requests merged

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 theirnames 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

NumPy 1.13.0 Release Notes

This release supports Python 2.7 and 3.4 - 3.6.

Highlights

  • Operations likea+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 temporariesto avoid problems.
  • New__array_ufunc__ attribute provides improved ability for classes tooverride default ufunc behavior.
  • Newnp.block function for creating blocked arrays.

New functions

  • Newnp.positive ufunc.
  • Newnp.divmod ufunc provides more efficient divmod.
  • Newnp.isnat ufunc tests for NaT special values.
  • Newnp.heaviside ufunc computes the Heaviside function.
  • Newnp.isin function, improves onin1d.
  • Newnp.block function for creating blocked arrays.
  • NewPyArray_MapIterArrayCopyIfOverlap added to NumPy C-API.

See below for details.

Deprecations

  • Callingnp.fix,np.isposinf, andnp.isneginf withf(x,y=out)is deprecated - the argument should be passed asf(x,out=out), whichmatches other ufunc-like interfaces.
  • Use of the C-APINPY_CHAR type number deprecated since version 1.7 willnow raise deprecation warnings at runtime. Extensions built with older f2pyversions need to be recompiled to remove the warning.
  • np.ma.argsort,np.ma.minimum.reduce, andnp.ma.maximum.reduceshould be called with an explicitaxis argument when applied to arrays withmore than 2 dimensions, as the default value of this argument (None) isinconsistent with the rest of numpy (-1,0, and0, respectively).
  • np.ma.MaskedArray.mini is deprecated, as it almost duplicates thefunctionality ofnp.MaskedArray.min. Exactly equivalent behaviourcan be obtained withnp.ma.minimum.reduce.
  • The single-argument form ofnp.ma.minimum andnp.ma.maximum isdeprecated.np.maximum.np.ma.minimum(x) should now be speltnp.ma.minimum.reduce(x), which is consistent with how this would be donewithnp.minimum.
  • Callingndarray.conjugate on non-numeric dtypes is deprecated (itshould match the behavior ofnp.conjugate, which throws an error).
  • Callingexpand_dims when theaxis keyword does not satisfy-a.ndim-1<=axis<=a.ndim, wherea is the array being reshaped,is deprecated.

Future Changes

  • Assignment between structured arrays with different field names will changein NumPy 1.14. Previously, fields in the dst would be set to the value of theidentically-named field in the src. In numpy 1.14 fields will instead beassigned ‘by position’: The n-th field of the dst will be set to the n-thfield of the src array. Note that theFutureWarning raised in NumPy 1.12incorrectly reported this change as scheduled for NumPy 1.13 rather thanNumPy 1.14.

Build System Changes

  • numpy.distutils now automatically determines C-file dependencies withGCC compatible compilers.

Compatibility notes

Error type changes

  • numpy.hstack() now throwsValueError instead ofIndexError wheninput is empty.
  • Functions taking an axis argument, when that argument is out of range, nowthrownp.AxisError instead of a mixture ofIndexError andValueError. For backwards compatibility,AxisError subclasses both ofthese.

Tuple object dtypes

Support has been removed for certain obscure dtypes that were unintentionallyallowed, of the form(old_dtype,new_dtype), where either of the dtypesis or contains theobject dtype. As an exception, dtypes of the form(object,[('name',object)]) are still supported due to evidence ofexisting use.

DeprecationWarning to error

See Changes section for more detail.

  • partition, TypeError when non-integer partition index is used.
  • NpyIter_AdvancedNew, ValueError whenoa_ndim==0 andop_axes is NULL
  • negative(bool_), TypeError when negative applied to booleans.
  • subtract(bool_,bool_), TypeError when subtracting boolean from boolean.
  • np.equal,np.not_equal, object identity doesn’t override failed comparison.
  • np.equal,np.not_equal, object identity doesn’t override non-boolean comparison.
  • Deprecated boolean indexing behavior dropped. See Changes below for details.
  • Deprecatednp.alterdot() andnp.restoredot() removed.

FutureWarning to changed behavior

See Changes section for more detail.

  • numpy.average preserves subclasses
  • array==None andarray!=None do element-wise comparison.
  • np.equal,np.not_equal, object identity doesn’t override comparison result.

dtypes are now always true

Previouslybool(dtype) would fall back to the default pythonimplementation, which checked iflen(dtype)>0. Sincedtype objectsimplement__len__ as the number of record fields,bool of scalar dtypeswould evaluate toFalse, which was unintuitive. Nowbool(dtype)==Truefor all dtypes.

__getslice__ and__setslice__ are no longer needed inndarray subclasses

When subclassing np.ndarray in Python 2.7, it is no longer _necessary_ toimplement__*slice__ on the derived class, as__*item__ will interceptthese calls correctly.

Any code that did implement these will work exactly as before. Code thatinvokes``ndarray.__getslice__`` (e.g. throughsuper(...).__getslice__) willnow issue a DeprecationWarning -.__getitem__(slice(start,end)) should beused instead.

Indexing MaskedArrays/Constants with... (ellipsis) now returns MaskedArray

This behavior mirrors that of np.ndarray, and accounts for nested arrays inMaskedArrays of object dtype, and ellipsis combined with other forms ofindexing.

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 meanthat code removing axes from NpyIter has to add an additional check whenaccessing the removed dimensions later on.

The largest followup change is that gufuncs are now allowed to have zero-sizedinner dimensions. This means that a gufunc now has to anticipate an empty innerdimension, while this was never possible and an error raised instead.

For most gufuncs no change should be necessary. However, it is now possiblefor gufuncs with a signature such as(...,N,M)->(...,M) to returna valid result ifN=0 without further wrapping code.

PyArray_MapIterArrayCopyIfOverlap added to NumPy C-API

Similar toPyArray_MapIterArray but with an additionalcopy_if_overlapargument. Ifcopy_if_overlap!=0, checks if input has memory overlap withany of the other arrays and make copies as appropriate to avoid problems if theinput is modified during the iteration. See the documentation for more completedocumentation.

New Features

__array_ufunc__ added

This is the renamed and redesigned__numpy_ufunc__. Any class, ndarraysubclass or not, can define this method or set it toNone in order tooverride the behavior of NumPy’s ufuncs. This works quite similarly to Python’s__mul__ and other binary operation routines. See the documentation for amore detailed description of the implementation and behavior of this newoption. The API is provisional, we do not yet guarantee backward compatibilityas modifications may be made pending feedback. See theNEP_ anddocumentation for more details.

Newpositive ufunc

This ufunc corresponds to unary+, but unlike+ on an ndarray it will raisean error if array values do not support numeric operations.

Newdivmod ufunc

This ufunc corresponds to the Python builtindivmod, and is used to implementdivmod when called on numpy arrays.np.divmod(x,y) calculates a resultequivalent to(np.floor_divide(x,y),np.remainder(x,y)) but isapproximately twice as fast as calling the functions separately.

np.isnat ufunc tests for NaT special datetime and timedelta values

The new ufuncnp.isnat finds the positions of special NaT valueswithin datetime and timedelta arrays. This is analogous tonp.isnan.

np.heaviside ufunc computes the Heaviside function

The new functionnp.heaviside(x,h0) (a ufunc) computes the Heavisidefunction:

{0ifx<0,heaviside(x,h0)={h0ifx==0,{1ifx>0.

np.block function for creating blocked arrays

Add a newblock function to the current stacking functionsvstack,hstack, andstack. This allows concatenation across multiple axessimultaneously, with a similar syntax to array creation, but where elementscan themselves be arrays. For instance:

>>>A=np.eye(2)*2>>>B=np.eye(3)*3>>>np.block([...[A,np.zeros((2,3))],...[np.ones((3,2)),B]...])array([[ 2.,  0.,  0.,  0.,  0.],       [ 0.,  2.,  0.,  0.,  0.],       [ 1.,  1.,  3.,  0.,  0.],       [ 1.,  1.,  0.,  3.,  0.],       [ 1.,  1.,  0.,  0.,  3.]])

While primarily useful for block matrices, this works for arbitrary dimensionsof arrays.

It is similar to Matlab’s square bracket notation for creating block matrices.

isin function, improving onin1d

The new functionisin tests whether each element of an N-dimensonalarray is present anywhere within a second array. It is an enhancementofin1d that preserves the shape of the first array.

Temporary elision

On platforms providing thebacktrace function NumPy will try to avoidcreating temporaries in expression involving basic numeric types.For exampled=a+b+c is transformed tod=a+b;d+=c which canimprove performance for large arrays as less memory bandwidth is required toperform the operation.

axes argument forunique

In an N-dimensional array, the user can now choose the axis along which to lookfor duplicate N-1-dimensional elements usingnumpy.unique. The originalbehaviour is recovered ifaxis=None (default).

np.gradient now supports unevenly spaced data

Users can now specify a not-constant spacing for data.In particularnp.gradient can now take:

  1. A single scalar to specify a sample distance for all dimensions.
  2. N scalars to specify a constant sample distance for each dimension.i.e.dx,dy,dz, …
  3. 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
  4. 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:

>>>f=np.array([[1,2,6],[3,4,5]],dtype=np.float)>>>dx=2.>>>y=[1.,1.5,3.5]>>>np.gradient(f,dx,y)[array([[ 1. ,  1. , -0.5], [ 1. ,  1. , -0.5]]), array([[ 2. ,  2. ,  2. ], [ 2. ,  1.7,  0.5]])]

Support for returning arrays of arbitrary dimensions inapply_along_axis

Previously, only scalars or 1D arrays could be returned by the function passedtoapply_along_axis. Now, it can return an array of any dimensionality(including 0D), and the shape of this array replaces the axis of the arraybeing iterated over.

.ndim property added todtype to complement.shape

For consistency withndarray andbroadcast,d.ndim is a shorthandforlen(d.shape).

Support for tracemalloc in Python 3.6

NumPy now supports memory tracing withtracemalloc module of Python 3.6 ornewer. Memory allocations from NumPy are placed into the domain defined bynumpy.lib.tracemalloc_domain.Note that NumPy allocation will not show up intracemalloc of earlier Pythonversions.

NumPy may be built with relaxed stride checking debugging

Setting NPY_RELAXED_STRIDES_DEBUG=1 in the environment when relaxed stridechecking is enabled will cause NumPy to be compiled with the affected stridesset to the maximum value of npy_intp in order to help detect invalid usage ofthe strides in downstream projects. When enabled, invalid usage often resultsin an error being raised, but the exact type of error depends on the details ofthe code. TypeError and OverflowError have been observed in the wild.

It was previously the case that this option was disabled for releases andenabled in master and changing between the two required editing the code. It isnow 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 overlapproduced undefined results in previous NumPy versions, due to datadependency issues. In NumPy 1.13.0, results from such operations arenow defined to be the same as for equivalent operations where there isno memory overlap.

Operations affected now make temporary copies, as needed to eliminatedata dependency. As detecting these cases is computationallyexpensive, a heuristic is used, which may in rare cases result toneedless temporary copies. For operations where the data dependencyis simple enough for the heuristic to analyze, temporary copies willnot be made even if the arrays overlap, if it can be deduced copiesare not necessary. As an example,``np.add(a, b, out=a)`` will notinvolve 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:

>>>np.add(x[1:].copy(),x[:-1].copy(),out=x[1:])

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 NumPyversions, 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 tox[...]=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 freeMinGW toolset, also under Python 3.5. This works best for extensions that onlydo 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 makeextensive use of the runtime, you will most likely run intoissues. 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 runtimelibrary from the (moveable) WinPython 3.4 distribution, which can be useful forprograms with a PySide1/Qt4 front-end.

Performance improvements forpackbits andunpackbits

The functionsnumpy.packbits with boolean input andnumpy.unpackbits havebeen optimized to be a significantly faster for contiguous data.

Fix for PPC long double floating point information

In previous versions of NumPy, thefinfo function returned invalidinformation about thedouble double format of thelongdouble float typeon Power PC (PPC). The invalid values resulted from the failure of the NumPyalgorithm to deal with the variable number of digits in the significandthat are a feature ofPPC long doubles. This release by-passes the failingalgorithm by using heuristics to detect the presence of the PPC double doubleformat. A side-effect of using these heuristics is that thefinfofunction is faster than previous releases.

Better default repr forndarray subclasses

Subclasses of ndarray with norepr specialization now correctly indenttheir data and type lines.

More reliable comparisons of masked arrays

Comparisons of masked arrays were buggy for masked scalars and failed forstructured arrays with dimension higher than one. Both problems are nowsolved. In the process, it was ensured that in getting the result for astructured array, masked fields are properly ignored, i.e., the result is equalif all fields that are non-masked in both are equal, thus making the behaviouridentical to what one gets by comparing an unstructured masked array and thendoing.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.

Morelinalg operations now accept empty vectors and matrices

All of the following functions innp.linalg now work when given inputarrays 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 withouta lapack library installed, under the name oflapack_lite. This has beenupgraded from LAPACK 3.0.0 (June 30, 1999) to LAPACK 3.2.2 (June 30, 2010). SeetheLAPACK changelogs for details on the all the changes this entails.

While no new features are exposed throughnumpy, this fixes some bugsregarding “workspace” sizes, and in some places may use faster algorithms.

reduce ofnp.hypot.reduce andnp.logical_xor allowed in more cases

This now works on empty arrays, returning 0, and can reduce over multiple axes.Previously, aValueError was thrown in these cases.

Betterrepr of object arrays

Object arrays that contain themselves no longer cause a recursion error.

Object arrays that containlist objects are now printed in a way that makesclear the difference between a 2d object array, and a 1d object array of lists.

Changes

argsort on masked arrays takes the same default arguments assort

By default,argsort now places the masked values at the end of the sortedarray, in the same way thatsort already did. Additionally, theend_with argument is added toargsort, for consistency withsort.Note that this argument is not added at the end, so breaks any code thatpassedfill_value as a positional argument.

average now preserves subclasses

For ndarray subclasses,numpy.average will now return an instance of thesubclass, matching the behavior of most other NumPy functions such asmean.As a consequence, also calls that returned a scalar may now return a subclassarray scalar.

array==None andarray!=None do element-wise comparison

Previously these operations returned scalarsFalse andTrue respectively.

np.equal,np.not_equal for object arrays ignores object identity

Previously, these functions always treated identical objects as equal. This hadthe effect of overriding comparison failures, comparison of objects that didnot return booleans, such as np.arrays, and comparison of objects where theresults differed from object identity, such as NaNs.

Boolean indexing changes

  • Boolean array-likes (such as lists of python bools) are always treated asboolean indexes.
  • Boolean scalars (including pythonTrue) are legal boolean indexes andnever 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 ofthe rhs.
  • Boolean indexing into scalar arrays return a new 1-d array. This means thatarray(1)[array(True)] givesarray([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 dealingwith the covariance matrix by using two new keyword arguments:

  • tol can be used to specify a tolerance to use when checking thatthe covariance matrix is positive semidefinite.
  • check_valid can be used to configure what the function will do in thepresence of a matrix that is not positive semidefinite. Valid options areignore,warn andraise. The default value,warn keeps thethe behavior used on previous releases.

assert_array_less comparesnp.inf and-np.inf now

Previously,np.testing.assert_array_less ignored all infinite values. Thisis not the expected behavior both according to documentation and intuitively.Now, -inf < x < inf is consideredTrue for any real number x and allother cases fail.

assert_array_ and masked arraysassert_equal hide less warnings

Some warnings that were previously hidden by theassert_array_functions are not hidden anymore. In most cases the warnings should becorrect and, should they occur, will require changes to the tests usingthese functions.For the masked arrayassert_equal version, warnings may occur whencomparing NaT. The function presently does not handle NaT or NaNspecifically and it may be best to avoid it at this time should a warningshow up due to this change.

offset attribute value inmemmap objects

Theoffset attribute in amemmap object is now set to theoffset into the file. This is a behaviour change only for offsetsgreater thanmmap.ALLOCATIONGRANULARITY.

np.real andnp.imag return scalars for scalar inputs

Previously,np.real andnp.imag used to return array objects whenprovided a scalar input, which was inconsistent with other functions likenp.angle andnp.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 polynomialconvenience class instance is passed as an argument to a ufunc, aTypeErrorwill 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 anout argument with a tuple for ufuncs with multiple outputs. This has nowbeen extended to output arguments in thereduce,accumulate, andreduceat methods. This is mostly for compatibility with__array_ufunc;there are no ufuncs yet that have more than one output.

NumPy 1.12.1 Release Notes

NumPy 1.12.1 supports Python 2.7 and 3.4 - 3.6 and fixes bugs and regressionsfound in NumPy 1.12.0. In particular, the regression in f2py constant parsingis 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

NumPy 1.12.0 Release Notes

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, butfew that stand out above all others. That makes picking out the highlightssomewhat arbitrary but the following may be of particular interest or indicateareas likely to have future consequences.

  • Order of operations innp.einsum can now be optimized for large speed improvements.
  • Newsignature argument tonp.vectorize for vectorizing with core dimensions.
  • Thekeepdims 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 (nditerupdateifcopy is not supported yet), this is a milestone for PyPy’sC-API compatibility layer.

Build System Changes

  • Library order is preserved, instead of being reordered to match that ofthe directories.

Deprecations

Assignment of ndarray object’sdata attribute

Assigning the ‘data’ attribute is an inherently unsafe operation as pointedout in gh-7083. Such a capability will be removed in the future.

Unsafe int casting of the num attribute inlinspace

np.linspace now raises DeprecationWarning when num cannot be safelyinterpreted as an integer.

Insufficient bit width parameter tobinary_repr

If a ‘width’ parameter is passed intobinary_repr that is insufficient torepresent the number in base 2 (positive) or 2’s complement (negative) form,the function used to silently ignore the parameter and return a representationusing the minimal number of bits needed for the form in question. Such behavioris now considered unsafe from a user perspective and will raise an error in thefuture.

Future Changes

  • In 1.13 NAT will always compare False except forNAT!=NAT,which will be True. In short, NAT will behave like NaN
  • In 1.13np.average will preserve subclasses, to match the behavior of mostother numpy functions such as np.mean. In particular, this means calls whichreturned 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 changein 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 bytescorresponding to intervening fields in the original array, unlike the copy in1.12, which will affect code such asarr[['f1','f3']].view(newdtype).

Second, for numpy versions 1.6 to 1.12 assignment between structured arraysoccurs “by field name”: Fields in the destination array are set to theidentically-named field in the source array or to 0 if the source does not havea 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>>>barray([(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 thedestination will be set to the Nth field of the source regardless of fieldname. The old behavior can be obtained by using indexing to reorder the fieldsbeforeassignment, e.g.,b[['x','y']]=a[['y','x']].

Compatibility notes

DeprecationWarning to error

  • Indexing with floats raisesIndexError,e.g., a[0, 0.0].
  • Indexing with non-integer array_like raisesIndexError,e.g.,a['1','2']
  • Indexing with multiple ellipsis raisesIndexError,e.g.,a[...,...].
  • Non-integers used as index values raiseTypeError,e.g., inreshape,take, and specifying reduce axis.

FutureWarning to changed behavior

  • np.full now returns an array of the fill-value’s dtype if no dtype isgiven, 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 numpyinteger 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 thecorrect float depending on the integer type combination.

All of these cases now raise aValueError except for those integercombinations whose common type is float, for instance uint64 and int8. It wasfelt that a simple rule was the best way to go rather than have specialexceptions for the integer units. If you need negative powers, use an inexacttype.

Relaxed stride checking is the default

This will have some impact on code that assumed thatF_CONTIGUOUS andC_CONTIGUOUS were mutually exclusive and could be set to determine thedefault order for arrays that are now both.

Thenp.percentile ‘midpoint’ interpolation method fixed for exact indices

The ‘midpoint’ interpolator now gives the same result as ‘lower’ and ‘higher’ whenthe two coincide. Previous behavior of ‘lower’ + 0.5 is fixed.

keepdims kwarg is passed through to user-class methods

numpy functions that take akeepdims kwarg now pass the valuethrough to the corresponding methods on ndarray sub-classes. Previously thekeepdims keyword would be silently dropped. These functions now havethe following behavior:

  1. If user does not providekeepdims, no keyword is passed to the underlyingmethod.
  2. Any user-provided value ofkeepdims is passed through as a keywordargument to the method.

This will raise in the case where the method does not support akeepdims kwarg and the user explicitly passes inkeepdims.

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 formore explanation.

ma.median warns and returns nan when unmasked invalid values are encountered

Similar to unmasked median the masked medianma.median now emits a Runtimewarning and returnsNaN in slices where an unmaskedNaN is present.

Greater consistency inassert_almost_equal

The precision check for scalars has been changed to match that for arrays. Itis now:

abs(actual-desired)<1.5*10**(-decimal)

Note that this is looser than previously documented, but agrees with theprevious implementation used inassert_array_almost_equal. Due to thechange in implementation some very delicate tests may fail that did notfail before.

NoseTester behaviour of warnings during testing

Whenraise_warnings="develop" is given, all uncaught warnings will nowbe 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 pythonsettings.

assert_warns anddeprecated decorator more specific

Theassert_warns function and context manager are now more specificto the given warning category. This increased specificity leads to thembeing handled according to the outer warning settings. This means thatno warning may be raised in cases where a wrong category warning is givenand ignored outside the context. Alternatively the increased specificitymay mean that warnings that were incorrectly ignored will now be shownor raised. See also the newsuppress_warnings context manager.The same is true for thedeprecated decorator.

C API

No changes.

New Features

Writeable keyword argument foras_strided

np.lib.stride_tricks.as_strided now has awriteablekeyword argument. It can be set to False when no write operationto the returned array is expected to avoid accidentalunpredictable writes.

axes keyword argument forrot90

Theaxes keyword argument inrot90 determines the plane in which thearray is rotated. It defaults toaxes=(0,1) as in the original function.

Generalizedflip

flipud andfliplr reverse the elements of an array along axis=0 andaxis=1 respectively. The newly addedflip function reverses the elements ofan array along any given axis.

  • np.count_nonzero now has anaxis parameter, allowingnon-zero counts to be generated on more than just a flattenedarray object.

BLIS support innumpy.distutils

Building against the BLAS implementation provided by the BLIS library is nowsupported. See the[blis] section insite.cfg.example (in the root ofthe numpy repo or source distribution).

Hook innumpy/__init__.py to run distribution-specific checks

Binary distributions of numpy may need to run specific hardware checks or loadspecific libraries during numpy initialization. For example, if we aredistributing numpy with a BLAS library that requires SSE2 instructions, wewould like to check the machine on which numpy is running does have SSE2 inorder to give an informative error.

Add a hook innumpy/__init__.py to import anumpy/_distributor_init.pyfile 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 nanfunctionsnancumsum andnancumprod added

Nan-functionsnancumsum andnancumprod have been added tocomputecumsum andcumprod by ignoring nans.

np.interp can now interpolate complex values

np.lib.interp(x,xp,fp) now allows the interpolated arrayfpto be complex and will interpolate atcomplex128 precision.

New polynomial evaluation functionpolyvalfromroots added

The new functionpolyvalfromroots evaluates a polynomial at given pointsfrom the roots of the polynomial. This is useful for higher order polynomials,where expansion into polynomial coefficients is inaccurate at machineprecision.

New array creation functiongeomspace added

The new functiongeomspace generates a geometric sequence. It is similartologspace, but with start and stop specified directly:geomspace(start,stop) behaves the same aslogspace(log10(start),log10(stop)).

New context manager for testing warnings

A new context managersuppress_warnings has been added to the testingutils. This context manager is designed to help reliably test warnings.Specifically to reliably filter/ignore warnings. Ignoring warningsby using an “ignore” filter in Python versions before 3.4.x can quicklyresult in these (or similar) warnings not being tested reliably.

The context manager allows to filter (as well as record) warnings similarto thecatch_warnings context, but allows for easier specificity.Also printing warnings that have not been filtered or nesting thecontext manager will work as expected. Additionally, it is possibleto use the context manager as a decorator which can be useful whenmultiple tests give need to hide the same warning.

New masked array functionsma.convolve andma.correlate added

These functions wrapped the non-masked versions, but propagate through maskedvalues. There are two different propagation modes. The default causes maskedvalues to contaminate the result with masks, but the other mode only outputsmasks if there is no alternative.

Newfloat_power ufunc

The newfloat_power ufunc is like thepower function except allcomputation is done in a minimum precision of float64. There was a longdiscussion on the numpy mailing list of how to treat integers to negativeinteger powers and a popular proposal was that the__pow__ operator shouldalways return results of at least float64 precision. Thefloat_powerfunction implements that option. Note that it does not support object arrays.

np.loadtxt now supports a single integer asusecol argument

Instead of usingusecol=(n,) to read the nth column of a fileit is now allowed to useusecol=n. Also the error message ismore user friendly when a non-integer is passed as a column index.

Improved automated bin estimators forhistogram

Added ‘doane’ and ‘sqrt’ estimators tohistogram via thebinsargument. Added support for range-restricted histograms with automatedbin estimation.

np.roll can now roll multiple axes at the same time

Theshift andaxis arguments toroll are now broadcast against eachother, and each specified axis is shifted accordingly.

The__complex__ method has been implemented for the ndarrays

Callingcomplex() on a size 1 array will now cast to a pythoncomplex.

pathlib.Path objects now supported

The standardnp.load,np.save,np.loadtxt,np.savez, and similarfunctions can now takepathlib.Path objects as an argument instead of afilename or open file object.

Newbits attribute fornp.finfo

This makesnp.finfo consistent withnp.iinfo which already has thatattribute.

Newsignature argument tonp.vectorize

This argument allows for vectorizing user defined functions with coredimensions, in the style of NumPy’sgeneralized universal functions. This allowsfor vectorizing a much broader class of functions. For example, an arbitrarydistance metric that combines two vectors to produce a scalar could bevectorized withsignature='(n),(n)->()'. Seenp.vectorize for fulldetails.

Emit py3kwarnings for division of integer arrays

To help people migrate their code bases from Python 2 to Python 3, thepython 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 weremasked out when the reduce method was used. The new identity is -1, whichshould work properly on twos complement machines as all bits will be set toone.

Generalized Ufuncs will now unlock the GIL

Generalized Ufuncs, including most of the linalg module, will now unlockthe Python global interpreter lock.

Caches innp.fft are now bounded in total size and item count

The caches innp.fft that speed up successive FFTs of the same length can nolonger grow without bounds. They have been replaced with LRU (least recentlyused) caches that automatically evict no longer needed items if either thememory 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-widthstring dtypes (i.e.dtype('S0') ordtype('U0'), and fixed severalbugs where such dtypes were not handled properly. In particular, changedndarray.__new__ to not implicitly convertdtype('S0') todtype('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 AVX2instructions. This feature is currently only available when compiled with GCC.

Order of operations optimization innp.einsum

np.einsum now supports theoptimize argument which will optimize theorder of contraction. For example,np.einsum would complete the chain dotexamplenp.einsum(‘ij,jk,kl->il’,a,b,c) in a single pass which wouldscale likeN^4; however, whenoptimize=Truenp.einsum will createan intermediate array to reduce this scaling toN^3 or effectivelynp.dot(a,b).dot(c). Usage of intermediate tensors to reduce scaling hasbeen applied to the general einsum summation notation. Seenp.einsum_pathfor more details.

quicksort has been changed to an introsort

The quicksort kind ofnp.sort andnp.argsort is now an introsort whichis regular quicksort but changing to a heapsort when not enough progress ismade. This retains the good quicksort performance while changing the worst caseruntime fromO(N^2) toO(N*log(N)).

ediff1d improved performance and subclass handling

The ediff1d function uses an array instead on a flat iterator for thesubtraction. When to_begin or to_end is not None, the subtraction is performedin place to eliminate a copy operation. A side effect is that certainsubclasses are handled better, namely astropy.Quantity, since the completearray is created, wrapped, and then begin and end values are set, instead ofusing concatenate.

Improved precision ofndarray.mean for float16 arrays

The computation of the mean of float16 arrays is now carried out in float32 forimproved precision. This should be useful in packages such as Theanowhere the precision of float16 is adequate and its smaller footprint isdesirable.

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 withpositional arguments instead of keyword arguments as their external signatureswere doing. This caused a complication in the downstream ‘pandas’ librarythat encountered an issue with ‘numpy’ compatibility. Now, all array-likemethods 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 memmapinstance even if the result was actually not memmapped. For example,arr+1 orarr+arr would return memmap instances, although no memoryfrom the output array is memmapped. Version 1.12 returns ordinary numpy arraysfrom these operations.

Also, reduction of a memmap (e.g..sum(axis=None) now returns a numpyscalar instead of a 0d memmap.

stacklevel of warnings increased

The stacklevel for python based warnings was increased so that most warningswill report the offending line of the user code instead of the line thewarning itself is given. Passing of stacklevel is now tested to ensure thatnew warnings will receive thestacklevel argument.

This causes warnings with the “default” or “module” filter to be shown oncefor every offending user code line or user module instead of only once. Onpython versions before 3.4, this can cause warnings to appear that were falselyignored before, which may be surprising especially in test suits.

NumPy 1.11.3 Release Notes

Numpy 1.11.3 fixes a bug that leads to file corruption when very large filesopened in append mode are used inndarray.tofile. It supports Pythonversions 2.6 - 2.7 and 3.2 - 3.5. Wheels for Linux, Windows, and OS X can befound on PyPI.

Contributors to maintenance/1.11.3

A total of 2 people contributed to this release. People with a “+” by theirnames contributed a patch for the first time.

  • Charles Harris
  • Pavel Potocek +

Pull Requests Merged

  • #8341: BUG: Fix ndarray.tofile large file corruption in append mode.
  • #8346: TST: Fix tests in PR #8341 for NumPy 1.11.x

NumPy 1.11.2 Release Notes

Numpy 1.11.2 supports Python 2.6 - 2.7 and 3.2 - 3.5. It fixes bugs andregressions found in Numpy 1.11.1 and includes several build relatedimprovements. 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.
  • #7778 DOC: Update Numpy 1.11.1 release notes.
  • #7793 BUG: MaskedArray.count treats negative axes incorrectly.
  • #7816 BUG: Fix array too big error for wide dtypes.
  • #7821 BUG: Make sure npy_mul_with_overflow_<type> detects overflow.
  • #7824 MAINT: Allocate fewer bytes for empty arrays.
  • #7847 MAINT,DOC: Fix some imp module uses and update f2py.compile docstring.
  • #7849 MAINT: Fix remaining uses of deprecated Python imp module.
  • #7851 BLD: Fix ATLAS version detection.
  • #7896 BUG: Construct ma.array from np.array which contains padding.
  • #7904 BUG: Fix float16 type not being called due to wrong ordering.
  • #7917 BUG: Production install of numpy should not require nose.
  • #7919 BLD: Fixed MKL detection for recent versions of this library.
  • #7920 BUG: Fix for issue #7835 (ma.median of 1d).
  • #7932 BUG: Monkey-patch _msvccompile.gen_lib_option like other compilers.
  • #7939 BUG: Check for HAVE_LDOUBLE_DOUBLE_DOUBLE_LE in npy_math_complex.
  • #7953 BUG: Guard against buggy comparisons in generic quicksort.
  • #7954 BUG: Use keyword arguments to initialize Extension base class.
  • #7955 BUG: Make sure numpy globals keep identity after reload.
  • #7972 BUG: MSVCCompiler grows ‘lib’ & ‘include’ env strings exponentially.
  • #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.

NumPy 1.11.1 Release Notes

Numpy 1.11.1 supports Python 2.6 - 2.7 and 3.2 - 3.5. It fixes bugs andregressions found in Numpy 1.11.0 and includes several build relatedimprovements. 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.
  • #7535 BUG: Extend glibc complex trig functions blacklist to glibc < 2.18.
  • #7551 BUG: Allow graceful recovery for no compiler.
  • #7558 BUG: Constant padding expected wrong type in constant_values.
  • #7578 BUG: Fix OverflowError in Python 3.x. in swig interface.
  • #7590 BLD: Fix configparser.InterpolationSyntaxError.
  • #7597 BUG: Make np.ma.take work on scalars.
  • #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.

NumPy 1.11.0 Release Notes

This release supports Python 2.6 - 2.7 and 3.2 - 3.5 and contains a numberof enhancements and improvements. Note also the build system changes listedbelow as they may have subtle effects.

No Windows (TM) binaries are provided for this release due to a brokentoolchain. One of the providers of Python packages for Windows (TM) is yourbest bet.

Highlights

Details of these improvements can be found below.

  • The datetime64 type is now timezone naive.
  • A dtype parameter has been added torandint.
  • Improved detection of two arrays possibly sharing memory.
  • Automatic bin size estimation fornp.histogram.
  • Speed optimization of A @ A.T and dot(A, A.T).
  • New functionnp.moveaxis for reordering array axes.

Build System Changes

  • Numpy now usessetuptools for its builds instead of plain distutils.This fixes usage ofinstall_requires='numpy' in thesetup.py files ofprojects that depend on Numpy (see gh-6551). It potentially affects the waythat build/install methods for Numpy itself behave though. Please report anyunexpected 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 releasenotes for a more extended discussion of what this change implies.
  • The behavior of the datetime64 “not a time” (NaT) value will be changedto match that of floating point “not a number” (NaN) values: allcomparisons involving NaT will return False, except for NaT != NaT whichwill return True.
  • Indexing with floats will raise IndexError,e.g., a[0, 0.0].
  • Indexing with non-integer array_like will raiseIndexError,e.g.,a['1','2']
  • Indexing with multiple ellipsis will raiseIndexError,e.g.,a[...,...].
  • Non-integers used as index values will raiseTypeError,e.g., inreshape,take, and specifying reduce axis.

In a future release the following changes will be made.

  • Therand function exposed innumpy.testing will be removed. Thatfunction is left over from early Numpy and was implemented using thePython random module. The random number generators fromnumpy.randomshould be used instead.
  • Thendarray.view method will only allow c_contiguous arrays to beviewed using a dtype of different size causing the last dimension tochange. That differs from the current behavior where arrays that aref_contiguous but not c_contiguous can be viewed as a dtype type ofdifferent size causing the first dimension to change.
  • Slicing aMaskedArray will return views of both dataand mask.Currently the mask is copy-on-write and changes to the mask in the slice donot propagate to the original mask. See the FutureWarnings section below fordetails.

Compatibility notes

datetime64 changes

In prior versions of NumPy the experimental datetime64 type always storedtimes in UTC. By default, creating a datetime64 object from a string orprinting 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 undesirableand at odds with how datetime64 is usually used (e.g., bypandas). For most use cases, a timezone naive datetimetype is preferred, similar to thedatetime.datetime type in the Pythonstandard library. Accordingly, datetime64 no longer assumes that input is inlocal time, nor does it print local times:

>>>> np.datetime64('2000-01-01T00:00:00')numpy.datetime64('2000-01-01T00:00:00')

For backwards compatibility, datetime64 still parses timezone offsets, whichit handles by converting to UTC. However, the resulting datetime is timezonenaive:

>>>np.datetime64('2000-01-01T00:00:00-08')DeprecationWarning: parsing timezone aware datetimes is deprecated;this will raise an error in the futurenumpy.datetime64('2000-01-01T08:00:00')

As a corollary to this change, we no longer prohibit casting between datetimeswith 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 thelinalg.norm function is now floating point withoutexception. Some of the norm types previously returned integers.

polynomial fit changes

The various fit functions in the numpy polynomial package no longer acceptnon-integers for degree specification.

np.dot now raisesTypeError instead ofValueError

This behaviour mimics that of other functions such asnp.inner. If the twoarguments cannot be cast to a common type, it could have raised aTypeErrororValueError depending on their order. Now,np.dot will now alwaysraise aTypeError.

FutureWarning to changed behavior

  • Innp.lib.split an empty array in the result always had dimension(0,) no matter the dimensions of the array being split. Thishas been changed so that the dimensions will be preserved. AFutureWarning for this change has been in place since Numpy 1.9 but,due to a bug, sometimes no warning was raised and the dimensions werealready preserved.

% and// operators

These operators are implemented with theremainder andfloor_dividefunctions respectively. Those functions are now based aroundfmod and arecomputed together so as to be compatible with each other and with the Pythonversions for float types. The results should be marginally more accurate oroutright bug fixes compared to the previous results, but they maydiffer significantly in cases where roundoff makes a difference in the integerreturned byfloor_divide. Some corner cases also change, for instance, NaNis always returned for both functions when the divisor is zero,divmod(1.0,inf) returns(0.0,1.0) except on MSVC 2008, anddivmod(-1.0,inf) returns(-1.0,inf).

C API

Removed thecheck_return andinner_loop_selector members ofthePyUFuncObject struct (replacing them withreserved slotsto preserve struct layout). These were never used for anything, soit’s unlikely that any third-party code is using them either, but wemention it here for completeness.

object dtype detection for old-style classes

In python 2, objects which are instances of old-style user-defined classes nolonger automatically count as ‘object’ type in the dtype-detection handler.Instead, as in python 3, they may potentially count as sequences, but only ifthey define both a__len__ and a__getitem__ method. This fixes a segfaultand inconsistency between python 2 and 3.

New Features

  • np.histogram now provides plugin estimators for automaticallyestimating the optimal number of bins. Passing one of [‘auto’, ‘fd’,‘scott’, ‘rice’, ‘sturges’] as the argument to ‘bins’ results in thecorresponding estimator being used.

  • A benchmark suite usingAirspeed Velocity has been added, converting theprevious vbench-based one. You can run the suite locally viapythonruntests.py--bench. For more details, seebenchmarks/README.rst.

  • A new functionnp.shares_memory that can check exactly whether twoarrays have memory overlap is added.np.may_share_memory also now hasan option to spend more effort to reduce false positives.

  • SkipTest andKnownFailureException exception classes are exposedin thenumpy.testing namespace. Raise them in a test function to markthe test to be skipped or mark it as a known failure, respectively.

  • f2py.compile has a newextension keyword parameter that allows thefortran extension to be specified for generated temp files. For instance,the files can be specifies to be*.f90. Theverbose argument isalso activated, it was previously ignored.

  • Adtype parameter has been added tonp.random.randintRandom ndarrays of the following types can now be generated:

    • np.bool,
    • np.int8,np.uint8,
    • np.int16,np.uint16,
    • np.int32,np.uint32,
    • np.int64,np.uint64,
    • np.int_``,``np.intp

    The specification is by precision rather than by C type. Hence, on someplatformsnp.int64 may be along instead oflonglong even ifthe specified dtype islonglong because the two may have the sameprecision. The resulting type depends on which C type numpy uses for thegiven precision. The byteorder specification is also ignored, thegenerated arrays are always in native byte order.

  • A newnp.moveaxis function allows for moving one or more array axesto a new position by explicitly providing source and destination axes.This function should be easier to use than the currentrollaxisfunction as well as providing more functionality.

  • Thedeg parameter of the variousnumpy.polynomial fits has beenextended to accept a list of the degrees of the terms to be included inthe fit, the coefficients of all other terms being constrained to zero.The change is backward compatible, passing a scalardeg will behaveas before.

  • A divmod function for float types modeled after the Python version hasbeen added to the npy_math library.

Improvements

np.gradient now supports anaxis argument

Theaxis parameter was added tonp.gradient for consistency. Itallows to specify over which axes the gradient is calculated.

np.lexsort now supports arrays with object data-type

The function now internally calls the genericnpy_amergesort when thetype does not implement a merge-sort kind ofargsort method.

np.ma.core.MaskedArray now supports anorder argument

When constructing a newMaskedArray instance, it can be configured withanorder argument analogous to the one when callingnp.ndarray. Theaddition of this argument allows for the proper processing of anorderargument in several MaskedArray-related utility functions such asnp.ma.core.array andnp.ma.core.asarray.

Memory and speed improvements for masked arrays

Creating a masked array withmask=True (resp.mask=False) now usesnp.ones (resp.np.zeros) to create the mask, which is faster andavoid a big memory peak. Another optimization was done to avoid a memorypeak and useless computations when printing a masked array.

ndarray.tofile now uses fallocate on linux

The function now uses the fallocate system call to reserve sufficientdisk space on file systems that support it.

Optimizations for operations of the formA.T@A andA@A.T

Previously,gemm BLAS operations were used for all matrix products. Now,if the matrix product is between a matrix and its transpose, it will usesyrk BLAS operations for a performance boost. This optimization has beenextended to@,numpy.dot,numpy.inner, andnumpy.matmul.

Note: Requires the transposed and non-transposed matrices to share data.

np.testing.assert_warns can now be used as a context manager

This matches the behavior ofassert_raises.

Speed improvement for np.random.shuffle

np.random.shuffle is now much faster for 1d ndarrays.

Changes

Pyrex support was removed fromnumpy.distutils

The methodbuild_src.generate_a_pyrex_source will remain available; ithas been monkeypatched by users to support Cython instead of Pyrex. It’srecommended to switch to a better supported method of build Cythonextensions though.

np.broadcast can now be called with a single argument

The resulting object in that case will simply mimic iteration overa single array. This change obsoletes distinctions like

if len(x) == 1:
shape = x[0].shape
else:
shape = np.broadcast(*x).shape

Instead,np.broadcast can be used in all cases.

np.trace now respects array subclasses

This behaviour mimics that of other functions such asnp.diagonal andensures, e.g., that for masked arraysnp.trace(ma) andma.trace() givethe same result.

np.dot now raisesTypeError instead ofValueError

This behaviour mimics that of other functions such asnp.inner. If the twoarguments cannot be cast to a common type, it could have raised aTypeErrororValueError depending on their order. Now,np.dot will now alwaysraise aTypeError.

linalg.norm return type changes

Thelinalg.norm function now does all its computations in floating pointand returns floating results. This change fixes bugs due to integer overflowand the failure of abs with signed integers of minimum value, e.g., int8(-128).For consistency, floats are used even where an integer might work.

Deprecations

Views of arrays in Fortran order

The F_CONTIGUOUS flag was used to signal that views using a dtype thatchanged the element size would change the first index. This was alwaysproblematical for arrays that were both F_CONTIGUOUS and C_CONTIGUOUSbecause C_CONTIGUOUS took precedence. Relaxed stride checking results inmore such dual contiguous arrays and breaks some existing code as a result.Note that this also affects changing the dtype by assigning to the dtypeattribute of an array. The aim of this deprecation is to restrict views toC_CONTIGUOUS arrays at some future time. A work around that is backwardcompatible is to usea.T.view(...).T instead. A parameter may also beadded to the view method to explicitly ask for Fortran order views, butthat will not be backward compatible.

Invalid arguments for array ordering

It is currently possible to pass in arguments for theorderparameter in methods likearray.flatten orarray.ravelthat were not one of the following: ‘C’, ‘F’, ‘A’, ‘K’ (note thatall of these possible values are both unicode and case insensitive).Such behavior will not be allowed in future releases.

Random number generator in thetesting namespace

The Python standard library random number generator was previously exposedin thetesting namespace astesting.rand. Using this generator isnot recommended and it will be removed in a future release. Use generatorsfromnumpy.random namespace instead.

Random integer generation on a closed interval

In accordance with the Python C API, which gives preference to the half-openinterval over the closed one,np.random.random_integers is beingdeprecated in favor of callingnp.random.randint, which has beenenhanced with thedtype parameter as described under “New Features”.However,np.random.random_integers will not be removed anytime soon.

FutureWarnings

Assigning to slices/views ofMaskedArray

Currently a slice of a masked array contains a view of the original data and acopy-on-write view of the mask. Consequently, any changes to the slice’s maskwill result in a copy of the original mask being made and that new mask beingchanged rather than the original. For example, if we make a slice of theoriginal like so,view=original[:], then modifications to the data in onearray will affect the data of the other but, because the mask will be copiedduring assignment operations, changes to the mask will remain local. A similarsituation occurs when explicitly constructing a masked array usingMaskedArray(data,mask), the returned array will contain a view ofdatabut the mask will be a copy-on-write view ofmask.

In the future, these cases will be normalized so that the data and mask arraysare treated the same way and modifications to either will propagate betweenviews. In 1.11, numpy will issue aMaskedArrayFutureWarning warningwhenever user code modifies the mask of a view that in the future may causevalues to propagate back to the original. To silence these warnings and makeyour code robust against the upcoming changes, you have two options: if youwant to keep the current behavior, callmasked_view.unshare_mask() beforemodifying the mask. If you want to get the future behavior early, usemasked_view._sharedmask=False. However, note that setting the_sharedmask attribute will break following explicit calls tomasked_view.unshare_mask().

NumPy 1.10.4 Release Notes

This release is a bugfix source release motivated by a segfault regression.No windows binaries are provided for this release, as there appear to bebugs in the toolchain we use to generate those files. Hopefully thatproblem will be fixed for the next release. In the meantime, we suggestusing one of the providers of windows binaries.

Compatibility notes

  • The trace function now calls the trace method on subclasses of ndarray,except for matrix, for which the current behavior is preserved. This isto help with the units package of AstroPy and hopefully will not causeproblems.

Issues Fixed

  • gh-6922 BUG: numpy.recarray.sort segfaults on Windows.
  • gh-6937 BUG: busday_offset does the wrong thing with modifiedpreceding roll.
  • gh-6949 BUG: Type is lost when slicing a subclass of recarray.

Merged PRs

The following PRs have been merged into 1.10.4. When the PR is a backport,the PR number for the original PR against master is listed.

  • gh-6840 TST: Update travis testing script in 1.10.x
  • gh-6843 BUG: Fix use of python 3 only FileNotFoundError in test_f2py.
  • gh-6884 REL: Update pavement.py and setup.py to reflect current version.
  • gh-6916 BUG: Fix test_f2py so it runs correctly in runtests.py.
  • gh-6924 BUG: Fix segfault gh-6922.
  • gh-6942 Fix datetime roll=’modifiedpreceding’ bug.
  • gh-6943 DOC,BUG: Fix some latex generation problems.
  • gh-6950 BUG trace is not subclass aware, np.trace(ma) != ma.trace().
  • gh-6952 BUG recarray slices should preserve subclass.

NumPy 1.10.3 Release Notes

N/A this release did not happen due to various screwups involving PyPi.

NumPy 1.10.2 Release Notes

This release deals with a number of bugs that turned up in 1.10.1 andadds various build and release improvements.

Numpy 1.10.1 supports Python 2.6 - 2.7 and 3.2 - 3.5.

Compatibility notes

Relaxed stride checking is no longer the default

There were back compatibility problems involving views changing the dtype ofmultidimensional Fortran arrays that need to be dealt with over a longertimeframe.

Fix swig bug innumpy.i

Relaxed stride checking revealed a bug inarray_is_fortran(a), that wasusing PyArray_ISFORTRAN to check for Fortran contiguity instead ofPyArray_IS_F_CONTIGUOUS. You may want to regenerate swigged files using theupdated numpy.i

Deprecate views changing dimensions in fortran order

This deprecates assignment of a new descriptor to the dtype attribute ofa non-C-contiguous array if it result in changing the shape. Thiseffectively bars viewing a multidimensional Fortran array using a dtypethat changes the element size along the first axis.

The reason for the deprecation is that, when relaxed strides checking isenabled, arrays that are both C and Fortran contiguous are always treatedas C contiguous which breaks some code that depended the two being mutuallyexclusive for non-scalar arrays of ndim > 1. This deprecation prepares theway to always enable relaxed stride checking.

Issues Fixed

  • gh-6019 Masked array repr fails for structured array with multi-dimensional column.
  • gh-6462 Median of empty array produces IndexError.
  • gh-6467 Performance regression for record array access.
  • gh-6468 numpy.interp uses ‘left’ value even when x[0]==xp[0].
  • gh-6475 np.allclose returns a memmap when one of its arguments is a memmap.
  • gh-6491 Error in broadcasting stride_tricks array.
  • gh-6495 Unrecognized command line option ‘-ffpe-summary’ in gfortran.
  • gh-6497 Failure of reduce operation on recarrays.
  • gh-6498 Mention change in default casting rule in 1.10 release notes.
  • gh-6530 The partition function errors out on empty input.
  • gh-6532 numpy.inner return wrong inaccurate value sometimes.
  • gh-6563 Intent(out) broken in recent versions of f2py.
  • gh-6569 Cannot run tests after ‘python setup.py build_ext -i’
  • gh-6572 Error in broadcasting stride_tricks array component.
  • gh-6575 BUG: Split produces empty arrays with wrong number of dimensions
  • gh-6590 Fortran Array problem in numpy 1.10.
  • gh-6602 Random __all__ missing choice and dirichlet.
  • gh-6611 ma.dot no longer always returns a masked array in 1.10.
  • gh-6618 NPY_FORTRANORDER in make_fortran() in numpy.i
  • gh-6636 Memory leak in nested dtypes in numpy.recarray
  • gh-6641 Subsetting recarray by fields yields a structured array.
  • gh-6667 ma.make_mask handles ma.nomask input incorrectly.
  • gh-6675 Optimized blas detection broken in master and 1.10.
  • gh-6678 Getting unexpected error from: X.dtype = complex (or Y = X.view(complex))
  • gh-6718 f2py test fail in pip installed numpy-1.10.1 in virtualenv.
  • gh-6719 Error compiling Cython file: Pythonic division not allowed without gil.
  • gh-6771 Numpy.rec.fromarrays losing dtype metadata between versions 1.9.2 and 1.10.1
  • gh-6781 The travis-ci script in maintenance/1.10.x needs fixing.
  • gh-6807 Windows testing errors for 1.10.2

Merged PRs

The following PRs have been merged into 1.10.2. When the PR is a backport,the PR number for the original PR against master is listed.

  • gh-5773 MAINT: Hide testing helper tracebacks when using them with pytest.
  • gh-6094 BUG: Fixed a bug with string representation of masked structured arrays.
  • gh-6208 MAINT: Speedup field access by removing unneeded safety checks.
  • gh-6460 BUG: Replacing the os.environ.clear by less invasive procedure.
  • gh-6470 BUG: Fix AttributeError in numpy distutils.
  • gh-6472 MAINT: Use Python 3.5 instead of 3.5-dev for travis 3.5 testing.
  • gh-6474 REL: Update Paver script for sdist and auto-switch test warnings.
  • gh-6478 BUG: Fix Intel compiler flags for OS X build.
  • gh-6481 MAINT: LIBPATH with spaces is now supported Python 2.7+ and Win32.
  • gh-6487 BUG: Allow nested use of parameters in definition of arrays in f2py.
  • gh-6488 BUG: Extend common blocks rather than overwriting in f2py.
  • gh-6499 DOC: Mention that default casting for inplace operations has changed.
  • gh-6500 BUG: Recarrays viewed as subarrays don’t convert to np.record type.
  • gh-6501 REL: Add “make upload” command for built docs, update “make dist”.
  • gh-6526 BUG: Fix use of __doc__ in setup.py for -OO mode.
  • gh-6527 BUG: Fix the IndexError when taking the median of an empty array.
  • gh-6537 BUG: Make ma.atleast_* with scalar argument return arrays.
  • gh-6538 BUG: Fix ma.masked_values does not shrink mask if requested.
  • gh-6546 BUG: Fix inner product regression for non-contiguous arrays.
  • gh-6553 BUG: Fix partition and argpartition error for empty input.
  • gh-6556 BUG: Error in broadcast_arrays with as_strided array.
  • gh-6558 MAINT: Minor update to “make upload” doc build command.
  • gh-6562 BUG: Disable view safety checks in recarray.
  • gh-6567 BUG: Revert some import * fixes in f2py.
  • gh-6574 DOC: Release notes for Numpy 1.10.2.
  • gh-6577 BUG: Fix for #6569, allowing build_ext –inplace
  • gh-6579 MAINT: Fix mistake in doc upload rule.
  • gh-6596 BUG: Fix swig for relaxed stride checking.
  • gh-6606 DOC: Update 1.10.2 release notes.
  • gh-6614 BUG: Add choice and dirichlet to numpy.random.__all__.
  • gh-6621 BUG: Fix swig make_fortran function.
  • gh-6628 BUG: Make allclose return python bool.
  • gh-6642 BUG: Fix memleak in _convert_from_dict.
  • gh-6643 ENH: make recarray.getitem return a recarray.
  • gh-6653 BUG: Fix ma dot to always return masked array.
  • gh-6668 BUG: ma.make_mask should always return nomask for nomask argument.
  • gh-6686 BUG: Fix a bug in assert_string_equal.
  • gh-6695 BUG: Fix removing tempdirs created during build.
  • gh-6697 MAINT: Fix spurious semicolon in macro definition of PyArray_FROM_OT.
  • gh-6698 TST: test np.rint bug for large integers.
  • gh-6717 BUG: Readd fallback CBLAS detection on linux.
  • gh-6721 BUG: Fix for #6719.
  • gh-6726 BUG: Fix bugs exposed by relaxed stride rollback.
  • gh-6757 BUG: link cblas library if cblas is detected.
  • gh-6756 TST: only test f2py, not f2py2.7 etc, fixes #6718.
  • gh-6747 DEP: Deprecate changing shape of non-C-contiguous array via descr.
  • gh-6775 MAINT: Include from __future__ boilerplate in some files missing it.
  • gh-6780 BUG: metadata is not copied to base_dtype.
  • gh-6783 BUG: Fix travis ci testing for new google infrastructure.
  • gh-6785 BUG: Quick and dirty fix for interp.
  • gh-6813 TST,BUG: Make test_mvoid_multidim_print work for 32 bit systems.
  • gh-6817 BUG: Disable 32-bit msvc9 compiler optimizations for npy_rint.
  • gh-6819 TST: Fix test_mvoid_multidim_print failures on Python 2.x for Windows.

Initial support for mingwpy was reverted as it was causing problems fornon-windows builds.

  • gh-6536 BUG: Revert gh-5614 to fix non-windows build problems

A fix for np.lib.split was reverted because it resulted in “fixing”behavior that will be present in the Numpy 1.11 and that was alreadypresent in Numpy 1.9. See the discussion of the issue at gh-6575 forclarification.

  • gh-6576 BUG: Revert gh-6376 to fix split behavior for empty arrays.

Relaxed stride checking was reverted. There were back compatibilityproblems involving views changing the dtype of multidimensional Fortranarrays that need to be dealt with over a longer timeframe.

  • gh-6735 MAINT: Make no relaxed stride checking the default for 1.10.

Notes

A bug in the Numpy 1.10.1 release resulted in exceptions being raised forRuntimeWarning andDeprecationWarning in projects depending on Numpy.That has been fixed.

NumPy 1.10.1 Release Notes

This release deals with a few build problems that showed up in 1.10.0. Mostusers would not have seen these problems. The differences are:

  • Compiling with msvc9 or msvc10 for 32 bit Windows now requires SSE2.This was the easiest fix for what looked to be some miscompiled code whenSSE2 was not used. If you need to compile for 32 bit Windows systemswithout SSE2 support, mingw32 should still work.
  • Make compiling with VS2008 python2.7 SDK easier
  • Change Intel compiler options so that code will also be generated tosupport systems without SSE4.2.
  • Some _config test functions needed an explicit integer return inorder to avoid the openSUSE rpmlinter erring out.
  • We ran into a problem with pipy not allowing reuse of filenames and aresulting proliferation of..*.postN releases. Not only were the namesgetting out of hand, some packages were unable to work with the postNsuffix.

Numpy 1.10.1 supports Python 2.6 - 2.7 and 3.2 - 3.5.

Commits:

45a3d84 DEP: Remove warning forfull when dtype is set.0c1a5df BLD: import setuptools to allow compile with VS2008 python2.7 sdk04211c6 BUG: mask nan to 1 in ordered compare826716f DOC: Document the reason msvc requires SSE2 on 32 bit platforms.49fa187 BLD: enable SSE2 for 32-bit msvc 9 and 10 compilersdcbc4cc MAINT: remove Wreturn-type warnings from config checksd6564cb BLD: do not build exclusively for SSE4.2 processors15cb66f BLD: do not build exclusively for SSE4.2 processorsc38bc08 DOC: fix var. reference in percentile docstring78497f4 DOC: Sync 1.10.0-notes.rst in 1.10.x branch with master.

NumPy 1.10.0 Release Notes

This release supports Python 2.6 - 2.7 and 3.2 - 3.5.

Highlights

  • numpy.distutils now supports parallel compilation via the –parallel/-jargument passed to setup.py build
  • numpy.distutils now supports additional customization via site.cfg tocontrol compilation parameters, i.e. runtime libraries, extralinking/compilation flags.
  • Addition ofnp.linalg.multi_dot: compute the dot product of two or morearrays in a single function call, while automatically selecting the fastestevaluation order.
  • The new functionnp.stack provides a general interface for joining asequence of arrays along a new axis, complementingnp.concatenate forjoining along an existing axis.
  • Addition ofnanprod to the set of nanfunctions.
  • Support for the ‘@’ operator in Python 3.5.

Dropped Support

  • The _dotblas module has been removed. CBLAS Support is now inMultiarray.
  • The testcalcs.py file has been removed.
  • The polytemplate.py file has been removed.
  • npy_PyFile_Dup and npy_PyFile_DupClose have been removed fromnpy_3kcompat.h.
  • splitcmdline has been removed from numpy/distutils/exec_command.py.
  • try_run and get_output have been removed fromnumpy/distutils/command/config.py
  • The a._format attribute is no longer supported for array printing.
  • Keywordsskiprows andmissing removed from np.genfromtxt.
  • Keywordold_behavior removed from np.correlate.

Future Changes

  • In array comparisons likearr1==arr2, many corner casesinvolving strings or structured dtypes that used to return scalarsnow issueFutureWarning orDeprecationWarning, and in thefuture will be change to either perform elementwise comparisons orraise an error.
  • Innp.lib.split an empty array in the result always had dimension(0,) no matter the dimensions of the array being split. In Numpy 1.11that behavior will be changed so that the dimensions will be preserved. AFutureWarning for this change has been in place since Numpy 1.9 but,due to a bug, sometimes no warning was raised and the dimensions werealready preserved.
  • The SafeEval class will be removed in Numpy 1.11.
  • The alterdot and restoredot functions will be removed in Numpy 1.11.

See below for more details on these changes.

Compatibility notes

Default casting rule change

Default casting for inplace operations has changed to'same_kind'. Forinstance, if n is an array of integers, and f is an array of floats, thenn+=f will result in aTypeError, whereas in previous Numpyversions the floats would be silently cast to ints. In the unlikely casethat the example code is not an actual bug, it can be updated in a backwardcompatible way by rewriting it asnp.add(n,f,out=n,casting='unsafe').The old'unsafe' default has been deprecated since Numpy 1.7.

numpy version string

The numpy version string for development builds has been changed fromx.y.z.dev-githash tox.y.z.dev0+githash (note the +) in order to complywith PEP 440.

relaxed stride checking

NPY_RELAXED_STRIDE_CHECKING is now true by default.

UPDATE: In 1.10.2 the default value of NPY_RELAXED_STRIDE_CHECKING waschanged to false for back compatibility reasons. More time is needed beforeit can be made the default. As part of the roadmap a deprecation ofdimension changing views of f_contiguous not c_contiguous arrays was alsoadded.

Concatenation of 1d arrays along any butaxis=0 raisesIndexError

Using axis != 0 has raised a DeprecationWarning since NumPy 1.7, it nowraises an error.

np.ravel,np.diagonal andnp.diag now preserve subtypes

There was inconsistent behavior betweenx.ravel() andnp.ravel(x), aswell as betweenx.diagonal() andnp.diagonal(x), with the methodspreserving subtypes while the functions did not. This has been fixed andthe functions now behave like the methods, preserving subtypes except inthe case of matrices. Matrices are special cased for backwardcompatibility and still return 1-D arrays as before. If you need topreserve the matrix subtype, use the methods instead of the functions.

rollaxis andswapaxes always return a view

Previously, a view was returned except when no change was made in the orderof the axes, in which case the input array was returned. A view is nowreturned in all cases.

nonzero now returns base ndarrays

Previously, an inconsistency existed between 1-D inputs (returning abase ndarray) and higher dimensional ones (which preserved subclasses).Behavior has been unified, and the return will now be a base ndarray.Subclasses can still override this behavior by providing their ownnonzero method.

C API

The changes toswapaxes also apply to thePyArray_SwapAxes C function,which now returns a view in all cases.

The changes tononzero also apply to thePyArray_Nonzero C function,which now returns a base ndarray in all cases.

The dtype structure (PyArray_Descr) has a new member at the end to cacheits hash value. This shouldn’t affect any well-written applications.

The change to the concatenation function DeprecationWarning also affectsPyArray_ConcatenateArrays,

recarray field return types

Previously the returned types for recarray fields accessed by attribute and byindex were inconsistent, and fields of string type were returned as chararrays.Now, fields accessed by either attribute or indexing will return an ndarray forfields of non-structured type, and a recarray for fields of structured type.Notably, this affect recarrays containing strings with whitespace, as trailingwhitespace is trimmed from chararrays but kept in ndarrays of string type.Also, the dtype.type of nested structured fields is now inherited.

recarray views

Viewing an ndarray as a recarray now automatically converts the dtype tonp.record. See new record array documentation. Additionally, viewing a recarraywith a non-structured dtype no longer converts the result’s type to ndarray -the result will remain a recarray.

‘out’ keyword argument of ufuncs now accepts tuples of arrays

When using the ‘out’ keyword argument of a ufunc, a tuple of arrays, one perufunc output, can be provided. For ufuncs with a single output a single arrayis also a valid ‘out’ keyword argument. Previously a single array could beprovided in the ‘out’ keyword argument, and it would be used as the firstoutput for ufuncs with multiple outputs, is deprecated, and will result in aDeprecationWarning now and an error in the future.

byte-array indices now raises an IndexError

Indexing an ndarray using a byte-string in Python 3 now raises an IndexErrorinstead of a ValueError.

Masked arrays containing objects with arrays

For such (rare) masked arrays, getting a single masked item no longer returns acorrupted masked array, but a fully masked version of the item.

Median warns and returns nan when invalid values are encountered

Similar to mean, median and percentile now emits a Runtime warning andreturnsNaN in slices where aNaN is present.To compute the median or percentile while ignoring invalid values use thenewnanmedian ornanpercentile functions.

Functions available from numpy.ma.testutils have changed

All functions from numpy.testing were once available fromnumpy.ma.testutils but not all of them were redefined to work with maskedarrays. Most of those functions have now been removed fromnumpy.ma.testutils with a small subset retained in order to preservebackward compatibility. In the long run this should help avoid mistaken useof the wrong functions, but it may cause import problems for some.

New Features

Reading extra flags from site.cfg

Previously customization of compilation of dependency libraries and numpyitself was only accomblishable via code changes in the distutils package.Now numpy.distutils reads in the following extra flags from each group of thesite.cfg:

  • runtime_library_dirs/rpath, sets runtime library directories to override
    LD_LIBRARY_PATH
  • extra_compile_args, add extra flags to the compilation of sources
  • extra_link_args, add extra flags when linking libraries

This should, at least partially, complete user customization.

np.cbrt to compute cube root for real floats

np.cbrt wraps the C99 cube root functioncbrt.Compared tonp.power(x, 1./3.) it is well defined for negative real floatsand a bit faster.

numpy.distutils now allows parallel compilation

By passing–parallel=n or-j n tosetup.py build the compilation ofextensions is now performed inn parallel processes.The parallelization is limited to files within one extension so projects usingCython will not profit because it builds extensions from single files.

genfromtxt has a newmax_rows argument

Amax_rows argument has been added togenfromtxt to limit thenumber of rows read in a single call. Using this functionality, it ispossible to read in multiple arrays stored in a single file by makingrepeated calls to the function.

New functionnp.broadcast_to for invoking array broadcasting

np.broadcast_to manually broadcasts an array to a given shape according tonumpy’s broadcasting rules. The functionality is similar to broadcast_arrays,which in fact has been rewritten to use broadcast_to internally, but only asingle array is necessary.

New context managerclear_and_catch_warnings for testing warnings

When Python emits a warning, it records that this warning has been emitted inthe module that caused the warning, in a module attribute__warningregistry__. Once this has happened, it is not possible to emitthe warning again, unless you clear the relevant entry in__warningregistry__. This makes is hard and fragile to test warnings,because if your test comes after another that has already caused the warning,you will not be able to emit the warning or test it. The context managerclear_and_catch_warnings clears warnings from the module registry on entryand resets them on exit, meaning that warnings can be re-raised.

cov has newfweights andaweights arguments

Thefweights andaweights arguments add new functionality tocovariance calculations by applying two types of weighting to observationvectors. An array offweights indicates the number of repeats of eachobservation vector, and an array ofaweights provides their relativeimportance or probability.

Support for the ‘@’ operator in Python 3.5+

Python 3.5 adds support for a matrix multiplication operator ‘@’ proposedin PEP465. Preliminary support for that has been implemented, and anequivalent functionmatmul has also been added for testing purposes anduse in earlier Python versions. The function is preliminary and the orderand number of its optional arguments can be expected to change.

New argumentnorm to fft functions

The default normalization has the direct transforms unscaled and the inversetransforms are scaled by1/n. It is possible to obtain unitarytransforms by setting the keyword argumentnorm to"ortho" (default isNone) so that both direct and inverse transforms will be scaled by1/\\sqrt{n}.

Improvements

np.digitize using binary search

np.digitize is now implemented in terms ofnp.searchsorted. This meansthat a binary search is used to bin the values, which scales much betterfor larger number of bins than the previous linear search. It also removesthe requirement for the input array to be 1-dimensional.

np.poly now casts integer inputs to float

np.poly will now cast 1-dimensional input arrays of integer type to doubleprecision floating point, to prevent integer overflow when computing the monicpolynomial. It is still possible to obtain higher precision results bypassing in an array of object type, filled e.g. with Python ints.

np.interp can now be used with periodic functions

np.interp now has a new parameterperiod that supplies the period of theinput dataxp. In such case, the input data is properly normalized to thegiven period and one end point is added to each extremity ofxp in order toclose the previous and the next period cycles, resulting in the correctinterpolation behavior.

np.pad supports more input types forpad_width andconstant_values

constant_values parameters now accepts NumPy arrays and float values.NumPy arrays are supported as input forpad_width, and an exception israised if its values are not of integral type.

np.argmax andnp.argmin now support anout argument

Theout parameter was added tonp.argmax andnp.argmin for consistencywithndarray.argmax andndarray.argmin. The new parameter behaves exactlyas it does in those methods.

More system C99 complex functions detected and used

All of the functionsincomplex.h are now detected. There are newfallback implementations of the following functions.

  • npy_ctan,
  • npy_cacos, npy_casin, npy_catan
  • npy_ccosh, npy_csinh, npy_ctanh,
  • npy_cacosh, npy_casinh, npy_catanh

As a result of these improvements, there will be some small changes inreturned values, especially for corner cases.

np.loadtxt support for the strings produced by thefloat.hex method

The strings produced byfloat.hex look like0x1.921fb54442d18p+1,so this is not the hex used to represent unsigned integer types.

np.isclose properly handles minimal values of integer dtypes

In order to properly handle minimal values of integer types,np.isclose willnow cast to the float dtype during comparisons. This aligns its behavior withwhat was provided bynp.allclose.

np.allclose usesnp.isclose internally.

np.allclose now usesnp.isclose internally and inherits the ability tocompare NaNs as equal by settingequal_nan=True. Subclasses, such asnp.ma.MaskedArray, are also preserved now.

np.genfromtxt now handles large integers correctly

np.genfromtxt now correctly handles integers larger than2**31-1 on32-bit systems and larger than2**63-1 on 64-bit systems (it previouslycrashed with anOverflowError in these cases). Integers larger than2**63-1 are converted to floating-point values.

np.load,np.save have pickle backward compatibility flags

The functionsnp.load andnp.save have additional keywordarguments for controlling backward compatibility of pickled Pythonobjects. This enables Numpy on Python 3 to load npy files containingobject arrays that were generated on Python 2.

MaskedArray support for more complicated base classes

Built-in assumptions that the baseclass behaved like a plain array are beingremoved. In particular, setting and getting elements and ranges will respectbaseclass overrides of__setitem__ and__getitem__, and arithmeticwill respect overrides of__add__,__sub__, etc.

Changes

dotblas functionality moved to multiarray

The cblas versions of dot, inner, and vdot have been integrated intothe multiarray module. In particular, vdot is now a multiarray function,which it was not before.

stricter check of gufunc signature compliance

Inputs to generalized universal functions are now more strictly checkedagainst the function’s signature: all core dimensions are now required tobe present in input arrays; core dimensions with the same label must havethe exact same size; and output core dimension’s must be specified, eitherby a same label input core dimension or by a passed-in output array.

views returned fromnp.einsum are writeable

Views returned bynp.einsum will now be writeable whenever the inputarray is writeable.

np.argmin skips NaT values

np.argmin now skips NaT values in datetime64 and timedelta64 arrays,making it consistent withnp.min,np.argmax andnp.max.

Deprecations

Array comparisons involving strings or structured dtypes

Normally, comparison operations on arrays perform elementwisecomparisons and return arrays of booleans. But in some corner cases,especially involving strings are structured dtypes, NumPy hashistorically returned a scalar instead. For example:

### Current behaviournp.arange(2)=="foo"# -> Falsenp.arange(2)<"foo"# -> True on Python 2, error on Python 3np.ones(2,dtype="i4,i4")==np.ones(2,dtype="i4,i4,i4")# -> False

Continuing work started in 1.9, in 1.10 these comparisons will nowraiseFutureWarning orDeprecationWarning, and in the futurethey will be modified to behave more consistently with othercomparison operations, e.g.:

### Future behaviournp.arange(2)=="foo"# -> array([False, False])np.arange(2)<"foo"# -> error, strings and numbers are not orderablenp.ones(2,dtype="i4,i4")==np.ones(2,dtype="i4,i4,i4")# -> [False, False]

SafeEval

The SafeEval class in numpy/lib/utils.py is deprecated and will be removedin the next release.

alterdot, restoredot

The alterdot and restoredot functions no longer do anything, and aredeprecated.

pkgload, PackageLoader

These ways of loading packages are now deprecated.

bias, ddof arguments to corrcoef

The values for thebias andddof arguments to thecorrcoeffunction canceled in the division implied by the correlation coefficient andso had no effect on the returned values.

We now deprecate these arguments tocorrcoef and the masked array versionma.corrcoef.

Because we are deprecating thebias argument toma.corrcoef, we alsodeprecate the use of theallow_masked argument as a positional argument,as its position will change with the removal ofbias.allow_maskedwill in due course become a keyword-only argument.

dtype string representation changes

Since 1.6, creating a dtype object from its string representation, e.g.'f4', would issue a deprecation warning if the size did not correspondto an existing type, and default to creating a dtype of the default sizefor the type. Starting with this release, this will now raise aTypeError.

The only exception is object dtypes, where both'O4' and'O8' willstill issue a deprecation warning. This platform-dependent representationwill raise an error in the next release.

In preparation for this upcoming change, the string representation of anobject dtype, i.e.np.dtype(object).str, no longer includes the itemsize, i.e. will return'|O' instead of'|O4' or'|O8' asbefore.

NumPy 1.9.2 Release Notes

This is a bugfix only release in the 1.9.x series.

Issues fixed

  • #5316: fix too large dtype alignment of strings and complex types
  • #5424: fix ma.median when used on ndarrays
  • #5481: Fix astype for structured array fields of different byte order
  • #5354: fix segfault when clipping complex arrays
  • #5524: allow np.argpartition on non ndarrays
  • #5612: Fixes ndarray.fill to accept full range of uint64
  • #5155: Fix loadtxt with comments=None and a string None data
  • #4476: Masked array view fails if structured dtype has datetime component
  • #5388: Make RandomState.set_state and RandomState.get_state threadsafe
  • #5390: make seed, randint and shuffle threadsafe
  • #5374: Fixed incorrect assert_array_almost_equal_nulp documentation
  • #5393: Add support for ATLAS > 3.9.33.
  • #5313: PyArray_AsCArray caused segfault for 3d arrays
  • #5492: handle out of memory in rfftf
  • #4181: fix a few bugs in the random.pareto docstring
  • #5359: minor changes to linspace docstring
  • #4723: fix a compile issues on AIX

NumPy 1.9.1 Release Notes

This is a bugfix only release in the 1.9.x series.

Issues fixed

  • gh-5184: restore linear edge behaviour of gradient to as it was in < 1.9.The second order behaviour is available via theedge_order keyword
  • gh-4007: workaround Accelerate sgemv crash on OSX 10.9
  • gh-5100: restore object dtype inference from iterable objects withoutlen()
  • gh-5163: avoid gcc-4.1.2 (red hat 5) miscompilation causing a crash
  • gh-5138: fix nanmedian on arrays containing inf
  • gh-5240: fix not returning out array from ufuncs with subok=False set
  • gh-5203: copy inherited masks in MaskedArray.__array_finalize__
  • gh-2317: genfromtxt did not handle filling_values=0 correctly
  • gh-5067: restore api of npy_PyFile_DupClose in python2
  • gh-5063: cannot convert invalid sequence index to tuple
  • gh-5082: Segmentation fault with argmin() on unicode arrays
  • gh-5095: don’t propagate subtypes from np.where
  • gh-5104: np.inner segfaults with SciPy’s sparse matrices
  • gh-5251: Issue with fromarrays not using correct format for unicode arrays
  • gh-5136: Import dummy_threading if importing threading fails
  • gh-5148: Make numpy import when run with Python flag ‘-OO’
  • gh-5147: Einsum double contraction in particular order causes ValueError
  • gh-479: Make f2py work with intent(in out)
  • gh-5170: Make python2 .npy files readable in python3
  • gh-5027: Use ‘ll’ as the default length specifier for long long
  • gh-4896: fix build error with MSVC 2013 caused by C99 complex support
  • gh-4465: Make PyArray_PutTo respect writeable flag
  • gh-5225: fix crash when using arange on datetime without dtype set
  • gh-5231: fix build in c99 mode

NumPy 1.9.0 Release Notes

This release supports Python 2.6 - 2.7 and 3.2 - 3.4.

Highlights

  • Numerous performance improvements in various areas, most notably indexing andoperations on small arrays are significantly faster.Indexing operations now also release the GIL.
  • Addition ofnanmedian andnanpercentile rounds out the nanfunction set.

Dropped Support

  • The oldnumeric and numarray modules have been removed.
  • The doc/pyrex and doc/cython directories have been removed.
  • The doc/numpybook directory has been removed.
  • The numpy/testing/numpytest.py file has been removed together withthe importall function it contained.

Future Changes

  • The numpy/polynomial/polytemplate.py file will be removed in NumPy 1.10.0.
  • Default casting for inplace operations will change to ‘same_kind’ inNumpy 1.10.0. This will certainly break some code that is currentlyignoring the warning.
  • Relaxed stride checking will be the default in 1.10.0
  • String version checks will break because, e.g., ‘1.9’ > ‘1.10’ is True. ANumpyVersion class has been added that can be used for such comparisons.
  • The diagonal and diag functions will return writeable views in 1.10.0
  • TheS and/ora dtypes may be changed to represent Python stringsinstead of bytes, in Python 3 these two types are very different.

Compatibility notes

The diagonal and diag functions return readonly views.

In NumPy 1.8, the diagonal and diag functions returned readonly copies, inNumPy 1.9 they return readonly views, and in 1.10 they will return writeableviews.

Special scalar float values don’t cause upcast to double anymore

In previous numpy versions operations involving floating point scalarscontaining special valuesNaN,Inf and-Inf caused the resulttype to be at leastfloat64. As the special values can be representedin the smallest available floating point type, the upcast is not performedanymore.

For example the dtype of:

np.array([1.],dtype=np.float32)*float('nan')

now remainsfloat32 instead of being cast tofloat64.Operations involving non-special values have not been changed.

Percentile output changes

If given more than one percentile to compute numpy.percentile returns anarray instead of a list. A single percentile still returns a scalar. Thearray is equivalent to converting the list returned in older versionsto an array vianp.array.

If theoverwrite_input option is used the input is only partiallyinstead of fully sorted.

ndarray.tofile exception type

Alltofile exceptions are nowIOError, some were previouslyValueError.

Invalid fill value exceptions

Two changes to numpy.ma.core._check_fill_value:

  • When the fill value is a string and the array type is not one of‘OSUV’, TypeError is raised instead of the default fill value being used.
  • When the fill value overflows the array type, TypeError is raised insteadof OverflowError.

Polynomial Classes no longer derived from PolyBase

This may cause problems with folks who depended on the polynomial classesbeing derived from PolyBase. They are now all derived from the abstractbase class ABCPolyBase. Strictly speaking, there should be a deprecationinvolved, but no external code making use of the old baseclass could befound.

Using numpy.random.binomial may change the RNG state vs. numpy < 1.9

A bug in one of the algorithms to generate a binomial random variate hasbeen fixed. This change will likely alter the number of random drawsperformed, and hence the sequence location will be different after acall to distribution.c::rk_binomial_btpe. Any tests which rely on the RNGbeing in a known state should be checked and/or updated as a result.

Random seed enforced to be a 32 bit unsigned integer

np.random.seed andnp.random.RandomState now throw aValueErrorif the seed cannot safely be converted to 32 bit unsigned integers.Applications that now fail can be fixed by masking the higher 32 bit values tozero:seed=seed&0xFFFFFFFF. This is what is done silently in olderversions so the random stream remains the same.

Argmin and argmax out argument

Theout argument tonp.argmin andnp.argmax and theirequivalent C-API functions is now checked to match the desired output shapeexactly. If the check fails aValueError instead ofTypeError israised.

Einsum

Remove unnecessary broadcasting notation restrictions.np.einsum('ijk,j->ijk',A,B) can also be written asnp.einsum('ij...,j->ij...',A,B) (ellipsis is no longer required on ‘j’)

Indexing

The NumPy indexing has seen a complete rewrite in this version. This makesmost advanced integer indexing operations much faster and should have noother implications. However some subtle changes and deprecations wereintroduced in advanced indexing operations:

  • Boolean indexing into scalar arrays will always return a new 1-d array.This means thatarray(1)[array(True)] givesarray([1]) andnot the original array.
  • Advanced indexing into one dimensional arrays used to have(undocumented) special handling regarding repeating the value array inassignments when the shape of the value array was too small or did notmatch. Code using this will raise an error. For compatibility you canusearr.flat[index]=values, which uses the old code branch. (forexamplea=np.ones(10);a[np.arange(10)]=[1,2,3])
  • The iteration order over advanced indexes used to be always C-order.In NumPy 1.9. the iteration order adapts to the inputs and is notguaranteed (with the exception of asingle advanced index which isnever reversed for compatibility reasons). This means that the resultis undefined if multiple values are assigned to the same element. Anexample for this isarr[[0,0],[1,1]]=[1,2], which may setarr[0,1] to either 1 or 2.
  • Equivalent to the iteration order, the memory layout of the advancedindexing result is adapted for faster indexing and cannot be predicted.
  • All indexing operations return a view or a copy. No indexing operationwill return the original array object. (For examplearr[...])
  • In the future Boolean array-likes (such as lists of python bools) willalways be treated as Boolean indexes and Boolean scalars (includingpythonTrue) will be a legalboolean index. At this time, this isalready the case for scalar arrays to allow the generalpositive=a[a>0] to work whena is zero dimensional.
  • In NumPy 1.8 it was possible to usearray(True) andarray(False) equivalent to 1 and 0 if the result of the operationwas a scalar. This will raise an error in NumPy 1.9 and, as notedabove, treated as a boolean index in the future.
  • All non-integer array-likes are deprecated, object arrays of custominteger like objects may have to be cast explicitly.
  • The error reporting for advanced indexing is more informative, howeverthe error type has changed in some cases. (Broadcasting errors ofindexing arrays are reported asIndexError)
  • Indexing with more then one ellipsis (...) is deprecated.

Non-integer reduction axis indexes are deprecated

Non-integer axis indexes to reduction ufuncs likeadd.reduce orsum aredeprecated.

promote_types and string dtype

promote_types function now returns a valid string length when given aninteger or float dtype as one argument and a string dtype as anotherargument. Previously it always returned the input string dtype, even if itwasn’t long enough to store the max integer/float value converted to astring.

can_cast and string dtype

can_cast function now returns False in “safe” casting mode forinteger/float dtype and string dtype if the string dtype length is not longenough to store the max integer/float value converted to a string.Previouslycan_cast in “safe” mode returned True for integer/floatdtype and a string dtype of any length.

astype and string dtype

Theastype method now returns an error if the string dtype to cast tois not long enough in “safe” casting mode to hold the max value ofinteger/float array that is being casted. Previously the casting wasallowed even if the result was truncated.

npyio.recfromcsv keyword arguments change

npyio.recfromcsv no longer accepts the undocumentedupdate keyword,which used to override thedtype keyword.

Thedoc/swig directory moved

Thedoc/swig directory has been moved totools/swig.

Thenpy_3kcompat.h header changed

The unusedsimple_capsule_dtor function has been removed fromnpy_3kcompat.h. Note that this header is not meant to be used outsideof numpy; other projects should be using their own copy of this file whenneeded.

Negative indices in C-Apisq_item andsq_ass_item sequence methods

When directly accessing thesq_item orsq_ass_item PyObject slotsfor item getting, negative indices will not be supported anymore.PySequence_GetItem andPySequence_SetItem however fix negativeindices so that they can be used there.

NDIter

WhenNpyIter_RemoveAxis is now called, the iterator range will be reset.

When a multi index is being tracked and an iterator is not buffered, it ispossible to useNpyIter_RemoveAxis. In this case an iterator can shrinkin size. Because the total size of an iterator is limited, the iteratormay be too large before these calls. In this case its size will be set to-1and an error issued not at construction time but when removing the multiindex, setting the iterator range, or getting the next function.

This has no effect on currently working code, but highlights the necessityof checking for an error return if these conditions can occur. In mostcases the arrays being iterated are as large as the iterator so that sucha problem cannot occur.

This change was already applied to the 1.8.1 release.

zeros_like for string dtypes now returns empty strings

To match thezeros functionzeros_like now returns an array initializedwith empty strings instead of an array filled with‘0’.

New Features

Percentile supports more interpolation options

np.percentile now has the interpolation keyword argument to specify inwhich way points should be interpolated if the percentiles fall between twovalues. See the documentation for the available options.

Generalized axis support for median and percentile

np.median andnp.percentile now support generalized axis arguments likeufunc reductions do since 1.7. One can now say axis=(index, index) to pick alist of axes for the reduction. Thekeepdims keyword argument was alsoadded to allow convenient broadcasting to arrays of the original shape.

Dtype parameter added tonp.linspace andnp.logspace

The returned data type from thelinspace andlogspace functions cannow be specified using the dtype parameter.

More generalnp.triu andnp.tril broadcasting

For arrays withndim exceeding 2, these functions will now apply to thefinal two axes instead of raising an exception.

tobytes alias fortostring method

ndarray.tobytes andMaskedArray.tobytes have been added as aliasesfortostring which exports arrays asbytes. This is more consistentin Python 3 wherestr andbytes are not the same.

Build system

Added experimental support for the ppc64le and OpenRISC architecture.

Compatibility to pythonnumbers module

All numerical numpy types are now registered with the type hierarchy inthe pythonnumbers module.

increasing parameter added tonp.vander

The ordering of the columns of the Vandermonde matrix can be specified withthis new boolean argument.

unique_counts parameter added tonp.unique

The number of times each unique item comes up in the input can now beobtained as an optional return value.

Support for median and percentile in nanfunctions

Thenp.nanmedian andnp.nanpercentile functions behave likethe median and percentile functions except that NaNs are ignored.

NumpyVersion class added

The class may be imported from numpy.lib and can be used for versioncomparison when the numpy version goes to 1.10.devel. For example:

>>>fromnumpy.libimportNumpyVersion>>>ifNumpyVersion(np.__version__)<'1.10.0'):...print('Wow, that is an old NumPy version!')

Allow saving arrays with large number of named columns

The numpy storage format 1.0 only allowed the array header to have a total sizeof 65535 bytes. This can be exceeded by structured arrays with a large numberof columns. A new format 2.0 has been added which extends the header size to 4GiB.np.save will automatically save in 2.0 format if the data requires it,else it will always use the more compatible 1.0 format.

Full broadcasting support fornp.cross

np.cross now properly broadcasts its two input arrays, even if theyhave different number of dimensions. In earlier versions this would resultin either an error being raised, or wrong results computed.

Improvements

Better numerical stability for sum in some cases

Pairwise summation is now used in the sum method, but only along the fastaxis and for groups of the values <= 8192 in length. This should alsoimprove the accuracy of var and std in some common cases.

Percentile implemented in terms ofnp.partition

np.percentile has been implemented in terms ofnp.partition whichonly partially sorts the data via a selection algorithm. This improves thetime complexity fromO(nlog(n)) toO(n).

Performance improvement fornp.array

The performance of converting lists containing arrays to arrays usingnp.array has been improved. It is now equivalent in speed tonp.vstack(list).

Performance improvement fornp.searchsorted

For the built-in numeric types,np.searchsorted no longer relies on thedata type’scompare function to perform the search, but is nowimplemented by type specific functions. Depending on the size of theinputs, this can result in performance improvements over 2x.

Optional reduced verbosity for np.distutils

Setnumpy.distutils.system_info.system_info.verbosity=0 and thencalls tonumpy.distutils.system_info.get_info('blas_opt') will notprint anything on the output. This is mostly for other packages usingnumpy.distutils.

Covariance check innp.random.multivariate_normal

ARuntimeWarning warning is raised when the covariance matrix is notpositive-semidefinite.

Polynomial Classes no longer template based

The polynomial classes have been refactored to use an abstract base classrather than a template in order to implement a common interface. This makesimporting the polynomial package faster as the classes do not need to becompiled on import.

More GIL releases

Several more functions now release the Global Interpreter Lock allowing moreefficient parallelization using thethreading module. Most notably the GIL isnow released for fancy indexing,np.where and therandom module nowuses a per-state lock instead of the GIL.

MaskedArray support for more complicated base classes

Built-in assumptions that the baseclass behaved like a plain array are beingremoved. In particalur,repr andstr should now work more reliably.

C-API

Deprecations

Non-integer scalars for sequence repetition

Using non-integer numpy scalars to repeat python sequences is deprecated.For examplenp.float_(2)*[1] will be an error in the future.

select input deprecations

The integer and empty input toselect is deprecated. In the future onlyboolean arrays will be valid conditions and an emptycondlist will beconsidered an input error instead of returning the default.

rank function

Therank function has been deprecated to avoid confusion withnumpy.linalg.matrix_rank.

Object array equality comparisons

In the future object array comparisons both== andnp.equal will notmake use of identity checks anymore. For example:

>>>a=np.array([np.array([1,2,3]),1])>>>b=np.array([np.array([1,2,3]),1])>>>a==b

will consistently return False (and in the future an error) even if the arrayina andb was the same object.

The equality operator== will in the future raise errors likenp.equalif broadcasting or element comparisons, etc. fails.

Comparison witharr == None will in the future do an elementwise comparisoninstead of just returning False. Code should be usingarr is None.

All of these changes will give Deprecation- or FutureWarnings at this time.

C-API

The utility function npy_PyFile_Dup and npy_PyFile_DupClose are broken by theinternal buffering python 3 applies to its file objects.To fix this two new functions npy_PyFile_Dup2 and npy_PyFile_DupClose2 aredeclared in npy_3kcompat.h and the old functions are deprecated.Due to the fragile nature of these functions it is recommended to instead usethe python API when possible.

This change was already applied to the 1.8.1 release.

NumPy 1.8.2 Release Notes

This is a bugfix only release in the 1.8.x series.

Issues fixed

  • gh-4836: partition produces wrong results for multiple selections in equal ranges
  • gh-4656: Make fftpack._raw_fft threadsafe
  • gh-4628: incorrect argument order to _copyto in in np.nanmax, np.nanmin
  • gh-4642: Hold GIL for converting dtypes types with fields
  • gh-4733: fix np.linalg.svd(b, compute_uv=False)
  • gh-4853: avoid unaligned simd load on reductions on i386
  • gh-4722: Fix seg fault converting empty string to object
  • gh-4613: Fix lack of NULL check in array_richcompare
  • gh-4774: avoid unaligned access for strided byteswap
  • gh-650: Prevent division by zero when creating arrays from some buffers
  • gh-4602: ifort has issues with optimization flag O2, use O1

NumPy 1.8.1 Release Notes

This is a bugfix only release in the 1.8.x series.

Issues fixed

  • gh-4276: Fix mean, var, std methods for object arrays
  • gh-4262: remove insecure mktemp usage
  • gh-2385: absolute(complex(inf)) raises invalid warning in python3
  • gh-4024: Sequence assignment doesn’t raise exception on shape mismatch
  • gh-4027: Fix chunked reading of strings longer than BUFFERSIZE
  • gh-4109: Fix object scalar return type of 0-d array indices
  • gh-4018: fix missing check for memory allocation failure in ufuncs
  • gh-4156: high order linalg.norm discards imaginary elements of complex arrays
  • gh-4144: linalg: norm fails on longdouble, signed int
  • gh-4094: fix NaT handling in _strided_to_strided_string_to_datetime
  • gh-4051: fix uninitialized use in _strided_to_strided_string_to_datetime
  • gh-4093: Loading compressed .npz file fails under Python 2.6.6
  • gh-4138: segfault with non-native endian memoryview in python 3.4
  • gh-4123: Fix missing NULL check in lexsort
  • gh-4170: fix native-only long long check in memoryviews
  • gh-4187: Fix large file support on 32 bit
  • gh-4152: fromfile: ensure file handle positions are in sync in python3
  • gh-4176: clang compatibility: Typos in conversion_utils
  • gh-4223: Fetching a non-integer item caused array return
  • gh-4197: fix minor memory leak in memoryview failure case
  • gh-4206: fix build with single-threaded python
  • gh-4220: add versionadded:: 1.8.0 to ufunc.at docstring
  • gh-4267: improve handling of memory allocation failure
  • gh-4267: fix use of capi without gil in ufunc.at
  • gh-4261: Detect vendor versions of GNU Compilers
  • gh-4253: IRR was returning nan instead of valid negative answer
  • gh-4254: fix unnecessary byte order flag change for byte arrays
  • gh-3263: numpy.random.shuffle clobbers mask of a MaskedArray
  • gh-4270: np.random.shuffle not work with flexible dtypes
  • gh-3173: Segmentation fault when ‘size’ argument to random.multinomial
  • gh-2799: allow using unique with lists of complex
  • gh-3504: fix linspace truncation for integer array scalar
  • gh-4191: get_info(‘openblas’) does not read libraries key
  • gh-3348: Access violation in _descriptor_from_pep3118_format
  • gh-3175: segmentation fault with numpy.array() from bytearray
  • gh-4266: histogramdd - wrong result for entries very close to last boundary
  • gh-4408: Fix stride_stricks.as_strided function for object arrays
  • gh-4225: fix log1p and exmp1 return for np.inf on windows compiler builds
  • gh-4359: Fix infinite recursion in str.format of flex arrays
  • gh-4145: Incorrect shape of broadcast result with the exponent operator
  • gh-4483: Fix commutativity of {dot,multiply,inner}(scalar, matrix_of_objs)
  • gh-4466: Delay npyiter size check when size may change
  • gh-4485: Buffered stride was erroneously marked fixed
  • gh-4354: byte_bounds fails with datetime dtypes
  • gh-4486: segfault/error converting from/to high-precision datetime64 objects
  • gh-4428: einsum(None, None, None, None) causes segfault
  • gh-4134: uninitialized use for for size 1 object reductions

Changes

NDIter

WhenNpyIter_RemoveAxis is now called, the iterator range will be reset.

When a multi index is being tracked and an iterator is not buffered, it ispossible to useNpyIter_RemoveAxis. In this case an iterator can shrinkin size. Because the total size of an iterator is limited, the iteratormay be too large before these calls. In this case its size will be set to-1and an error issued not at construction time but when removing the multiindex, setting the iterator range, or getting the next function.

This has no effect on currently working code, but highlights the necessityof checking for an error return if these conditions can occur. In mostcases the arrays being iterated are as large as the iterator so that sucha problem cannot occur.

Optional reduced verbosity for np.distutils

Setnumpy.distutils.system_info.system_info.verbosity=0 and thencalls tonumpy.distutils.system_info.get_info('blas_opt') will notprint anything on the output. This is mostly for other packages usingnumpy.distutils.

Deprecations

C-API

The utility function npy_PyFile_Dup and npy_PyFile_DupClose are broken by theinternal buffering python 3 applies to its file objects.To fix this two new functions npy_PyFile_Dup2 and npy_PyFile_DupClose2 aredeclared in npy_3kcompat.h and the old functions are deprecated.Due to the fragile nature of these functions it is recommended to instead usethe python API when possible.

NumPy 1.8.0 Release Notes

This release supports Python 2.6 -2.7 and 3.2 - 3.3.

Highlights

  • New, no 2to3, Python 2 and Python 3 are supported by a common code base.
  • New, gufuncs for linear algebra, enabling operations on stacked arrays.
  • New, inplace fancy indexing for ufuncs with the.at method.
  • New,partition function, partial sorting via selection for fast median.
  • New,nanmean,nanvar, andnanstd functions skipping NaNs.
  • New,full andfull_like functions to create value initialized arrays.
  • New,PyUFunc_RegisterLoopForDescr, better ufunc support for user dtypes.
  • Numerous performance improvements in many areas.

Dropped Support

Support for Python versions 2.4 and 2.5 has been dropped,

Support for SCons has been removed.

Future Changes

The Datetime64 type remains experimental in this release. In 1.9 there willprobably be some changes to make it more useable.

The diagonal method currently returns a new array and raises aFutureWarning. In 1.9 it will return a readonly view.

Multiple field selection from an array of structured type currentlyreturns a new array and raises a FutureWarning. In 1.9 it will return areadonly view.

The numpy/oldnumeric and numpy/numarray compatibility modules will beremoved in 1.9.

Compatibility notes

The doc/sphinxext content has been moved into its own github repository,and is included in numpy as a submodule. See the instructions indoc/HOWTO_BUILD_DOCS.rst.txt for how to access the content.

The hash function of numpy.void scalars has been changed. Previously thepointer to the data was hashed as an integer. Now, the hash function usesthe tuple-hash algorithm to combine the hash functions of the elements ofthe scalar, but only if the scalar is read-only.

Numpy has switched its build system to using ‘separate compilation’ bydefault. In previous releases this was supported, but not default. Thisshould produce the same results as the old system, but if you’re trying todo something complicated like link numpy statically or using an unusualcompiler, then it’s possible you will encounter problems. If so, pleasefile a bug and as a temporary workaround you can re-enable the old buildsystem by exporting the shell variable NPY_SEPARATE_COMPILATION=0.

For the AdvancedNew iterator theoa_ndim flag should now be -1 to indicatethat noop_axes anditershape are passed in. Theoa_ndim==0case, now indicates a 0-D iteration andop_axes being NULL and the oldusage is deprecated. This does not effect theNpyIter_New orNpyIter_MultiNew functions.

The functions nanargmin and nanargmax now return np.iinfo[‘intp’].min forthe index in all-NaN slices. Previously the functions would raise a ValueErrorfor array returns and NaN for scalar returns.

NPY_RELAXED_STRIDES_CHECKING

There is a new compile time environment variableNPY_RELAXED_STRIDES_CHECKING. If this variable is set to 1, thennumpy will consider more arrays to be C- or F-contiguous – forexample, it becomes possible to have a column vector which isconsidered both C- and F-contiguous simultaneously. The new definitionis more accurate, allows for faster code that makes fewer unnecessarycopies, and simplifies numpy’s code internally. However, it may alsobreak third-party libraries that make too-strong assumptions about thestride values of C- and F-contiguous arrays. (It is also currentlyknown that this breaks Cython code using memoryviews, which will befixed in Cython.) THIS WILL BECOME THE DEFAULT IN A FUTURE RELEASE, SOPLEASE TEST YOUR CODE NOW AGAINST NUMPY BUILT WITH:

NPY_RELAXED_STRIDES_CHECKING=1pythonsetup.pyinstall

You can check whether NPY_RELAXED_STRIDES_CHECKING is in effect byrunning:

np.ones((10,1),order="C").flags.f_contiguous

This will beTrue if relaxed strides checking is enabled, andFalse otherwise. The typical problem we’ve seen so far is C codethat works with C-contiguous arrays, and assumes that the itemsize canbe accessed by looking at the last element in thePyArray_STRIDES(arr)array. When relaxed strides are in effect, this is not true (and infact, it never was true in some corner cases). Instead, usePyArray_ITEMSIZE(arr).

For more information check the “Internal memory layout of an ndarray”section in the documentation.

Binary operations with non-arrays as second argument

Binary operations of the form<array-or-subclass>*<non-array-subclass>where<non-array-subclass> declares an__array_priority__ higher thanthat of<array-or-subclass> will now unconditionally returnNotImplemented, giving<non-array-subclass> a chance to handle theoperation. Previously,NotImplemented would only be returned if<non-array-subclass> actually implemented the reversed operation, and aftera (potentially expensive) array conversion of<non-array-subclass> had beenattempted. (bug,pull request)

Functionmedian used withoverwrite_input only partially sorts array

Ifmedian is used withoverwrite_input option the input array will now onlybe partially sorted instead of fully sorted.

Fix to financial.npv

The npv function had a bug. Contrary to what the documentation stated, itsummed from indexes1 toM instead of from0 toM-1. Thefix changes the returned value. The mirr function called the npv function,but worked around the problem, so that was also fixed and the return valueof the mirr function remains unchanged.

Runtime warnings when comparing NaN numbers

ComparingNaN floating point numbers now raises theinvalid runtimewarning. If aNaN is expected the warning can be ignored using np.errstate.E.g.:

withnp.errstate(invalid='ignore'):operation()

New Features

Support for linear algebra on stacked arrays

The gufunc machinery is now used for np.linalg, allowing operations onstacked arrays and vectors. For example:

>>>aarray([[[ 1.,  1.],        [ 0.,  1.]],       [[ 1.,  1.],        [ 0.,  1.]]])>>>np.linalg.inv(a)array([[[ 1., -1.],        [ 0.,  1.]],       [[ 1., -1.],        [ 0.,  1.]]])

In place fancy indexing for ufuncs

The functionat has been added to ufunc objects to allow in placeufuncs with no buffering when fancy indexing is used. For example, thefollowing will increment the first and second items in the array, and willincrement the third item twice:numpy.add.at(arr,[0,1,2,2],1)

This is what many have mistakenly thoughtarr[[0,1,2,2]]+=1 would do,but that does not work as the incremented value ofarr[2] is simply copiedinto the third slot inarr twice, not incremented twice.

New functionspartition andargpartition

New functions to partially sort arrays via a selection algorithm.

Apartition by indexk moves thek smallest element to the front ofan array. All elements beforek are then smaller or equal than the valuein positionk and all elements followingk are then greater or equalthan the value in positionk. The ordering of the values within thesebounds is undefined.A sequence of indices can be provided to sort all of them into their sortedposition at once iterative partitioning.This can be used to efficiently obtain order statistics like median orpercentiles of samples.partition has a linear time complexity ofO(n) while a full sort hasO(nlog(n)).

New functionsnanmean,nanvar andnanstd

New nan aware statistical functions are added. In these functions theresults are what would be obtained if nan values were omitted from allcomputations.

New functionsfull andfull_like

New convenience functions to create arrays filled with a specific value;complementary to the existingzeros andzeros_like functions.

IO compatibility with large files

Large NPZ files >2GB can be loaded on 64-bit systems.

Building against OpenBLAS

It is now possible to build numpy against OpenBLAS by editing site.cfg.

New constant

Euler’s constant is now exposed in numpy as euler_gamma.

New modes for qr

New modes ‘complete’, ‘reduced’, and ‘raw’ have been added to the qrfactorization and the old ‘full’ and ‘economic’ modes are deprecated.The ‘reduced’ mode replaces the old ‘full’ mode and is the default as wasthe ‘full’ mode, so backward compatibility can be maintained by notspecifying the mode.

The ‘complete’ mode returns a full dimensional factorization, which can beuseful for obtaining a basis for the orthogonal complement of the rangespace. The ‘raw’ mode returns arrays that contain the Householderreflectors and scaling factors that can be used in the future to apply qwithout needing to convert to a matrix. The ‘economic’ mode is simplydeprecated, there isn’t much use for it and it isn’t any more efficientthan the ‘raw’ mode.

Newinvert argument toin1d

The functionin1d now accepts ainvert argument which, whenTrue,causes the returned array to be inverted.

Advanced indexing usingnp.newaxis

It is now possible to usenp.newaxis/None together with indexarrays instead of only in simple indices. This means thatarray[np.newaxis,[0,1]] will now work as expected and select the firsttwo rows while prepending a new axis to the array.

C-API

New ufuncs can now be registered with builtin input types and a customoutput type. Before this change, NumPy wouldn’t be able to find the rightufunc loop function when the ufunc was called from Python, because the ufuncloop signature matching logic wasn’t looking at the output operand type.Now the correct ufunc loop is found, as long as the user provides an outputargument with the correct output type.

runtests.py

A simple test runner scriptruntests.py was added. It also builds Numpy viasetup.pybuild and can be used to run tests easily during development.

Improvements

IO performance improvements

Performance in reading large files was improved by chunking (see also IO compatibility).

Performance improvements topad

Thepad function has a new implementation, greatly improving performance forall inputs exceptmode= (retained for backwards compatibility).Scaling with dimensionality is dramatically improved for rank >= 4.

Performance improvements toisnan,isinf,isfinite andbyteswap

isnan,isinf,isfinite andbyteswap have been improved to takeadvantage of compiler builtins to avoid expensive calls to libc.This improves performance of these operations by about a factor of two on gnulibc systems.

Performance improvements via SSE2 vectorization

Several functions have been optimized to make use of SSE2 CPU SIMD instructions.

  • Float32 and float64:
    • base math (add,subtract,divide,multiply)
    • sqrt
    • minimum/maximum
    • absolute
  • Bool:
    • logical_or
    • logical_and
    • logical_not

This improves performance of these operations up to 4x/2x for float32/float64and up to 10x for bool depending on the location of the data in the CPU caches.The performance gain is greatest for in-place operations.

In order to use the improved functions the SSE2 instruction set must be enabledat compile time. It is enabled by default on x86_64 systems. On x86_32 with acapable CPU it must be enabled by passing the appropriate flag to the CFLAGSbuild variable (-msse2 with gcc).

Performance improvements tomedian

median is now implemented in terms ofpartition instead ofsort whichreduces its time complexity from O(n log(n)) to O(n).If used with theoverwrite_input option the array will now only be partiallysorted instead of fully sorted.

Overrideable operand flags in ufunc C-API

When creating a ufunc, the default ufunc operand flags can be overriddenvia the new op_flags attribute of the ufunc object. For example, to setthe operand flag for the first input to read/write:

PyObject *ufunc = PyUFunc_FromFuncAndData(…);ufunc->op_flags[0] = NPY_ITER_READWRITE;

This allows a ufunc to perform an operation in place. Also, global nditer flagscan be overridden via the new iter_flags attribute of the ufunc object.For example, to set the reduce flag for a ufunc:

ufunc->iter_flags = NPY_ITER_REDUCE_OK;

Changes

General

The function np.take now allows 0-d arrays as indices.

The separate compilation mode is now enabled by default.

Several changes to np.insert and np.delete:

  • Previously, negative indices and indices that pointed past the end ofthe array were simply ignored. Now, this will raise a Future or DeprecationWarning. In the future they will be treated like normal indexing treatsthem – negative indices will wrap around, and out-of-bound indices willgenerate an error.
  • Previously, boolean indices were treated as if they were integers (alwaysreferring to either the 0th or 1st item in the array). In the future, theywill be treated as masks. In this release, they raise a FutureWarningwarning of this coming change.
  • In Numpy 1.7. np.insert already allowed the syntaxnp.insert(arr, 3, [1,2,3]) to insert multiple items at a single position.In Numpy 1.8. this is also possible fornp.insert(arr, [3], [1, 2, 3]).

Padded regions from np.pad are now correctly rounded, not truncated.

C-API Array Additions

Four new functions have been added to the array C-API.

  • PyArray_Partition
  • PyArray_ArgPartition
  • PyArray_SelectkindConverter
  • PyDataMem_NEW_ZEROED

C-API Ufunc Additions

One new function has been added to the ufunc C-API that allows to registeran inner loop for user types using the descr.

  • PyUFunc_RegisterLoopForDescr

C-API Developer Improvements

ThePyArray_Type instance creation functiontp_new nowusestp_basicsize to determine how much memory to allocate.In previous releases onlysizeof(PyArrayObject) bytes ofmemory were allocated, often requiring C-API subtypes toreimplementtp_new.

Deprecations

The ‘full’ and ‘economic’ modes of qr factorization are deprecated.

General

The use of non-integer for indices and most integer arguments has beendeprecated. Previously float indices and function arguments such as axes orshapes were truncated to integers without warning. For examplearr.reshape(3., -1) orarr[0.] will trigger a deprecation warning inNumPy 1.8., and in some future version of NumPy they will raise an error.

Authors

This release contains work by the following people who contributed at leastone patch to this release. The names are in alphabetical order by first name:

  • 87
  • Adam Ginsburg +
  • Adam Griffiths +
  • Alexander Belopolsky +
  • Alex Barth +
  • Alex Ford +
  • Andreas Hilboll +
  • Andreas Kloeckner +
  • Andreas Schwab +
  • Andrew Horton +
  • argriffing +
  • Arink Verma +
  • Bago Amirbekian +
  • Bartosz Telenczuk +
  • bebert218 +
  • Benjamin Root +
  • Bill Spotz +
  • Bradley M. Froehle
  • Carwyn Pelley +
  • Charles Harris
  • Chris
  • Christian Brueffer +
  • Christoph Dann +
  • Christoph Gohlke
  • Dan Hipschman +
  • Daniel +
  • Dan Miller +
  • daveydave400 +
  • David Cournapeau
  • David Warde-Farley
  • Denis Laxalde
  • dmuellner +
  • Edward Catmur +
  • Egor Zindy +
  • endolith
  • Eric Firing
  • Eric Fode
  • Eric Moore +
  • Eric Price +
  • Fazlul Shahriar +
  • Félix Hartmann +
  • Fernando Perez
  • Frank B +
  • Frank Breitling +
  • Frederic
  • Gabriel
  • GaelVaroquaux
  • Guillaume Gay +
  • Han Genuit
  • HaroldMills +
  • hklemm +
  • jamestwebber +
  • Jason Madden +
  • Jay Bourque
  • jeromekelleher +
  • Jesús Gómez +
  • jmozmoz +
  • jnothman +
  • Johannes Schönberger +
  • John Benediktsson +
  • John Salvatier +
  • John Stechschulte +
  • Jonathan Waltman +
  • Joon Ro +
  • Jos de Kloe +
  • Joseph Martinot-Lagarde +
  • Josh Warner (Mac) +
  • Jostein Bø Fløystad +
  • Juan Luis Cano Rodríguez +
  • Julian Taylor +
  • Julien Phalip +
  • K.-Michael Aye +
  • Kumar Appaiah +
  • Lars Buitinck
  • Leon Weber +
  • Luis Pedro Coelho
  • Marcin Juszkiewicz
  • Mark Wiebe
  • Marten van Kerkwijk +
  • Martin Baeuml +
  • Martin Spacek
  • Martin Teichmann +
  • Matt Davis +
  • Matthew Brett
  • Maximilian Albert +
  • m-d-w +
  • Michael Droettboom
  • mwtoews +
  • Nathaniel J. Smith
  • Nicolas Scheffer +
  • Nils Werner +
  • ochoadavid +
  • Ondřej Čertík
  • ovillellas +
  • Paul Ivanov
  • Pauli Virtanen
  • peterjc
  • Ralf Gommers
  • Raul Cota +
  • Richard Hattersley +
  • Robert Costa +
  • Robert Kern
  • Rob Ruana +
  • Ronan Lamy
  • Sandro Tosi
  • Sascha Peilicke +
  • Sebastian Berg
  • Skipper Seabold
  • Stefan van der Walt
  • Steve +
  • Takafumi Arakaki +
  • Thomas Robitaille +
  • Tomas Tomecek +
  • Travis E. Oliphant
  • Valentin Haenel
  • Vladimir Rutsky +
  • Warren Weckesser
  • Yaroslav Halchenko
  • Yury V. Zaytsev +

A total of 119 people contributed to this release.People with a “+” by their names contributed a patch for the first time.

NumPy 1.7.2 Release Notes

This is a bugfix only release in the 1.7.x series.It supports Python 2.4 - 2.7 and 3.1 - 3.3 and is the last series thatsupports Python 2.4 - 2.5.

Issues fixed

  • gh-3153: Do not reuse nditer buffers when not filled enough
  • gh-3192: f2py crashes with UnboundLocalError exception
  • gh-442: Concatenate with axis=None now requires equal number of array elements
  • gh-2485: Fix for astype(‘S’) string truncate issue
  • gh-3312: bug in count_nonzero
  • gh-2684: numpy.ma.average casts complex to float under certain conditions
  • gh-2403: masked array with named components does not behave as expected
  • gh-2495: np.ma.compress treated inputs in wrong order
  • gh-576: add __len__ method to ma.mvoid
  • gh-3364: reduce performance regression of mmap slicing
  • gh-3421: fix non-swapping strided copies in GetStridedCopySwap
  • gh-3373: fix small leak in datetime metadata initialization
  • gh-2791: add platform specific python include directories to search paths
  • gh-3168: fix undefined function and add integer divisions
  • gh-3301: memmap does not work with TemporaryFile in python3
  • gh-3057: distutils.misc_util.get_shared_lib_extension returns wrong debug extension
  • gh-3472: add module extensions to load_library search list
  • gh-3324: Make comparison function (gt, ge, …) respect __array_priority__
  • gh-3497: np.insert behaves incorrectly with argument ‘axis=-1’
  • gh-3541: make preprocessor tests consistent in halffloat.c
  • gh-3458: array_ass_boolean_subscript() writes ‘non-existent’ data to array
  • gh-2892: Regression in ufunc.reduceat with zero-sized index array
  • gh-3608: Regression when filling struct from tuple
  • gh-3701: add support for Python 3.4 ast.NameConstant
  • gh-3712: do not assume that GIL is enabled in xerbla
  • gh-3712: fix LAPACK error handling in lapack_litemodule
  • gh-3728: f2py fix decref on wrong object
  • gh-3743: Hash changed signature in Python 3.3
  • gh-3793: scalar int hashing broken on 64 bit python3
  • gh-3160: SandboxViolation easyinstalling 1.7.0 on Mac OS X 10.8.3
  • gh-3871: npy_math.h has invalid isinf for Solaris with SUNWspro12.2
  • gh-2561: Disable check for oldstyle classes in python3
  • gh-3900: Ensure NotImplemented is passed on in MaskedArray ufunc’s
  • gh-2052: del scalar subscript causes segfault
  • gh-3832: fix a few uninitialized uses and memleaks
  • gh-3971: f2py changed string.lowercase to string.ascii_lowercase for python3
  • gh-3480: numpy.random.binomial raised ValueError for n == 0
  • gh-3992: hypot(inf, 0) shouldn’t raise a warning, hypot(inf, inf) wrong result
  • gh-4018: Segmentation fault dealing with very large arrays
  • gh-4094: fix NaT handling in _strided_to_strided_string_to_datetime
  • gh-4051: fix uninitialized use in _strided_to_strided_string_to_datetime
  • gh-4123: lexsort segfault
  • gh-4141: Fix a few issues that show up with python 3.4b1

NumPy 1.7.1 Release Notes

This is a bugfix only release in the 1.7.x series.It supports Python 2.4 - 2.7 and 3.1 - 3.3 and is the last series thatsupports Python 2.4 - 2.5.

Issues fixed

  • gh-2973: Fix1 is printed during numpy.test()
  • gh-2983: BUG: gh-2969: Backport memory leak fix 80b3a34.
  • gh-3007: Backport gh-3006
  • gh-2984: Backport fix complex polynomial fit
  • gh-2982: BUG: Make nansum work with booleans.
  • gh-2985: Backport large sort fixes
  • gh-3039: Backport object take
  • gh-3105: Backport nditer fix op axes initialization
  • gh-3108: BUG: npy-pkg-config ini files were missing after Bento build.
  • gh-3124: BUG: PyArray_LexSort allocates too much temporary memory.
  • gh-3131: BUG: Exported f2py_size symbol prevents linking multiple f2py modules.
  • gh-3117: Backport gh-2992
  • gh-3135: DOC: Add mention of PyArray_SetBaseObject stealing a reference
  • gh-3134: DOC: Fix typo in fft docs (the indexing variable is ‘m’, not ‘n’).
  • gh-3136: Backport #3128

NumPy 1.7.0 Release Notes

This release includes several new features as well as numerous bug fixes andrefactorings. It supports Python 2.4 - 2.7 and 3.1 - 3.3 and is the lastrelease that supports Python 2.4 - 2.5.

Highlights

  • where= parameter to ufuncs (allows the use of boolean arrays to choosewhere a computation should be done)
  • vectorize improvements (added ‘excluded’ and ‘cache’ keyword, generalcleanup and bug fixes)
  • numpy.random.choice (random sample generating function)

Compatibility notes

In a future version of numpy, the functions np.diag, np.diagonal, and thediagonal method of ndarrays will return a view onto the original array,instead of producing a copy as they do now. This makes a difference if youwrite to the array returned by any of these functions. To facilitate thistransition, numpy 1.7 produces a FutureWarning if it detects that you maybe attempting to write to such an array. See the documentation fornp.diagonal for details.

Similar to np.diagonal above, in a future version of numpy, indexing arecord array by a list of field names will return a view onto the originalarray, instead of producing a copy as they do now. As with np.diagonal,numpy 1.7 produces a FutureWarning if it detects that you may be attemptingto write to such an array. See the documentation for array indexing fordetails.

In a future version of numpy, the default casting rule for UFunc out=parameters will be changed from ‘unsafe’ to ‘same_kind’. (This also appliesto in-place operations like a += b, which is equivalent to np.add(a, b,out=a).) Most usages which violate the ‘same_kind’ rule are likely bugs, sothis change may expose previously undetected errors in projects that dependon NumPy. In this version of numpy, such usages will continue to succeed,but will raise a DeprecationWarning.

Full-array boolean indexing has been optimized to use a different,optimized code path. This code path should produce the same results,but any feedback about changes to your code would be appreciated.

Attempting to write to a read-only array (one witharr.flags.writeableset toFalse) used to raise either a RuntimeError, ValueError, orTypeError inconsistently, depending on which code path was taken. It nowconsistently raises a ValueError.

The <ufunc>.reduce functions evaluate some reductions in a different orderthan in previous versions of NumPy, generally providing higher performance.Because of the nature of floating-point arithmetic, this may subtly changesome results, just as linking NumPy to a different BLAS implementationssuch as MKL can.

If upgrading from 1.5, then generally in 1.6 and 1.7 there have beensubstantial code added and some code paths altered, particularly in theareas of type resolution and buffered iteration over universal functions.This might have an impact on your code particularly if you relied onaccidental behavior in the past.

New features

Reduction UFuncs Generalize axis= Parameter

Any ufunc.reduce function call, as well as other reductions like sum, prod,any, all, max and min support the ability to choose a subset of the axes toreduce over. Previously, one could say axis=None to mean all the axes oraxis=# to pick a single axis. Now, one can also say axis=(#,#) to pick alist of axes for reduction.

Reduction UFuncs New keepdims= Parameter

There is a new keepdims= parameter, which if set to True, doesn’t throwaway the reduction axes but instead sets them to have size one. When thisoption is set, the reduction result will broadcast correctly to theoriginal operand which was reduced.

Datetime support

Note

The datetime API isexperimental in 1.7.0, and may undergo changesin future versions of NumPy.

There have been a lot of fixes and enhancements to datetime64 comparedto NumPy 1.6:

  • the parser is quite strict about only accepting ISO 8601 dates, with a fewconvenience extensions
  • converts between units correctly
  • datetime arithmetic works correctly
  • business day functionality (allows the datetime to be used in contexts whereonly certain days of the week are valid)

The notes indoc/source/reference/arrays.datetime.rst(also available in the online docs atarrays.datetime.html) should beconsulted for more details.

Custom formatter for printing arrays

See the newformatter parameter of thenumpy.set_printoptionsfunction.

New function numpy.random.choice

A generic sampling function has been added which will generate samples froma given array-like. The samples can be with or without replacement, andwith uniform or given non-uniform probabilities.

New function isclose

Returns a boolean array where two arrays are element-wise equal within atolerance. Both relative and absolute tolerance can be specified.

Preliminary multi-dimensional support in the polynomial package

Axis keywords have been added to the integration and differentiationfunctions and a tensor keyword was added to the evaluation functions.These additions allow multi-dimensional coefficient arrays to be used inthose functions. New functions for evaluating 2-D and 3-D coefficientarrays on grids or sets of points were added together with 2-D and 3-Dpseudo-Vandermonde matrices that can be used for fitting.

Ability to pad rank-n arrays

A pad module containing functions for padding n-dimensional arrays has beenadded. The various private padding functions are exposed as options to apublic ‘pad’ function. Example:

pad(a,5,mode='mean')

Current modes areconstant,edge,linear_ramp,maximum,mean,median,minimum,reflect,symmetric,wrap, and<function>.

New argument to searchsorted

The function searchsorted now accepts a ‘sorter’ argument that is apermutation array that sorts the array to search.

Build system

Added experimental support for the AArch64 architecture.

C API

New functionPyArray_RequireWriteable provides a consistent interfacefor checking array writeability – any C code which works with arrays whoseWRITEABLE flag is not known to be True a priori, should make sure to callthis function before writing.

NumPy C Style Guide added (doc/C_STYLE_GUIDE.rst.txt).

Changes

General

The function np.concatenate tries to match the layout of its input arrays.Previously, the layout did not follow any particular reason, and dependedin an undesirable way on the particular axis chosen for concatenation. Abug was also fixed which silently allowed out of bounds axis arguments.

The ufuncs logical_or, logical_and, and logical_not now follow Python’sbehavior with object arrays, instead of trying to call methods on theobjects. For example the expression (3 and ‘test’) produces the string‘test’, and now np.logical_and(np.array(3, ‘O’), np.array(‘test’, ‘O’))produces ‘test’ as well.

The.base attribute on ndarrays, which is used on views to ensure that theunderlying array owning the memory is not deallocated prematurely, nowcollapses out references when you have a view-of-a-view. For example:

a=np.arange(10)b=a[1:]c=b[1:]

In numpy 1.6,c.base isb, andc.base.base isa. In numpy 1.7,c.base isa.

To increase backwards compatibility for software which relies on the oldbehaviour of.base, we only ‘skip over’ objects which have exactly the sametype as the newly created view. This makes a difference if you usendarraysubclasses. For example, if we have a mix ofndarray andmatrix objectswhich are all views on the same originalndarray:

a=np.arange(10)b=np.asmatrix(a)c=b[0,1:]d=c[0,1:]

thend.base will beb. This is becaused is amatrix object,and so the collapsing process only continues so long as it encounters othermatrix objects. It considersc,b, anda in that order, andb is the last entry in that list which is amatrix object.

Casting Rules

Casting rules have undergone some changes in corner cases, due to theNA-related work. In particular for combinations of scalar+scalar:

  • thelonglong type (q) now stayslonglong for operations with any othernumber (? b h i l q p B H I), previously it was cast asint_ (l). Theulonglong type (Q) now stays asulonglong instead ofuint (L).
  • thetimedelta64 type (m) can now be mixed with any integer type (b h i lq p B H I L Q P), previously it raisedTypeError.

For array + scalar, the above rules just broadcast except the case whenthe array and scalars are unsigned/signed integers, then the result getsconverted to the array type (of possibly larger size) as illustrated by thefollowing examples:

>>>(np.zeros((2,),dtype=np.uint8)+np.int16(257)).dtypedtype('uint16')>>>(np.zeros((2,),dtype=np.int8)+np.uint16(257)).dtypedtype('int16')>>>(np.zeros((2,),dtype=np.int16)+np.uint32(2**17)).dtypedtype('int32')

Whether the size gets increased depends on the size of the scalar, forexample:

>>>(np.zeros((2,),dtype=np.uint8)+np.int16(255)).dtypedtype('uint8')>>>(np.zeros((2,),dtype=np.uint8)+np.int16(256)).dtypedtype('uint16')

Also acomplex128 scalar +float32 array is cast tocomplex64.

In NumPy 1.7 thedatetime64 type (M) must be constructed by explicitlyspecifying the type as the second argument (e.g.np.datetime64(2000,'Y')).

Deprecations

General

Specifying a custom string formatter with a_format array attribute isdeprecated. The newformatter keyword innumpy.set_printoptions ornumpy.array2string can be used instead.

The deprecated imports in the polynomial package have been removed.

concatenate now raises DepractionWarning for 1D arrays ifaxis!=0.Versions of numpy < 1.7.0 ignored axis argument value for 1D arrays. Weallow this for now, but in due course we will raise an error.

C-API

Direct access to the fields of PyArrayObject* has been deprecated. Directaccess has been recommended against for many releases. Expect similardeprecations for PyArray_Descr* and other core objects in the future aspreparation for NumPy 2.0.

The macros in old_defines.h are deprecated and will be removed in the nextmajor release (>= 2.0). The sed script tools/replace_old_macros.sed can beused to replace these macros with the newer versions.

You can test your code against the deprecated C API by #definingNPY_NO_DEPRECATED_API to the target version number, for exampleNPY_1_7_API_VERSION, before including any NumPy headers.

TheNPY_CHAR member of theNPY_TYPES enum is deprecated and will beremoved in NumPy 1.8. See the discussion atgh-2801 for more details.

NumPy 1.6.2 Release Notes

This is a bugfix release in the 1.6.x series. Due to the delay of the NumPy1.7.0 release, this release contains far more fixes than a regular NumPy bugfixrelease. It also includes a number of documentation and build improvements.

Issues fixed

numpy.core

  • #2063: make unique() return consistent index
  • #1138: allow creating arrays from empty buffers or empty slices
  • #1446: correct note about correspondence vstack and concatenate
  • #1149: make argmin() work for datetime
  • #1672: fix allclose() to work for scalar inf
  • #1747: make np.median() work for 0-D arrays
  • #1776: make complex division by zero to yield inf properly
  • #1675: add scalar support for the format() function
  • #1905: explicitly check for NaNs in allclose()
  • #1952: allow floating ddof in std() and var()
  • #1948: fix regression for indexing chararrays with empty list
  • #2017: fix type hashing
  • #2046: deleting array attributes causes segfault
  • #2033: a**2.0 has incorrect type
  • #2045: make attribute/iterator_element deletions not segfault
  • #2021: fix segfault in searchsorted()
  • #2073: fix float16 __array_interface__ bug

numpy.lib

  • #2048: break reference cycle in NpzFile
  • #1573: savetxt() now handles complex arrays
  • #1387: allow bincount() to accept empty arrays
  • #1899: fixed histogramdd() bug with empty inputs
  • #1793: fix failing npyio test under py3k
  • #1936: fix extra nesting for subarray dtypes
  • #1848: make tril/triu return the same dtype as the original array
  • #1918: use Py_TYPE to access ob_type, so it works also on Py3

numpy.distutils

  • #1261: change compile flag on AIX from -O5 to -O3
  • #1377: update HP compiler flags
  • #1383: provide better support for C++ code on HPUX
  • #1857: fix build for py3k + pip
  • BLD: raise a clearer warning in case of building without cleaning up first
  • BLD: follow build_ext coding convention in build_clib
  • BLD: fix up detection of Intel CPU on OS X in system_info.py
  • BLD: add support for the new X11 directory structure on Ubuntu & co.
  • BLD: add ufsparse to the libraries search path.
  • BLD: add ‘pgfortran’ as a valid compiler in the Portland Group
  • BLD: update version match regexp for IBM AIX Fortran compilers.

numpy.random

  • BUG: Use npy_intp instead of long in mtrand

Changes

numpy.f2py

  • ENH: Introduce new options extra_f77_compiler_args and extra_f90_compiler_args
  • BLD: Improve reporting of fcompiler value
  • BUG: Fix f2py test_kind.py test

numpy.poly

  • ENH: Add some tests for polynomial printing
  • ENH: Add companion matrix functions
  • DOC: Rearrange the polynomial documents
  • BUG: Fix up links to classes
  • DOC: Add version added to some of the polynomial package modules
  • DOC: Document xxxfit functions in the polynomial package modules
  • BUG: The polynomial convenience classes let different types interact
  • DOC: Document the use of the polynomial convenience classes
  • DOC: Improve numpy reference documentation of polynomial classes
  • ENH: Improve the computation of polynomials from roots
  • STY: Code cleanup in polynomial [*]fromroots functions
  • DOC: Remove references to cast and NA, which were added in 1.7

NumPy 1.6.1 Release Notes

This is a bugfix only release in the 1.6.x series.

Issues Fixed

  • #1834: einsum fails for specific shapes
  • #1837: einsum throws nan or freezes python for specific array shapes
  • #1838: object <-> structured type arrays regression
  • #1851: regression for SWIG based code in 1.6.0
  • #1863: Buggy results when operating on array copied with astype()
  • #1870: Fix corner case of object array assignment
  • #1843: Py3k: fix error with recarray
  • #1885: nditer: Error in detecting double reduction loop
  • #1874: f2py: fix –include_paths bug
  • #1749: Fix ctypes.load_library()
  • #1895/1896: iter: writeonly operands weren’t always being buffered correctly

NumPy 1.6.0 Release Notes

This release includes several new features as well as numerous bug fixes andimproved documentation. It is backward compatible with the 1.5.0 release, andsupports Python 2.4 - 2.7 and 3.1 - 3.2.

Highlights

  • Re-introduction of datetime dtype support to deal with dates in arrays.
  • A new 16-bit floating point type.
  • A new iterator, which improves performance of many functions.

New features

New 16-bit floating point type

This release adds support for the IEEE 754-2008 binary16 format, available asthe data typenumpy.half. Within Python, the type behaves similarly tofloat ordouble, and C extensions can add support for it with the exposedhalf-float API.

New iterator

A new iterator has been added, replacing the functionality of theexisting iterator and multi-iterator with a single object and API.This iterator works well with general memory layouts different fromC or Fortran contiguous, and handles both standard NumPy andcustomized broadcasting. The buffering, automatic data typeconversion, and optional output parameters, offered byufuncs but difficult to replicate elsewhere, are now exposed by thisiterator.

Legendre, Laguerre, Hermite, HermiteE polynomials innumpy.polynomial

Extend the number of polynomials available in the polynomial package. Inaddition, a newwindow attribute has been added to the classes inorder to specify the range thedomain maps to. This is mostly usefulfor the Laguerre, Hermite, and HermiteE polynomials whose natural domainsare infinite and provides a more intuitive way to get the correct mappingof values without playing unnatural tricks with the domain.

Fortran assumed shape array and size function support innumpy.f2py

F2py now supports wrapping Fortran 90 routines that use assumed shapearrays. Before such routines could be called from Python but thecorresponding Fortran routines received assumed shape arrays as zerolength arrays which caused unpredicted results. Thanks to LorenzHüdepohl for pointing out the correct way to interface routines withassumed shape arrays.

In addition, f2py supports now automatic wrapping of Fortran routinesthat use two argumentsize function in dimension specifications.

Other new functions

numpy.ravel_multi_index : Converts a multi-index tuple intoan array of flat indices, applying boundary modes to the indices.

numpy.einsum : Evaluate the Einstein summation convention. Using theEinstein summation convention, many common multi-dimensional array operationscan be represented in a simple fashion. This function provides a way computesuch summations.

numpy.count_nonzero : Counts the number of non-zero elements in an array.

numpy.result_type andnumpy.min_scalar_type : These functions exposethe underlying type promotion used by the ufuncs and other operations todetermine the types of outputs. These improve upon thenumpy.common_typeandnumpy.mintypecode which provide similar functionality but donot match the ufunc implementation.

Changes

defaulterrorhandling

The default error handling has been change fromprint towarn forall except forunderflow, which remains asignore.

numpy.distutils

Several new compilers are supported for building Numpy: the Portland GroupFortran compiler on OS X, the PathScale compiler suite and the 64-bit Intel Ccompiler on Linux.

numpy.testing

The testing framework gainednumpy.testing.assert_allclose, which providesa more convenient way to compare floating point arrays thanassert_almost_equal,assert_approx_equal andassert_array_almost_equal.

CAPI

In addition to the APIs for the new iterator and half data type, a numberof other additions have been made to the C API. The type promotionmechanism used by ufuncs is exposed viaPyArray_PromoteTypes,PyArray_ResultType, andPyArray_MinScalarType. A new enumerationNPY_CASTING has been added which controls what types of casts arepermitted. This is used by the new functionsPyArray_CanCastArrayToandPyArray_CanCastTypeTo. A more flexible way to handleconversion of arbitrary python objects into arrays is exposed byPyArray_GetArrayParamsFromObject.

Deprecated features

The “normed” keyword innumpy.histogram is deprecated. Its functionalitywill be replaced by the new “density” keyword.

Removed features

numpy.fft

The functionsrefft,refft2,refftn,irefft,irefft2,irefftn,which were aliases for the same functions without the ‘e’ in the name, wereremoved.

numpy.memmap

Thesync() andclose() methods of memmap were removed. Useflush() and“del memmap” instead.

numpy.lib

The deprecated functionsnumpy.unique1d,numpy.setmember1d,numpy.intersect1d_nu andnumpy.lib.ufunclike.log2 were removed.

numpy.ma

Several deprecated items were removed from thenumpy.ma module:

* ``numpy.ma.MaskedArray`` "raw_data" method* ``numpy.ma.MaskedArray`` constructor "flag" keyword* ``numpy.ma.make_mask`` "flag" keyword* ``numpy.ma.allclose`` "fill_value" keyword

numpy.distutils

Thenumpy.get_numpy_include function was removed, usenumpy.get_includeinstead.

NumPy 1.5.0 Release Notes

Highlights

Python 3 compatibility

This is the first NumPy release which is compatible with Python 3. Support forPython 3 and Python 2 is done from a single code base. Extensive notes onchanges can be found athttp://projects.scipy.org/numpy/browser/trunk/doc/Py3K.txt.

Note that the Numpy testing framework relies on nose, which does not have aPython 3 compatible release yet. A working Python 3 branch of nose can be foundathttp://bitbucket.org/jpellerin/nose3/ however.

Porting of SciPy to Python 3 is expected to be completed soon.

PEP 3118 compatibility

The new buffer protocol described by PEP 3118 is fully supported in thisversion of Numpy. On Python versions >= 2.6 Numpy arrays expose the bufferinterface, and array(), asarray() and other functions accept new-style buffersas input.

New features

Warning on casting complex to real

Numpy now emits anumpy.ComplexWarning when a complex number is castinto a real number. For example:

>>>x=np.array([1,2,3])>>>x[:2]=np.array([1+2j,1-2j])ComplexWarning: Casting complex values to real discards the imaginary part

The cast indeed discards the imaginary part, and this may not be theintended behavior in all cases, hence the warning. This warning can beturned off in the standard way:

>>>importwarnings>>>warnings.simplefilter("ignore",np.ComplexWarning)

Dot method for ndarrays

Ndarrays now have the dot product also as a method, which allows writingchains of matrix products as

>>>a.dot(b).dot(c)

instead of the longer alternative

>>>np.dot(a,np.dot(b,c))

linalg.slogdet function

The slogdet function returns the sign and logarithm of the determinantof a matrix. Because the determinant may involve the product of manysmall/large values, the result is often more accurate than that obtainedby simple multiplication.

new header

The new header file ndarraytypes.h contains the symbols fromndarrayobject.h that do not depend on the PY_ARRAY_UNIQUE_SYMBOL andNO_IMPORT/_ARRAY macros. Broadly, these symbols are types, typedefs,and enumerations; the array function calls are left inndarrayobject.h. This allows users to include array-related types andenumerations without needing to concern themselves with the macroexpansions and their side- effects.

Changes

polynomial.polynomial

  • The polyint and polyder functions now check that the specified numberintegrations or derivations is a non-negative integer. The number 0 isa valid value for both functions.
  • A degree method has been added to the Polynomial class.
  • A trimdeg method has been added to the Polynomial class. It operates liketruncate except that the argument is the desired degree of the result,not the number of coefficients.
  • Polynomial.fit now uses None as the default domain for the fit. The defaultPolynomial domain can be specified by using [] as the domain value.
  • Weights can be used in both polyfit and Polynomial.fit
  • A linspace method has been added to the Polynomial class to ease plotting.
  • The polymulx function was added.

polynomial.chebyshev

  • The chebint and chebder functions now check that the specified numberintegrations or derivations is a non-negative integer. The number 0 isa valid value for both functions.
  • A degree method has been added to the Chebyshev class.
  • A trimdeg method has been added to the Chebyshev class. It operates liketruncate except that the argument is the desired degree of the result,not the number of coefficients.
  • Chebyshev.fit now uses None as the default domain for the fit. The defaultChebyshev domain can be specified by using [] as the domain value.
  • Weights can be used in both chebfit and Chebyshev.fit
  • A linspace method has been added to the Chebyshev class to ease plotting.
  • The chebmulx function was added.
  • Added functions for the Chebyshev points of the first and second kind.

histogram

After a two years transition period, the old behavior of the histogram functionhas been phased out, and the “new” keyword has been removed.

correlate

The old behavior of correlate was deprecated in 1.4.0, the new behavior (theusual definition for cross-correlation) is now the default.

NumPy 1.4.0 Release Notes

This minor includes numerous bug fixes, as well as a few new features. Itis backward compatible with 1.3.0 release.

Highlights

  • New datetime dtype support to deal with dates in arrays
  • Faster import time
  • Extended array wrapping mechanism for ufuncs
  • New Neighborhood iterator (C-level only)
  • C99-like complex functions in npymath

New features

Extended array wrapping mechanism for ufuncs

An __array_prepare__ method has been added to ndarray to provide subclassesgreater flexibility to interact with ufuncs and ufunc-like functions. ndarrayalready provided __array_wrap__, which allowed subclasses to set the array typefor the result and populate metadata on the way out of the ufunc (as seen inthe implementation of MaskedArray). For some applications it is necessary toprovide checks and populate metadataon the way in. __array_prepare__ istherefore called just after the ufunc has initialized the output array butbefore computing the results and populating it. This way, checks can be madeand errors raised before operations which may modify data in place.

Automatic detection of forward incompatibilities

Previously, if an extension was built against a version N of NumPy, and used ona system with NumPy M < N, the import_array was successful, which could causecrashes because the version M does not have a function in N. Starting fromNumPy 1.4.0, this will cause a failure in import_array, so the error will becaught early on.

New iterators

A new neighborhood iterator has been added to the C API. It can be used toiterate over the items in a neighborhood of an array, and can handle boundariesconditions automatically. Zero and one padding are available, as well asarbitrary constant value, mirror and circular padding.

New polynomial support

New modules chebyshev and polynomial have been added. The new polynomial moduleis not compatible with the current polynomial support in numpy, but is muchlike the new chebyshev module. The most noticeable difference to most willbe that coefficients are specified from low to high power, that the lowlevel functions donot work with the Chebyshev and Polynomial classes asarguments, and that the Chebyshev and Polynomial classes include a domain.Mapping between domains is a linear substitution and the two classes can beconverted one to the other, allowing, for instance, a Chebyshev series inone domain to be expanded as a polynomial in another domain. The new classesshould generally be used instead of the low level functions, the latter areprovided for those who wish to build their own classes.

The new modules are not automatically imported into the numpy namespace,they must be explicitly brought in with an “import numpy.polynomial”statement.

New C API

The following C functions have been added to the C API:

  1. PyArray_GetNDArrayCFeatureVersion: return theAPI version of theloaded numpy.
  2. PyArray_Correlate2 - like PyArray_Correlate, but implements the usualdefinition of correlation. Inputs are not swapped, and conjugate istaken for complex arrays.
  3. PyArray_NeighborhoodIterNew - a new iterator to iterate over aneighborhood of a point, with automatic boundaries handling. It isdocumented in the iterators section of the C-API reference, and you canfind some examples in the multiarray_test.c.src file in numpy.core.

New ufuncs

The following ufuncs have been added to the C API:

  1. copysign - return the value of the first argument with the sign copiedfrom the second argument.
  2. nextafter - return the next representable floating point value of thefirst argument toward the second argument.

New defines

The alpha processor is now defined and available in numpy/npy_cpu.h. Thefailed detection of the PARISC processor has been fixed. The defines are:

  1. NPY_CPU_HPPA: PARISC
  2. NPY_CPU_ALPHA: Alpha

Testing

  1. deprecated decorator: this decorator may be used to avoid clutteringtesting output while testing DeprecationWarning is effectively raised bythe decorated test.
  2. assert_array_almost_equal_nulps: new method to compare two arrays offloating point values. With this function, two values are consideredclose if there are not many representable floating point values inbetween, thus being more robust than assert_array_almost_equal when thevalues fluctuate a lot.
  3. assert_array_max_ulp: raise an assertion if there are more than Nrepresentable numbers between two floating point values.
  4. assert_warns: raise an AssertionError if a callable does not generate awarning of the appropriate class, without altering the warning state.

Reusing npymath

In 1.3.0, we started putting portable C math routines in npymath library, sothat people can use those to write portable extensions. Unfortunately, it wasnot possible to easily link against this library: in 1.4.0, support has beenadded to numpy.distutils so that 3rd party can reuse this library. See coremathdocumentation for more information.

Improved set operations

In previous versions of NumPy some set functions (intersect1d,setxor1d, setdiff1d and setmember1d) could return incorrect results ifthe input arrays contained duplicate items. These now work correctlyfor input arrays with duplicates. setmember1d has been renamed toin1d, as with the change to accept arrays with duplicates it isno longer a set operation, and is conceptually similar to anelementwise version of the Python operator ‘in’. All of thesefunctions now accept the boolean keyword assume_unique. This is Falseby default, but can be set True if the input arrays are known notto contain duplicates, which can increase the functions’ executionspeed.

Improvements

  1. numpy import is noticeably faster (from 20 to 30 % depending on theplatform and computer)

  2. The sort functions now sort nans to the end.

    • Real sort order is [R, nan]
    • Complex sort order is [R + Rj, R + nanj, nan + Rj, nan + nanj]

    Complex numbers with the same nan placements are sorted according tothe non-nan part if it exists.

  3. The type comparison functions have been made consistent with the newsort order of nans. Searchsorted now works with sorted arrayscontaining nan values.

  4. Complex division has been made more resistant to overflow.

  5. Complex floor division has been made more resistant to overflow.

Deprecations

The following functions are deprecated:

  1. correlate: it takes a new keyword argument old_behavior. When True (thedefault), it returns the same result as before. When False, compute theconventional correlation, and take the conjugate for complex arrays. Theold behavior will be removed in NumPy 1.5, and raises aDeprecationWarning in 1.4.
  2. unique1d: use unique instead. unique1d raises a deprecationwarning in 1.4, and will be removed in 1.5.
  3. intersect1d_nu: use intersect1d instead. intersect1d_nu raisesa deprecation warning in 1.4, and will be removed in 1.5.
  4. setmember1d: use in1d instead. setmember1d raises a deprecationwarning in 1.4, and will be removed in 1.5.

The following raise errors:

  1. When operating on 0-d arrays,numpy.max and other functions acceptonlyaxis=0,axis=-1 andaxis=None. Using an out-of-boundsaxes is an indication of a bug, so Numpy raises an error for these casesnow.
  2. Specifyingaxis>MAX_DIMS is no longer allowed; Numpy raises now anerror instead of behaving similarly as foraxis=None.

Internal changes

Use C99 complex functions when available

The numpy complex types are now guaranteed to be ABI compatible with C99complex type, if available on the platform. Moreover, the complex ufunc now usethe platform C99 functions instead of our own.

split multiarray and umath source code

The source code of multiarray and umath has been split into separate logiccompilation units. This should make the source code more amenable fornewcomers.

Separate compilation

By default, every file of multiarray (and umath) is merged into one forcompilation as was the case before, but if NPY_SEPARATE_COMPILATION envvariable is set to a non-negative value, experimental individual compilation ofeach file is enabled. This makes the compile/debug cycle much faster whenworking on core numpy.

Separate core math library

New functions which have been added:

  • npy_copysign
  • npy_nextafter
  • npy_cpack
  • npy_creal
  • npy_cimag
  • npy_cabs
  • npy_cexp
  • npy_clog
  • npy_cpow
  • npy_csqr
  • npy_ccos
  • npy_csin

NumPy 1.3.0 Release Notes

This minor includes numerous bug fixes, official python 2.6 support, andseveral new features such as generalized ufuncs.

Highlights

Python 2.6 support

Python 2.6 is now supported on all previously supported platforms, includingwindows.

http://www.python.org/dev/peps/pep-0361/

Generalized ufuncs

There is a general need for looping over not only functions on scalars but alsoover functions on vectors (or arrays), as explained onhttp://scipy.org/scipy/numpy/wiki/GeneralLoopingFunctions. We propose torealize this concept by generalizing the universal functions (ufuncs), andprovide a C implementation that adds ~500 lines to the numpy code base. Incurrent (specialized) ufuncs, the elementary function is limited toelement-by-element operations, whereas the generalized version supports“sub-array” by “sub-array” operations. The Perl vector library PDL provides asimilar functionality and its terms are re-used in the following.

Each generalized ufunc has information associated with it that states what the“core” dimensionality of the inputs is, as well as the correspondingdimensionality of the outputs (the element-wise ufuncs have zero coredimensions). The list of the core dimensions for all arguments is called the“signature” of a ufunc. For example, the ufunc numpy.add has signature“(),()->()” defining two scalar inputs and one scalar output.

Another example is (see the GeneralLoopingFunctions page) the functioninner1d(a,b) with a signature of “(i),(i)->()”. This applies the inner productalong the last axis of each input, but keeps the remaining indices intact. Forexample, where a is of shape (3,5,N) and b is of shape (5,N), this will returnan output of shape (3,5). The underlying elementary function is called 3*5times. In the signature, we specify one core dimension “(i)” for each input andzero core dimensions “()” for the output, since it takes two 1-d arrays andreturns a scalar. By using the same name “i”, we specify that the twocorresponding dimensions should be of the same size (or one of them is of size1 and will be broadcasted).

The dimensions beyond the core dimensions are called “loop” dimensions. In theabove example, this corresponds to (3,5).

The usual numpy “broadcasting” rules apply, where the signature determines howthe dimensions of each input/output object are split into core and loopdimensions:

While an input array has a smaller dimensionality than the corresponding numberof core dimensions, 1’s are pre-pended to its shape. The core dimensions areremoved from all inputs and the remaining dimensions are broadcasted; definingthe loop dimensions. The output is given by the loop dimensions plus theoutput core dimensions.

Experimental Windows 64 bits support

Numpy can now be built on windows 64 bits (amd64 only, not IA64), with both MScompilers and mingw-w64 compilers:

This ishighly experimental: DO NOT USE FOR PRODUCTION USE. See INSTALL.txt,Windows 64 bits section for more information on limitations and how to build itby yourself.

New features

Formatting issues

Float formatting is now handled by numpy instead of the C runtime: this enableslocale independent formatting, more robust fromstring and related methods.Special values (inf and nan) are also more consistent across platforms (nan vsIND/NaN, etc…), and more consistent with recent python formatting work (in2.6 and later).

Nan handling in max/min

The maximum/minimum ufuncs now reliably propagate nans. If one of thearguments is a nan, then nan is returned. This affects np.min/np.max, amin/amaxand the array methods max/min. New ufuncs fmax and fmin have been added to dealwith non-propagating nans.

Nan handling in sign

The ufunc sign now returns nan for the sign of anan.

New ufuncs

  1. fmax - same as maximum for integer types and non-nan floats. Returns thenon-nan argument if one argument is nan and returns nan if both argumentsare nan.
  2. fmin - same as minimum for integer types and non-nan floats. Returns thenon-nan argument if one argument is nan and returns nan if both argumentsare nan.
  3. deg2rad - converts degrees to radians, same as the radians ufunc.
  4. rad2deg - converts radians to degrees, same as the degrees ufunc.
  5. log2 - base 2 logarithm.
  6. exp2 - base 2 exponential.
  7. trunc - truncate floats to nearest integer towards zero.
  8. logaddexp - add numbers stored as logarithms and return the logarithmof the result.
  9. logaddexp2 - add numbers stored as base 2 logarithms and return the base 2logarithm of the result.

Masked arrays

Several new features and bug fixes, including:

  • structured arrays should now be fully supported by MaskedArray(r6463, r6324, r6305, r6300, r6294…)
  • Minor bug fixes (r6356, r6352, r6335, r6299, r6298)
  • Improved support for __iter__ (r6326)
  • made baseclass, sharedmask and hardmask accessible to the user (butread-only)
  • doc update

gfortran support on windows

Gfortran can now be used as a fortran compiler for numpy on windows, even whenthe C compiler is Visual Studio (VS 2005 and above; VS 2003 will NOT work).Gfortran + Visual studio does not work on windows 64 bits (but gcc + gfortrandoes). It is unclear whether it will be possible to use gfortran and visualstudio at all on x64.

Arch option for windows binary

Automatic arch detection can now be bypassed from the command line for the superpack installed:

numpy-1.3.0-superpack-win32.exe /arch=nosse

will install a numpy which works on any x86, even if the running computersupports SSE set.

Deprecated features

Histogram

The semantics of histogram has been modified to fix long-standing issueswith outliers handling. The main changes concern

  1. the definition of the bin edges, now including the rightmost edge, and
  2. the handling of upper outliers, now ignored rather than tallied in therightmost bin.

The previous behavior is still accessible usingnew=False, but this isdeprecated, and will be removed entirely in 1.4.0.

Documentation changes

A lot of documentation has been added. Both user guide and references can bebuilt from sphinx.

New C API

Multiarray API

The following functions have been added to the multiarray C API:

  • PyArray_GetEndianness: to get runtime endianness

Ufunc API

The following functions have been added to the ufunc API:

  • PyUFunc_FromFuncAndDataAndSignature: to declare a more general ufunc(generalized ufunc).

New defines

New public C defines are available for ARCH specific code through numpy/npy_cpu.h:

  • NPY_CPU_X86: x86 arch (32 bits)
  • NPY_CPU_AMD64: amd64 arch (x86_64, NOT Itanium)
  • NPY_CPU_PPC: 32 bits ppc
  • NPY_CPU_PPC64: 64 bits ppc
  • NPY_CPU_SPARC: 32 bits sparc
  • NPY_CPU_SPARC64: 64 bits sparc
  • NPY_CPU_S390: S390
  • NPY_CPU_IA64: ia64
  • NPY_CPU_PARISC: PARISC

New macros for CPU endianness has been added as well (see internal changesbelow for details):

  • NPY_BYTE_ORDER: integer
  • NPY_LITTLE_ENDIAN/NPY_BIG_ENDIAN defines

Those provide portable alternatives to glibc endian.h macros for platformswithout it.

Portable NAN, INFINITY, etc…

npy_math.h now makes available several portable macro to get NAN, INFINITY:

  • NPY_NAN: equivalent to NAN, which is a GNU extension
  • NPY_INFINITY: equivalent to C99 INFINITY
  • NPY_PZERO, NPY_NZERO: positive and negative zero respectively

Corresponding single and extended precision macros are available as well. Allreferences to NAN, or home-grown computation of NAN on the fly have beenremoved for consistency.

Internal changes

numpy.core math configuration revamp

This should make the porting to new platforms easier, and more robust. Inparticular, the configuration stage does not need to execute any code on thetarget platform, which is a first step toward cross-compilation.

http://numpy.github.io/neps/math_config_clean.html

umath refactor

A lot of code cleanup for umath/ufunc code (charris).

Improvements to build warnings

Numpy can now build with -W -Wall without warnings

http://numpy.github.io/neps/warnfix.html

Separate core math library

The core math functions (sin, cos, etc… for basic C types) have been put intoa separate library; it acts as a compatibility layer, to support most C99 mathsfunctions (real only for now). The library includes platform-specific fixes forvarious maths functions, such as using those versions should be more robustthan using your platform functions directly. The API for existing functions isexactly the same as the C99 math functions API; the only difference is the npyprefix (npy_cos vs cos).

The core library will be made available to any extension in 1.4.0.

CPU arch detection

npy_cpu.h defines numpy specific CPU defines, such as NPY_CPU_X86, etc…Those are portable across OS and toolchains, and set up when the header isparsed, so that they can be safely used even in the case of cross-compilation(the values is not set when numpy is built), or for multi-arch binaries (e.g.fat binaries on Max OS X).

npy_endian.h defines numpy specific endianness defines, modeled on the glibcendian.h. NPY_BYTE_ORDER is equivalent to BYTE_ORDER, and one ofNPY_LITTLE_ENDIAN or NPY_BIG_ENDIAN is defined. As for CPU archs, those are setwhen the header is parsed by the compiler, and as such can be used forcross-compilation and multi-arch binaries.

Table Of Contents

Previous topic

Current steering council and institutional partners

Next topic

About NumPy

Quick search

  • © Copyright 2008-2018, The SciPy community.
  • Last updated on Jul 24, 2018.
  • Created usingSphinx 1.6.6.

[8]ページ先頭

©2009-2025 Movatter.jp