UNPKG

npyjs

Version:
27 lines (25 loc) 1.49 kB
type DType = "i1" | "u1" | "i2" | "u2" | "i4" | "u4" | "i8" | "u8" | "f2" | "f4" | "f8" | "b1" | `U${number}`; type TypedArray = Int8Array | Int16Array | Int32Array | BigInt64Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Float32Array | Float64Array; interface NpyArray<T extends ArrayBufferView = ArrayBufferView> { data: T; shape: number[]; dtype: DType; fortranOrder: boolean; } interface Options { /** Convert float16 to float32. Default true. */ convertFloat16?: boolean; } declare function load(source: string | ArrayBuffer | ArrayBufferView | Blob, opts?: Options): Promise<NpyArray>; declare function float16ToFloat32(u16: number): number; declare function arrayToTypedArray(dtype: DType, array: ArrayLike<number | string>): TypedArray; declare function inferDtypeFromArray(array: Array<number | number[] | string | string[]>): DType; declare function dump(array: TypedArray | Array<number | string>, shape: number[] | undefined): ArrayBuffer; declare class N { private opts; constructor(opts?: Options); load(source: string | ArrayBuffer | ArrayBufferView): Promise<NpyArray<ArrayBufferView<ArrayBufferLike>>>; static float16ToFloat32(u16: number): number; dump(array: TypedArray | Array<number | string>, shape: number[]): ArrayBuffer; } export { type DType, type NpyArray, type Options, type TypedArray, arrayToTypedArray, N as default, dump, float16ToFloat32, inferDtypeFromArray, load };