Skip to content

Commit 7c6c171

Browse files
committed
Improved logic
1 parent 7142864 commit 7c6c171

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/utils/sparse-vector.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ class SparseVector {
5050
this.values = [];
5151

5252
for (const [i, v] of value.entries()) {
53-
if (v != 0) {
53+
const f = Number(v);
54+
if (f != 0) {
5455
this.indices.push(Number(i));
55-
this.values.push(Number(v));
56+
this.values.push(f);
5657
}
5758
}
5859
}
@@ -64,9 +65,10 @@ class SparseVector {
6465

6566
const entries = map instanceof Map ? map.entries() : Object.entries(map);
6667
for (const [i, v] of entries) {
67-
if (v != 0) {
68+
const f = Number(v);
69+
if (f != 0) {
6870
this.indices.push(Number(i));
69-
this.values.push(Number(v));
71+
this.values.push(f);
7072
}
7173
}
7274
}

0 commit comments

Comments
 (0)