API reference · v1.0.2
API reference
This reference describes every function, class and option in numera 1.0.2, grouped like the NumPy reference. Each entry gives the signature, its arguments, the return type and an example. Every example is executed by the test suite, and a // => comment shows the result: for an NDArray, that is .toArray().
Naming
NumPy names become camelCase: expand_dims → expandDims, linalg.matrix_rank → linalg.matrixRank.
Keyword arguments
Python keyword arguments become an options object: np.sum(a, axis=0) → np.sum(a, { axis: 0 }).
Indexing
JavaScript has no a[1:3] syntax, so indexing uses a.get(...), a.slice(...) and a.set(...).
Array objects
Universal functions
Universal functions (ufunc)
How element-wise functions broadcast, promote types and take out/where; the full ufunc list.
Math (ufuncs)
Element-wise functions with NumPy broadcasting and type promotion.
31 entriesComparison, logic and bitwise
Element-wise comparisons and logical operations return bool arrays.
Routines
Array creation
np.array, np.asarray, np.zeros, np.ones, np.empty, np.full
Shape manipulation
All of these return views (no data copy) unless noted.
41 entriesIndexing
JavaScript has no a[1:3, ::2] syntax, so indexing uses methods.
Grids and index helpers
JS has no obj[...] overloading, so NumPy's index-trick objects (mgrid, ogrid, r_, c_, s_, index_exp) are functions here.
Triangle and diagonal indices
np.trilIndices, np.triuIndices, np.trilIndicesFrom, np.triuIndicesFrom, np.diagIndices, np.diagIndicesFrom
Reductions
Each one exists as a function (np.sum(a, opts)) and as a method (a.sum(opts)).
Reductions with where= / out=
All seven scalar reductions (sum, prod, min, max, mean, var, std) accept where (a boolean mask broadcast to a) and out (a pre-allocated result array).
Sorting, searching and sets
Sorts, partitions, binary search, unique values and set operations.
15 entriesStatistics
Order statistics, averages, correlations and histograms (NumPy numpy statistics routines).
Polynomials
NumPy's legacy polynomial API (np.poly1d and the np.poly* functions).
Window functions
Tapering windows used in signal processing, as in NumPy.
5 entriesInput and output
NumPy .npy/.npz files and text files.
Utilities
np.mayShareMemory, np.copy, np.ascontiguousarray, np.asfortranarray, np.memoryStats, np.lib.stride_tricks.asStrided
Errors
Native errors never reach JS as raw C++ exceptions.
3 entriesModules
np.linalg
Dense linear algebra on LAPACK: Apple Accelerate on macOS, and a portable built-in backend elsewhere.
35 entriesnp.fft
Discrete Fourier transforms on the pocketfft algorithm (the same one NumPy uses).
8 entriesnp.random
Random number generation.
6 entriesRandom — bit generators
Low-level bit generators that back np.random.Generator.
Random — discrete distributions (Generator)
Discrete distribution samplers on np.random.Generator.
Random — continuous distributions (Generator)
Continuous distribution samplers on np.random.Generator.
Random — multivariate distributions (Generator)
Multivariate samplers on np.random.Generator.
Random state
np.get_state, np.set_state, np.ranf, np.sample, np.random_integers
np.emath (complex-valued math)
Functions of numpy.emath that switch to complex results outside the real domain.
np.testing (assertions)
NumPy's array assertion helpers.
8 entriesnp.polynomial (series classes)
Power, Chebyshev, Legendre, Laguerre, Hermite and HermiteE series: classes with domain/window mapping, plus the per-basis module functions.
4 entriesMasked arrays (np.ma)
The np.ma module provides a MaskedArray class that wraps an NDArray with an optional boolean mask.
String operations (np.strings / np.char)
Element-wise string operations on StringArray objects.
Record arrays (np.rec)
Lightweight structured record arrays as named NDArray columns.
5 entries