Skip to content

Commit

Permalink
v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
j6k4m8 committed Jan 13, 2025
1 parent f03b25c commit b0cd99b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.`);
});
```

Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -20,4 +20,4 @@
"dependencies": {
"cross-fetch": "^3.1.5"
}
}
}

0 comments on commit b0cd99b

Please sign in to comment.