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.
- package/README.md +18 -14
- package/dist/esm/common/broadcasting.js +1 -0
- package/dist/esm/common/complex.js +1 -0
- package/dist/esm/common/dtype.js +1 -0
- package/dist/esm/common/internal/compute.js +1 -0
- package/dist/esm/common/internal/indexing.js +1 -0
- package/dist/esm/common/ndarray-core.js +1 -0
- package/dist/esm/common/ops/advanced.js +1 -0
- package/dist/esm/common/ops/arithmetic.js +1 -0
- package/dist/esm/common/ops/bitwise.js +1 -0
- package/dist/esm/common/ops/comparison.js +1 -0
- package/dist/esm/common/ops/complex.js +1 -0
- package/dist/esm/common/ops/exponential.js +1 -0
- package/dist/esm/common/ops/fft.js +1 -0
- package/dist/esm/common/ops/formatting.js +4 -0
- package/dist/esm/common/ops/gradient.js +1 -0
- package/dist/esm/common/ops/hyperbolic.js +1 -0
- package/dist/esm/common/ops/linalg.js +2 -0
- package/dist/esm/common/ops/logic.js +1 -0
- package/dist/esm/common/ops/random.js +1 -0
- package/dist/esm/common/ops/reduction.js +1 -0
- package/dist/esm/common/ops/rounding.js +1 -0
- package/dist/esm/common/ops/sets.js +1 -0
- package/dist/esm/common/ops/shape.js +1 -0
- package/dist/esm/common/ops/sorting.js +1 -0
- package/dist/esm/common/ops/statistics.js +1 -0
- package/dist/esm/common/ops/trig.js +1 -0
- package/dist/esm/common/slicing.js +1 -0
- package/dist/esm/common/storage.js +1 -0
- package/dist/esm/core/advanced.js +1 -0
- package/dist/esm/core/arithmetic.js +1 -0
- package/dist/esm/core/bitwise.js +1 -0
- package/dist/esm/core/complex.js +1 -0
- package/dist/esm/core/creation.js +1 -0
- package/dist/esm/core/formatting.js +1 -0
- package/dist/esm/core/gradient.js +1 -0
- package/dist/esm/core/index.js +1 -0
- package/dist/esm/core/linalg.js +1 -0
- package/dist/esm/core/logic.js +1 -0
- package/dist/esm/core/polynomial.js +1 -0
- package/dist/esm/core/reduction.js +1 -0
- package/dist/esm/core/rounding.js +1 -0
- package/dist/esm/core/sets.js +1 -0
- package/dist/esm/core/shape-extra.js +1 -0
- package/dist/esm/core/shape.js +1 -0
- package/dist/esm/core/sorting.js +1 -0
- package/dist/esm/core/statistics.js +1 -0
- package/dist/esm/core/trig.js +1 -0
- package/dist/esm/core/typechecking.js +1 -0
- package/dist/esm/core/types.js +1 -0
- package/dist/esm/core/utility.js +1 -0
- package/dist/esm/core.js +1 -0
- package/dist/esm/full/index.js +1 -0
- package/dist/esm/full/ndarray.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/io/index.js +1 -0
- package/dist/esm/io/npy/format.js +1 -0
- package/dist/esm/io/npy/index.js +1 -0
- package/dist/esm/io/npy/parser.js +1 -0
- package/dist/esm/io/npy/serializer.js +2 -0
- package/dist/esm/io/npz/index.js +1 -0
- package/dist/esm/io/npz/parser.js +1 -0
- package/dist/esm/io/npz/serializer.js +1 -0
- package/dist/esm/io/txt/index.js +1 -0
- package/dist/esm/io/txt/parser.js +1 -0
- package/dist/esm/io/txt/serializer.js +2 -0
- package/dist/esm/io/zip/index.js +1 -0
- package/dist/esm/io/zip/reader.js +1 -0
- package/dist/esm/io/zip/types.js +1 -0
- package/dist/esm/io/zip/writer.js +1 -0
- package/dist/esm/node.js +1 -0
- package/dist/numpy-ts.browser.js +7 -2
- package/dist/numpy-ts.node-io.cjs +7 -3
- package/dist/numpy-ts.node-io.cjs.map +4 -4
- package/dist/numpy-ts.node-io.mjs +7 -3
- package/dist/numpy-ts.node-io.mjs.map +4 -4
- package/dist/numpy-ts.node.cjs +7 -2
- package/dist/numpy-ts.node.cjs.map +4 -4
- package/dist/types/common/complex.d.ts +94 -0
- package/dist/types/{internal → common/internal}/compute.d.ts +1 -1
- package/dist/types/{internal → common/internal}/indexing.d.ts +6 -0
- package/dist/types/common/ndarray-core.d.ts +126 -0
- package/dist/types/{ops → common/ops}/advanced.d.ts +2 -2
- package/dist/types/{ops → common/ops}/arithmetic.d.ts +1 -1
- package/dist/types/{ops → common/ops}/bitwise.d.ts +1 -1
- package/dist/types/{ops → common/ops}/comparison.d.ts +1 -1
- package/dist/types/{ops → common/ops}/complex.d.ts +1 -1
- package/dist/types/{ops → common/ops}/exponential.d.ts +1 -1
- package/dist/types/common/ops/fft.d.ts +166 -0
- package/dist/types/common/ops/formatting.d.ts +229 -0
- package/dist/types/{ops → common/ops}/gradient.d.ts +1 -1
- package/dist/types/{ops → common/ops}/hyperbolic.d.ts +1 -1
- package/dist/types/{ops → common/ops}/linalg.d.ts +24 -3
- package/dist/types/{ops → common/ops}/logic.d.ts +2 -2
- package/dist/types/common/ops/random.d.ts +376 -0
- package/dist/types/{ops → common/ops}/reduction.d.ts +2 -2
- package/dist/types/{ops → common/ops}/rounding.d.ts +1 -1
- package/dist/types/{ops → common/ops}/sets.d.ts +1 -1
- package/dist/types/{ops → common/ops}/shape.d.ts +1 -1
- package/dist/types/{ops → common/ops}/sorting.d.ts +1 -1
- package/dist/types/{ops → common/ops}/statistics.d.ts +1 -1
- package/dist/types/{ops → common/ops}/trig.d.ts +1 -1
- package/dist/types/{core → common}/storage.d.ts +1 -0
- package/dist/types/core/advanced.d.ts +54 -0
- package/dist/types/core/arithmetic.d.ts +110 -0
- package/dist/types/core/bitwise.d.ts +34 -0
- package/dist/types/core/complex.d.ts +15 -90
- package/dist/types/core/creation.d.ts +98 -0
- package/dist/types/core/formatting.d.ts +29 -0
- package/dist/types/core/gradient.d.ts +14 -0
- package/dist/types/core/index.d.ts +40 -0
- package/dist/types/core/linalg.d.ts +141 -0
- package/dist/types/core/logic.d.ts +72 -0
- package/dist/types/core/polynomial.d.ts +50 -0
- package/dist/types/core/reduction.d.ts +82 -0
- package/dist/types/core/rounding.d.ts +24 -0
- package/dist/types/core/sets.d.ts +48 -0
- package/dist/types/core/shape-extra.d.ts +24 -0
- package/dist/types/core/shape.d.ts +77 -0
- package/dist/types/core/sorting.d.ts +34 -0
- package/dist/types/core/statistics.d.ts +32 -0
- package/dist/types/core/trig.d.ts +58 -0
- package/dist/types/core/typechecking.d.ts +50 -0
- package/dist/types/core/types.d.ts +43 -0
- package/dist/types/core/utility.d.ts +30 -0
- package/dist/types/core.d.ts +30 -0
- package/dist/types/full/index.d.ts +603 -0
- package/dist/types/full/ndarray.d.ts +880 -0
- package/dist/types/index.d.ts +140 -26
- package/dist/types/io/npy/format.d.ts +1 -1
- package/dist/types/io/npy/parser.d.ts +3 -3
- package/dist/types/io/npy/serializer.d.ts +2 -2
- package/dist/types/io/npz/parser.d.ts +4 -4
- package/dist/types/io/npz/serializer.d.ts +6 -6
- package/dist/types/io/txt/parser.d.ts +5 -5
- package/dist/types/io/txt/serializer.d.ts +2 -2
- package/dist/types/node.d.ts +12 -8
- package/package.json +30 -29
- package/dist/numpy-ts.esm.js +0 -2
- package/dist/types/core/ndarray.d.ts +0 -3923
- package/dist/types/ops/random.d.ts +0 -136
- /package/dist/types/{core → common}/broadcasting.d.ts +0 -0
- /package/dist/types/{core → common}/dtype.d.ts +0 -0
- /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
|