Overview
NumPy 2.0 introduced significant breaking changes affecting type promotion, API surface, and array standard compliance.
NEP 50: Promotion Rules for Python Scalars
Status: Final | Full Text
The Problem Solved
NumPy 1.x used value-based promotion - inspecting scalar values to determine output types:
np.result_type(np.int8, 1) == np.int8 # 1 fits in int8
np.result_type(np.int8, 255) == np.int16 # 255 doesn't fit - UPCASTED
NumPy 2.x Behavior
Weak scalar promotion - Python scalars defer to array dtype:
uint8(1) + 2 → uint8(3) # Python int defers to uint8
uint8(1) + 255 → uint8(0) # Overflow with warning
int16(2) + int64(3) → int64(5) # NumPy scalar is "strong"
Kind Hierarchy
boolean < integral < inexact
- Cross-kind uses default precision (int64, float64, complex128)
NEP 52: Python API Cleanup for NumPy 2.0
Status: Final | Full Text
Removed Aliases
| Removed |
Canonical |
np.round_ |
np.round |
np.product |
np.prod |
np.sometrue |
np.any |
np.alltrue |
np.all |
Removed Functions
byte_bounds, disp, safe_eval, who
maximum_sctype and related sctype functions
Namespace Changes
numpy.core → numpy._core (private)
np.compat removed
NEP 56: Array API Standard Support
Status: Final | Full Text
New Strict Behaviors
.T errors for ndim > 2
cross() errors on size-2 vectors
outer() raises on >1-D inputs
DType Changes
ceil/floor/trunc return integer dtype (was float)
New Functions
isdtype(dtype, kind) - dtype introspection
unique_values(), unique_counts(), unique_inverse(), unique_all()
matrix_transpose(), vecdot(), matrix_norm(), vector_norm()
New Aliases
- Trig:
acos, asin, atan, atan2 (for arc* versions)
- Other:
concat, permute_dims, pow, bitwise_*
New Properties
ndarray.mT - matrix transpose (last 2 axes)
ndarray.device - returns CPU device
copy= Semantics
np.asarray(x, copy=True) # Always copy
np.asarray(x, copy=False) # Never copy (raise if needed)
np.asarray(x, copy=None) # Copy if necessary
Suggested Implementation for NumSharp
Phase 1: Type Promotion (NEP 50)
- Audit
np._FindCommonType for value-based logic
- Implement weak scalar semantics in arithmetic operators
- Add overflow warnings
Phase 2: API Cleanup (NEP 52)
- Audit for deprecated function names
- Ensure only canonical names exposed
- Address dead code per CLAUDE.md
Phase 3: Array API (NEP 56)
- Add function aliases (acos, concat, etc.)
- Implement
isdtype() function
- Add
unique_* family
- Implement
.mT property
- Update
copy parameter semantics
- Add
.T validation for ndim > 2
Documentation
See docs/neps/NEP50.md, docs/neps/NEP52.md, docs/neps/NEP56.md
Overview
NumPy 2.0 introduced significant breaking changes affecting type promotion, API surface, and array standard compliance.
NEP 50: Promotion Rules for Python Scalars
Status: Final | Full Text
The Problem Solved
NumPy 1.x used value-based promotion - inspecting scalar values to determine output types:
NumPy 2.x Behavior
Weak scalar promotion - Python scalars defer to array dtype:
Kind Hierarchy
boolean < integral < inexactNEP 52: Python API Cleanup for NumPy 2.0
Status: Final | Full Text
Removed Aliases
np.round_np.roundnp.productnp.prodnp.sometruenp.anynp.alltruenp.allRemoved Functions
byte_bounds,disp,safe_eval,whomaximum_sctypeand related sctype functionsNamespace Changes
numpy.core→numpy._core(private)np.compatremovedNEP 56: Array API Standard Support
Status: Final | Full Text
New Strict Behaviors
.Terrors for ndim > 2cross()errors on size-2 vectorsouter()raises on >1-D inputsDType Changes
ceil/floor/truncreturn integer dtype (was float)New Functions
isdtype(dtype, kind)- dtype introspectionunique_values(),unique_counts(),unique_inverse(),unique_all()matrix_transpose(),vecdot(),matrix_norm(),vector_norm()New Aliases
acos,asin,atan,atan2(for arc* versions)concat,permute_dims,pow,bitwise_*New Properties
ndarray.mT- matrix transpose (last 2 axes)ndarray.device- returns CPU devicecopy= Semantics
Suggested Implementation for NumSharp
Phase 1: Type Promotion (NEP 50)
np._FindCommonTypefor value-based logicPhase 2: API Cleanup (NEP 52)
Phase 3: Array API (NEP 56)
isdtype()functionunique_*family.mTpropertycopyparameter semantics.Tvalidation for ndim > 2Documentation
See
docs/neps/NEP50.md,docs/neps/NEP52.md,docs/neps/NEP56.md