numpy-ts 0.3.0 → 0.5.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.
@@ -135,6 +135,101 @@ export declare class NDArray {
135
135
  * @returns New array with signs
136
136
  */
137
137
  sign(): NDArray;
138
+ /**
139
+ * Sine of each element (in radians)
140
+ * Promotes integer types to float64
141
+ * @returns New array with sine values
142
+ */
143
+ sin(): NDArray;
144
+ /**
145
+ * Cosine of each element (in radians)
146
+ * Promotes integer types to float64
147
+ * @returns New array with cosine values
148
+ */
149
+ cos(): NDArray;
150
+ /**
151
+ * Tangent of each element (in radians)
152
+ * Promotes integer types to float64
153
+ * @returns New array with tangent values
154
+ */
155
+ tan(): NDArray;
156
+ /**
157
+ * Inverse sine of each element
158
+ * Promotes integer types to float64
159
+ * @returns New array with arcsin values (radians)
160
+ */
161
+ arcsin(): NDArray;
162
+ /**
163
+ * Inverse cosine of each element
164
+ * Promotes integer types to float64
165
+ * @returns New array with arccos values (radians)
166
+ */
167
+ arccos(): NDArray;
168
+ /**
169
+ * Inverse tangent of each element
170
+ * Promotes integer types to float64
171
+ * @returns New array with arctan values (radians)
172
+ */
173
+ arctan(): NDArray;
174
+ /**
175
+ * Element-wise arc tangent of this/other choosing the quadrant correctly
176
+ * @param other - x-coordinates (array or scalar)
177
+ * @returns Angle in radians between -π and π
178
+ */
179
+ arctan2(other: NDArray | number): NDArray;
180
+ /**
181
+ * Given the "legs" of a right triangle, return its hypotenuse
182
+ * Equivalent to sqrt(this**2 + other**2), element-wise
183
+ * @param other - Second leg (array or scalar)
184
+ * @returns Hypotenuse values
185
+ */
186
+ hypot(other: NDArray | number): NDArray;
187
+ /**
188
+ * Convert angles from radians to degrees
189
+ * @returns New array with angles in degrees
190
+ */
191
+ degrees(): NDArray;
192
+ /**
193
+ * Convert angles from degrees to radians
194
+ * @returns New array with angles in radians
195
+ */
196
+ radians(): NDArray;
197
+ /**
198
+ * Hyperbolic sine of each element
199
+ * Promotes integer types to float64
200
+ * @returns New array with sinh values
201
+ */
202
+ sinh(): NDArray;
203
+ /**
204
+ * Hyperbolic cosine of each element
205
+ * Promotes integer types to float64
206
+ * @returns New array with cosh values
207
+ */
208
+ cosh(): NDArray;
209
+ /**
210
+ * Hyperbolic tangent of each element
211
+ * Promotes integer types to float64
212
+ * @returns New array with tanh values
213
+ */
214
+ tanh(): NDArray;
215
+ /**
216
+ * Inverse hyperbolic sine of each element
217
+ * Promotes integer types to float64
218
+ * @returns New array with arcsinh values
219
+ */
220
+ arcsinh(): NDArray;
221
+ /**
222
+ * Inverse hyperbolic cosine of each element
223
+ * Promotes integer types to float64
224
+ * @returns New array with arccosh values
225
+ */
226
+ arccosh(): NDArray;
227
+ /**
228
+ * Inverse hyperbolic tangent of each element
229
+ * Promotes integer types to float64
230
+ * @returns New array with arctanh values
231
+ */
232
+ arctanh(): NDArray;
138
233
  /**
139
234
  * Element-wise greater than comparison
140
235
  * @param other - Value or array to compare with
@@ -303,12 +398,76 @@ export declare class NDArray {
303
398
  * @returns Array with additional dimension (always a view)
304
399
  */
305
400
  expand_dims(axis: number): NDArray;
401
+ /**
402
+ * Swap two axes of an array
403
+ * @param axis1 - First axis
404
+ * @param axis2 - Second axis
405
+ * @returns Array with swapped axes (always a view)
406
+ */
407
+ swapaxes(axis1: number, axis2: number): NDArray;
408
+ /**
409
+ * Move axes to new positions
410
+ * @param source - Original positions of axes to move
411
+ * @param destination - New positions for axes
412
+ * @returns Array with moved axes (always a view)
413
+ */
414
+ moveaxis(source: number | number[], destination: number | number[]): NDArray;
415
+ /**
416
+ * Repeat elements of an array
417
+ * @param repeats - Number of repetitions for each element
418
+ * @param axis - Axis along which to repeat (if undefined, flattens first)
419
+ * @returns New array with repeated elements
420
+ */
421
+ repeat(repeats: number | number[], axis?: number): NDArray;
422
+ /**
423
+ * Take elements from array along an axis
424
+ * @param indices - Indices of elements to take
425
+ * @param axis - Axis along which to take (if undefined, flattens first)
426
+ * @returns New array with selected elements
427
+ */
428
+ take(indices: number[], axis?: number): NDArray;
429
+ /**
430
+ * Put values at specified indices (modifies array in-place)
431
+ * @param indices - Indices at which to place values
432
+ * @param values - Values to put
433
+ */
434
+ put(indices: number[], values: NDArray | number | bigint): void;
306
435
  /**
307
436
  * Matrix multiplication
308
437
  * @param other - Array to multiply with
309
438
  * @returns Result of matrix multiplication
310
439
  */
311
440
  matmul(other: NDArray): NDArray;
441
+ /**
442
+ * Dot product (matching NumPy behavior)
443
+ * @param other - Array to dot with
444
+ * @returns Result of dot product (scalar or array depending on dimensions)
445
+ */
446
+ dot(other: NDArray): NDArray | number | bigint;
447
+ /**
448
+ * Sum of diagonal elements (trace)
449
+ * @returns Sum of diagonal elements
450
+ */
451
+ trace(): number | bigint;
452
+ /**
453
+ * Inner product (contracts over last axes of both arrays)
454
+ * @param other - Array to compute inner product with
455
+ * @returns Inner product result
456
+ */
457
+ inner(other: NDArray): NDArray | number | bigint;
458
+ /**
459
+ * Outer product (flattens inputs then computes a[i]*b[j])
460
+ * @param other - Array to compute outer product with
461
+ * @returns 2D outer product matrix
462
+ */
463
+ outer(other: NDArray): NDArray;
464
+ /**
465
+ * Tensor dot product along specified axes
466
+ * @param other - Array to contract with
467
+ * @param axes - Axes to contract (integer or [a_axes, b_axes])
468
+ * @returns Tensor dot product result
469
+ */
470
+ tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
312
471
  /**
313
472
  * Slice the array using NumPy-style string syntax
314
473
  *
@@ -545,4 +704,322 @@ export declare function positive(x: NDArray): NDArray;
545
704
  * @returns Array of reciprocals
546
705
  */
547
706
  export declare function reciprocal(x: NDArray): NDArray;
707
+ /**
708
+ * Dot product of two arrays
709
+ *
710
+ * Fully NumPy-compatible. Behavior depends on input dimensions:
711
+ * - 0D · 0D: Multiply scalars → scalar
712
+ * - 0D · ND or ND · 0D: Element-wise multiply → ND
713
+ * - 1D · 1D: Inner product → scalar
714
+ * - 2D · 2D: Matrix multiplication → 2D
715
+ * - 2D · 1D: Matrix-vector product → 1D
716
+ * - 1D · 2D: Vector-matrix product → 1D
717
+ * - ND · 1D (N>2): Sum over last axis → (N-1)D
718
+ * - 1D · ND (N>2): Sum over first axis → (N-1)D
719
+ * - ND · MD (N,M≥2): Tensor contraction → (N+M-2)D
720
+ *
721
+ * @param a - First array
722
+ * @param b - Second array
723
+ * @returns Result of dot product
724
+ */
725
+ export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint;
726
+ /**
727
+ * Sum of diagonal elements
728
+ *
729
+ * @param a - Input 2D array
730
+ * @returns Sum of diagonal elements
731
+ */
732
+ export declare function trace(a: NDArray): number | bigint;
733
+ /**
734
+ * Permute array dimensions
735
+ *
736
+ * @param a - Input array
737
+ * @param axes - Optional permutation of axes (defaults to reverse order)
738
+ * @returns Transposed view
739
+ */
740
+ export declare function transpose(a: NDArray, axes?: number[]): NDArray;
741
+ /**
742
+ * Inner product of two arrays
743
+ *
744
+ * Contracts over last axes of both arrays.
745
+ * Result shape: (*a.shape[:-1], *b.shape[:-1])
746
+ *
747
+ * @param a - First array
748
+ * @param b - Second array
749
+ * @returns Inner product result
750
+ */
751
+ export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint;
752
+ /**
753
+ * Outer product of two arrays
754
+ *
755
+ * Flattens inputs then computes result[i,j] = a[i] * b[j]
756
+ *
757
+ * @param a - First array
758
+ * @param b - Second array
759
+ * @returns 2D outer product matrix
760
+ */
761
+ export declare function outer(a: NDArray, b: NDArray): NDArray;
762
+ /**
763
+ * Tensor dot product along specified axes
764
+ *
765
+ * @param a - First array
766
+ * @param b - Second array
767
+ * @param axes - Axes to contract (integer or [a_axes, b_axes])
768
+ * @returns Tensor dot product
769
+ */
770
+ export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
771
+ /**
772
+ * Element-wise sine
773
+ * @param x - Input array (angles in radians)
774
+ * @returns Array of sine values
775
+ */
776
+ export declare function sin(x: NDArray): NDArray;
777
+ /**
778
+ * Element-wise cosine
779
+ * @param x - Input array (angles in radians)
780
+ * @returns Array of cosine values
781
+ */
782
+ export declare function cos(x: NDArray): NDArray;
783
+ /**
784
+ * Element-wise tangent
785
+ * @param x - Input array (angles in radians)
786
+ * @returns Array of tangent values
787
+ */
788
+ export declare function tan(x: NDArray): NDArray;
789
+ /**
790
+ * Element-wise inverse sine
791
+ * @param x - Input array (values in range [-1, 1])
792
+ * @returns Array of angles in radians
793
+ */
794
+ export declare function arcsin(x: NDArray): NDArray;
795
+ /**
796
+ * Element-wise inverse cosine
797
+ * @param x - Input array (values in range [-1, 1])
798
+ * @returns Array of angles in radians
799
+ */
800
+ export declare function arccos(x: NDArray): NDArray;
801
+ /**
802
+ * Element-wise inverse tangent
803
+ * @param x - Input array
804
+ * @returns Array of angles in radians
805
+ */
806
+ export declare function arctan(x: NDArray): NDArray;
807
+ /**
808
+ * Element-wise arc tangent of x1/x2 choosing the quadrant correctly
809
+ * @param x1 - y-coordinates
810
+ * @param x2 - x-coordinates (array or scalar)
811
+ * @returns Angles in radians between -π and π
812
+ */
813
+ export declare function arctan2(x1: NDArray, x2: NDArray | number): NDArray;
814
+ /**
815
+ * Given the "legs" of a right triangle, return its hypotenuse
816
+ * Equivalent to sqrt(x1**2 + x2**2), element-wise
817
+ * @param x1 - First leg
818
+ * @param x2 - Second leg (array or scalar)
819
+ * @returns Hypotenuse values
820
+ */
821
+ export declare function hypot(x1: NDArray, x2: NDArray | number): NDArray;
822
+ /**
823
+ * Convert angles from radians to degrees
824
+ * @param x - Input array (angles in radians)
825
+ * @returns Angles in degrees
826
+ */
827
+ export declare function degrees(x: NDArray): NDArray;
828
+ /**
829
+ * Convert angles from degrees to radians
830
+ * @param x - Input array (angles in degrees)
831
+ * @returns Angles in radians
832
+ */
833
+ export declare function radians(x: NDArray): NDArray;
834
+ /**
835
+ * Element-wise hyperbolic sine
836
+ * @param x - Input array
837
+ * @returns Array of sinh values
838
+ */
839
+ export declare function sinh(x: NDArray): NDArray;
840
+ /**
841
+ * Element-wise hyperbolic cosine
842
+ * @param x - Input array
843
+ * @returns Array of cosh values
844
+ */
845
+ export declare function cosh(x: NDArray): NDArray;
846
+ /**
847
+ * Element-wise hyperbolic tangent
848
+ * @param x - Input array
849
+ * @returns Array of tanh values
850
+ */
851
+ export declare function tanh(x: NDArray): NDArray;
852
+ /**
853
+ * Element-wise inverse hyperbolic sine
854
+ * @param x - Input array
855
+ * @returns Array of arcsinh values
856
+ */
857
+ export declare function arcsinh(x: NDArray): NDArray;
858
+ /**
859
+ * Element-wise inverse hyperbolic cosine
860
+ * @param x - Input array (values >= 1)
861
+ * @returns Array of arccosh values
862
+ */
863
+ export declare function arccosh(x: NDArray): NDArray;
864
+ /**
865
+ * Element-wise inverse hyperbolic tangent
866
+ * @param x - Input array (values in range (-1, 1))
867
+ * @returns Array of arctanh values
868
+ */
869
+ export declare function arctanh(x: NDArray): NDArray;
870
+ /**
871
+ * Swap two axes of an array
872
+ *
873
+ * @param a - Input array
874
+ * @param axis1 - First axis
875
+ * @param axis2 - Second axis
876
+ * @returns View with axes swapped
877
+ */
878
+ export declare function swapaxes(a: NDArray, axis1: number, axis2: number): NDArray;
879
+ /**
880
+ * Move axes to new positions
881
+ *
882
+ * @param a - Input array
883
+ * @param source - Original positions of axes to move
884
+ * @param destination - New positions for axes
885
+ * @returns View with axes moved
886
+ */
887
+ export declare function moveaxis(a: NDArray, source: number | number[], destination: number | number[]): NDArray;
888
+ /**
889
+ * Concatenate arrays along an existing axis
890
+ *
891
+ * @param arrays - Arrays to concatenate
892
+ * @param axis - Axis along which to concatenate (default: 0)
893
+ * @returns Concatenated array
894
+ */
895
+ export declare function concatenate(arrays: NDArray[], axis?: number): NDArray;
896
+ /**
897
+ * Stack arrays along a new axis
898
+ *
899
+ * @param arrays - Arrays to stack (must have same shape)
900
+ * @param axis - Axis in the result array along which to stack (default: 0)
901
+ * @returns Stacked array
902
+ */
903
+ export declare function stack(arrays: NDArray[], axis?: number): NDArray;
904
+ /**
905
+ * Stack arrays vertically (row-wise)
906
+ *
907
+ * @param arrays - Arrays to stack
908
+ * @returns Vertically stacked array
909
+ */
910
+ export declare function vstack(arrays: NDArray[]): NDArray;
911
+ /**
912
+ * Stack arrays horizontally (column-wise)
913
+ *
914
+ * @param arrays - Arrays to stack
915
+ * @returns Horizontally stacked array
916
+ */
917
+ export declare function hstack(arrays: NDArray[]): NDArray;
918
+ /**
919
+ * Stack arrays depth-wise (along third axis)
920
+ *
921
+ * @param arrays - Arrays to stack
922
+ * @returns Depth-stacked array
923
+ */
924
+ export declare function dstack(arrays: NDArray[]): NDArray;
925
+ /**
926
+ * Split array into multiple sub-arrays
927
+ *
928
+ * @param a - Array to split
929
+ * @param indicesOrSections - Number of equal sections or indices where to split
930
+ * @param axis - Axis along which to split (default: 0)
931
+ * @returns List of sub-arrays
932
+ */
933
+ export declare function split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
934
+ /**
935
+ * Split array into multiple sub-arrays (allows unequal splits)
936
+ *
937
+ * @param a - Array to split
938
+ * @param indicesOrSections - Number of sections or indices where to split
939
+ * @param axis - Axis along which to split (default: 0)
940
+ * @returns List of sub-arrays
941
+ */
942
+ export declare function array_split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
943
+ /**
944
+ * Split array vertically (row-wise)
945
+ *
946
+ * @param a - Array to split
947
+ * @param indicesOrSections - Number of sections or indices where to split
948
+ * @returns List of sub-arrays
949
+ */
950
+ export declare function vsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
951
+ /**
952
+ * Split array horizontally (column-wise)
953
+ *
954
+ * @param a - Array to split
955
+ * @param indicesOrSections - Number of sections or indices where to split
956
+ * @returns List of sub-arrays
957
+ */
958
+ export declare function hsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
959
+ /**
960
+ * Tile array by repeating along each axis
961
+ *
962
+ * @param a - Input array
963
+ * @param reps - Number of repetitions along each axis
964
+ * @returns Tiled array
965
+ */
966
+ export declare function tile(a: NDArray, reps: number | number[]): NDArray;
967
+ /**
968
+ * Repeat elements of an array
969
+ *
970
+ * @param a - Input array
971
+ * @param repeats - Number of repetitions for each element
972
+ * @param axis - Axis along which to repeat (if undefined, flattens first)
973
+ * @returns Array with repeated elements
974
+ */
975
+ export declare function repeat(a: NDArray, repeats: number | number[], axis?: number): NDArray;
976
+ /**
977
+ * Broadcast an array to a given shape
978
+ *
979
+ * @param a - Input array
980
+ * @param shape - Target shape
981
+ * @returns View broadcast to target shape
982
+ */
983
+ export declare function broadcast_to(a: NDArray, shape: number[]): NDArray;
984
+ /**
985
+ * Broadcast arrays to a common shape
986
+ *
987
+ * @param arrays - Arrays to broadcast
988
+ * @returns Arrays broadcast to common shape
989
+ */
990
+ export declare function broadcast_arrays(...arrays: NDArray[]): NDArray[];
991
+ /**
992
+ * Take elements from an array along an axis
993
+ *
994
+ * @param a - Input array
995
+ * @param indices - Indices of elements to take
996
+ * @param axis - Axis along which to take (if undefined, flattens first)
997
+ * @returns Array with selected elements
998
+ */
999
+ export declare function take(a: NDArray, indices: number[], axis?: number): NDArray;
1000
+ /**
1001
+ * Put values at specified indices (modifies array in-place)
1002
+ *
1003
+ * @param a - Target array
1004
+ * @param indices - Indices at which to place values
1005
+ * @param values - Values to put
1006
+ */
1007
+ export declare function put(a: NDArray, indices: number[], values: NDArray | number | bigint): void;
1008
+ /**
1009
+ * Construct array from index array and choices
1010
+ *
1011
+ * @param a - Index array (integer indices into choices)
1012
+ * @param choices - Arrays to choose from
1013
+ * @returns Array constructed from choices
1014
+ */
1015
+ export declare function choose(a: NDArray, choices: NDArray[]): NDArray;
1016
+ /**
1017
+ * Check if two arrays are element-wise equal
1018
+ *
1019
+ * @param a - First array
1020
+ * @param b - Second array
1021
+ * @param equal_nan - Whether to consider NaN equal to NaN (default: false)
1022
+ * @returns True if arrays are equal element-wise
1023
+ */
1024
+ export declare function array_equal(a: NDArray, b: NDArray, equal_nan?: boolean): boolean;
548
1025
  //# sourceMappingURL=ndarray.d.ts.map
@@ -3,6 +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, sqrt, power, absolute, negative, sign, mod, floor_divide, positive, reciprocal, } 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, sqrt, power, absolute, negative, sign, mod, floor_divide, positive, reciprocal, dot, trace, transpose, inner, outer, tensordot, sin, cos, tan, arcsin, arccos, arctan, arctan2, hypot, degrees, radians, sinh, cosh, tanh, arcsinh, arccosh, arctanh, swapaxes, moveaxis, concatenate, stack, vstack, hstack, dstack, split, array_split, vsplit, hsplit, tile, repeat, broadcast_to, broadcast_arrays, take, put, choose, array_equal, } from './core/ndarray';
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';
7
8
  export declare const __version__: string;
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * IO module for numpy-ts
3
+ *
4
+ * This module provides parsing and serialization for NPY and NPZ formats.
5
+ * These functions work with bytes (Uint8Array/ArrayBuffer) and are environment-agnostic.
6
+ *
7
+ * For file system operations (save/load), use the Node.js-specific entry point:
8
+ * import { save, load } from 'numpy-ts/node';
9
+ *
10
+ * For browser usage, use fetch or FileReader to get the bytes, then use these functions.
11
+ */
12
+ export { parseNpy, parseNpyHeader, parseNpyData } from './npy/parser';
13
+ export { serializeNpy } from './npy/serializer';
14
+ export { UnsupportedDTypeError, InvalidNpyError, SUPPORTED_DTYPES, DTYPE_TO_DESCR, type NpyHeader, type NpyMetadata, type NpyVersion, } from './npy/format';
15
+ export { parseNpz, parseNpzSync, loadNpz, loadNpzSync, type NpzParseOptions, type NpzParseResult, } from './npz/parser';
16
+ export { serializeNpz, serializeNpzSync, type NpzSerializeOptions } from './npz/serializer';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,91 @@
1
+ /**
2
+ * NPY file format constants and type definitions
3
+ *
4
+ * NPY is NumPy's native binary format for storing arrays.
5
+ * Spec: https://numpy.org/doc/stable/reference/generated/numpy.lib.format.html
6
+ */
7
+ import type { DType } from '../../core/dtype';
8
+ /**
9
+ * NPY magic number: \x93NUMPY (6 bytes)
10
+ */
11
+ export declare const NPY_MAGIC: Uint8Array<ArrayBuffer>;
12
+ /**
13
+ * Supported NPY format versions
14
+ * - v1.0: 2-byte header length (max 65535 bytes)
15
+ * - v2.0: 4-byte header length (max 4GB)
16
+ * - v3.0: allows UTF-8 in description (same as v2 otherwise)
17
+ *
18
+ * We read v1, v2, and v3; we write v2 only
19
+ */
20
+ export interface NpyVersion {
21
+ major: number;
22
+ minor: number;
23
+ }
24
+ /**
25
+ * NPY header information
26
+ */
27
+ export interface NpyHeader {
28
+ /** Data type descriptor (e.g., '<f8', '>i4') */
29
+ descr: string;
30
+ /** Whether array is Fortran-contiguous (column-major) */
31
+ fortran_order: boolean;
32
+ /** Array shape */
33
+ shape: number[];
34
+ }
35
+ /**
36
+ * Parsed NPY metadata including version
37
+ */
38
+ export interface NpyMetadata {
39
+ version: NpyVersion;
40
+ header: NpyHeader;
41
+ /** Byte offset where data starts */
42
+ dataOffset: number;
43
+ }
44
+ /**
45
+ * Result of parsing an NPY header descriptor to our DType
46
+ */
47
+ export interface DTypeParseResult {
48
+ dtype: DType;
49
+ /** Whether the data needs byte swapping (big-endian on little-endian or vice versa) */
50
+ needsByteSwap: boolean;
51
+ /** Element size in bytes */
52
+ itemsize: number;
53
+ }
54
+ /**
55
+ * All dtypes we support
56
+ */
57
+ export declare const SUPPORTED_DTYPES: DType[];
58
+ /**
59
+ * Detect system endianness
60
+ */
61
+ export declare function isSystemLittleEndian(): boolean;
62
+ /**
63
+ * DType to NPY descriptor mapping (for serialization)
64
+ * We always write little-endian
65
+ */
66
+ export declare const DTYPE_TO_DESCR: Record<DType, string>;
67
+ /**
68
+ * Unsupported dtype types (for error messages)
69
+ */
70
+ export declare const UNSUPPORTED_DTYPE_PATTERNS: Record<string, string>;
71
+ /**
72
+ * Parse a NumPy dtype descriptor string to our DType
73
+ *
74
+ * @param descr - NumPy descriptor like '<f8', '>i4', '|b1'
75
+ * @returns Parsed result with dtype and byte order info
76
+ * @throws Error if dtype is not supported
77
+ */
78
+ export declare function parseDescriptor(descr: string): DTypeParseResult;
79
+ /**
80
+ * Custom error for unsupported dtypes
81
+ */
82
+ export declare class UnsupportedDTypeError extends Error {
83
+ constructor(message: string);
84
+ }
85
+ /**
86
+ * Custom error for invalid NPY format
87
+ */
88
+ export declare class InvalidNpyError extends Error {
89
+ constructor(message: string);
90
+ }
91
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * NPY format reading and writing
3
+ */
4
+ export { parseNpy, parseNpyHeader, parseNpyData } from './parser';
5
+ export { serializeNpy } from './serializer';
6
+ export { NPY_MAGIC, DTYPE_TO_DESCR, SUPPORTED_DTYPES, parseDescriptor, isSystemLittleEndian, UnsupportedDTypeError, InvalidNpyError, type NpyVersion, type NpyHeader, type NpyMetadata, type DTypeParseResult, } from './format';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * NPY file parser
3
+ *
4
+ * Parses NumPy .npy files (both v1 and v2/v3 formats) into NDArray objects.
5
+ */
6
+ import { NDArray } from '../../core/ndarray';
7
+ import { type NpyMetadata } from './format';
8
+ /**
9
+ * Parse an NPY file from a Uint8Array or ArrayBuffer
10
+ *
11
+ * @param buffer - The NPY file contents
12
+ * @returns An NDArray containing the parsed data
13
+ * @throws InvalidNpyError if the file format is invalid
14
+ * @throws UnsupportedDTypeError if the dtype is not supported
15
+ */
16
+ export declare function parseNpy(buffer: ArrayBuffer | Uint8Array): NDArray;
17
+ /**
18
+ * Parse just the NPY header without reading the data
19
+ *
20
+ * @param bytes - The NPY file bytes
21
+ * @returns Parsed metadata including version, header, and data offset
22
+ */
23
+ export declare function parseNpyHeader(bytes: Uint8Array): NpyMetadata;
24
+ /**
25
+ * Parse the data section of an NPY file given parsed metadata
26
+ */
27
+ export declare function parseNpyData(bytes: Uint8Array, metadata: NpyMetadata): NDArray;
28
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * NPY file serializer
3
+ *
4
+ * Serializes NDArray objects to NumPy .npy format (v3.0).
5
+ * Always writes in little-endian, C-contiguous order.
6
+ *
7
+ * v3.0 is identical to v2.0 but allows UTF-8 in dtype descriptions.
8
+ */
9
+ import { NDArray } from '../../core/ndarray';
10
+ /**
11
+ * Serialize an NDArray to NPY format (v3.0)
12
+ *
13
+ * @param arr - The NDArray to serialize
14
+ * @returns A Uint8Array containing the NPY file data
15
+ */
16
+ export declare function serializeNpy(arr: NDArray): Uint8Array;
17
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * NPZ format reading and writing
3
+ */
4
+ export { parseNpz, parseNpzSync, loadNpz, loadNpzSync, type NpzParseOptions, type NpzParseResult, } from './parser';
5
+ export { serializeNpz, serializeNpzSync, type NpzSerializeOptions, type NpzArraysInput, } from './serializer';
6
+ //# sourceMappingURL=index.d.ts.map