summaryrefslogtreecommitdiff
path: root/doc/release/2.0.0-notes.rst
blob: 0ba7594fecb858b4d85187c3cd673bc97fcdcf4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
=========================
NumPy 2.0.0 Release Notes
=========================

[Possibly 1.7.0 release notes, as ABI compatibility is still being maintained]

Highlights
==========


New features
============


Mask-based NA missing values
----------------------------

Support for NA missing values similar to those in R has been implemented.
This was done by adding optional NA masks to the core array object.

While a significant amount of the NumPy functionality has been extended to
support NA masks, not everything is yet supported. Here is a list of things
that do and do not work with NA values:

What works with NA:
    * Basic indexing and slicing, as well as full boolean mask indexing.
    * All element-wise ufuncs.
    * UFunc.reduce methods, with a new skipna parameter.
    * Array methods:
       + ndarray.clip, ndarray.min, ndarray.max, ndarray.sum, ndarray.prod,
         ndarray.conjugate, ndarray.diagonal
       + numpy.concatenate, numpy.column_stack, numpy.hstack,
         numpy.vstack, numpy.dstack

What doesn't work with NA:
    * Fancy indexing, such as with lists and partial boolean masks.
    * ndarray.flat and any other methods that use the old iterator
      mechanism instead of the newer nditer.
    * UFunc.reduce of multi-dimensional arrays, with skipna=True and a ufunc
      that doesn't have an identity.
    * UFunc.accumulate, UFunc.reduceat.
    * np.logical_and, np.logical_or, np.all, and np.any don't satisfy the
      rules NA | True == True and NA & False == False yet.
    * Array methods:
       + ndarray.argmax, ndarray.argmin,
       + numpy.repeat


Custom formatter for printing arrays
------------------------------------



Changes
=======

The default casting rule for UFunc out= parameters has been changed from
'unsafe' to 'same_kind'.  Most usages which violate the 'same_kind'
rule are likely bugs, so this change may expose previously undetected
errors in projects that depend on NumPy.

The functions np.diag, np.diagonal, and <ndarray>.diagonal now return a
view into the original array instead of making a copy. This makes these
functions more consistent with NumPy's general approach of taking views
where possible, and performs much faster as well.

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


Deprecations
============

Specifying a custom string formatter with a `_format` array attribute is
deprecated. The new `formatter` keyword in ``numpy.set_printoptions`` or
``numpy.array2string`` can be used instead.

In the C API, direct access to the fields of PyArrayObject* has been
deprecated. Direct access has been recommended against for many releases, but
now you can test your code against the deprecated C API by #defining
NPY_NO_DEPRECATED_API before including any NumPy headers. Expect
something similar for PyArray_Descr* and other core objects in the
future as preparation for NumPy 2.0.