We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0cc5064 commit 7504497Copy full SHA for 7504497
src/filters/x/__tests__/calibrateX.test.ts
@@ -13,7 +13,7 @@ describe('calibrateX', () => {
13
14
let shifted = calibrateX(data);
15
expect(shifted.data.x).toMatchCloseTo(
16
- Float64Array.from([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]),
+ Float64Array.from([-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6]),
17
);
18
expect(shifted.data.y).toStrictEqual(data.y);
19
});
@@ -81,8 +81,10 @@ describe('calibrateX', () => {
81
82
// because we look for the real maximum it is not exactly 2
83
84
- Float64Array.from([-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
+ Float64Array.from([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]),
85
+ );
86
+ expect(shifted.data.y).toStrictEqual(
87
+ Float64Array.from([1, 1, 1, 1, 700, 1, 5, 1, 1, 1, 1, 1, 1]),
88
- expect(shifted.data.y).toStrictEqual(data.y);
89
90
src/filters/x/calibrateX.ts
@@ -1,6 +1,6 @@
1
import { DataXY } from 'cheminfo-types';
2
import { gsd, GSDOptions } from 'ml-gsd';
3
-import { xFindClosestIndex, xMean, xSubtract } from 'ml-spectra-processing';
+import { xFindClosestIndex, xMean, xAdd } from 'ml-spectra-processing';
4
5
export interface CalibrateFilter {
6
name: 'calibrateX';
@@ -68,5 +68,5 @@ export function calibrateX(
68
if (peaks.length === 0) return { data };
69
70
const middle = xMean(peaks.map((peak) => peak.x));
71
- return { data: { x: xSubtract(data.x, targetX - middle), y: data.y } };
+ return { data: { x: xAdd(data.x, targetX - middle), y: data.y } };
72
}
0 commit comments