numpy-ts 0.12.0 → 0.13.1

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.
Files changed (144) hide show
  1. package/README.md +18 -14
  2. package/dist/esm/common/broadcasting.js +1 -0
  3. package/dist/esm/common/complex.js +1 -0
  4. package/dist/esm/common/dtype.js +1 -0
  5. package/dist/esm/common/internal/compute.js +1 -0
  6. package/dist/esm/common/internal/indexing.js +1 -0
  7. package/dist/esm/common/ndarray-core.js +1 -0
  8. package/dist/esm/common/ops/advanced.js +1 -0
  9. package/dist/esm/common/ops/arithmetic.js +1 -0
  10. package/dist/esm/common/ops/bitwise.js +1 -0
  11. package/dist/esm/common/ops/comparison.js +1 -0
  12. package/dist/esm/common/ops/complex.js +1 -0
  13. package/dist/esm/common/ops/exponential.js +1 -0
  14. package/dist/esm/common/ops/fft.js +1 -0
  15. package/dist/esm/common/ops/formatting.js +4 -0
  16. package/dist/esm/common/ops/gradient.js +1 -0
  17. package/dist/esm/common/ops/hyperbolic.js +1 -0
  18. package/dist/esm/common/ops/linalg.js +2 -0
  19. package/dist/esm/common/ops/logic.js +1 -0
  20. package/dist/esm/common/ops/random.js +1 -0
  21. package/dist/esm/common/ops/reduction.js +1 -0
  22. package/dist/esm/common/ops/rounding.js +1 -0
  23. package/dist/esm/common/ops/sets.js +1 -0
  24. package/dist/esm/common/ops/shape.js +1 -0
  25. package/dist/esm/common/ops/sorting.js +1 -0
  26. package/dist/esm/common/ops/statistics.js +1 -0
  27. package/dist/esm/common/ops/trig.js +1 -0
  28. package/dist/esm/common/slicing.js +1 -0
  29. package/dist/esm/common/storage.js +1 -0
  30. package/dist/esm/core/advanced.js +1 -0
  31. package/dist/esm/core/arithmetic.js +1 -0
  32. package/dist/esm/core/bitwise.js +1 -0
  33. package/dist/esm/core/complex.js +1 -0
  34. package/dist/esm/core/creation.js +1 -0
  35. package/dist/esm/core/formatting.js +1 -0
  36. package/dist/esm/core/gradient.js +1 -0
  37. package/dist/esm/core/index.js +1 -0
  38. package/dist/esm/core/linalg.js +1 -0
  39. package/dist/esm/core/logic.js +1 -0
  40. package/dist/esm/core/polynomial.js +1 -0
  41. package/dist/esm/core/reduction.js +1 -0
  42. package/dist/esm/core/rounding.js +1 -0
  43. package/dist/esm/core/sets.js +1 -0
  44. package/dist/esm/core/shape-extra.js +1 -0
  45. package/dist/esm/core/shape.js +1 -0
  46. package/dist/esm/core/sorting.js +1 -0
  47. package/dist/esm/core/statistics.js +1 -0
  48. package/dist/esm/core/trig.js +1 -0
  49. package/dist/esm/core/typechecking.js +1 -0
  50. package/dist/esm/core/types.js +1 -0
  51. package/dist/esm/core/utility.js +1 -0
  52. package/dist/esm/core.js +1 -0
  53. package/dist/esm/full/index.js +1 -0
  54. package/dist/esm/full/ndarray.js +1 -0
  55. package/dist/esm/index.js +1 -0
  56. package/dist/esm/io/index.js +1 -0
  57. package/dist/esm/io/npy/format.js +1 -0
  58. package/dist/esm/io/npy/index.js +1 -0
  59. package/dist/esm/io/npy/parser.js +1 -0
  60. package/dist/esm/io/npy/serializer.js +2 -0
  61. package/dist/esm/io/npz/index.js +1 -0
  62. package/dist/esm/io/npz/parser.js +1 -0
  63. package/dist/esm/io/npz/serializer.js +1 -0
  64. package/dist/esm/io/txt/index.js +1 -0
  65. package/dist/esm/io/txt/parser.js +1 -0
  66. package/dist/esm/io/txt/serializer.js +2 -0
  67. package/dist/esm/io/zip/index.js +1 -0
  68. package/dist/esm/io/zip/reader.js +1 -0
  69. package/dist/esm/io/zip/types.js +1 -0
  70. package/dist/esm/io/zip/writer.js +1 -0
  71. package/dist/esm/node.js +1 -0
  72. package/dist/numpy-ts.browser.js +7 -2
  73. package/dist/numpy-ts.node-io.cjs +7 -3
  74. package/dist/numpy-ts.node-io.cjs.map +4 -4
  75. package/dist/numpy-ts.node-io.mjs +7 -3
  76. package/dist/numpy-ts.node-io.mjs.map +4 -4
  77. package/dist/numpy-ts.node.cjs +7 -2
  78. package/dist/numpy-ts.node.cjs.map +4 -4
  79. package/dist/types/common/complex.d.ts +94 -0
  80. package/dist/types/{internal → common/internal}/compute.d.ts +1 -1
  81. package/dist/types/{internal → common/internal}/indexing.d.ts +6 -0
  82. package/dist/types/common/ndarray-core.d.ts +126 -0
  83. package/dist/types/{ops → common/ops}/advanced.d.ts +2 -2
  84. package/dist/types/{ops → common/ops}/arithmetic.d.ts +1 -1
  85. package/dist/types/{ops → common/ops}/bitwise.d.ts +1 -1
  86. package/dist/types/{ops → common/ops}/comparison.d.ts +1 -1
  87. package/dist/types/{ops → common/ops}/complex.d.ts +1 -1
  88. package/dist/types/{ops → common/ops}/exponential.d.ts +1 -1
  89. package/dist/types/common/ops/fft.d.ts +166 -0
  90. package/dist/types/common/ops/formatting.d.ts +229 -0
  91. package/dist/types/{ops → common/ops}/gradient.d.ts +1 -1
  92. package/dist/types/{ops → common/ops}/hyperbolic.d.ts +1 -1
  93. package/dist/types/{ops → common/ops}/linalg.d.ts +24 -3
  94. package/dist/types/{ops → common/ops}/logic.d.ts +2 -2
  95. package/dist/types/common/ops/random.d.ts +376 -0
  96. package/dist/types/{ops → common/ops}/reduction.d.ts +2 -2
  97. package/dist/types/{ops → common/ops}/rounding.d.ts +1 -1
  98. package/dist/types/{ops → common/ops}/sets.d.ts +1 -1
  99. package/dist/types/{ops → common/ops}/shape.d.ts +1 -1
  100. package/dist/types/{ops → common/ops}/sorting.d.ts +1 -1
  101. package/dist/types/{ops → common/ops}/statistics.d.ts +1 -1
  102. package/dist/types/{ops → common/ops}/trig.d.ts +1 -1
  103. package/dist/types/{core → common}/storage.d.ts +1 -0
  104. package/dist/types/core/advanced.d.ts +54 -0
  105. package/dist/types/core/arithmetic.d.ts +110 -0
  106. package/dist/types/core/bitwise.d.ts +34 -0
  107. package/dist/types/core/complex.d.ts +15 -90
  108. package/dist/types/core/creation.d.ts +98 -0
  109. package/dist/types/core/formatting.d.ts +29 -0
  110. package/dist/types/core/gradient.d.ts +14 -0
  111. package/dist/types/core/index.d.ts +40 -0
  112. package/dist/types/core/linalg.d.ts +141 -0
  113. package/dist/types/core/logic.d.ts +72 -0
  114. package/dist/types/core/polynomial.d.ts +50 -0
  115. package/dist/types/core/reduction.d.ts +82 -0
  116. package/dist/types/core/rounding.d.ts +24 -0
  117. package/dist/types/core/sets.d.ts +48 -0
  118. package/dist/types/core/shape-extra.d.ts +24 -0
  119. package/dist/types/core/shape.d.ts +77 -0
  120. package/dist/types/core/sorting.d.ts +34 -0
  121. package/dist/types/core/statistics.d.ts +32 -0
  122. package/dist/types/core/trig.d.ts +58 -0
  123. package/dist/types/core/typechecking.d.ts +50 -0
  124. package/dist/types/core/types.d.ts +43 -0
  125. package/dist/types/core/utility.d.ts +30 -0
  126. package/dist/types/core.d.ts +30 -0
  127. package/dist/types/full/index.d.ts +603 -0
  128. package/dist/types/full/ndarray.d.ts +880 -0
  129. package/dist/types/index.d.ts +140 -26
  130. package/dist/types/io/npy/format.d.ts +1 -1
  131. package/dist/types/io/npy/parser.d.ts +3 -3
  132. package/dist/types/io/npy/serializer.d.ts +2 -2
  133. package/dist/types/io/npz/parser.d.ts +4 -4
  134. package/dist/types/io/npz/serializer.d.ts +6 -6
  135. package/dist/types/io/txt/parser.d.ts +5 -5
  136. package/dist/types/io/txt/serializer.d.ts +2 -2
  137. package/dist/types/node.d.ts +12 -8
  138. package/package.json +30 -29
  139. package/dist/numpy-ts.esm.js +0 -2
  140. package/dist/types/core/ndarray.d.ts +0 -3923
  141. package/dist/types/ops/random.d.ts +0 -136
  142. /package/dist/types/{core → common}/broadcasting.d.ts +0 -0
  143. /package/dist/types/{core → common}/dtype.d.ts +0 -0
  144. /package/dist/types/{core → common}/slicing.d.ts +0 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Type checking and dtype utility functions
