From 86be8a1639a402aa1a6f185a74871cef6b49512f Mon Sep 17 00:00:00 2001 From: Andrew Champion Date: Fri, 8 Feb 2019 12:14:44 -0500 Subject: [PATCH 1/5] Support BigInt64Array/BigUint64Array Add support for typed arrays of 64-bit integers (BigInt) now available in many browsers. Without this patch these typed arrays were given the "generic" dtype, which then attempted to use getters and setters rather than indexing, causing an error since typed arrays do not provide these. These changes are compatible with browsers that do not have these 64-bit typed arrays. --- README.md | 2 ++ ndarray.js | 6 ++++++ test/test.js | 11 +++++++++++ 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index a7989ef..259fa0d 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,8 @@ Data type | String `Uint8Array` | "uint8" `Uint16Array` | "uint16" `Uint32Array` | "uint32" +`BigInt64Array` | "bigint64" +`BigUint64Array` | "biguint64" `Float32Array` | "float32" `Float64Array` | "float64" `Array` | "array" diff --git a/ndarray.js b/ndarray.js index f50d99e..43c9b5a 100644 --- a/ndarray.js +++ b/ndarray.js @@ -276,6 +276,10 @@ function arrayDType(data) { return "uint32" case "[object Uint8ClampedArray]": return "uint8_clamped" + case "[object BigInt64Array]": + return "bigint64" + case "[object BigUint64Array]": + return "biguint64" } } if(Array.isArray(data)) { @@ -295,6 +299,8 @@ var CACHED_CONSTRUCTORS = { "uint32":[], "array":[], "uint8_clamped":[], + "bigint64": [], + "biguint64": [], "buffer":[], "generic":[] } diff --git a/test/test.js b/test/test.js index 92ed2de..7c79eb9 100644 --- a/test/test.js +++ b/test/test.js @@ -63,6 +63,17 @@ test("uint8clamped", function(t) { t.end() }) +if((typeof BigInt64Array) !== "undefined") +test("bigint64", function(t) { + var p = ndarray(new BigInt64Array([1,2,3,4].map(BigInt)), [4]) + t.equals(p.dtype, "bigint64") + t.equals(p.get(0), BigInt(1)) + t.equals(p.get(1), BigInt(2)) + t.equals(p.get(2), BigInt(3)) + t.equals(p.get(3), BigInt(4)) + t.end() +}) + test("buffer", function(t) { var p = ndarray(new Buffer(5)) t.equals(p.dtype, "buffer") From 58f5d8ca9cd37fa708c3996b0e8bbad0937678fc Mon Sep 17 00:00:00 2001 From: mikola Date: Sun, 5 Jan 2020 11:55:06 +0800 Subject: [PATCH 2/5] 1.0.19 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e570f4a..bbfb670 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ndarray", - "version": "1.0.18", + "version": "1.0.19", "description": "Multidimensional Arrays", "main": "ndarray.js", "directories": { From c8b3bba379eedd30baef3ba3a82cdb0bc8b35d3e Mon Sep 17 00:00:00 2001 From: Nick Thompson Date: Fri, 21 Aug 2026 08:44:54 -0700 Subject: [PATCH 3/5] Support Float16Array Without this a `Float16Array` gets the "generic" dtype, so `.get()` fails with `this.data.get is not a function` -- the same breakage `BigInt64Array` had before 86be8a1. --- README.md | 1 + ndarray.js | 3 +++ test/test.js | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 259fa0d..4b219dd 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ Data type | String `Uint32Array` | "uint32" `BigInt64Array` | "bigint64" `BigUint64Array` | "biguint64" +`Float16Array` | "float16" `Float32Array` | "float32" `Float64Array` | "float64" `Array` | "array" diff --git a/ndarray.js b/ndarray.js index 43c9b5a..0c93775 100644 --- a/ndarray.js +++ b/ndarray.js @@ -262,6 +262,8 @@ function arrayDType(data) { return "float64" case "[object Float32Array]": return "float32" + case "[object Float16Array]": + return "float16" case "[object Int8Array]": return "int8" case "[object Int16Array]": @@ -291,6 +293,7 @@ function arrayDType(data) { var CACHED_CONSTRUCTORS = { "float32":[], "float64":[], + "float16":[], "int8":[], "int16":[], "int32":[], diff --git a/test/test.js b/test/test.js index 7c79eb9..330c2b0 100644 --- a/test/test.js +++ b/test/test.js @@ -74,6 +74,22 @@ test("bigint64", function(t) { t.end() }) +if((typeof Float16Array) !== "undefined") +test("float16", function(t) { + var p = ndarray(new Float16Array([1,2,3,4]), [4]) + t.equals(p.dtype, "float16") + t.equals(p.get(0), 1) + t.equals(p.get(1), 2) + t.equals(p.get(2), 3) + t.equals(p.get(3), 4) + p.set(0, 0.5) + t.equals(p.get(0), 0.5) + //values are rounded to the nearest half, as the array itself does + p.set(1, 0.1) + t.equals(p.get(1), new Float16Array([0.1])[0]) + t.end() +}) + test("buffer", function(t) { var p = ndarray(new Buffer(5)) t.equals(p.dtype, "buffer") From 89da94cd41cca52da458ad4cad585269177de732 Mon Sep 17 00:00:00 2001 From: Ricky Reusser <572717+rreusser@users.noreply.github.com> Date: Tue, 25 Aug 2026 20:52:32 -0700 Subject: [PATCH 4/5] v1.1.0 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9adfb8a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 1.1.0 (2026-08-25) + +- Added `Float16Array` support: it now gets a `"float16"` dtype instead of falling back to `"generic"`, which previously caused `.get()` to throw with `this.data.get is not a function` ([#49](https://github.com/scijs/ndarray/pull/49), thanks [@NAThompson](https://github.com/NAThompson)) diff --git a/package.json b/package.json index bbfb670..d5367b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ndarray", - "version": "1.0.19", + "version": "1.1.0", "description": "Multidimensional Arrays", "main": "ndarray.js", "directories": { From 95281edad9188d3d28377bf463edd3f82297fa48 Mon Sep 17 00:00:00 2001 From: Ricky Reusser <572717+rreusser@users.noreply.github.com> Date: Tue, 25 Aug 2026 20:57:53 -0700 Subject: [PATCH 5/5] v1.1.1 --- CHANGELOG.md | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9adfb8a..536449d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog -## 1.1.0 (2026-08-25) +## 1.1.1 (2026-08-25) + +Note: published as 1.1.1 because the version number 1.1.0 was published and unpublished in 2014, and npm permanently reserves it. - Added `Float16Array` support: it now gets a `"float16"` dtype instead of falling back to `"generic"`, which previously caused `.get()` to throw with `this.data.get is not a function` ([#49](https://github.com/scijs/ndarray/pull/49), thanks [@NAThompson](https://github.com/NAThompson)) diff --git a/package.json b/package.json index d5367b3..6ad3c9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ndarray", - "version": "1.1.0", + "version": "1.1.1", "description": "Multidimensional Arrays", "main": "ndarray.js", "directories": {