numpy-ts 0.7.0 → 0.9.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 +15 -15
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node-io.cjs +3 -2
- package/dist/numpy-ts.node-io.cjs.map +4 -4
- package/dist/numpy-ts.node-io.mjs +3 -2
- package/dist/numpy-ts.node-io.mjs.map +4 -4
- package/dist/numpy-ts.node.cjs +2 -2
- package/dist/numpy-ts.node.cjs.map +4 -4
- package/dist/types/core/ndarray.d.ts +526 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/io/index.d.ts +5 -4
- package/dist/types/io/txt/index.d.ts +12 -0
- package/dist/types/io/txt/parser.d.ts +109 -0
- package/dist/types/io/txt/serializer.d.ts +67 -0
- package/dist/types/node.d.ts +122 -0
- package/dist/types/ops/exponential.d.ts +79 -1
- package/dist/types/ops/gradient.d.ts +57 -0
- package/dist/types/ops/linalg.d.ts +220 -0
- package/dist/types/ops/rounding.d.ts +36 -0
- package/dist/types/ops/sets.d.ts +38 -0
- package/dist/types/ops/sorting.d.ts +95 -0
- package/package.json +1 -1
|
@@ -120,6 +120,66 @@ export declare class NDArray {
|
|
|
120
120
|
* @returns New array with powered values
|
|
121
121
|
*/
|
|
122
122
|
power(exponent: NDArray | number): NDArray;
|
|
123
|
+
/**
|
|
124
|
+
* Natural exponential (e^x) of each element
|
|
125
|
+
* Promotes integer types to float64
|
|
126
|
+
* @returns New array with exp values
|
|
127
|
+
*/
|
|
128
|
+
exp(): NDArray;
|
|
129
|
+
/**
|
|
130
|
+
* Base-2 exponential (2^x) of each element
|
|
131
|
+
* Promotes integer types to float64
|
|
132
|
+
* @returns New array with exp2 values
|
|
133
|
+
*/
|
|
134
|
+
exp2(): NDArray;
|
|
135
|
+
/**
|
|
136
|
+
* Exponential minus one (e^x - 1) of each element
|
|
137
|
+
* More accurate than exp(x) - 1 for small x
|
|
138
|
+
* Promotes integer types to float64
|
|
139
|
+
* @returns New array with expm1 values
|
|
140
|
+
*/
|
|
141
|
+
expm1(): NDArray;
|
|
142
|
+
/**
|
|
143
|
+
* Natural logarithm (ln) of each element
|
|
144
|
+
* Promotes integer types to float64
|
|
145
|
+
* @returns New array with log values
|
|
146
|
+
*/
|
|
147
|
+
log(): NDArray;
|
|
148
|
+
/**
|
|
149
|
+
* Base-2 logarithm of each element
|
|
150
|
+
* Promotes integer types to float64
|
|
151
|
+
* @returns New array with log2 values
|
|
152
|
+
*/
|
|
153
|
+
log2(): NDArray;
|
|
154
|
+
/**
|
|
155
|
+
* Base-10 logarithm of each element
|
|
156
|
+
* Promotes integer types to float64
|
|
157
|
+
* @returns New array with log10 values
|
|
158
|
+
*/
|
|
159
|
+
log10(): NDArray;
|
|
160
|
+
/**
|
|
161
|
+
* Natural logarithm of (1 + x) of each element
|
|
162
|
+
* More accurate than log(1 + x) for small x
|
|
163
|
+
* Promotes integer types to float64
|
|
164
|
+
* @returns New array with log1p values
|
|
165
|
+
*/
|
|
166
|
+
log1p(): NDArray;
|
|
167
|
+
/**
|
|
168
|
+
* Logarithm of the sum of exponentials: log(exp(x1) + exp(x2))
|
|
169
|
+
* More numerically stable than computing the expression directly
|
|
170
|
+
* Promotes integer types to float64
|
|
171
|
+
* @param x2 - Second operand (array or scalar)
|
|
172
|
+
* @returns New array with logaddexp values
|
|
173
|
+
*/
|
|
174
|
+
logaddexp(x2: NDArray | number): NDArray;
|
|
175
|
+
/**
|
|
176
|
+
* Logarithm base 2 of the sum of exponentials: log2(2^x1 + 2^x2)
|
|
177
|
+
* More numerically stable than computing the expression directly
|
|
178
|
+
* Promotes integer types to float64
|
|
179
|
+
* @param x2 - Second operand (array or scalar)
|
|
180
|
+
* @returns New array with logaddexp2 values
|
|
181
|
+
*/
|
|
182
|
+
logaddexp2(x2: NDArray | number): NDArray;
|
|
123
183
|
/**
|
|
124
184
|
* Absolute value of each element
|
|
125
185
|
* @returns New array with absolute values
|
|
@@ -135,6 +195,43 @@ export declare class NDArray {
|
|
|
135
195
|
* @returns New array with signs
|
|
136
196
|
*/
|
|
137
197
|
sign(): NDArray;
|
|
198
|
+
/**
|
|
199
|
+
* Round an array to the given number of decimals
|
|
200
|
+
* @param decimals - Number of decimal places to round to (default: 0)
|
|
201
|
+
* @returns New array with rounded values
|
|
202
|
+
*/
|
|
203
|
+
around(decimals?: number): NDArray;
|
|
204
|
+
/**
|
|
205
|
+
* Round an array to the given number of decimals (alias for around)
|
|
206
|
+
* @param decimals - Number of decimal places to round to (default: 0)
|
|
207
|
+
* @returns New array with rounded values
|
|
208
|
+
*/
|
|
209
|
+
round(decimals?: number): NDArray;
|
|
210
|
+
/**
|
|
211
|
+
* Return the ceiling of the input, element-wise
|
|
212
|
+
* @returns New array with ceiling values
|
|
213
|
+
*/
|
|
214
|
+
ceil(): NDArray;
|
|
215
|
+
/**
|
|
216
|
+
* Round to nearest integer towards zero
|
|
217
|
+
* @returns New array with values truncated towards zero
|
|
218
|
+
*/
|
|
219
|
+
fix(): NDArray;
|
|
220
|
+
/**
|
|
221
|
+
* Return the floor of the input, element-wise
|
|
222
|
+
* @returns New array with floor values
|
|
223
|
+
*/
|
|
224
|
+
floor(): NDArray;
|
|
225
|
+
/**
|
|
226
|
+
* Round elements to the nearest integer
|
|
227
|
+
* @returns New array with rounded integer values
|
|
228
|
+
*/
|
|
229
|
+
rint(): NDArray;
|
|
230
|
+
/**
|
|
231
|
+
* Return the truncated value of the input, element-wise
|
|
232
|
+
* @returns New array with truncated values
|
|
233
|
+
*/
|
|
234
|
+
trunc(): NDArray;
|
|
138
235
|
/**
|
|
139
236
|
* Sine of each element (in radians)
|
|
140
237
|
* Promotes integer types to float64
|
|
@@ -534,6 +631,51 @@ export declare class NDArray {
|
|
|
534
631
|
* @returns Median of array elements ignoring NaNs
|
|
535
632
|
*/
|
|
536
633
|
nanmedian(axis?: number, keepdims?: boolean): NDArray | number;
|
|
634
|
+
/**
|
|
635
|
+
* Return a sorted copy of the array
|
|
636
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
637
|
+
* @returns Sorted array
|
|
638
|
+
*/
|
|
639
|
+
sort(axis?: number): NDArray;
|
|
640
|
+
/**
|
|
641
|
+
* Returns the indices that would sort this array
|
|
642
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
643
|
+
* @returns Array of indices that sort the array
|
|
644
|
+
*/
|
|
645
|
+
argsort(axis?: number): NDArray;
|
|
646
|
+
/**
|
|
647
|
+
* Partially sort the array
|
|
648
|
+
* @param kth - Element index to partition by
|
|
649
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
650
|
+
* @returns Partitioned array
|
|
651
|
+
*/
|
|
652
|
+
partition(kth: number, axis?: number): NDArray;
|
|
653
|
+
/**
|
|
654
|
+
* Returns indices that would partition the array
|
|
655
|
+
* @param kth - Element index to partition by
|
|
656
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
657
|
+
* @returns Array of indices
|
|
658
|
+
*/
|
|
659
|
+
argpartition(kth: number, axis?: number): NDArray;
|
|
660
|
+
/**
|
|
661
|
+
* Return the indices of non-zero elements
|
|
662
|
+
* @returns Tuple of arrays, one for each dimension
|
|
663
|
+
*/
|
|
664
|
+
nonzero(): NDArray[];
|
|
665
|
+
/**
|
|
666
|
+
* Find indices where elements should be inserted to maintain order
|
|
667
|
+
* @param v - Values to insert
|
|
668
|
+
* @param side - 'left' or 'right' side to insert
|
|
669
|
+
* @returns Indices where values should be inserted
|
|
670
|
+
*/
|
|
671
|
+
searchsorted(v: NDArray, side?: 'left' | 'right'): NDArray;
|
|
672
|
+
/**
|
|
673
|
+
* Calculate the n-th discrete difference along the given axis
|
|
674
|
+
* @param n - Number of times values are differenced (default: 1)
|
|
675
|
+
* @param axis - Axis along which to compute difference (default: -1)
|
|
676
|
+
* @returns Array of differences
|
|
677
|
+
*/
|
|
678
|
+
diff(n?: number, axis?: number): NDArray;
|
|
537
679
|
/**
|
|
538
680
|
* Reshape array to a new shape
|
|
539
681
|
* Returns a new array with the specified shape
|
|
@@ -989,6 +1131,66 @@ export declare function sqrt(x: NDArray): NDArray;
|
|
|
989
1131
|
* @returns Array of x raised to exponent
|
|
990
1132
|
*/
|
|
991
1133
|
export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
|
|
1134
|
+
/**
|
|
1135
|
+
* Element-wise natural exponential (e^x)
|
|
1136
|
+
* @param x - Input array
|
|
1137
|
+
* @returns Array of e^x values
|
|
1138
|
+
*/
|
|
1139
|
+
export declare function exp(x: NDArray): NDArray;
|
|
1140
|
+
/**
|
|
1141
|
+
* Element-wise base-2 exponential (2^x)
|
|
1142
|
+
* @param x - Input array
|
|
1143
|
+
* @returns Array of 2^x values
|
|
1144
|
+
*/
|
|
1145
|
+
export declare function exp2(x: NDArray): NDArray;
|
|
1146
|
+
/**
|
|
1147
|
+
* Element-wise exponential minus one (e^x - 1)
|
|
1148
|
+
* More accurate than exp(x) - 1 for small x
|
|
1149
|
+
* @param x - Input array
|
|
1150
|
+
* @returns Array of expm1 values
|
|
1151
|
+
*/
|
|
1152
|
+
export declare function expm1(x: NDArray): NDArray;
|
|
1153
|
+
/**
|
|
1154
|
+
* Element-wise natural logarithm (ln)
|
|
1155
|
+
* @param x - Input array
|
|
1156
|
+
* @returns Array of log values
|
|
1157
|
+
*/
|
|
1158
|
+
export declare function log(x: NDArray): NDArray;
|
|
1159
|
+
/**
|
|
1160
|
+
* Element-wise base-2 logarithm
|
|
1161
|
+
* @param x - Input array
|
|
1162
|
+
* @returns Array of log2 values
|
|
1163
|
+
*/
|
|
1164
|
+
export declare function log2(x: NDArray): NDArray;
|
|
1165
|
+
/**
|
|
1166
|
+
* Element-wise base-10 logarithm
|
|
1167
|
+
* @param x - Input array
|
|
1168
|
+
* @returns Array of log10 values
|
|
1169
|
+
*/
|
|
1170
|
+
export declare function log10(x: NDArray): NDArray;
|
|
1171
|
+
/**
|
|
1172
|
+
* Element-wise natural logarithm of (1 + x)
|
|
1173
|
+
* More accurate than log(1 + x) for small x
|
|
1174
|
+
* @param x - Input array
|
|
1175
|
+
* @returns Array of log1p values
|
|
1176
|
+
*/
|
|
1177
|
+
export declare function log1p(x: NDArray): NDArray;
|
|
1178
|
+
/**
|
|
1179
|
+
* Logarithm of the sum of exponentials: log(exp(x1) + exp(x2))
|
|
1180
|
+
* More numerically stable than computing the expression directly
|
|
1181
|
+
* @param x1 - First input array
|
|
1182
|
+
* @param x2 - Second input array or scalar
|
|
1183
|
+
* @returns Array of logaddexp values
|
|
1184
|
+
*/
|
|
1185
|
+
export declare function logaddexp(x1: NDArray, x2: NDArray | number): NDArray;
|
|
1186
|
+
/**
|
|
1187
|
+
* Logarithm base 2 of the sum of exponentials: log2(2^x1 + 2^x2)
|
|
1188
|
+
* More numerically stable than computing the expression directly
|
|
1189
|
+
* @param x1 - First input array
|
|
1190
|
+
* @param x2 - Second input array or scalar
|
|
1191
|
+
* @returns Array of logaddexp2 values
|
|
1192
|
+
*/
|
|
1193
|
+
export declare function logaddexp2(x1: NDArray, x2: NDArray | number): NDArray;
|
|
992
1194
|
/**
|
|
993
1195
|
* Element-wise absolute value
|
|
994
1196
|
* @param x - Input array
|
|
@@ -1866,6 +2068,108 @@ export declare function unpackbits(a: NDArray, axis?: number, count?: number, bi
|
|
|
1866
2068
|
* einsum('ii->', a)
|
|
1867
2069
|
*/
|
|
1868
2070
|
export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint;
|
|
2071
|
+
/**
|
|
2072
|
+
* numpy.linalg module - Linear algebra functions
|
|
2073
|
+
*/
|
|
2074
|
+
export declare const linalg: {
|
|
2075
|
+
/**
|
|
2076
|
+
* Cross product of two vectors.
|
|
2077
|
+
*/
|
|
2078
|
+
cross: (a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number, axis?: number) => NDArray | number;
|
|
2079
|
+
/**
|
|
2080
|
+
* Compute the norm of a vector or matrix.
|
|
2081
|
+
*/
|
|
2082
|
+
norm: (x: NDArray, ord?: number | "fro" | "nuc" | null, axis?: number | [number, number] | null, keepdims?: boolean) => NDArray | number;
|
|
2083
|
+
/**
|
|
2084
|
+
* Compute the vector norm.
|
|
2085
|
+
*/
|
|
2086
|
+
vector_norm: (x: NDArray, ord?: number, axis?: number | null, keepdims?: boolean) => NDArray | number;
|
|
2087
|
+
/**
|
|
2088
|
+
* Compute the matrix norm.
|
|
2089
|
+
*/
|
|
2090
|
+
matrix_norm: (x: NDArray, ord?: number | "fro" | "nuc", keepdims?: boolean) => NDArray | number;
|
|
2091
|
+
/**
|
|
2092
|
+
* QR decomposition.
|
|
2093
|
+
*/
|
|
2094
|
+
qr: (a: NDArray, mode?: "reduced" | "complete" | "r" | "raw") => {
|
|
2095
|
+
q: NDArray;
|
|
2096
|
+
r: NDArray;
|
|
2097
|
+
} | NDArray | {
|
|
2098
|
+
h: NDArray;
|
|
2099
|
+
tau: NDArray;
|
|
2100
|
+
};
|
|
2101
|
+
/**
|
|
2102
|
+
* Cholesky decomposition.
|
|
2103
|
+
*/
|
|
2104
|
+
cholesky: (a: NDArray, upper?: boolean) => NDArray;
|
|
2105
|
+
/**
|
|
2106
|
+
* Singular Value Decomposition.
|
|
2107
|
+
*/
|
|
2108
|
+
svd: (a: NDArray, full_matrices?: boolean, compute_uv?: boolean) => {
|
|
2109
|
+
u: NDArray;
|
|
2110
|
+
s: NDArray;
|
|
2111
|
+
vt: NDArray;
|
|
2112
|
+
} | NDArray;
|
|
2113
|
+
/**
|
|
2114
|
+
* Compute the determinant of a matrix.
|
|
2115
|
+
*/
|
|
2116
|
+
det: (a: NDArray) => number;
|
|
2117
|
+
/**
|
|
2118
|
+
* Compute the matrix inverse.
|
|
2119
|
+
*/
|
|
2120
|
+
inv: (a: NDArray) => NDArray;
|
|
2121
|
+
/**
|
|
2122
|
+
* Solve a linear system.
|
|
2123
|
+
*/
|
|
2124
|
+
solve: (a: NDArray, b: NDArray) => NDArray;
|
|
2125
|
+
/**
|
|
2126
|
+
* Least-squares solution to a linear matrix equation.
|
|
2127
|
+
*/
|
|
2128
|
+
lstsq: (a: NDArray, b: NDArray, rcond?: number | null) => {
|
|
2129
|
+
x: NDArray;
|
|
2130
|
+
residuals: NDArray;
|
|
2131
|
+
rank: number;
|
|
2132
|
+
s: NDArray;
|
|
2133
|
+
};
|
|
2134
|
+
/**
|
|
2135
|
+
* Compute the condition number.
|
|
2136
|
+
*/
|
|
2137
|
+
cond: (a: NDArray, p?: number | "fro" | "nuc") => number;
|
|
2138
|
+
/**
|
|
2139
|
+
* Compute the matrix rank.
|
|
2140
|
+
*/
|
|
2141
|
+
matrix_rank: (a: NDArray, tol?: number) => number;
|
|
2142
|
+
/**
|
|
2143
|
+
* Raise a square matrix to an integer power.
|
|
2144
|
+
*/
|
|
2145
|
+
matrix_power: (a: NDArray, n: number) => NDArray;
|
|
2146
|
+
/**
|
|
2147
|
+
* Compute the Moore-Penrose pseudo-inverse.
|
|
2148
|
+
*/
|
|
2149
|
+
pinv: (a: NDArray, rcond?: number) => NDArray;
|
|
2150
|
+
/**
|
|
2151
|
+
* Compute eigenvalues and eigenvectors.
|
|
2152
|
+
*/
|
|
2153
|
+
eig: (a: NDArray) => {
|
|
2154
|
+
w: NDArray;
|
|
2155
|
+
v: NDArray;
|
|
2156
|
+
};
|
|
2157
|
+
/**
|
|
2158
|
+
* Compute eigenvalues and eigenvectors of a Hermitian matrix.
|
|
2159
|
+
*/
|
|
2160
|
+
eigh: (a: NDArray, UPLO?: "L" | "U") => {
|
|
2161
|
+
w: NDArray;
|
|
2162
|
+
v: NDArray;
|
|
2163
|
+
};
|
|
2164
|
+
/**
|
|
2165
|
+
* Compute eigenvalues of a matrix.
|
|
2166
|
+
*/
|
|
2167
|
+
eigvals: (a: NDArray) => NDArray;
|
|
2168
|
+
/**
|
|
2169
|
+
* Compute eigenvalues of a Hermitian matrix.
|
|
2170
|
+
*/
|
|
2171
|
+
eigvalsh: (a: NDArray, UPLO?: "L" | "U") => NDArray;
|
|
2172
|
+
};
|
|
1869
2173
|
/**
|
|
1870
2174
|
* Take values from the input array by matching 1d index and data slices along axis.
|
|
1871
2175
|
*
|
|
@@ -2011,4 +2315,226 @@ export declare function ravel_multi_index(multi_index: NDArray[], dims: number[]
|
|
|
2011
2315
|
* @returns Tuple of coordinate arrays
|
|
2012
2316
|
*/
|
|
2013
2317
|
export declare function unravel_index(indices: NDArray | number, shape: number[], order?: 'C' | 'F'): NDArray[];
|
|
2318
|
+
/**
|
|
2319
|
+
* Return a sorted copy of an array
|
|
2320
|
+
* @param a - Input array
|
|
2321
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
2322
|
+
* @returns Sorted array
|
|
2323
|
+
*/
|
|
2324
|
+
export declare function sort(a: NDArray, axis?: number): NDArray;
|
|
2325
|
+
/**
|
|
2326
|
+
* Returns the indices that would sort an array
|
|
2327
|
+
* @param a - Input array
|
|
2328
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
2329
|
+
* @returns Array of indices that sort the input array
|
|
2330
|
+
*/
|
|
2331
|
+
export declare function argsort(a: NDArray, axis?: number): NDArray;
|
|
2332
|
+
/**
|
|
2333
|
+
* Perform an indirect stable sort using a sequence of keys
|
|
2334
|
+
* @param keys - Array of NDArrays, the last key is the primary sort key
|
|
2335
|
+
* @returns Array of indices that would sort the keys
|
|
2336
|
+
*/
|
|
2337
|
+
export declare function lexsort(keys: NDArray[]): NDArray;
|
|
2338
|
+
/**
|
|
2339
|
+
* Partially sort an array
|
|
2340
|
+
* @param a - Input array
|
|
2341
|
+
* @param kth - Element index to partition by
|
|
2342
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
2343
|
+
* @returns Partitioned array
|
|
2344
|
+
*/
|
|
2345
|
+
export declare function partition(a: NDArray, kth: number, axis?: number): NDArray;
|
|
2346
|
+
/**
|
|
2347
|
+
* Returns indices that would partition an array
|
|
2348
|
+
* @param a - Input array
|
|
2349
|
+
* @param kth - Element index to partition by
|
|
2350
|
+
* @param axis - Axis along which to sort. Default is -1 (last axis)
|
|
2351
|
+
* @returns Array of indices
|
|
2352
|
+
*/
|
|
2353
|
+
export declare function argpartition(a: NDArray, kth: number, axis?: number): NDArray;
|
|
2354
|
+
/**
|
|
2355
|
+
* Sort a complex array using the real part first, then the imaginary part
|
|
2356
|
+
* For real arrays, returns a sorted 1D array
|
|
2357
|
+
* @param a - Input array
|
|
2358
|
+
* @returns Sorted 1D array
|
|
2359
|
+
*/
|
|
2360
|
+
export declare function sort_complex(a: NDArray): NDArray;
|
|
2361
|
+
/**
|
|
2362
|
+
* Return the indices of the elements that are non-zero
|
|
2363
|
+
* @param a - Input array
|
|
2364
|
+
* @returns Tuple of arrays, one for each dimension
|
|
2365
|
+
*/
|
|
2366
|
+
export declare function nonzero(a: NDArray): NDArray[];
|
|
2367
|
+
/**
|
|
2368
|
+
* Return indices of non-zero elements in flattened array
|
|
2369
|
+
* @param a - Input array
|
|
2370
|
+
* @returns Array of indices
|
|
2371
|
+
*/
|
|
2372
|
+
export declare function flatnonzero(a: NDArray): NDArray;
|
|
2373
|
+
/**
|
|
2374
|
+
* Return elements from x or y depending on condition
|
|
2375
|
+
* If only condition is given, returns indices where condition is true (like nonzero)
|
|
2376
|
+
* @param condition - Boolean array or condition
|
|
2377
|
+
* @param x - Values where condition is true (optional)
|
|
2378
|
+
* @param y - Values where condition is false (optional)
|
|
2379
|
+
* @returns Array with elements chosen from x or y, or indices if only condition given
|
|
2380
|
+
*/
|
|
2381
|
+
export declare function where(condition: NDArray, x?: NDArray, y?: NDArray): NDArray | NDArray[];
|
|
2382
|
+
/**
|
|
2383
|
+
* Find indices where elements should be inserted to maintain order
|
|
2384
|
+
* @param a - Input array (must be sorted in ascending order)
|
|
2385
|
+
* @param v - Values to insert
|
|
2386
|
+
* @param side - 'left' or 'right' side to insert
|
|
2387
|
+
* @returns Indices where values should be inserted
|
|
2388
|
+
*/
|
|
2389
|
+
export declare function searchsorted(a: NDArray, v: NDArray, side?: 'left' | 'right'): NDArray;
|
|
2390
|
+
/**
|
|
2391
|
+
* Return the elements of an array that satisfy some condition
|
|
2392
|
+
* @param condition - Boolean array
|
|
2393
|
+
* @param a - Input array
|
|
2394
|
+
* @returns 1D array of elements where condition is true
|
|
2395
|
+
*/
|
|
2396
|
+
export declare function extract(condition: NDArray, a: NDArray): NDArray;
|
|
2397
|
+
/**
|
|
2398
|
+
* Count number of non-zero values in the array
|
|
2399
|
+
* @param a - Input array
|
|
2400
|
+
* @param axis - Axis along which to count (optional)
|
|
2401
|
+
* @returns Count of non-zero values
|
|
2402
|
+
*/
|
|
2403
|
+
export declare function count_nonzero(a: NDArray, axis?: number): NDArray | number;
|
|
2404
|
+
/**
|
|
2405
|
+
* Round an array to the given number of decimals
|
|
2406
|
+
* @param a - Input array
|
|
2407
|
+
* @param decimals - Number of decimal places to round to (default: 0)
|
|
2408
|
+
* @returns Rounded array
|
|
2409
|
+
*/
|
|
2410
|
+
export declare function around(a: NDArray, decimals?: number): NDArray;
|
|
2411
|
+
/**
|
|
2412
|
+
* Return the ceiling of the input, element-wise
|
|
2413
|
+
* @param x - Input array
|
|
2414
|
+
* @returns Element-wise ceiling
|
|
2415
|
+
*/
|
|
2416
|
+
export declare function ceil(x: NDArray): NDArray;
|
|
2417
|
+
/**
|
|
2418
|
+
* Round to nearest integer towards zero
|
|
2419
|
+
* @param x - Input array
|
|
2420
|
+
* @returns Array with values truncated towards zero
|
|
2421
|
+
*/
|
|
2422
|
+
export declare function fix(x: NDArray): NDArray;
|
|
2423
|
+
/**
|
|
2424
|
+
* Return the floor of the input, element-wise
|
|
2425
|
+
* @param x - Input array
|
|
2426
|
+
* @returns Element-wise floor
|
|
2427
|
+
*/
|
|
2428
|
+
export declare function floor(x: NDArray): NDArray;
|
|
2429
|
+
/**
|
|
2430
|
+
* Round elements of the array to the nearest integer
|
|
2431
|
+
* @param x - Input array
|
|
2432
|
+
* @returns Array with rounded integer values
|
|
2433
|
+
*/
|
|
2434
|
+
export declare function rint(x: NDArray): NDArray;
|
|
2435
|
+
/**
|
|
2436
|
+
* Evenly round to the given number of decimals (alias for around)
|
|
2437
|
+
* @param a - Input array
|
|
2438
|
+
* @param decimals - Number of decimal places to round to (default: 0)
|
|
2439
|
+
* @returns Rounded array
|
|
2440
|
+
*/
|
|
2441
|
+
export { around as round };
|
|
2442
|
+
/**
|
|
2443
|
+
* Return the truncated value of the input, element-wise
|
|
2444
|
+
* @param x - Input array
|
|
2445
|
+
* @returns Element-wise truncated values
|
|
2446
|
+
*/
|
|
2447
|
+
export declare function trunc(x: NDArray): NDArray;
|
|
2448
|
+
/**
|
|
2449
|
+
* Find the unique elements of an array
|
|
2450
|
+
* @param ar - Input array
|
|
2451
|
+
* @param returnIndex - If True, also return the indices of the first occurrences
|
|
2452
|
+
* @param returnInverse - If True, also return the indices to reconstruct the original array
|
|
2453
|
+
* @param returnCounts - If True, also return the number of times each unique value appears
|
|
2454
|
+
* @returns Unique sorted values, and optionally indices/inverse/counts
|
|
2455
|
+
*/
|
|
2456
|
+
export declare function unique(ar: NDArray, returnIndex?: boolean, returnInverse?: boolean, returnCounts?: boolean): NDArray | {
|
|
2457
|
+
values: NDArray;
|
|
2458
|
+
indices?: NDArray;
|
|
2459
|
+
inverse?: NDArray;
|
|
2460
|
+
counts?: NDArray;
|
|
2461
|
+
};
|
|
2462
|
+
/**
|
|
2463
|
+
* Test whether each element of a 1-D array is also present in a second array
|
|
2464
|
+
* @param ar1 - Input array
|
|
2465
|
+
* @param ar2 - Test values
|
|
2466
|
+
* @returns Boolean array indicating membership
|
|
2467
|
+
*/
|
|
2468
|
+
export declare function in1d(ar1: NDArray, ar2: NDArray): NDArray;
|
|
2469
|
+
/**
|
|
2470
|
+
* Find the intersection of two arrays
|
|
2471
|
+
* @param ar1 - First input array
|
|
2472
|
+
* @param ar2 - Second input array
|
|
2473
|
+
* @returns Sorted 1D array of common and unique elements
|
|
2474
|
+
*/
|
|
2475
|
+
export declare function intersect1d(ar1: NDArray, ar2: NDArray): NDArray;
|
|
2476
|
+
/**
|
|
2477
|
+
* Test whether each element of an ND array is also present in a second array
|
|
2478
|
+
* @param element - Input array
|
|
2479
|
+
* @param testElements - Test values
|
|
2480
|
+
* @returns Boolean array indicating membership (same shape as element)
|
|
2481
|
+
*/
|
|
2482
|
+
export declare function isin(element: NDArray, testElements: NDArray): NDArray;
|
|
2483
|
+
/**
|
|
2484
|
+
* Find the set difference of two arrays
|
|
2485
|
+
* @param ar1 - First input array
|
|
2486
|
+
* @param ar2 - Second input array
|
|
2487
|
+
* @returns Sorted 1D array of values in ar1 that are not in ar2
|
|
2488
|
+
*/
|
|
2489
|
+
export declare function setdiff1d(ar1: NDArray, ar2: NDArray): NDArray;
|
|
2490
|
+
/**
|
|
2491
|
+
* Find the set exclusive-or of two arrays
|
|
2492
|
+
* @param ar1 - First input array
|
|
2493
|
+
* @param ar2 - Second input array
|
|
2494
|
+
* @returns Sorted 1D array of values that are in only one array
|
|
2495
|
+
*/
|
|
2496
|
+
export declare function setxor1d(ar1: NDArray, ar2: NDArray): NDArray;
|
|
2497
|
+
/**
|
|
2498
|
+
* Find the union of two arrays
|
|
2499
|
+
* @param ar1 - First input array
|
|
2500
|
+
* @param ar2 - Second input array
|
|
2501
|
+
* @returns Sorted 1D array of unique values from both arrays
|
|
2502
|
+
*/
|
|
2503
|
+
export declare function union1d(ar1: NDArray, ar2: NDArray): NDArray;
|
|
2504
|
+
/**
|
|
2505
|
+
* Calculate the n-th discrete difference along the given axis
|
|
2506
|
+
* @param a - Input array
|
|
2507
|
+
* @param n - Number of times values are differenced (default: 1)
|
|
2508
|
+
* @param axis - Axis along which to compute difference (default: -1)
|
|
2509
|
+
* @returns Array of differences
|
|
2510
|
+
*/
|
|
2511
|
+
export declare function diff(a: NDArray, n?: number, axis?: number): NDArray;
|
|
2512
|
+
/**
|
|
2513
|
+
* The differences between consecutive elements of a flattened array
|
|
2514
|
+
* @param ary - Input array
|
|
2515
|
+
* @param to_end - Number(s) to append at the end
|
|
2516
|
+
* @param to_begin - Number(s) to prepend at the beginning
|
|
2517
|
+
* @returns Array of differences
|
|
2518
|
+
*/
|
|
2519
|
+
export declare function ediff1d(ary: NDArray, to_end?: number[] | null, to_begin?: number[] | null): NDArray;
|
|
2520
|
+
/**
|
|
2521
|
+
* Return the gradient of an N-dimensional array
|
|
2522
|
+
* The gradient is computed using second order accurate central differences
|
|
2523
|
+
* in the interior and first order accurate one-sided differences at the boundaries.
|
|
2524
|
+
* @param f - Input array
|
|
2525
|
+
* @param varargs - Spacing between values (scalar or array per dimension)
|
|
2526
|
+
* @param axis - Axis or axes along which to compute gradient
|
|
2527
|
+
* @returns Array of gradients (one per axis) or single gradient
|
|
2528
|
+
*/
|
|
2529
|
+
export declare function gradient(f: NDArray, varargs?: number | number[], axis?: number | number[] | null): NDArray | NDArray[];
|
|
2530
|
+
/**
|
|
2531
|
+
* Return the cross product of two (arrays of) vectors
|
|
2532
|
+
* @param a - First input array
|
|
2533
|
+
* @param b - Second input array
|
|
2534
|
+
* @param axisa - Axis of a that defines the vector(s) (default: -1)
|
|
2535
|
+
* @param axisb - Axis of b that defines the vector(s) (default: -1)
|
|
2536
|
+
* @param axisc - Axis of c containing the cross product (default: -1)
|
|
2537
|
+
* @returns Cross product array
|
|
2538
|
+
*/
|
|
2539
|
+
export declare function cross(a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number): NDArray;
|
|
2014
2540
|
//# sourceMappingURL=ndarray.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module numpy-ts
|
|
5
5
|
*/
|
|
6
|
-
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, absolute, negative, sign, mod, floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, sin, cos, tan, arcsin, arccos, arctan, arctan2, hypot, degrees, radians, deg2rad, rad2deg, sinh, cosh, tanh, arcsinh, arccosh, arctanh, 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, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, 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, cumprod, 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, } from './core/ndarray';
|
|
6
|
+
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, exp, exp2, expm1, log, log2, log10, log1p, logaddexp, logaddexp2, absolute, negative, sign, mod, floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, linalg, sin, cos, tan, arcsin, arccos, arctan, arctan2, hypot, degrees, radians, deg2rad, rad2deg, sinh, cosh, tanh, arcsinh, arccosh, arctanh, 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, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, 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, cumprod, 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, sort, argsort, lexsort, partition, argpartition, sort_complex, nonzero, flatnonzero, where, searchsorted, extract, count_nonzero, around, ceil, fix, floor, rint, round, trunc, unique, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, diff, ediff1d, gradient, cross, } from './core/ndarray';
|
|
7
7
|
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';
|
|
8
8
|
export declare const __version__: string;
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/types/io/index.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* IO module for numpy-ts
|
|
3
3
|
*
|
|
4
|
-
* This module provides parsing and serialization for NPY and
|
|
5
|
-
* These functions work with bytes
|
|
4
|
+
* This module provides parsing and serialization for NPY, NPZ, and text formats.
|
|
5
|
+
* These functions work with bytes/strings and are environment-agnostic.
|
|
6
6
|
*
|
|
7
7
|
* For file system operations (save/load), use the Node.js-specific entry point:
|
|
8
|
-
* import { save, load } from 'numpy-ts/node';
|
|
8
|
+
* import { save, load, loadtxt, savetxt } from 'numpy-ts/node';
|
|
9
9
|
*
|
|
10
|
-
* For browser usage, use fetch or FileReader to get the bytes, then use these functions.
|
|
10
|
+
* For browser usage, use fetch or FileReader to get the bytes/text, then use these functions.
|
|
11
11
|
*/
|
|
12
12
|
export { parseNpy, parseNpyHeader, parseNpyData } from './npy/parser';
|
|
13
13
|
export { serializeNpy } from './npy/serializer';
|
|
14
14
|
export { UnsupportedDTypeError, InvalidNpyError, SUPPORTED_DTYPES, DTYPE_TO_DESCR, type NpyHeader, type NpyMetadata, type NpyVersion, } from './npy/format';
|
|
15
15
|
export { parseNpz, parseNpzSync, loadNpz, loadNpzSync, type NpzParseOptions, type NpzParseResult, } from './npz/parser';
|
|
16
16
|
export { serializeNpz, serializeNpzSync, type NpzSerializeOptions } from './npz/serializer';
|
|
17
|
+
export { parseTxt, genfromtxt, fromregex, serializeTxt, type ParseTxtOptions, type SerializeTxtOptions, } from './txt';
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text I/O module for numpy-ts
|
|
3
|
+
*
|
|
4
|
+
* Provides parsing and serialization for delimited text formats (CSV, TSV, etc.).
|
|
5
|
+
* These functions work with strings and are environment-agnostic.
|
|
6
|
+
*
|
|
7
|
+
* For file system operations, use the Node.js-specific entry point:
|
|
8
|
+
* import { loadtxt, savetxt } from 'numpy-ts/node';
|
|
9
|
+
*/
|
|
10
|
+
export { parseTxt, genfromtxt, fromregex, type ParseTxtOptions } from './parser';
|
|
11
|
+
export { serializeTxt, type SerializeTxtOptions } from './serializer';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|