Metadata-Version: 1.2
Name: numpy
-Version: 1.23.0
+Version: 1.23.1
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
--- /dev/null
+
+Contributors
+============
+
+A total of 7 people contributed to this release. People with a "+" by their
+names contributed a patch for the first time.
+
+* Charles Harris
+* Matthias Koeppe +
+* Pranab Das +
+* Rohit Goswami
+* Sebastian Berg
+* Serge Guelton
+* Srimukh Sripada +
+
+Pull requests merged
+====================
+
+A total of 8 pull requests were merged for this release.
+
+* `#21866 <https://github.com/numpy/numpy/pull/21866>`__: BUG: Fix discovered MachAr (still used within valgrind)
+* `#21867 <https://github.com/numpy/numpy/pull/21867>`__: BUG: Handle NaNs correctly for float16 during sorting
+* `#21868 <https://github.com/numpy/numpy/pull/21868>`__: BUG: Use ``keepdims`` during normalization in ``np.average`` and...
+* `#21869 <https://github.com/numpy/numpy/pull/21869>`__: DOC: mention changes to ``max_rows`` behaviour in ``np.loadtxt``
+* `#21870 <https://github.com/numpy/numpy/pull/21870>`__: BUG: Reject non integer array-likes with size 1 in delete
+* `#21949 <https://github.com/numpy/numpy/pull/21949>`__: BLD: Make can_link_svml return False for 32bit builds on x86_64
+* `#21951 <https://github.com/numpy/numpy/pull/21951>`__: BUG: Reorder extern "C" to only apply to function declarations...
+* `#21952 <https://github.com/numpy/numpy/pull/21952>`__: BUG: Fix KeyError in crackfortran operator support
.. toctree::
:maxdepth: 3
+ 1.23.1 <release/1.23.1-notes>
1.23.0 <release/1.23.0-notes>
1.22.4 <release/1.22.4-notes>
1.22.3 <release/1.22.3-notes>
--- /dev/null
+.. currentmodule:: numpy
+
+==========================
+NumPy 1.23.1 Release Notes
+==========================
+
+The NumPy 1.23.1 is a maintenance release that fixes bugs discovered after the
+1.23.0 release. Notable fixes are:
+
+- Fix searchsorted for float16 NaNs
+- Fix compilation on Apple M1
+- Fix KeyError in crackfortran operator support (Slycot)
+
+The Python version supported for this release are 3.8-3.10.
+
+
+Contributors
+============
+
+A total of 7 people contributed to this release. People with a "+" by their
+names contributed a patch for the first time.
+
+* Charles Harris
+* Matthias Koeppe +
+* Pranab Das +
+* Rohit Goswami
+* Sebastian Berg
+* Serge Guelton
+* Srimukh Sripada +
+
+
+Pull requests merged
+====================
+
+A total of 8 pull requests were merged for this release.
+
+* `#21866 <https://github.com/numpy/numpy/pull/21866>`__: BUG: Fix discovered MachAr (still used within valgrind)
+* `#21867 <https://github.com/numpy/numpy/pull/21867>`__: BUG: Handle NaNs correctly for float16 during sorting
+* `#21868 <https://github.com/numpy/numpy/pull/21868>`__: BUG: Use ``keepdims`` during normalization in ``np.average`` and...
+* `#21869 <https://github.com/numpy/numpy/pull/21869>`__: DOC: mention changes to ``max_rows`` behaviour in ``np.loadtxt``
+* `#21870 <https://github.com/numpy/numpy/pull/21870>`__: BUG: Reject non integer array-likes with size 1 in delete
+* `#21949 <https://github.com/numpy/numpy/pull/21949>`__: BLD: Make can_link_svml return False for 32bit builds on x86_64
+* `#21951 <https://github.com/numpy/numpy/pull/21951>`__: BUG: Reorder extern "C" to only apply to function declarations...
+* `#21952 <https://github.com/numpy/numpy/pull/21952>`__: BUG: Fix KeyError in crackfortran operator support
+
version_json = '''
{
- "date": "2022-06-22T13:57:27-0600",
+ "date": "2022-07-08T16:31:18-0600",
"dirty": false,
"error": null,
- "full-revisionid": "54c52f13713f3d21795926ca4dbb27e16fada171",
- "version": "1.23.0"
+ "full-revisionid": "1f82da745496092d85b402b1703877462a7c2de2",
+ "version": "1.23.1"
}
''' # END VERSION_JSON
self.tiny = self.xmin
self.huge = self.xmax
self.smallest_normal = self.xmin
+ self._str_smallest_normal = float_to_str(self.xmin)
self.smallest_subnormal = float_to_float(smallest_subnormal)
+ self._str_smallest_subnormal = float_to_str(smallest_subnormal)
import math
self.precision = int(-math.log10(float_to_float(self.eps)))
return ma_like
# Fall back to parameter discovery
warnings.warn(
- 'Signature {} for {} does not match any known type: '
- 'falling back to type probe function'.format(key, ftype),
+ f'Signature {key} for {ftype} does not match any known type: '
+ 'falling back to type probe function.\n'
+ 'This warnings indicates broken support for the dtype!',
UserWarning, stacklevel=2)
return _discovered_machar(ftype)
#ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_MATH_H_
#define NUMPY_CORE_INCLUDE_NUMPY_NPY_MATH_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include <numpy/npy_common.h>
#include <math.h>
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* NAN and INFINITY like macros (same behavior as glibc for NAN, same as C99
* for INFINITY)
import os
import sys
+import sysconfig
import pickle
import copy
import warnings
-import platform
import textwrap
import glob
from os.path import join
"""
if NPY_DISABLE_SVML:
return False
- machine = platform.machine()
- system = platform.system()
- return "x86_64" in machine and system == "Linux"
+ platform = sysconfig.get_platform()
+ return ("x86_64" in platform
+ and "linux" in platform
+ and sys.maxsize > 2**31)
def check_svml_submodule(svmlpath):
if not os.path.exists(svmlpath + "/README.md"):
npy::bool_tag, npy::byte_tag, npy::ubyte_tag, npy::short_tag,
npy::ushort_tag, npy::int_tag, npy::uint_tag, npy::long_tag,
npy::ulong_tag, npy::longlong_tag, npy::ulonglong_tag,
- npy::half_tag, npy::float_tag, npy::double_tag,
- npy::longdouble_tag, npy::cfloat_tag, npy::cdouble_tag,
- npy::clongdouble_tag, npy::datetime_tag, npy::timedelta_tag>;
+ npy::float_tag, npy::double_tag, npy::longdouble_tag,
+ npy::cfloat_tag, npy::cdouble_tag, npy::clongdouble_tag,
+ npy::datetime_tag, npy::timedelta_tag, npy::half_tag>;
static constexpr std::array<value_type, taglist::size> map =
make_binsearch_map(taglist());
assert_raises(ValueError, d.sort, kind=k)
assert_raises(ValueError, d.argsort, kind=k)
- def test_searchsorted(self):
- # test for floats and complex containing nans. The logic is the
- # same for all float types so only test double types for now.
- # The search sorted routines use the compare functions for the
- # array type, so this checks if that is consistent with the sort
- # order.
-
- # check double
- a = np.array([0, 1, np.nan])
- msg = "Test real searchsorted with nans, side='l'"
+ @pytest.mark.parametrize('a', [
+ np.array([0, 1, np.nan], dtype=np.float16),
+ np.array([0, 1, np.nan], dtype=np.float32),
+ np.array([0, 1, np.nan]),
+ ])
+ def test_searchsorted_floats(self, a):
+ # test for floats arrays containing nans. Explicitly test
+ # half, single, and double precision floats to verify that
+ # the NaN-handling is correct.
+ msg = "Test real (%s) searchsorted with nans, side='l'" % a.dtype
b = a.searchsorted(a, side='left')
assert_equal(b, np.arange(3), msg)
- msg = "Test real searchsorted with nans, side='r'"
+ msg = "Test real (%s) searchsorted with nans, side='r'" % a.dtype
b = a.searchsorted(a, side='right')
assert_equal(b, np.arange(1, 4), msg)
# check keyword arguments
a.searchsorted(v=1)
+ x = np.array([0, 1, np.nan], dtype='float32')
+ y = np.searchsorted(x, x[-1])
+ assert_equal(y, 2)
+
+ def test_searchsorted_complex(self):
+ # test for complex arrays containing nans.
+ # The search sorted routines use the compare functions for the
+ # array type, so this checks if that is consistent with the sort
+ # order.
# check double complex
a = np.zeros(9, dtype=np.complex128)
a.real += [0, 0, 1, 1, 0, 1, np.nan, np.nan, np.nan]
a = np.array([0, 128], dtype='>i4')
b = a.searchsorted(np.array(128, dtype='>i4'))
assert_equal(b, 1, msg)
-
+
+ def test_searchsorted_n_elements(self):
# Check 0 elements
a = np.ones(0)
b = a.searchsorted([0, 1, 2], 'left')
b = a.searchsorted([0, 1, 2], 'right')
assert_equal(b, [0, 2, 2])
+ def test_searchsorted_unaligned_array(self):
# Test searching unaligned array
a = np.arange(10)
aligned = np.empty(a.itemsize * a.size + 1, 'uint8')
b = a.searchsorted(unaligned, 'right')
assert_equal(b, a + 1)
+ def test_searchsorted_resetting(self):
# Test smart resetting of binsearch indices
a = np.arange(5)
b = a.searchsorted([6, 5, 4], 'left')
b = a.searchsorted([6, 5, 4], 'right')
assert_equal(b, [5, 5, 5])
+ def test_searchsorted_type_specific(self):
# Test all type specific binary search functions
types = ''.join((np.typecodes['AllInteger'], np.typecodes['AllFloat'],
np.typecodes['Datetime'], '?O'))
as_ = args
b = postcrack(b, as_, tab=tab + '\t')
if b['block'] in ['interface', 'abstract interface'] and \
- not b['body'] and not b['implementedby']:
+ not b['body'] and not b.get('implementedby'):
if 'f2pyenhancements' not in b:
continue
if b['block'].replace(' ', '') == 'pythonmodule':
wgt = np.broadcast_to(wgt, (a.ndim-1)*(1,) + wgt.shape)
wgt = wgt.swapaxes(-1, axis)
- scl = wgt.sum(axis=axis, dtype=result_dtype)
+ scl = wgt.sum(axis=axis, dtype=result_dtype, **keepdims_kw)
if np.any(scl == 0.0):
raise ZeroDivisionError(
"Weights sum to zero, can't be normalized")
single_value = False
_obj = obj
obj = np.asarray(obj)
+ # `size == 0` to allow empty lists similar to indexing, but (as there)
+ # is really too generic:
if obj.size == 0 and not isinstance(_obj, np.ndarray):
obj = obj.astype(intp)
- elif obj.size == 1 and not isinstance(_obj, bool):
- obj = obj.astype(intp).reshape(())
+ elif obj.size == 1 and obj.dtype.kind in "ui":
+ # For a size 1 integer array we can use the single-value path
+ # (most dtypes, except boolean, should just fail later).
+ obj = obj.item()
single_value = True
if single_value:
.. versionadded:: 1.14.0
max_rows : int, optional
- Read `max_rows` lines of content after `skiprows` lines. The default
- is to read all the lines.
+ Read `max_rows` rows of content after `skiprows` lines. The default is
+ to read all the rows. Note that empty rows containing no data such as
+ empty lines and comment lines are not counted towards `max_rows`,
+ while such lines are counted in `skiprows`.
.. versionadded:: 1.16.0
+
+ .. versionchanged:: 1.23.0
+ Lines containing no data, including comment lines (e.g., lines
+ starting with '#' or as specified via `comments`) are not counted
+ towards `max_rows`.
quotechar : unicode character or None, optional
The character used to denote the start and end of a quoted item.
Occurrences of the delimiter or comment characters are ignored within
assert_(np.average(y3, weights=w3).dtype == np.result_type(y3, w3))
+ # test weights with `keepdims=False` and `keepdims=True`
+ x = np.array([2, 3, 4]).reshape(3, 1)
+ w = np.array([4, 5, 6]).reshape(3, 1)
+
+ actual = np.average(x, weights=w, axis=1, keepdims=False)
+ desired = np.array([2., 3., 4.])
+ assert_array_equal(actual, desired)
+
+ actual = np.average(x, weights=w, axis=1, keepdims=True)
+ desired = np.array([[2.], [3.], [4.]])
+ assert_array_equal(actual, desired)
+
def test_returned(self):
y = np.array([[1, 2, 3], [4, 5, 6]])
with pytest.raises(IndexError):
np.delete([0, 1, 2], np.array([], dtype=float))
- def test_single_item_array(self):
- a_del = delete(self.a, 1)
- a_del_arr = delete(self.a, np.array([1]))
- a_del_lst = delete(self.a, [1])
- a_del_obj = delete(self.a, np.array([1], dtype=object))
- assert_equal(a_del, a_del_arr, a_del_lst, a_del_obj)
-
- nd_a_del = delete(self.nd_a, 1, axis=1)
- nd_a_del_arr = delete(self.nd_a, np.array([1]), axis=1)
- nd_a_del_lst = delete(self.nd_a, [1], axis=1)
- nd_a_del_obj = delete(self.nd_a, np.array([1], dtype=object), axis=1)
- assert_equal(nd_a_del, nd_a_del_arr, nd_a_del_lst, nd_a_del_obj)
+ @pytest.mark.parametrize("indexer", [np.array([1]), [1]])
+ def test_single_item_array(self, indexer):
+ a_del_int = delete(self.a, 1)
+ a_del = delete(self.a, indexer)
+ assert_equal(a_del_int, a_del)
+
+ nd_a_del_int = delete(self.nd_a, 1, axis=1)
+ nd_a_del = delete(self.nd_a, np.array([1]), axis=1)
+ assert_equal(nd_a_del_int, nd_a_del)
+
+ def test_single_item_array_non_int(self):
+ # Special handling for integer arrays must not affect non-integer ones.
+ # If `False` was cast to `0` it would delete the element:
+ res = delete(np.ones(1), np.array([False]))
+ assert_array_equal(res, np.ones(1))
+
+ # Test the more complicated (with axis) case from gh-21840
+ x = np.ones((3, 1))
+ false_mask = np.array([False], dtype=bool)
+ true_mask = np.array([True], dtype=bool)
+
+ res = delete(x, false_mask, axis=-1)
+ assert_array_equal(res, x)
+ res = delete(x, true_mask, axis=-1)
+ assert_array_equal(res, x[:, :0])
+
+ # Object or e.g. timedeltas should *not* be allowed
+ with pytest.raises(IndexError):
+ delete(np.ones(2), np.array([0], dtype=object))
+
+ with pytest.raises(IndexError):
+ # timedeltas are sometimes "integral, but clearly not allowed:
+ delete(np.ones(2), np.array([0], dtype="m8[ns]"))
class TestGradient:
wgt = wgt*(~a.mask)
wgt.mask |= a.mask
- scl = wgt.sum(axis=axis, dtype=result_dtype)
+ scl = wgt.sum(axis=axis, dtype=result_dtype, **keepdims_kw)
avg = np.multiply(a, wgt,
dtype=result_dtype).sum(axis, **keepdims_kw) / scl
a2dma = average(a2dm, axis=1)
assert_equal(a2dma, [1.5, 4.0])
+ def test_testAverage4(self):
+ # Test that `keepdims` works with average
+ x = np.array([2, 3, 4]).reshape(3, 1)
+ b = np.ma.array(x, mask=[[False], [False], [True]])
+ w = np.array([4, 5, 6]).reshape(3, 1)
+ actual = average(b, weights=w, axis=1, keepdims=True)
+ desired = masked_array([[2.], [3.], [4.]], [[False], [False], [True]])
+ assert_equal(actual, desired)
+
def test_onintegers_with_mask(self):
# Test average on integers with mask
a = average(array([1, 2]))
#-----------------------------------
# Path to the release notes
-RELEASE_NOTES = 'doc/source/release/1.23.0-notes.rst'
+RELEASE_NOTES = 'doc/source/release/1.23.1-notes.rst'
#-------------------------------------------------------