Compatibility sweep and remaining boundaries
This guide collects additional supported paths and the remaining boundaries. The support matrix is the API contract; being listed in NumPy's inventory does not itself imply unitx support.
Additional supported paths
blockaligns all leaves to the first wrapped leaf's complete unit or point coordinate and follows NumPy's nested-list/shape rules.choose(a, choices, out=None, mode='raise')takes bare integer indices and compatible choices, including points; its output uses staged fixed-unit writes.select(condlist, choicelist, default=0)takes bare boolean conditions and compatible choices. Its default fills otherwise-unselected positions: bare defaults are stored readings, and wrapped defaults convert to the retained unit/coordinate, as for padding.nan_to_num(x, copy=True, nan=0, posinf=None, neginf=None)retains the wrapper. Bare replacements are readings; wrapped replacements align to the input. Native complex behavior replaces real and imaginary components separately.copy=Falseon ndarray magnitudes stages all computation before writing into the same Quantity/point and buffer. Read-only, conversion, casting and shape failures preserve the input. Scalars follow native allocation rules.ediff1dflattens stored values before differencing and returns the complete difference unit, including for points. Optionalto_begin/to_endvalues must be compatible differences; bare values are dimensionless.cumulative_sumretains linear units.cumulative_prodnormalizes dimensionless input and returns a coherent dimensionless result. Native axis/dtype/include_initial rules apply, including the required axis for multidimensional input. Both support stagedoutwrites and reject points.array_equalaligns compatible units/coordinates, requires equal shapes, and forwardsequal_nan.array_equivallows native broadcasting. Different dimensions, point families/conventions, or point/difference operands return False. Conversion and equality use NumPy numerical semantics, including floating rounding, rather than scalar Quantity's exact comparison.all/anyuse stored readings, including coordinate zero for points. They return bare booleans and accept axis, keepdims, a bare boolean where mask and a staged boolean ndarray out.isreal/iscomplexand their*objforms return native bare predicates;isposinf/isneginfalso accept boolean out.shares_memory/may_share_memoryinspect magnitudes without converting units; native max_work options apply.resizeretains units/coordinates and NumPy's flat repetition behavior.trim_zerosuses stored zero readings and preserves native views.unstackreturns a tuple of wrapped views.astyperetains complete units/coordinates, supports native dtype/copy/device options and rejects unsupported magnitude dtypes.sort_complexretains linear units; points are unsupported because the result is complex.i0requires dimensionless linear input and normalizes its full scale.ldexppreserves the first input's complete linear unit with dimensionless integer exponents, reconstructingfrexp.spacingandnextafteruse stored floating representations and retain linear units;nextafteraligns its second operand. These representation-dependent operations need not commute with changing the stored unit.heavisideuses the sign of any linear input and a coherent dimensionless value at zero.linalg.matmul,linalg.outer,linalg.crossandlinalg.tensordotreturn product units with their stricter native Array API shapes and keywords.linalg.traceretains linear units, whilelinalg.diagonalalso retains point coordinates and native view flags.matvecandvecmatpreserve product units, native conjugation, call options and staged out.
import numpy as np
from unitx import Quantity, Unit
q = Quantity(np.array([1.0, np.nan, 3.0]), 'm')
clean = np.nan_to_num(q, nan=Quantity(200, 'cm'))
prefix = np.cumulative_sum(clean, include_initial=True)
np.testing.assert_array_equal(prefix.value, [0, 1, 3, 6])
assert np.array_equal(clean, clean.to('cm'))
blocks = np.block([[clean], [clean.to('cm')]])
assert blocks.unit == Unit('m') and blocks.shape == (2, 3)
mantissa, exponent = np.frexp(clean)
assert np.array_equal(np.ldexp(mantissa, exponent), clean)
assert np.shares_memory(clean, clean[1:])
Inventory audit and version policy
The sweep examined the public inventories exposed by
get_overridable_numpy_array_functions
and get_overridable_numpy_ufuncs,
then compared the remaining entries with the single-unit numeric-array model.
Inventories include constructors with like=, record/string functions, internal
ufuncs and aliases; counting their names is not a measure of useful coverage.
The matrix documents supported behavior and options rather than claiming full
NumPy parity or Array API conformance.
NumPy 2.1 is the minimum. Array API cumulative functions, unstack, the strict
linalg functions and astype are available there. matvec/vecmat require
NumPy 2.2 and are looked up only when available. Version-dependent native
keywords, such as unique(sorted=...) and newer trim_zeros options, remain
the installed NumPy's responsibility: unsupported options raise rather than
being silently emulated. Device is restricted by NumPy's CPU backend. General
ufunc signature/axes remapping and NumPy 2.5's out=... extension are outside
the documented call options. NumPy stubs still do not infer arbitrary dispatched
Quantity results; see typing.
| Remaining category | Boundary / explicit numerical exit |
|---|---|
array, asarray, asanyarray, contiguity/require coercions |
Implicit stripping remains rejected. Use .value/.value_in() when an external API needs numbers. |
| Bare constructors, random sampling, index constructors, dtype promotion helpers | Construct numerical arrays first, then attach a unit; like=q is not an implicit unit constructor. |
Dimensional power with varying or empty exponent arrays |
Rejected. Nonempty constant exponent arrays preserve numerical broadcasting and one common result unit. No per-element-unit result is constructed. |
polyfit, polynomial coefficients/roots, vander, dimensional slogdet |
Coefficients or logarithms need heterogeneous units/reference scales; no misleading single-unit wrapper is returned. |
piecewise, apply_along_axis, apply_over_axes |
Callback input/output units and mutable views require a separate explicit contract. |
| Bitwise, gcd/lcm, string, datetime, record and masked-array APIs | Outside the supported numeric magnitude/unit model. |
Automatic complex-domain lib.scimath functions |
Use explicit complex numeric magnitudes and the supported ufuncs. |
File and text I/O (save*, loadtxt, savetxt, etc.) |
Explicitly choose numeric units and separate metadata; the scalar serialization format does not serialize ndarray storage. |
| Dimensional cumulative/segmented products | Explicitly rejected: partial results can have different units. Ordinary dimensionless inputs normalize to one coherent unit. |
| Packed raw QR | Reflectors and triangular entries have different units; extract numerical values explicitly for this low-level representation. |