3
+ *
4
+ * Tree-shakeable standalone functions for dtype operations.
5
+ */
6
+ import { NDArrayCore, type DType } from '../common/ndarray-core';
7
+ /**
8
+ * Check if a cast between dtypes is possible according to the casting rule
9
+ */
10
+ export declare function can_cast(from_: DType | NDArrayCore, to: DType, casting?: 'no' | 'equiv' | 'safe' | 'same_kind' | 'unsafe'): boolean;
11
+ /**
12
+ * Return a scalar type common to input arrays
13
+ *
14
+ * This returns a floating-point type that can represent all input types.
15
+ * Integers are promoted to floats that can hold their full range.
16
+ */
17
+ export declare function common_type(...arrays: NDArrayCore[]): DType;
18
+ /**
19
+ * Return the type that results from applying promotion rules
20
+ *
21
+ * NumPy-compatible type promotion:
22
+ * - Integers promote to larger integers that can hold both ranges
23
+ * - int32 + uint32 -> int64 (needs signed type that fits both)
24
+ * - Integer + float -> float64 if integer is 32+ bits
25
+ * - float32 + complex64 -> complex64
26
+ * - float64 + complex64 -> complex128
27
+ */
28
+ export declare function result_type(...arrays_and_dtypes: (NDArrayCore | DType)[]): DType;
29
+ /**
30
+ * Return the minimum scalar type needed to represent a value
31
+ */
32
+ export declare function min_scalar_type(val: number | bigint | boolean): DType;
33
+ /**
34
+ * Check if dtype1 is a subtype of dtype2
35
+ */
36
+ export declare function issubdtype(dtype1: DType | NDArrayCore, dtype2: DType | string): boolean;
37
+ /**
38
+ * Return a description for the given dtype
39
+ *
40
+ * Returns the dtype name directly (NumPy compatible).
41
+ */
42
+ export declare function typename(dtype: DType): string;
43
+ /**
44
+ * Return the character code of the minimum-size type needed
45
+ *
46
+ * Returns the minimum type from typeset that can safely represent all input types.
47
+ * Uses safe casting rules to ensure no precision loss.
48
+ */
49
+ export declare function mintypecode(typechars: string, typeset?: string, default_?: string): string;
50
+ //# sourceMappingURL=typechecking.d.ts.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Shared types for standalone function modules
3
+ *
4
+ * This module provides type definitions and helper functions used by
5
+ * standalone function wrappers for tree-shaking support.
6
+ */
7
+ import { NDArrayCore } from '../common/ndarray-core';
8
+ import { ArrayStorage } from '../common/storage';
9
+ import { Complex } from '../common/complex';
10
+ export type { DType, TypedArray } from '../common/dtype';
11
+ export { NDArrayCore, ArrayStorage, Complex };
12
+ /**
13
+ * Input type for functions that accept arrays
14
+ * Can be an NDArrayCore instance or nested arrays
15
+ */
16
+ export type ArrayLike = NDArrayCore | number[] | number[][] | number[][][] | number | bigint;
17
+ /**
18
+ * Convert input to ArrayStorage
19
+ * Handles both NDArrayCore and NDArray (which has _storage property)
20
+ */
21
+ export declare function toStorage(a: NDArrayCore | ArrayStorage): ArrayStorage;
22
+ /**
23
+ * Wrap ArrayStorage result in NDArrayCore
24
+ */
25
+ export declare function fromStorage(storage: ArrayStorage, base?: NDArrayCore): NDArrayCore;
26
+ /**
27
+ * Wrap ArrayStorage result in NDArrayCore as a view of the input array
28
+ * Sets the base to track the view relationship
29
+ */
30
+ export declare function fromStorageView(storage: ArrayStorage, original: NDArrayCore): NDArrayCore;
31
+ /**
32
+ * Wrap multiple ArrayStorage results
33
+ */
34
+ export declare function fromStorageArray(storages: ArrayStorage[]): NDArrayCore[];
35
+ /**
36
+ * Wrap multiple ArrayStorage results as views of the original array
37
+ */
38
+ export declare function fromStorageViewArray(storages: ArrayStorage[], original: NDArrayCore): NDArrayCore[];
39
+ /**
40
+ * Wrap a tuple of ArrayStorage results
41
+ */
42
+ export declare function fromStorageTuple(tuple: [ArrayStorage, ArrayStorage]): [NDArrayCore, NDArrayCore];
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Utility functions
3
+ *
4
+ * Tree-shakeable standalone functions for array introspection.
5
+ */
6
+ import { NDArrayCore, type DType } from '../common/ndarray-core';
7
+ import { Complex } from '../common/complex';
8
+ /**
9
+ * Return the number of dimensions of an array.
10
+ * Works with NDArrayCore, scalars, and nested arrays.
11
+ */
12
+ export declare function ndim(a: NDArrayCore | number | bigint | boolean | unknown[] | unknown): number;
13
+ /**
14
+ * Return the shape of an array.
15
+ * Works with NDArrayCore, scalars, and nested arrays.
16
+ */
17
+ export declare function shape(a: NDArrayCore | number | bigint | boolean | unknown[] | unknown): readonly number[] | number[];
18
+ /**
19
+ * Return the number of elements in an array.
20
+ * Works with NDArrayCore, scalars, and nested arrays.
21
+ */
22
+ export declare function size(a: NDArrayCore | number | bigint | boolean | unknown[] | unknown): number;
23
+ export declare function item(a: NDArrayCore, ...args: number[]): number | bigint | boolean | Complex;
24
+ export declare function tolist(a: NDArrayCore): unknown;
25
+ export declare function tobytes(a: NDArrayCore, order?: 'C' | 'F'): Uint8Array;
26
+ export declare function byteswap(a: NDArrayCore, inplace?: boolean): NDArrayCore;
27
+ export declare function view(a: NDArrayCore, dtype?: DType): NDArrayCore;
28
+ export declare function tofile(_a: NDArrayCore, _file: string, _sep?: string, _format?: string): void;
29
+ export declare function fill(a: NDArrayCore, value: number | bigint | boolean | Complex): void;
30
+ //# sourceMappingURL=utility.d.ts.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * numpy-ts/core - Tree-shakeable entry point
3
+ *
4
+ * This module provides standalone functions that return NDArrayCore.
5
+ * Use this entry point when bundle size is critical and you don't need method chaining.
6
+ *
7
+ * All functions in this module are designed for optimal tree-shaking.
8
+ * Import only what you need to get minimal bundle sizes.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { array, add, reshape } from 'numpy-ts/core';
13
+ *
14
+ * const a = array([1, 2, 3, 4]);
15
+ * const b = add(a, 10); // Standalone function
16
+ * const c = reshape(b, [2, 2]); // Standalone function
17
+ * console.log(c.shape); // [2, 2]
18
+ * ```
19
+ *
20
+ * For method chaining, use the main entry point instead:
21
+ * ```typescript
22
+ * import { array } from 'numpy-ts';
23
+ *
24
+ * const c = array([1, 2, 3, 4]).add(10).reshape([2, 2]);
25
+ * ```
26
+ *
27
+ * @module numpy-ts/core
28
+ */
29
+ export * from './core/index';
30
+ //# sourceMappingURL=core.d.ts.map