Skip to main content

Crate rumpy

Crate rumpy 

Source
Expand description

rumpy — a numpy-feature-compatible Python module implemented in Rust on top of ndarray, exposed to rustpython_vm as the module numpy.

Supports the full numpy numeric dtype set:

  • bool
  • signed integers: int8 / int16 / int32 / int64
  • unsigned integers: uint8 / uint16 / uint32 / uint64
  • floats: float16 / float32 / float64
  • complex: complex64 / complex128

Element type promotion follows numpy.result_type (see promote.rs). The on-array data is a plain ndarray::ArrayD<T> per dtype — there is no internal locking; synchronization is the embedder’s responsibility.

Re-exports§

pub use dtype::ArrayElement;
pub use dtype::ArraysD;
pub use dtype::CoerceArray;
pub use dtype::DType;

Modules§

convert
Python ↔ ArraysD conversion.
create
Array constructors: zeros, ones, full, eye, arange, linspace.
dtype
Dtype machinery: the DType enum, the ArraysD storage enum that holds one ndarray::ArrayD<T> per numpy element type, and the dispatch macros and helpers used by every operation.
einsum
numpy.einsum — the subscript-string variant.
extras
Second-tier numpy operations: logical/bitwise/finite predicates, clip, cumulative ops, where/nonzero, sort/argsort/unique, stack/squeeze/expand, repeat/tile, median/ptp.
extras2
Additional creation helpers, trig auxiliaries, and stats — the “obvious-numpy” surface that wasn’t in the first cut.
fft
numpy.fft — 1-D forward/inverse FFT, 2-D variants, and real-input transforms, all routed through rustfft. Frequencies follow numpy’s fftfreq/rfftfreq conventions.
fmt
repr() and str() formatting for ArraysD.
index
Indexing & slicing.
internal
Small helpers for “this should not happen, but if it does, raise a clean Python error instead of panicking.”
linalg
dot / matmul (numpy semantics for 1-D and 2-D cases).
linalg_extra
numpy.linalg algorithms: norm, det, inv, solve, matrix_rank. Pure-Rust implementations on f64 (input promoted to f64 first).
more_ops
Third-tier numpy operations: flip/roll/rot90, column_stack/dstack, diag/triu/tril/diagflat, atleast_Nd, count_nonzero/bincount/histogram, nan-aware reductions, searchsorted, meshgrid, interp/trapz/gradient.
npy
Reader/writer for the numpy .npy format, version 1.0.
npz
Reader/writer for the numpy .npz format.
ops
Elementwise binary arithmetic with broadcasting + unary ufuncs.
poly
Polynomial helpers: polyval, roots, polyfit.
promote
Numpy-compatible type promotion (numpy.result_type).
random
numpy.random — pseudo-random generators and distribution sampling.
reduce
Reductions: sum / prod / mean / min / max / std / var.
textio
numpy.savetxt / loadtxt (text format) and tofile / fromfile (raw binary).

Macros§

dispatch_numeric
Dispatch that ONLY covers the 14 numeric variants. Non-numeric variants (Object, Str, …) take the wildcard arm $other, useful for ops that only make sense on numeric data.
dispatch_view
“View-style” dispatch — runs $body once per arm with $a bound to a reference to the inner array. Useful for read-only inspection where the element type does not appear in the result.

Structs§

PyNdArray
Python-visible ndarray. Wraps an ArraysD — a tagged union over all numpy element types.

Functions§

module_def
Return the numpy module definition for embedding into a rustpython_vm::Interpreter.