Skip to content

Commit df54ad6

Browse files
authored
fix: keep input type in reimZeroFilling (#336)
1 parent bfab310 commit df54ad6

39 files changed

+125
-86
lines changed

src/matrix/__tests__/matrixAutoCorrelation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('simple', () => {
1717
test('matrixAutoCorrelation too small', () => {
1818
const matrix = [[0]];
1919

20-
expect(() => matrixAutoCorrelation(matrix)).toThrow(
20+
expect(() => matrixAutoCorrelation(matrix)).toThrowError(
2121
'can not calculate info if matrix contains less than 2 rows',
2222
);
2323
});

src/matrix/__tests__/matrixBoxPlot.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ test('matrixBoxPlot odd small', () => {
6666
test('matrixBoxPlot too small', () => {
6767
const matrix = [[0], [1], [2], [4]];
6868

69-
expect(() => matrixBoxPlot(matrix)).toThrow(
69+
expect(() => matrixBoxPlot(matrix)).toThrowError(
7070
'can not calculate info if matrix contains less than 5 rows',
7171
);
7272
});

src/matrix/__tests__/matrixCheck.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('should throw error', () => {
88
[3, 2, 3],
99
];
1010

11-
expect(() => matrixCheck(wrongMatrix)).toThrow(
11+
expect(() => matrixCheck(wrongMatrix)).toThrowError(
1212
'all rows must has the same length',
1313
);
1414
});

src/matrix/__tests__/matrixCheckRanges.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('should not throw error for valid indices', () => {
1818
endColumn: 2,
1919
};
2020

21-
expect(() => matrixCheckRanges(matrix, options)).not.toThrow();
21+
expect(() => matrixCheckRanges(matrix, options)).not.toThrowError();
2222
});
2323

2424
test('should throw RangeError for out-of-range indices', () => {
@@ -38,5 +38,5 @@ test('should throw RangeError for out-of-range indices', () => {
3838
};
3939

4040
// Call the function and expect test to throw RangeError
41-
expect(() => matrixCheckRanges(matrix, options)).toThrow(RangeError);
41+
expect(() => matrixCheckRanges(matrix, options)).toThrowError(RangeError);
4242
});

src/matrix/__tests__/matrixGetSubMatrix.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ test('should throw RangeError for out-of-range indices', () => {
6464
duplicate: true,
6565
};
6666

67-
expect(() => matrixGetSubMatrix(matrix, options)).toThrow(RangeError);
67+
expect(() => matrixGetSubMatrix(matrix, options)).toThrowError(RangeError);
6868
});

src/matrix/__tests__/matrixMaxAbsoluteZ.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ test('large negative', () => {
2727
test('zero', () => {
2828
expect(() => {
2929
matrixMaxAbsoluteZ([[]]);
30-
}).toThrow('matrix must have at least 1 row and 1 column');
30+
}).toThrowError('matrix must have at least 1 row and 1 column');
3131
});

src/matrix/__tests__/matrixMinMaxAbsoluteZ.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ test('zero', () => {
1818

1919
expect(() => {
2020
matrixMinMaxAbsoluteZ(matrix);
21-
}).toThrow('matrixMinMaxAbsoluteZ requires at least 1 row and 1 column');
21+
}).toThrowError('matrixMinMaxAbsoluteZ requires at least 1 row and 1 column');
2222
});

src/matrix/__tests__/matrixMinMaxZ.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ test('basic', () => {
1616
test('zero', () => {
1717
expect(() => {
1818
matrixMinMaxZ([[]]);
19-
}).toThrow('matrix must contain data');
19+
}).toThrowError('matrix must contain data');
2020
});

src/matrix/__tests__/matrixSetSubMatrix.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ test('simple case', () => {
2424
[3, 4, 5, 0, 0],
2525
]);
2626

27-
expect(() => matrixSetSubMatrix(matrix, subMatrix, 2, 4)).toThrow(
27+
expect(() => matrixSetSubMatrix(matrix, subMatrix, 2, 4)).toThrowError(
2828
'submatrix indices are out of range',
2929
);
3030

3131
expect(() =>
3232
matrixSetSubMatrix(matrix, subMatrix.concat([0, 0]), 2, 3),
33-
).toThrow('submatrix indices are out of range');
33+
).toThrowError('submatrix indices are out of range');
3434
});

src/reim/__tests__/reimZeroFilling.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@ test('xreimZeroFilling over', () => {
1414
re: [0, 1, 2, 3, 0, 0],
1515
im: [4, 5, 6, 7, 0, 0],
1616
});
17+
18+
expect(result.re).toBeInstanceOf(Array);
19+
expect(result.im).toBeInstanceOf(Array);
20+
});
21+
22+
test('xreimZeroFilling over with Float64', () => {
23+
const re = new Float64Array([0, 1, 2, 3]);
24+
const im = new Float64Array([4, 5, 6, 7]);
25+
const result = reimZeroFilling({ re, im }, 6);
26+
27+
const newRe = Array.from(result.re);
28+
const newIm = Array.from(result.im);
29+
30+
expect({ re: newRe, im: newIm }).toStrictEqual({
31+
re: [0, 1, 2, 3, 0, 0],
32+
im: [4, 5, 6, 7, 0, 0],
33+
});
34+
35+
expect(result.re).toBeInstanceOf(Float64Array);
36+
expect(result.im).toBeInstanceOf(Float64Array);
1737
});
1838

1939
test('xreimZeroFilling equal', () => {
@@ -30,8 +50,8 @@ test('xreimZeroFilling equal', () => {
3050
});
3151

3252
test('xreimZeroFilling under', () => {
33-
const re = [0, 1, 2, 3];
34-
const im = [4, 5, 6, 7];
53+
const re = new Float64Array([0, 1, 2, 3]);
54+
const im = new Float64Array([4, 5, 6, 7]);
3555
const result = reimZeroFilling({ re, im }, 2);
3656
const newRe = Array.from(result.re);
3757
const newIm = Array.from(result.im);

0 commit comments

Comments
 (0)