@@ -8,6 +8,25 @@ This document contains a set of instructions on how to update your code to
8
8
work with Numpy 2.0.
9
9
10
10
11
+ Ruff plugin
12
+ ===========
13
+
14
+ Many of the changes covered in the 2.0 release notes and in this migration
15
+ guide can be automatically adapted to in downstream code with a dedicated
16
+ `Ruff <https://docs.astral.sh/ruff/ >`__ rule, namely rule
17
+ `NPY201 <https://docs.astral.sh/ruff/rules/numpy2-deprecation/ >`_.
18
+
19
+ You should install ``ruff>=0.2.0 `` and add the ``NPY201 `` rule to your
20
+ ``pyproject.toml ``::
21
+
22
+ [tool.ruff.lint]
23
+ select = ["NPY201"]
24
+
25
+ You can also apply the NumPy 2.0 rule directly from the command line::
26
+
27
+ $ ruff check path/to/code/ --select NPY201
28
+
29
+
11
30
.. _migration_promotion_changes :
12
31
13
32
Changes to NumPy data type promotion
@@ -188,8 +207,8 @@ The underlying type remains a struct under C++ (all of the above still remains
188
207
valid).
189
208
190
209
191
- Namespace changes
192
- =================
210
+ Changes to namespaces
211
+ =====================
193
212
194
213
In NumPy 2.0 certain functions, modules, and constants were moved or removed
195
214
to make the NumPy namespace more user-friendly by removing unnecessary or
@@ -298,8 +317,8 @@ downstream libraries we don't provide any information on how to replace them:
298
317
``MAY_SHARE_BOUNDS ``]
299
318
300
319
301
- Lib namespace
302
- -------------
320
+ numpy.lib namespace
321
+ -------------------
303
322
304
323
Most of the functions available within ``np.lib `` are also present in the main
305
324
namespace, which is their primary location. To make it unambiguous how to access each
@@ -321,10 +340,10 @@ the main namespace, then you're using a private member. You should either use th
321
340
API or, in case it's infeasible, reach out to us with a request to restore the removed entry.
322
341
323
342
324
- Core namespace
325
- --------------
343
+ numpy.core namespace
344
+ --------------------
326
345
327
- ``np.core `` namespace is now officially private and has been renamed to ``np._core ``.
346
+ The ``np.core `` namespace is now officially private and has been renamed to ``np._core ``.
328
347
The user should never fetch members from the ``_core `` directly - instead the main
329
348
namespace should be used to access the attribute in question. The layout of the ``_core ``
330
349
module might change in the future without notice, contrary to public modules which adhere
@@ -333,8 +352,8 @@ then you should either use the existing API or, in case it's infeasible, reach o
333
352
with a request to restore the removed entry.
334
353
335
354
336
- ndarray and scalar namespace
337
- ----------------------------
355
+ ndarray and scalar methods
356
+ --------------------------
338
357
339
358
A few methods from ``np.ndarray `` and ``np.generic `` scalar classes have been removed.
340
359
The table below provides replacements for the removed members:
@@ -349,32 +368,18 @@ setitem Use ``arr[index] = value`` instead.
349
368
====================== ========================================================
350
369
351
370
352
- Strings namespace
353
- -----------------
371
+ numpy.strings namespace
372
+ -----------------------
354
373
355
- A new `` np .strings` ` namespace has been created, where most of the string
356
- operations are implemented as ufuncs. The old `` np .char` ` namespace still is
374
+ A new `numpy .strings ` namespace has been created, where most of the string
375
+ operations are implemented as ufuncs. The old `numpy .char ` namespace still is
357
376
available, and, wherever possible, uses the new ufuncs for greater performance.
358
- We recommend using the ``np.strings `` methods going forward. The ``np.char ``
359
- namespace may be deprecated in the future.
360
-
361
-
362
- Ruff plugin
363
- -----------
364
-
365
- All the changes that we covered in the previous sections can be automatically applied
366
- to the codebase with the dedicated Ruff rule,
367
- `NPY201 <https://docs.astral.sh/ruff/rules/numpy2-deprecation/ >`_.
377
+ We recommend using the `~numpy.strings ` function going forward. The
378
+ `~numpy.char ` namespace may be deprecated in the future.
368
379
369
- You should install Ruff, version ``0.2.0 `` or above, and add the ``NPY201 `` rule to
370
- your ``pyproject.toml ``::
371
380
372
- [tool.ruff.lint]
373
- select = ["NPY201"]
374
-
375
- You can run NumPy 2.0 rule also directly from the command line::
376
-
377
- $ ruff check path/to/code/ --select NPY201
381
+ Other changes
382
+ =============
378
383
379
384
380
385
Note about pickled files
0 commit comments