# NumPy 2.0.0 Release Notes#

## NumPy 2.0 Python API removals#

Alias

`np.float_`

has been removed. Use`np.float64`

instead.Alias

`np.complex_`

has been removed. Use`np.complex128`

instead.Alias

`np.longfloat`

has been removed. Use`np.longdouble`

instead.Alias

`np.singlecomplex`

has been removed. Use`np.complex64`

instead.Alias

`np.cfloat`

has been removed. Use`np.complex128`

instead.Alias

`np.longcomplex`

has been removed. Use`np.clongdouble`

instead.Alias

`np.clongfloat`

has been removed. Use`np.clongdouble`

instead.Alias

`np.string_`

has been removed. Use`np.bytes_`

instead.Alias

`np.unicode_`

has been removed. Use`np.str_`

instead.Alias

`np.Inf`

has been removed. Use`np.inf`

instead.Alias

`np.Infinity`

has been removed. Use`np.inf`

instead.Alias

`np.NaN`

has been removed. Use`np.nan`

instead.Alias

`np.infty`

has been removed. Use`np.inf`

instead.Alias

`np.mat`

has been removed. Use`np.asmatrix`

instead.`np.issubclass_`

has been removed. Use`issubclass`

builtin instead.`np.asfarray`

has been removed. Use`np.asarray`

with a proper dtype instead.`np.set_string_function`

has been removed. Use`np.set_printoptions`

instead with a formatter for custom printing of NumPy objects.`np.tracemalloc_domain`

is now only available from`np.lib`

.`np.recfromcsv`

and`recfromtxt`

are now only available from`np.lib.npyio`

.`np.issctype`

,`np.maximum_sctype`

,`np.obj2sctype`

,`np.sctype2char`

,`np.sctypeDict`

,`np.sctypes`

,`np.issubsctype`

were all removed from the main namespace without replacement, as they where niche members.Deprecated

`np.deprecate`

and`np.deprecate_with_doc`

has been removed from the main namespace. Use`DeprecationWarning`

instead.Deprecated

`np.safe_eval`

has been removed from the main namespace. Use`ast.literal_eval`

instead.(gh-24376)

`np.find_common_type`

has been removed. Use`numpy.promote_types`

or`numpy.result_type`

instead. To achieve semantics for the`scalar_types`

argument, use`numpy.result_type`

and pass the Pythonvalues`0`

,`0.0`

, or`0j`

.`np.round_`

has been removed. Use`np.round`

instead.`np.nbytes`

has been removed. Use`np.dtype(<dtype>).itemsize`

instead.(gh-24477)

`np.compare_chararrays`

has been removed from the main namespace. Use`np.char.compare_chararrays`

instead.The

`charrarray`

in the main namespace has been deprecated. It can be imported without a deprecation warning from`np.char.chararray`

for now, but we are planning to fully deprecate and remove`chararray`

in the future.`np.format_parser`

has been removed from the main namespace. Use`np.rec.format_parser`

instead.(gh-24587)

## Deprecations#

`np.trapz`

has been deprecated. Use`scipy.interpolate.trapezoid`

instead.`np.in1d`

has been deprecated. Use`np.isin`

instead.Alias

`np.row_stack`

has been deprecated. Use`np.vstack`

directly.(gh-24445)

## New Features#

*np.bitwise_count* to compute the number of 1-bits in an integer array#

This new function counts the number of 1-bits in a number.
*np.bitwise_count* works on all the numpy integer types and
integer-like objects.

```
>>> a = np.array([2**i - 1 for i in range(16)])
>>> np.bitwise_count(a)
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
dtype=uint8)
```

(gh-19355)

Support for the updated Accelerate BLAS/LAPACK library, including ILP64 (64-bit integer) support, in macOS 13.3 has been added. This brings arm64 support, and significant performance improvements of up to 10x for commonly used linear algebra operations. When Accelerate is selected at build time, the 13.3+ version will automatically be used if available.

(gh-24053)

### Improved CPU Optimization Tracking#

Introduces a tracer mechanism that enables tracking of the enabled targets for each optimized function in the NumPy library. With this enhancement, it becomes possible to precisely monitor the enabled CPU dispatch targets for the dispatched functions.

A new function named *opt_func_info* has been added to the new namespace `numpy.lib.introspect`

,
offering this tracing capability. This function allows you to retrieve information
about the enabled targets based on function names and data type signatures.

(gh-24420)

`meson`

backend for `f2py`

#

`f2py`

in compile mode (i.e. `f2py -c`

) now accepts the `--backend meson`

option. This is the default option
for Python `3.12`

on-wards. Older versions will still default to ```
--backend
distutils
```

.

To support this in realistic use-cases, in compile mode `f2py`

takes a
`--dep`

flag one or many times which maps to `dependency()`

calls in the
`meson`

backend, and does nothing in the `distutils`

backend.

There are no changes for users of `f2py`

only as a code generator, i.e. without `-c`

.

(gh-24532)

`bind(c)`

support for `f2py`

#

Both functions and subroutines can be annotated with `bind(c)`

. `f2py`

will
handle both the correct type mapping, and preserve the unique label for other
`C`

interfaces.

**Note:**`bind(c, name = 'routine_name_other_than_fortran_routine')`

is nothonored by the

`f2py`

bindings by design, since`bind(c)`

with the`name`

is meant to guarantee only the same name in`C`

and`Fortran`

, not in`Python`

and`Fortran`

.

(gh-24555)

`strict`

option for *testing.assert_allclose*#

The `strict`

option is now available for *testing.assert_allclose*.
Setting `strict=True`

will disable the broadcasting behaviour for scalars
and ensure that input arrays have the same data type.

(gh-24680)

## Improvements#

`iso_c_binding`

support for `f2py`

#

Previously, users would have to define their own custom `f2cmap`

file to use
type mappings defined by the Fortran2003 `iso_c_binding`

intrinsic module.
These type maps are now natively supported by `f2py`

(gh-24555)

## Changes#

`np.lib.array_utils`

public module has been introduced and in its initial version it hosts three functions:`byte_bounds`

(moved from`np.lib.utils`

),`normalize_axis_tuple`

and`normalize_axis_index`

(gh-24540)

The “relaxed strides” debug build option, which was previously enabled through
the `NPY_RELAXED_STRIDES_DEBUG`

environment variable or the
`-Drelaxed-strides-debug`

config-settings flag, has been removed.

(gh-24717)