numpy-ts 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -19
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node-io.cjs +3 -3
- package/dist/numpy-ts.node-io.cjs.map +3 -3
- package/dist/numpy-ts.node-io.mjs +3 -3
- package/dist/numpy-ts.node-io.mjs.map +3 -3
- package/dist/numpy-ts.node.cjs +2 -2
- package/dist/numpy-ts.node.cjs.map +3 -3
- package/dist/types/core/ndarray.d.ts +757 -0
- package/dist/types/index.d.ts +5 -5
- package/dist/types/ops/advanced.d.ts +65 -0
- package/dist/types/ops/arithmetic.d.ts +99 -0
- package/dist/types/ops/bitwise.d.ts +30 -0
- package/dist/types/ops/linalg.d.ts +124 -0
- package/dist/types/ops/reduction.d.ts +8 -0
- package/dist/types/ops/sets.d.ts +49 -0
- package/dist/types/ops/shape.d.ts +13 -0
- package/dist/types/ops/statistics.d.ts +22 -0
- package/package.json +3 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
* @module numpy-ts
|
|
5
5
|
*/
|
|
6
6
|
export { Complex, type ComplexInput } from './core/complex';
|
|
7
|
-
export { NDArray, zeros, ones, array, arange, linspace, logspace, geomspace, eye, empty, full, identity, asarray, copy, zeros_like, ones_like, empty_like, full_like, asanyarray, ascontiguousarray, asfortranarray, diag, diagflat, frombuffer, fromfile, fromfunction, fromiter, fromstring, meshgrid, tri, tril, triu, vander, sqrt, power, pow, // alias for power
|
|
7
|
+
export { NDArray, zeros, ones, array, arange, linspace, logspace, geomspace, eye, empty, full, identity, asarray, copy, zeros_like, ones_like, empty_like, full_like, asanyarray, asarray_chkfinite, ascontiguousarray, asfortranarray, require, diag, diagflat, frombuffer, fromfile, fromfunction, fromiter, fromstring, meshgrid, tri, tril, triu, vander, sqrt, power, pow, // alias for power
|
|
8
8
|
exp, exp2, expm1, log, log2, log10, log1p, logaddexp, logaddexp2, absolute, abs, // alias for absolute
|
|
9
9
|
negative, sign, mod, divide, true_divide, // alias for divide
|
|
10
|
-
floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, float_power, fmod, frexp, gcd, lcm, ldexp, modf, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, linalg, sin, cos, tan, arcsin, asin, // alias for arcsin
|
|
10
|
+
floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, float_power, fmod, frexp, gcd, lcm, ldexp, modf, clip, maximum, minimum, fmax, fmin, nan_to_num, interp, unwrap, sinc, i0, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, vdot, vecdot, matrix_transpose, permute_dims, matvec, vecmat, linalg, sin, cos, tan, arcsin, asin, // alias for arcsin
|
|
11
11
|
arccos, acos, // alias for arccos
|
|
12
12
|
arctan, atan, // alias for arctan
|
|
13
13
|
arctan2, atan2, // alias for arctan2
|
|
14
14
|
hypot, degrees, radians, deg2rad, rad2deg, sinh, cosh, tanh, arcsinh, asinh, // alias for arcsinh
|
|
15
15
|
arccosh, acosh, // alias for arccosh
|
|
16
16
|
arctanh, atanh, // alias for arctanh
|
|
17
|
-
swapaxes, moveaxis, concatenate, stack, vstack, hstack, dstack, split, array_split, vsplit, hsplit, tile, repeat, ravel, reshape, squeeze, expand_dims, flip, fliplr, flipud, rot90, roll, rollaxis, atleast_1d, atleast_2d, atleast_3d, dsplit, column_stack, row_stack, resize, append, delete_ as delete, insert, pad, broadcast_to, broadcast_arrays, broadcast_shapes, take, put, iindex, bindex, copyto, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, fill_diagonal, diag_indices, diag_indices_from, tril_indices, tril_indices_from, triu_indices, triu_indices_from, mask_indices, indices, ix_, ravel_multi_index, unravel_index, cumsum, cumulative_sum, // alias for cumsum
|
|
17
|
+
swapaxes, moveaxis, concatenate, stack, vstack, hstack, dstack, concat, unstack, block, split, array_split, vsplit, hsplit, tile, repeat, ravel, flatten, fill, item, tolist, tobytes, byteswap, view, tofile, reshape, squeeze, expand_dims, flip, fliplr, flipud, rot90, roll, rollaxis, atleast_1d, atleast_2d, atleast_3d, dsplit, column_stack, row_stack, resize, append, delete_ as delete, insert, pad, broadcast_to, broadcast_arrays, broadcast_shapes, take, put, iindex, bindex, copyto, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, fill_diagonal, diag_indices, diag_indices_from, tril_indices, tril_indices_from, triu_indices, triu_indices_from, mask_indices, indices, ix_, ravel_multi_index, unravel_index, cumsum, cumulative_sum, // alias for cumsum
|
|
18
18
|
cumprod, cumulative_prod, // alias for cumprod
|
|
19
19
|
max, amax, // alias for max
|
|
20
20
|
min, amin, // alias for min
|
|
21
|
-
ptp, median, percentile, quantile, average, nansum, nanprod, nanmean, nanvar, nanstd, nanmin, nanmax, nanargmin, nanargmax, nancumsum, nancumprod, nanmedian, bitwise_and, bitwise_or, bitwise_xor, bitwise_not, invert, left_shift, right_shift, packbits, unpackbits, logical_and, logical_or, logical_not, logical_xor, isfinite, isinf, isnan, isnat, iscomplex, iscomplexobj, isreal, isrealobj, real, imag, conj, conjugate, angle, isneginf, isposinf, isfortran, real_if_close, isscalar, iterable, isdtype, promote_types, copysign, signbit, nextafter, spacing, sort, argsort, lexsort, partition, argpartition, sort_complex, nonzero, argwhere, flatnonzero, where, searchsorted, extract, count_nonzero, around, round_, // alias for around
|
|
22
|
-
ceil, fix, floor, rint, round, trunc, unique, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, diff, ediff1d, gradient, cross, bincount, digitize, histogram, histogram2d, histogramdd, correlate, convolve, cov, corrcoef, } from './core/ndarray';
|
|
21
|
+
ptp, median, percentile, quantile, average, nansum, nanprod, nanmean, nanvar, nanstd, nanmin, nanmax, nanargmin, nanargmax, nancumsum, nancumprod, nanmedian, nanquantile, nanpercentile, bitwise_and, bitwise_or, bitwise_xor, bitwise_not, invert, left_shift, right_shift, packbits, unpackbits, bitwise_count, bitwise_invert, bitwise_left_shift, bitwise_right_shift, logical_and, logical_or, logical_not, logical_xor, isfinite, isinf, isnan, isnat, iscomplex, iscomplexobj, isreal, isrealobj, real, imag, conj, conjugate, angle, isneginf, isposinf, isfortran, real_if_close, isscalar, iterable, isdtype, promote_types, copysign, signbit, nextafter, spacing, sort, argsort, lexsort, partition, argpartition, sort_complex, nonzero, argwhere, flatnonzero, where, searchsorted, extract, count_nonzero, around, round_, // alias for around
|
|
22
|
+
ceil, fix, floor, rint, round, trunc, unique, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, trim_zeros, unique_all, unique_counts, unique_inverse, unique_values, diff, ediff1d, gradient, cross, bincount, digitize, histogram, histogram2d, histogramdd, correlate, convolve, cov, corrcoef, histogram_bin_edges, trapezoid, apply_along_axis, apply_over_axes, may_share_memory, shares_memory, ndim, shape, size, geterr, seterr, can_cast, common_type, result_type, min_scalar_type, issubdtype, typename, mintypecode, poly, polyadd, polyder, polydiv, polyfit, polyint, polymul, polysub, polyval, roots, } from './core/ndarray';
|
|
23
23
|
export { parseNpy, serializeNpy, parseNpyHeader, parseNpyData, UnsupportedDTypeError, InvalidNpyError, SUPPORTED_DTYPES, DTYPE_TO_DESCR, type NpyHeader, type NpyMetadata, type NpyVersion, parseNpz, parseNpzSync, loadNpz, loadNpzSync, serializeNpz, serializeNpzSync, type NpzParseOptions, type NpzParseResult, type NpzSerializeOptions, } from './io';
|
|
24
24
|
import * as randomOps from './ops/random';
|
|
25
25
|
import { ArrayStorage } from './core/storage';
|
|
@@ -112,4 +112,69 @@ export declare function unravel_index(indices: ArrayStorage | number, shape: num
|
|
|
112
112
|
* @param wrap - Whether to wrap for tall matrices
|
|
113
113
|
*/
|
|
114
114
|
export declare function fill_diagonal(a: ArrayStorage, val: ArrayStorage | number, wrap?: boolean): void;
|
|
115
|
+
/**
|
|
116
|
+
* Apply a function along a given axis.
|
|
117
|
+
*
|
|
118
|
+
* @param arr - Input array storage
|
|
119
|
+
* @param axis - Axis along which to apply the function
|
|
120
|
+
* @param func1d - Function that takes a 1D array and returns a 1D array or scalar
|
|
121
|
+
* @returns Result array
|
|
122
|
+
*/
|
|
123
|
+
export declare function apply_along_axis(arr: ArrayStorage, axis: number, func1d: (slice: ArrayStorage) => ArrayStorage | number): ArrayStorage;
|
|
124
|
+
/**
|
|
125
|
+
* Apply a function over multiple axes.
|
|
126
|
+
*
|
|
127
|
+
* @param arr - Input array storage
|
|
128
|
+
* @param func - Function that operates on an array
|
|
129
|
+
* @param axes - Axes over which to apply the function
|
|
130
|
+
* @returns Result array
|
|
131
|
+
*/
|
|
132
|
+
export declare function apply_over_axes(arr: ArrayStorage, func: (a: ArrayStorage, axis: number) => ArrayStorage, axes: number[]): ArrayStorage;
|
|
133
|
+
/**
|
|
134
|
+
* Check if two arrays may share memory.
|
|
135
|
+
*
|
|
136
|
+
* In JavaScript, we can't directly check memory sharing like in Python.
|
|
137
|
+
* This is a conservative implementation that returns true if they share
|
|
138
|
+
* the same underlying buffer.
|
|
139
|
+
*
|
|
140
|
+
* @param a - First array storage
|
|
141
|
+
* @param b - Second array storage
|
|
142
|
+
* @returns True if arrays may share memory
|
|
143
|
+
*/
|
|
144
|
+
export declare function may_share_memory(a: ArrayStorage, b: ArrayStorage): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Check if two arrays share memory.
|
|
147
|
+
*
|
|
148
|
+
* This is the same as may_share_memory in our implementation since
|
|
149
|
+
* JavaScript doesn't have the same memory model as Python/NumPy.
|
|
150
|
+
*
|
|
151
|
+
* @param a - First array storage
|
|
152
|
+
* @param b - Second array storage
|
|
153
|
+
* @returns True if arrays share memory
|
|
154
|
+
*/
|
|
155
|
+
export declare function shares_memory(a: ArrayStorage, b: ArrayStorage): boolean;
|
|
156
|
+
type ErrorMode = 'ignore' | 'warn' | 'raise' | 'call' | 'print' | 'log';
|
|
157
|
+
export interface FloatErrorState {
|
|
158
|
+
divide: ErrorMode;
|
|
159
|
+
over: ErrorMode;
|
|
160
|
+
under: ErrorMode;
|
|
161
|
+
invalid: ErrorMode;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get the current floating-point error handling.
|
|
165
|
+
*
|
|
166
|
+
* @returns Current error handling settings
|
|
167
|
+
*/
|
|
168
|
+
export declare function geterr(): FloatErrorState;
|
|
169
|
+
/**
|
|
170
|
+
* Set how floating-point errors are handled.
|
|
171
|
+
*
|
|
172
|
+
* @param all - Set all error modes at once (optional)
|
|
173
|
+
* @param divide - Treatment for division by zero
|
|
174
|
+
* @param over - Treatment for floating-point overflow
|
|
175
|
+
* @param under - Treatment for floating-point underflow
|
|
176
|
+
* @param invalid - Treatment for invalid floating-point operation
|
|
177
|
+
* @returns Previous error handling settings
|
|
178
|
+
*/
|
|
179
|
+
export declare function seterr(all?: ErrorMode, divide?: ErrorMode, over?: ErrorMode, under?: ErrorMode, invalid?: ErrorMode): FloatErrorState;
|
|
115
180
|
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -212,4 +212,103 @@ export declare function ldexp(x1: ArrayStorage, x2: ArrayStorage | number): Arra
|
|
|
212
212
|
* @returns Tuple of [fractional, integral] arrays
|
|
213
213
|
*/
|
|
214
214
|
export declare function modf(x: ArrayStorage): [ArrayStorage, ArrayStorage];
|
|
215
|
+
/**
|
|
216
|
+
* Clip (limit) the values in an array
|
|
217
|
+
* Given an interval, values outside the interval are clipped to the interval edges.
|
|
218
|
+
*
|
|
219
|
+
* @param a - Input array storage
|
|
220
|
+
* @param a_min - Minimum value (null to not clip minimum)
|
|
221
|
+
* @param a_max - Maximum value (null to not clip maximum)
|
|
222
|
+
* @returns Clipped array storage
|
|
223
|
+
*/
|
|
224
|
+
export declare function clip(a: ArrayStorage, a_min: number | ArrayStorage | null, a_max: number | ArrayStorage | null): ArrayStorage;
|
|
225
|
+
/**
|
|
226
|
+
* Element-wise maximum of array elements
|
|
227
|
+
*
|
|
228
|
+
* @param x1 - First array storage
|
|
229
|
+
* @param x2 - Second array storage or scalar
|
|
230
|
+
* @returns Element-wise maximum
|
|
231
|
+
*/
|
|
232
|
+
export declare function maximum(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
233
|
+
/**
|
|
234
|
+
* Element-wise minimum of array elements
|
|
235
|
+
*
|
|
236
|
+
* @param x1 - First array storage
|
|
237
|
+
* @param x2 - Second array storage or scalar
|
|
238
|
+
* @returns Element-wise minimum
|
|
239
|
+
*/
|
|
240
|
+
export declare function minimum(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
241
|
+
/**
|
|
242
|
+
* Element-wise maximum of array elements, ignoring NaNs
|
|
243
|
+
*
|
|
244
|
+
* @param x1 - First array storage
|
|
245
|
+
* @param x2 - Second array storage or scalar
|
|
246
|
+
* @returns Element-wise maximum, NaN-aware
|
|
247
|
+
*/
|
|
248
|
+
export declare function fmax(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
249
|
+
/**
|
|
250
|
+
* Element-wise minimum of array elements, ignoring NaNs
|
|
251
|
+
*
|
|
252
|
+
* @param x1 - First array storage
|
|
253
|
+
* @param x2 - Second array storage or scalar
|
|
254
|
+
* @returns Element-wise minimum, NaN-aware
|
|
255
|
+
*/
|
|
256
|
+
export declare function fmin(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
257
|
+
/**
|
|
258
|
+
* Replace NaN with zero and Inf with large finite numbers
|
|
259
|
+
*
|
|
260
|
+
* @param x - Input array storage
|
|
261
|
+
* @param nan - Value to replace NaN (default: 0.0)
|
|
262
|
+
* @param posinf - Value to replace positive infinity (default: largest finite)
|
|
263
|
+
* @param neginf - Value to replace negative infinity (default: most negative finite)
|
|
264
|
+
* @returns Array with replacements
|
|
265
|
+
*/
|
|
266
|
+
export declare function nan_to_num(x: ArrayStorage, nan?: number, posinf?: number, neginf?: number): ArrayStorage;
|
|
267
|
+
/**
|
|
268
|
+
* One-dimensional linear interpolation
|
|
269
|
+
*
|
|
270
|
+
* Returns the one-dimensional piecewise linear interpolant to a function
|
|
271
|
+
* with given discrete data points (xp, fp), evaluated at x.
|
|
272
|
+
*
|
|
273
|
+
* @param x - The x-coordinates at which to evaluate the interpolated values
|
|
274
|
+
* @param xp - The x-coordinates of the data points (must be increasing)
|
|
275
|
+
* @param fp - The y-coordinates of the data points
|
|
276
|
+
* @param left - Value for x < xp[0] (default: fp[0])
|
|
277
|
+
* @param right - Value for x > xp[-1] (default: fp[-1])
|
|
278
|
+
* @returns Interpolated values
|
|
279
|
+
*/
|
|
280
|
+
export declare function interp(x: ArrayStorage, xp: ArrayStorage, fp: ArrayStorage, left?: number, right?: number): ArrayStorage;
|
|
281
|
+
/**
|
|
282
|
+
* Unwrap by changing deltas between values to 2*pi complement
|
|
283
|
+
*
|
|
284
|
+
* Unwrap radian phase p by changing absolute jumps greater than
|
|
285
|
+
* discont to their 2*pi complement along the given axis.
|
|
286
|
+
*
|
|
287
|
+
* @param p - Input array of phase angles in radians
|
|
288
|
+
* @param discont - Maximum discontinuity between values (default: pi)
|
|
289
|
+
* @param axis - Axis along which to unwrap (default: -1, last axis)
|
|
290
|
+
* @param period - Size of the range over which the input wraps (default: 2*pi)
|
|
291
|
+
* @returns Unwrapped array
|
|
292
|
+
*/
|
|
293
|
+
export declare function unwrap(p: ArrayStorage, discont?: number, axis?: number, period?: number): ArrayStorage;
|
|
294
|
+
/**
|
|
295
|
+
* Return the normalized sinc function
|
|
296
|
+
*
|
|
297
|
+
* sinc(x) = sin(pi*x) / (pi*x)
|
|
298
|
+
*
|
|
299
|
+
* The sinc function is 1 at x = 0, and sin(pi*x)/(pi*x) otherwise.
|
|
300
|
+
*
|
|
301
|
+
* @param x - Input array
|
|
302
|
+
* @returns Array of sinc values
|
|
303
|
+
*/
|
|
304
|
+
export declare function sinc(x: ArrayStorage): ArrayStorage;
|
|
305
|
+
/**
|
|
306
|
+
* Modified Bessel function of the first kind, order 0
|
|
307
|
+
*
|
|
308
|
+
* Uses polynomial approximation.
|
|
309
|
+
*
|
|
310
|
+
* @param x - Input array
|
|
311
|
+
* @returns Array of I0 values
|
|
312
|
+
*/
|
|
313
|
+
export declare function i0(x: ArrayStorage): ArrayStorage;
|
|
215
314
|
//# sourceMappingURL=arithmetic.d.ts.map
|
|
@@ -88,4 +88,34 @@ export declare function packbits(a: ArrayStorage, axis?: number, bitorder?: 'big
|
|
|
88
88
|
* @returns Unpacked uint8 array of 0s and 1s
|
|
89
89
|
*/
|
|
90
90
|
export declare function unpackbits(a: ArrayStorage, axis?: number, count?: number, bitorder?: 'big' | 'little'): ArrayStorage;
|
|
91
|
+
/**
|
|
92
|
+
* Count the number of 1-bits in each element (population count).
|
|
93
|
+
*
|
|
94
|
+
* @param x - Input array (must be integer type)
|
|
95
|
+
* @returns Array with population count for each element
|
|
96
|
+
*/
|
|
97
|
+
export declare function bitwise_count(x: ArrayStorage): ArrayStorage;
|
|
98
|
+
/**
|
|
99
|
+
* Bitwise invert (alias for bitwise_not)
|
|
100
|
+
*
|
|
101
|
+
* @param x - Input array (must be integer type)
|
|
102
|
+
* @returns Result storage with bitwise NOT values
|
|
103
|
+
*/
|
|
104
|
+
export declare function bitwise_invert(x: ArrayStorage): ArrayStorage;
|
|
105
|
+
/**
|
|
106
|
+
* Bitwise left shift (alias for left_shift)
|
|
107
|
+
*
|
|
108
|
+
* @param x1 - Input array (must be integer type)
|
|
109
|
+
* @param x2 - Shift amount (array or scalar)
|
|
110
|
+
* @returns Result storage with left-shifted values
|
|
111
|
+
*/
|
|
112
|
+
export declare function bitwise_left_shift(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
113
|
+
/**
|
|
114
|
+
* Bitwise right shift (alias for right_shift)
|
|
115
|
+
*
|
|
116
|
+
* @param x1 - Input array (must be integer type)
|
|
117
|
+
* @param x2 - Shift amount (array or scalar)
|
|
118
|
+
* @returns Result storage with right-shifted values
|
|
119
|
+
*/
|
|
120
|
+
export declare function bitwise_right_shift(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
91
121
|
//# sourceMappingURL=bitwise.d.ts.map
|
|
@@ -364,4 +364,128 @@ export declare function eigvals(a: ArrayStorage): ArrayStorage;
|
|
|
364
364
|
* @returns Array of eigenvalues (sorted ascending)
|
|
365
365
|
*/
|
|
366
366
|
export declare function eigvalsh(a: ArrayStorage, UPLO?: 'L' | 'U'): ArrayStorage;
|
|
367
|
+
/**
|
|
368
|
+
* Return the dot product of two vectors (flattened).
|
|
369
|
+
*
|
|
370
|
+
* Unlike dot(), vdot flattens both inputs before computing the dot product.
|
|
371
|
+
* For complex numbers, vdot uses the complex conjugate of the first argument.
|
|
372
|
+
*
|
|
373
|
+
* @param a - First input array (will be flattened)
|
|
374
|
+
* @param b - Second input array (will be flattened)
|
|
375
|
+
* @returns Scalar dot product
|
|
376
|
+
*/
|
|
377
|
+
export declare function vdot(a: ArrayStorage, b: ArrayStorage): number | bigint | Complex;
|
|
378
|
+
/**
|
|
379
|
+
* Vector dot product along the last axis.
|
|
380
|
+
*
|
|
381
|
+
* Computes the dot product of vectors along the last axis of both inputs.
|
|
382
|
+
* The last dimensions of a and b must match.
|
|
383
|
+
*
|
|
384
|
+
* @param a - First input array
|
|
385
|
+
* @param b - Second input array
|
|
386
|
+
* @param axis - Axis along which to compute (default: -1, meaning last axis)
|
|
387
|
+
* @returns Result with last dimension removed
|
|
388
|
+
*/
|
|
389
|
+
export declare function vecdot(a: ArrayStorage, b: ArrayStorage, axis?: number): ArrayStorage | number | bigint | Complex;
|
|
390
|
+
/**
|
|
391
|
+
* Transpose the last two axes of an array.
|
|
392
|
+
*
|
|
393
|
+
* Equivalent to swapaxes(a, -2, -1) or transpose with axes that swap the last two.
|
|
394
|
+
* For a 2D array, this is the same as transpose.
|
|
395
|
+
*
|
|
396
|
+
* @param a - Input array with at least 2 dimensions
|
|
397
|
+
* @returns Array with last two axes transposed
|
|
398
|
+
*/
|
|
399
|
+
export declare function matrix_transpose(a: ArrayStorage): ArrayStorage;
|
|
400
|
+
/**
|
|
401
|
+
* Permute the dimensions of an array.
|
|
402
|
+
*
|
|
403
|
+
* This is an alias for transpose to match the Array API standard.
|
|
404
|
+
*
|
|
405
|
+
* @param a - Input array
|
|
406
|
+
* @param axes - Permutation of axes. If not specified, reverses the axes.
|
|
407
|
+
* @returns Transposed array
|
|
408
|
+
*/
|
|
409
|
+
export declare function permute_dims(a: ArrayStorage, axes?: number[]): ArrayStorage;
|
|
410
|
+
/**
|
|
411
|
+
* Matrix-vector multiplication.
|
|
412
|
+
*
|
|
413
|
+
* Computes the matrix-vector product over the last two axes of x1 and
|
|
414
|
+
* the last axis of x2.
|
|
415
|
+
*
|
|
416
|
+
* @param x1 - First input array (matrix) with shape (..., M, N)
|
|
417
|
+
* @param x2 - Second input array (vector) with shape (..., N)
|
|
418
|
+
* @returns Result with shape (..., M)
|
|
419
|
+
*/
|
|
420
|
+
export declare function matvec(x1: ArrayStorage, x2: ArrayStorage): ArrayStorage;
|
|
421
|
+
/**
|
|
422
|
+
* Vector-matrix multiplication.
|
|
423
|
+
*
|
|
424
|
+
* Computes the vector-matrix product over the last axis of x1 and
|
|
425
|
+
* the second-to-last axis of x2.
|
|
426
|
+
*
|
|
427
|
+
* @param x1 - First input array (vector) with shape (..., M)
|
|
428
|
+
* @param x2 - Second input array (matrix) with shape (..., M, N)
|
|
429
|
+
* @returns Result with shape (..., N)
|
|
430
|
+
*/
|
|
431
|
+
export declare function vecmat(x1: ArrayStorage, x2: ArrayStorage): ArrayStorage;
|
|
432
|
+
/**
|
|
433
|
+
* Compute sign and (natural) logarithm of the determinant.
|
|
434
|
+
*
|
|
435
|
+
* Returns (sign, logabsdet) where sign is the sign of the determinant
|
|
436
|
+
* and logabsdet is the natural log of the absolute value of the determinant.
|
|
437
|
+
*
|
|
438
|
+
* This is useful for computing determinants of large matrices where the
|
|
439
|
+
* determinant itself might overflow or underflow.
|
|
440
|
+
*
|
|
441
|
+
* @param a - Square matrix
|
|
442
|
+
* @returns { sign, logabsdet }
|
|
443
|
+
*/
|
|
444
|
+
export declare function slogdet(a: ArrayStorage): {
|
|
445
|
+
sign: number;
|
|
446
|
+
logabsdet: number;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Compute singular values of a matrix.
|
|
450
|
+
*
|
|
451
|
+
* This is equivalent to svd(a, compute_uv=False) but more efficient
|
|
452
|
+
* as it doesn't compute the U and V matrices.
|
|
453
|
+
*
|
|
454
|
+
* @param a - Input matrix (m x n)
|
|
455
|
+
* @returns 1D array of singular values in descending order
|
|
456
|
+
*/
|
|
457
|
+
export declare function svdvals(a: ArrayStorage): ArrayStorage;
|
|
458
|
+
/**
|
|
459
|
+
* Compute the dot product of two or more arrays in a single function call.
|
|
460
|
+
*
|
|
461
|
+
* Optimizes the order of multiplications to minimize computation.
|
|
462
|
+
* For example, for three arrays A, B, C with shapes (10, 100), (100, 5), (5, 50),
|
|
463
|
+
* it's more efficient to compute (A @ B) @ C than A @ (B @ C).
|
|
464
|
+
*
|
|
465
|
+
* @param arrays - List of arrays to multiply
|
|
466
|
+
* @returns Result of multiplying all arrays
|
|
467
|
+
*/
|
|
468
|
+
export declare function multi_dot(arrays: ArrayStorage[]): ArrayStorage;
|
|
469
|
+
/**
|
|
470
|
+
* Compute the 'inverse' of an N-dimensional array.
|
|
471
|
+
*
|
|
472
|
+
* The inverse is defined such that tensordot(tensorinv(a), a, ind) == I
|
|
473
|
+
* where I is the identity operator.
|
|
474
|
+
*
|
|
475
|
+
* @param a - Input array to invert
|
|
476
|
+
* @param ind - Number of first indices that are involved in the inverse sum (default: 2)
|
|
477
|
+
* @returns Tensor inverse
|
|
478
|
+
*/
|
|
479
|
+
export declare function tensorinv(a: ArrayStorage, ind?: number): ArrayStorage;
|
|
480
|
+
/**
|
|
481
|
+
* Solve the tensor equation a x = b for x.
|
|
482
|
+
*
|
|
483
|
+
* This is equivalent to solve after reshaping a and b appropriately.
|
|
484
|
+
*
|
|
485
|
+
* @param a - Coefficient tensor
|
|
486
|
+
* @param b - Target tensor
|
|
487
|
+
* @param axes - Axes of a to be summed over in the contraction (default based on b.ndim)
|
|
488
|
+
* @returns Solution tensor x
|
|
489
|
+
*/
|
|
490
|
+
export declare function tensorsolve(a: ArrayStorage, b: ArrayStorage, axes?: number[] | null): ArrayStorage;
|
|
367
491
|
//# sourceMappingURL=linalg.d.ts.map
|
|
@@ -142,4 +142,12 @@ export declare function nancumprod(storage: ArrayStorage, axis?: number): ArrayS
|
|
|
142
142
|
* Compute median ignoring NaN values
|
|
143
143
|
*/
|
|
144
144
|
export declare function nanmedian(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
145
|
+
/**
|
|
146
|
+
* Compute the q-th quantile of data along specified axis, ignoring NaNs
|
|
147
|
+
*/
|
|
148
|
+
export declare function nanquantile(storage: ArrayStorage, q: number, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
149
|
+
/**
|
|
150
|
+
* Compute the q-th percentile of data along specified axis, ignoring NaNs
|
|
151
|
+
*/
|
|
152
|
+
export declare function nanpercentile(storage: ArrayStorage, q: number, axis?: number, keepdims?: boolean): ArrayStorage | number;
|
|
145
153
|
//# sourceMappingURL=reduction.d.ts.map
|
package/dist/types/ops/sets.d.ts
CHANGED
|
@@ -35,4 +35,53 @@ export declare function setxor1d(ar1: ArrayStorage, ar2: ArrayStorage): ArraySto
|
|
|
35
35
|
* Find the union of two arrays
|
|
36
36
|
*/
|
|
37
37
|
export declare function union1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
|
|
38
|
+
/**
|
|
39
|
+
* Trim leading and/or trailing zeros from a 1-D array.
|
|
40
|
+
*
|
|
41
|
+
* @param filt - Input 1-D array
|
|
42
|
+
* @param trim - 'fb' to trim front and back, 'f' for front only, 'b' for back only (default: 'fb')
|
|
43
|
+
* @returns Trimmed array
|
|
44
|
+
*/
|
|
45
|
+
export declare function trim_zeros(filt: ArrayStorage, trim?: 'f' | 'b' | 'fb'): ArrayStorage;
|
|
46
|
+
/**
|
|
47
|
+
* Find the unique elements of an array, returning all optional outputs.
|
|
48
|
+
*
|
|
49
|
+
* @param x - Input array (flattened for uniqueness)
|
|
50
|
+
* @returns Object with values, indices, inverse_indices, and counts
|
|
51
|
+
*/
|
|
52
|
+
export declare function unique_all(x: ArrayStorage): {
|
|
53
|
+
values: ArrayStorage;
|
|
54
|
+
indices: ArrayStorage;
|
|
55
|
+
inverse_indices: ArrayStorage;
|
|
56
|
+
counts: ArrayStorage;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Find the unique elements of an array and their counts.
|
|
60
|
+
*
|
|
61
|
+
* @param x - Input array (flattened for uniqueness)
|
|
62
|
+
* @returns Object with values and counts
|
|
63
|
+
*/
|
|
64
|
+
export declare function unique_counts(x: ArrayStorage): {
|
|
65
|
+
values: ArrayStorage;
|
|
66
|
+
counts: ArrayStorage;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Find the unique elements of an array and their inverse indices.
|
|
70
|
+
*
|
|
71
|
+
* @param x - Input array (flattened for uniqueness)
|
|
72
|
+
* @returns Object with values and inverse_indices
|
|
73
|
+
*/
|
|
74
|
+
export declare function unique_inverse(x: ArrayStorage): {
|
|
75
|
+
values: ArrayStorage;
|
|
76
|
+
inverse_indices: ArrayStorage;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Find the unique elements of an array (values only).
|
|
80
|
+
*
|
|
81
|
+
* This is equivalent to unique(x) but with a clearer name for the Array API.
|
|
82
|
+
*
|
|
83
|
+
* @param x - Input array (flattened for uniqueness)
|
|
84
|
+
* @returns Array of unique values, sorted
|
|
85
|
+
*/
|
|
86
|
+
export declare function unique_values(x: ArrayStorage): ArrayStorage;
|
|
38
87
|
//# sourceMappingURL=sets.d.ts.map
|
|
@@ -141,4 +141,17 @@ export declare function atleast2d(storages: ArrayStorage[]): ArrayStorage[];
|
|
|
141
141
|
* Convert arrays to at least 3D
|
|
142
142
|
*/
|
|
143
143
|
export declare function atleast3d(storages: ArrayStorage[]): ArrayStorage[];
|
|
144
|
+
/**
|
|
145
|
+
* Alias for concatenate
|
|
146
|
+
*/
|
|
147
|
+
export declare function concat(storages: ArrayStorage[], axis?: number): ArrayStorage;
|
|
148
|
+
/**
|
|
149
|
+
* Split an array into a sequence of sub-arrays along an axis (inverse of stack)
|
|
150
|
+
*/
|
|
151
|
+
export declare function unstack(storage: ArrayStorage, axis?: number): ArrayStorage[];
|
|
152
|
+
/**
|
|
153
|
+
* Assemble an nd-array from nested lists of blocks
|
|
154
|
+
* For a simple list [a, b] of nD arrays, concatenates along the last axis (like np.block)
|
|
155
|
+
*/
|
|
156
|
+
export declare function block(storages: ArrayStorage[], _depth?: number): ArrayStorage;
|
|
144
157
|
//# sourceMappingURL=shape.d.ts.map
|
|
@@ -105,4 +105,26 @@ export declare function cov(m: ArrayStorage, y?: ArrayStorage, rowvar?: boolean,
|
|
|
105
105
|
* @returns Correlation coefficient matrix
|
|
106
106
|
*/
|
|
107
107
|
export declare function corrcoef(x: ArrayStorage, y?: ArrayStorage, rowvar?: boolean): ArrayStorage;
|
|
108
|
+
/**
|
|
109
|
+
* Compute the edges of the bins for histogram.
|
|
110
|
+
*
|
|
111
|
+
* This function computes the bin edges without computing the histogram itself.
|
|
112
|
+
*
|
|
113
|
+
* @param a - Input data (flattened if not 1D)
|
|
114
|
+
* @param bins - Number of bins (default: 10) or a string specifying the bin algorithm
|
|
115
|
+
* @param range - Lower and upper range of bins. If not provided, uses [a.min(), a.max()]
|
|
116
|
+
* @param weights - Optional weights for each data point (used for some algorithms)
|
|
117
|
+
* @returns Array of bin edges (length = bins + 1)
|
|
118
|
+
*/
|
|
119
|
+
export declare function histogram_bin_edges(a: ArrayStorage, bins?: number | 'auto' | 'fd' | 'doane' | 'scott' | 'stone' | 'rice' | 'sturges' | 'sqrt', range?: [number, number], _weights?: ArrayStorage): ArrayStorage;
|
|
120
|
+
/**
|
|
121
|
+
* Integrate along the given axis using the composite trapezoidal rule.
|
|
122
|
+
*
|
|
123
|
+
* @param y - Input array to integrate
|
|
124
|
+
* @param x - Optional sample points corresponding to y values. If not provided, spacing is assumed to be 1.
|
|
125
|
+
* @param dx - Spacing between sample points when x is not given (default: 1.0)
|
|
126
|
+
* @param axis - The axis along which to integrate (default: -1, meaning last axis)
|
|
127
|
+
* @returns Definite integral approximated using the composite trapezoidal rule
|
|
128
|
+
*/
|
|
129
|
+
export declare function trapezoid(y: ArrayStorage, x?: ArrayStorage, dx?: number, axis?: number): ArrayStorage | number;
|
|
108
130
|
//# sourceMappingURL=statistics.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "numpy-ts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Complete NumPy implementation for TypeScript and JavaScript (
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"description": "Complete NumPy implementation for TypeScript and JavaScript (81% API coverage)",
|
|
5
5
|
"main": "dist/numpy-ts.node.cjs",
|
|
6
6
|
"browser": "dist/numpy-ts.browser.js",
|
|
7
7
|
"module": "dist/numpy-ts.esm.js",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"@vitest/coverage-v8": "^4.0.3",
|
|
106
106
|
"chart.js": "^4.5.1",
|
|
107
107
|
"chartjs-node-canvas": "^5.0.0",
|
|
108
|
-
"esbuild": "^0.
|
|
108
|
+
"esbuild": "^0.27.2",
|
|
109
109
|
"eslint": "^9.38.0",
|
|
110
110
|
"eslint-config-prettier": "^10.1.8",
|
|
111
111
|
"eslint-plugin-prettier": "^5.0.1",
|