https://github.com/minhqdao/npy
Read and write NumPy binary files (.npy and .npz formats) in Dart.
https://github.com/minhqdao/npy
array dart dartlang flutter library ndarray npy npz numpy package plugin pub pub-dev
Last synced: 14 days ago
JSON representation
Read and write NumPy binary files (.npy and .npz formats) in Dart.
- Host: GitHub
- URL: https://github.com/minhqdao/npy
- Owner: minhqdao
- License: mit
- Created: 2024-08-28T19:24:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-03T06:55:09.000Z (11 months ago)
- Last Synced: 2026-01-13T20:43:16.957Z (15 days ago)
- Topics: array, dart, dartlang, flutter, library, ndarray, npy, npz, numpy, package, plugin, pub, pub-dev
- Language: Dart
- Homepage:
- Size: 169 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/minhqdao/npy/blob/main/LICENSE)
[](https://github.com/minhqdao/npy/actions/workflows/ci.yml)
Read and write NumPy binary files (`.npy` and `.npz`) in Dart.
## Usage
Load an `ndarray` from an `.npy` file:
```dart
final ndarray = await NdArray.load('example.npy');
```
Create an `ndarray` and save it as an `.npy` file:
```dart
final ndarray = NdArray.fromList([1.0, 2.0, 3.0]);
await ndarray.save('example_save.npy');
```
Conveniently save an n-dimensional `List` to an `.npy` file:
```dart
await save('example_save.npy', [[1, 2, 3], [4, 5, 6]]);
```
Read (compressed) `.npz` files:
```dart
final npzFile = await NpzFile.load('example.npz');
final arr_0 = npzFile.take('arr_0.npy');
final arr_1 = npzFile.take('arr_1.npy');
```
Write (compressed) `.npz` files:
```dart
final array1 = NdArray.fromList([1.0, 2.0, 3.0]);
final array2 = NdArray.fromList([[true, false, true]]);
final npzFile = NpzFile();
npzFile.add(array1);
npzFile.add(array2);
await npzFile.save('example_save.npz');
```
## Features
Load and save n-dimensional arrays from and to the following file formats:
✅ `.npy` \
✅ `.npz` (compressed and uncompressed)
Supported data types:
✅ float64, float32\
✅ int64, int32, int16, int8\
✅ uint64, uint32, uint16, uint8\
✅ bool
Supported memory representations:
✅ Little and big endian\
✅ C and Fortran order
## Tests
`dart test` will run integration tests, too, so make sure to have `python` and `numpy` installed and `python` available in your system's `PATH`.
## Contribute
- Feel free to [create an issue](https://github.com/minhqdao/npy/issues) in case you found a bug, have any questions or want to propose new features.
- Please [check open issues](https://github.com/minhqdao/npy/issues) before creating a new one.
- Make sure to satisfy formatter, analyzer and tests when [opening a pull request](https://github.com/minhqdao/npy/pulls).
## Further Reading
More information on the `.npy` format can be found [here](https://numpy.org/doc/stable/reference/generated/numpy.lib.format.html).
## License
You can use, redistribute and/or modify the code under the terms of the [MIT License](https://github.com/minhqdao/npy/blob/main/LICENSE).