From b0cd99b7f4c2bff791b4977e16dec3478519920b Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Mon, 13 Jan 2025 18:00:40 -0500 Subject: [PATCH] v0.7.0 --- CHANGELOG.md | 6 +++++- README.md | 30 +++++++++++++++++------------- package.json | 4 ++-- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d1c84..1462de2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ # Changelog +## 0.7.0 + +- add support for f16 dtypes, with f32 conversion as needed (#49, thanks @eek!) + ## 0.6.0 -- Add type declarations +- Add type declarations ## 0.5.0 diff --git a/README.md b/README.md index f1e4834..d234da7 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,16 @@ yarn add npyjs # npm i npyjs ``` -## Import +## Import + ```javascript import npyjs from "npyjs"; ``` - ## Usage + - Create a new npyjs object: + ```javascript let n = new npyjs(); // Or with options: @@ -39,9 +41,7 @@ let n = new npyjs({ convertFloat16: false }); // Disable float16 to float32 conv n.load("my-array.npy", (array, shape) => { // `array` is a one-dimensional array of the raw data // `shape` is a one-dimensional array that holds a numpy-style shape. - console.log( - `You loaded an array with ${array.length} elements and ${shape.length} dimensions.` - ); + console.log(`You loaded an array with ${array.length} elements and ${shape.length} dimensions.`); }); ``` @@ -64,21 +64,25 @@ const npyArray = await n.load("test.npy"); ```javascript import ndarray from "ndarray"; const npyArray = ndarray(data, shape); -npyArray.get(10, 15) +npyArray.get(10, 15); ``` ## Supported Data Types + The library supports the following NumPy data types: -- `int8`, `uint8` -- `int16`, `uint16` -- `int32`, `uint32` -- `int64`, `uint64` (as BigInt) -- `float32` -- `float64` -- `float16` (converted to float32 by default) + +- `int8`, `uint8` +- `int16`, `uint16` +- `int32`, `uint32` +- `int64`, `uint64` (as BigInt) +- `float32` +- `float64` +- `float16` (converted to float32 by default) ### Float16 Support + By default, float16 arrays are automatically converted to float32 for compatibility, since JavaScript doesn't natively support float16. You can control this behavior with the constructor options: + ```javascript // Default behavior - float16 is converted to float32 const n1 = new npyjs(); diff --git a/package.json b/package.json index 6cab4db..cec10ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "npyjs", - "version": "0.6.0", + "version": "0.7.0", "type": "module", "description": "Parse npy files in JS", "exports": "./index.js", @@ -20,4 +20,4 @@ "dependencies": { "cross-fetch": "^3.1.5" } -} +} \ No newline at end of file