|
| 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>`__) |
0 commit comments