8000 MAINT: rework release note, changes from review · mattip/numpy@ed2e7ac · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ed2e7ac

Browse files
committed
MAINT: rework release note, changes from review
1 parent 6541cf5 commit ed2e7ac

File tree

6 files changed

+309
-23
lines changed

6 files changed

+309
-23
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
``ufunc.at`` can be much faster
22
-------------------------------
3-
If called on ufuncs with appropriate indexed loops, ``ufunc.at`` can be up to
4-
60x faster. Generic ``ufunc.at`` can be up to 9x faster. The conditions for
5-
any speedup::
3+
Generic ``ufunc.at`` can be up to 9x faster. The conditions for this speedup:
64

75
- contiguous arguments
86
- no casting
97

10-
The conditions for the extra speedup::
11-
12-
- calling the ufuncs ``add``, ``subtract``, ``multiply``, ``divide`` (and
13-
``floor_divide``)
14-
- 1d arguments
8+
If ufuncs with appropriate indexed loops on 1d arguments with the above
9+
conditions, ``ufunc.at`` can be up to 60x faster (an additional 7x speedup).
10+
Appropriate indexed loops have been added to ``add``, ``subtract``,
11+
``multiply``, ``divide`` (and ``floor_divide``)
1512

1613
The internal logic is similar to the logic used for regular ufuncs, which also
1714
have a fast path for contiguous, non-casting, 1d arrays.
15+
16+
Thanks to the `D. E. Shaw group <https://deshaw.com/>`_ for sponsoring this
17+
work.
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
=============================
2+
NumPy 1.25.dev0 Release Notes
3+
=============================
4+
5+
6+
Deprecations
7+
============
8+
9+
* ``np.core.MachAr`` is deprecated. It is private API. In names
10+
defined in ``np.core`` should generally be considered private.
11+
12+
(`gh-22638 <https://github.com/numpy/numpy/pull/22638>`__)
13+
14+
* ``np.finfo(None)`` is deprecated.
15+
16+
(`gh-23011 <https://github.com/numpy/numpy/pull/23011>`__)
17+
18+
19+
Expired deprecations
20+
====================
21+
22+
* ``np.core.machar`` and ``np.finfo.machar`` have been removed.
23+
24+
(`gh-22638 <https://github.com/numpy/numpy/pull/22638>`__)
25+
26+
* ``+arr`` will now raise an error when the dtype is not
27+
numeric (and positive is undefined).
28+
29+
(`gh-22998 <https://github.com/numpy/numpy/pull/22998>`__)
30+
31+
* A sequence must now be passed into the stacking family of functions
32+
(``stack``, ``vstack``, ``hstack``, ``dstack`` and ``column_stack``).
33+
34+
(`gh-23019 <https://github.com/numpy/numpy/pull/23019>`__)
35+
36+
``==`` and ``!=`` warnings finalized
37+
------------------------------------
38+
The ``==`` and ``!=`` operators on arrays now always:
39+
40+
* raise errors that occur during comparisons such as when the arrays
41+
have incompatible shapes (``np.array([1, 2]) == np.array([1, 2, 3])``).
42+
* return an array of all ``True`` or all ``False`` when values are
43+
fundamentally not comparable (e.g. have different dtypes). An example
44+
is ``np.array(["a"]) == np.array([1])``.
45+
46+
This mimics the Python behavior of returning ``False`` and ``True``
47+
when comparing incompatible types like ``"a" == 1`` and ``"a" != 1``.
48+
For a long time these gave ``DeprecationWarning`` or ``FutureWarning``.
49+
50+
(`gh-22707 <https://github.com/numpy/numpy/pull/22707>`__)
51+
52+
Nose suppport has been removed
53+
------------------------------
54+
NumPy switched to using pytest in 2018 and nose has been unmaintained for many
55+
years. We have kept NumPy's nose support to avoid breaking downstream projects
56+
who might have been using it and not yet switched to pytest or some other
57+
testing framework. With the arrival of Python 3.12, unpatched nose will raise
58+
an error. It is time to move on.
59+
60+
Decorators removed
61+
^^^^^^^^^^^^^^^^^^
62+
- raises
63+
- slow
64+
- setastest
65+
- skipif
66+
- knownfailif
67+
- deprecated
68+
- parametrize
69+
- _needs_refcount
70+
71+
These are not to be confused with pytest versions with similar names, e.g.,
72+
pytest.mark.slow, pytest.mark.skipif, pytest.mark.parametrize.
73+
74+
Functions removed
75+
^^^^^^^^^^^^^^^^^
76+
- Tester
77+
- import_nose
78+
- run_module_suite
79+
80+
(`gh-23041 <https://github.com/numpy/numpy/pull/23041>`__)
81+
82+
The ``numpy.testing.utils`` shim has been removed.
83+
--------------------------------------------------
84+
Importing from the ``numpy.testing.utils`` shim has been deprecated since 2019,
85+
the shim has now been removed. All imports should be made directly from
86+
``numpy.testing``.
87+
88+
(`gh-23060 <https://github.com/numpy/numpy/pull/23060>`__)
89+
90+
91+
Compatibility notes
92+
===================
93+
94+
* When comparing datetimes and timedelta using ``np.equal`` or ``np.not_equal``
95+
numpy previously allowed the comparison with ``casting="unsafe"``.
96+
This operation now fails. Forcing the output dtype using the ``dtype``
97+
kwarg can make the operation succeed, but we do not recommend it.
98+
99+
(`gh-22707 <https://github.com/numpy/numpy/pull/22707>`__)
100+
101+
* When loading data from a file handle using ``np.load``,
102+
if the handle is at the end of file, as can happen when reading
103+
multiple arrays by calling ``np.load`` repeatedly, numpy previously
104+
raised ``ValueError`` if ``allow_pickle=False``, and ``OSError`` if
105+
``allow_pickle=True``. Now it raises ``EOFError`` instead, in both cases.
106+
107+
(`gh-23105 <https://github.com/numpy/numpy/pull/23105>`__)
108+
109+
``np.pad`` with ``mode=wrap`` pads with strict multiples of original data
110+
-------------------------------------------------------------------------
111+
112+
Code based on earlier version of ``pad`` that uses ``mode="wrap"`` will return
113+
different results when the padding size is larger than initial array.
114+
115+
``np.pad`` with ``mode=wrap`` now always fills the space with
116+
strict multiples of original data even if the padding size is larger than the
117+
initial array.
118+
119+
(`gh-22575 <https://github.com/numpy/numpy/pull/22575>`__)
120+
121+
Cython ``long_t`` and ``ulong_t`` removed
122+
-----------------------------------------
123+
``long_t`` and ``ulong_t`` were aliases for ``longlong_t`` and ``ulonglong_t``
124+
and confusing (a remainder from of Python 2). This change may lead to the errors::
125+
126+
'long_t' is not a type identifier
127+
'ulong_t' is not a type identifier
128+
129+
We recommend use of bit-sized types such as ``cnp.int64_t`` or the use of
130+
``cnp.intp_t`` which is 32 bits on 32 bit systems and 64 bits on 64 bit
131+
systems (this is most compatible with indexing).
132+
If C ``long`` is desired, use plain ``long`` or ``npy_long``.
133+
``cnp.int_t`` is also ``long`` (NumPy's default integer). However, ``long``
134+
is 32 bit on 64 bit windows and we may wish to adjust this even in NumPy.
135+
(Please do not hesitate to contact NumPy developers if you are curious about this.)
136+
137+
(`gh-22637 <https://github.com/numpy/numpy/pull/22637>`__)
138+
139+
Changed error message and type for bad ``axes`` argument to ``ufunc``
140+
---------------------------------------------------------------------
141+
The error message and type when a wrong ``axes`` value is passed to
142+
``ufunc(..., axes=[...])``` has changed. The message is now more indicative of
143+
the problem, and if the value is mismatched an ``AxisError`` will be raised.
144+
A ``TypeError`` will still be raised for invalid input types.
145+
146+
(`gh-22675 <https://github.com/numpy/numpy/pull/22675>`__)
147+
148+
149+
New Features
150+
============
151+
152+
NumPy now has an ``np.exceptions`` namespace
153+
--------------------------------------------
154+
NumPy now has a dedicated namespace making most exceptions
155+
and warnings available. All of these remain available in the
156+
main namespace, although some may be moved slowly in the future.
157+
The main reason for this is to increase discoverably and add
158+
future exceptions.
159+
160+
(`gh-22644 <https://github.com/numpy/numpy/pull/22644>`__)
161+
162+
String functions in np.char are compatible with NEP 42 custom dtypes
163+
--------------------------------------------------------------------
164+
Custom dtypes that represent unicode strings or byte strings can now be
165+
passed to the string functions in np.char.
166+
167+
(`gh-22863 <https://github.com/numpy/numpy/pull/22863>`__)
168+
169+
String dtype instances can be created from the string abstract dtype classes
170+
----------------------------------------------------------------------------
171+
It is now possible to create a string dtype instance with a size without
172+
using the string name of the dtype. For example, ``type(np.dtype('U'))(8)``
173+
will create a dtype that is equivalent to ``np.dtype('U8')``. This feature
174+
is most useful when writing generic code dealing with string dtype
175+
classes.
176+
177+
(`gh-22963 <https://github.com/numpy/numpy/pull/22963>`__)
178+
179+
180+
Improvements
181+
============
182+
183+
- The ``NDArrayOperatorsMixin`` class now specifies that it contains no
184+
``__slots__`` ensureing that subclasses can now make use of this feature in
185+
Python.
186+
187+
(`gh-23113 <https://github.com/numpy/numpy/pull/23113>`__)
188+
189+
Fix power of complex zero
190+
-------------------------
191+
``np.power`` now returns a different result for ``0^{non-zero}``
192+
for complex numbers. Note that the value is only defined when
193+
the real part of the exponent is larger than zero.
194+
Previously, NaN was returned unless the imaginary part was strictly
195+
zero. The return value is either ``0+0j`` or ``0-0j``.
196+
197+
(`gh-18535 <https://github.com/numpy/numpy/pull/18535>`__)
198+
199+
New ``DTypePromotionError``
200+
---------------------------
201+
NumPy now has a new ``DTypePromotionError`` which is used when two
202+
dtypes cannot be promoted to a common one, for example::
203+
204+
np.result_type("M8[s]", np.complex128)
205+
206+
raises this new exception.
207+
208+
(`gh-22707 <https://github.com/numpy/numpy/pull/22707>`__)
209+
210+
`np.show_config` uses information from Meson
211+
--------------------------------------------
212+
Build and system information now contains information from Meson.
213+
`np.show_config` now has a new optional parameter ``mode`` to help
214+
customize the output.
215+
216+
(`gh-22769 <https://github.com/numpy/numpy/pull/22769>`__)
217+
218+
Fix ``np.ma.diff`` not preserving the mask when called with arguments prepend/append.
219+
-------------------------------------------------------------------------------------
220+
Calling ``np.ma.diff`` with arguments prepend and/or append now returns a
221+
``MaskedArray`` with the input mask preserved.
222+
223+
Previously, a ``MaskedArray`` without the mask was returned.
224+
225+
(`gh-22776 <https://github.com/numpy/numpy/pull/22776>`__)
226+
227+
Corrected error handling for NumPy C-API in Cython
228+
--------------------------------------------------
229+
Many NumPy C functions defined for use in Cython were lacking the
230+
correct error indicator like ``except -1`` or ``except *``.
231+
These have now been added.
232+
233+
(`gh-22997 <https://github.com/numpy/numpy/pull/22997>`__)
234+
235+
236+
Performance improvements and changes
237+
====================================
238+
239+
``__array_function__`` machinery is now much faster
240+
---------------------------------------------------
241+
The overhead of the majority of functions in NumPy is now smaller
242+
especially when keyword arguments are used. This change significantly
243+
speeds up many simple function calls.
244+
245+
(`gh-23020 <https://github.com/numpy/numpy/pull/23020>`__)
246+
247+
``ufunc.at`` can be much faster
248+
-------------------------------
249+
If called on ufuncs with appropriate indexed loops, ``ufunc.at`` can be up to
250+
60x faster. Generic ``ufunc.at`` can be up to 9x faster. The conditions for
251+
any speedup:
252+
253+
- contiguous arguments
254+
- no casting
255+
256+
Additional conditions for the extra speedup:
257+
258+
- calling the ufuncs ``add``, ``subtract``, ``multiply``, ``divide`` (and
259+
``floor_divide``)
260+
- 1d arguments
261+
262+
The internal logic is similar to the logic used for regular ufuncs, which also
263+
have a fast path for contiguous, non-casting, 1d arrays.
264+
265+
Thanks to the `D. E. Shaw group <https://deshaw.com/>`_ for sponsoring this
266+
work.
267+
268+
(`gh-23136 <https://github.com/numpy/numpy/pull/23136>`__)
269+
270+
271+
Changes
272+
=======
273+
274+
Most NumPy functions are wrapped into a C-callable
275+
--------------------------------------------------
276+
To speed up the ``__array_function__`` dispatching, most NumPy functions
277+
are now wrapped into C-callables and are not proper Python functions or
278+
C methods.
279+
They still look and feel the same as before (like a Python function), and this
280+
should only improve performance and user experience (cleaner tracebacks).
281+
However, please inform the NumPy developers if this change confuses your
282+
program for some reason.
283+
284+
(`gh-23020 <https://github.com/numpy/numpy/pull/23020>`__)

numpy/core/src/multiarray/argfunc.dispatch.c.src

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ simd_@func@_@sfx@(npyv_lanetype_@sfx@ *ip, npy_intp len)
194194
npyv_@bsfx@ nnan_ab = npyv_and_@bsfx@(nnan_a, nnan_b);
195195
npyv_@bsfx@ nnan_cd = npyv_and_@bsfx@(nnan_c, nnan_d);
196196
npy_uint64 nnan = npyv_tobits_@bsfx@(npyv_and_@bsfx@(nnan_ab, nnan_cd));
197-
if ((long long int)nnan != ((1LL << vstep) - 1)) {
197+
if ((unsigned long long int)nnan != ((1ULL << vstep) - 1)) {
198198
npy_uint64 nnan_4[4];
199199
nnan_4[0] = npyv_tobits_@bsfx@(nnan_a);
200200
nnan_4[1] = npyv_tobits_@bsfx@(nnan_b);
@@ -219,7 +219,7 @@ simd_@func@_@sfx@(npyv_lanetype_@sfx@ *ip, npy_intp len)
219219
#if @is_fp@
220220
npyv_@bsfx@ nnan_a = npyv_notnan_@sfx@(a);
221221
npy_uint64 nnan = npyv_tobits_@bsfx@(nnan_a);
222-
if ((long long int)nnan != ((1LL << vstep) - 1)) {
222+
if ((unsigned long long int)nnan != ((1ULL << vstep) - 1)) {
223223
for (int vi = 0; vi < vstep; ++vi) {
224224
if (!((nnan >> vi) & 1)) {
225225
return i + vi;

numpy/core/src/umath/loops_arithm_fp.dispatch.c.src

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,14 @@ NPY_NO_EXPORT int NPY_CPU_DISPATCH_CURFX(@TYPE@_@kind@_indexed)
551551
(PyArrayMethod_Context *NPY_UNUSED(context), char * const*args, npy_intp const *dimensions, npy_intp const *steps, NpyAuxData *NPY_UNUSED(func))
552552
{
553553
char *ip1 = args[0];
554-
npy_intp *indx = (npy_intp *)args[1];
554+
char *indx = args[1];
555555
char *value = args[2];
556-
npy_intp is1 = steps[0], isindex = steps[1] / sizeof(npy_intp), isb = steps[2];
556+
npy_intp is1 = steps[0], isindex = steps[1], isb = steps[2];
557557
npy_intp n = dimensions[0];
558558
npy_intp i;
559559
@type@ *indexed;
560560
for(i = 0; i < n; i++, indx += isindex, value += isb) {
561-
indexed = (@type@ *)(ip1 + is1 * indx[0]);
561+
indexed = (@type@ *)(ip1 + is1 * *(npy_intp *)indx);
562562
indexed[0] = indexed[0] @OP@ *(@type@ *)value;
563563
}
564564
return 0;

numpy/core/src/umath/loops_arithmetic.dispatch.c.src

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,14 @@ NPY_NO_EXPORT int NPY_CPU_DISPATCH_CURFX(@TYPE@_divide_indexed)
400400
(PyArrayMethod_Context *NPY_UNUSED(context), char * const*args, npy_intp co F15A nst *dimensions, npy_intp const *steps, NpyAuxData *NPY_UNUSED(func))
401401
{
402402
char *ip1 = args[0];
403-
npy_intp *indx = (npy_intp *)args[1];
403+
char *indx = args[1];
404404
char *value = args[2];
405-
npy_intp is1 = steps[0], isindex = steps[1] / sizeof(npy_intp), isb = steps[2];
405+
npy_intp is1 = steps[0], isindex = steps[1], isb = steps[2];
406406
npy_intp n = dimensions[0];
407407
npy_intp i;
408408
@type@ *indexed;
409409
for(i = 0; i < n; i++, indx += isindex, value += isb) {
410-
indexed = (@type@ *)(ip1 + is1 * indx[0]);
410+
indexed = (@type@ *)(ip1 + is1 * *(npy_intp *)indx);
411411
indexed[0] = floor_div_@TYPE@(indexed[0], *(@type@ *)value);
412412
}
413413
return 0;
@@ -486,14 +486,14 @@ NPY_NO_EXPORT int NPY_CPU_DISPATCH_CURFX(@TYPE@_divide_indexed)
486486
(PyArrayMethod_Context *NPY_UNUSED(context), char * const*args, npy_intp const *dimensions, npy_intp const *steps, NpyAuxData *NPY_UNUSED(func))
487487
{
488488
char *ip1 = args[0];
489-
npy_intp *indx = (npy_intp *)args[1];
489+
char *indx = args[1];
490490
char *value = args[2];
491-
npy_intp is1 = steps[0], isindex = steps[1] / sizeof(npy_intp), isb = steps[2];
491+
npy_intp is1 = steps[0], isindex = steps[1], isb = steps[2];
492492
npy_intp n = dimensions[0];
493493
npy_intp i;
494494
@type@ *indexed;
495495
for(i = 0; i < n; i++, indx += isindex, value += isb) {
496-
indexed = (@type@ *)(ip1 + is1 * indx[0]);
496+
indexed = (@type@ *)(ip1 + is1 * *(npy_intp *)indx);
497497
@type@ in2 = *(@type@ *)value;
498498
if (NPY_UNLIKELY(in2 == 0)) {
499499
npy_set_floatstatus_divbyzero();

0 commit comments

Comments
 (0)
0