SciSharp / SciSharp/NumSharp

[NEP50 NEP52 NEP56] NumPy 2.0 Breaking Changes

Open
#547 0 comments 0 reactions 1 assignee View on GitHub

@Nucs is already working on this.

Since Feb 18, 2026.

api documentation-needed enhancement NumPy 2.x Compliance
Dominant language
C#
Stars
1.5k
Forks
205
Avg merge
7d 7h
Merged PRs (30d)
2

Description

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.corenumpy._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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.