From 98128b85ea08bc1c9a3ebbecf4ddc2fca0b3e3b3 Mon Sep 17 00:00:00 2001 From: jose alejandro bolanos arroyave Date: Tue, 10 Aug 2021 11:44:22 +0200 Subject: [PATCH] feat: update ml-peak-shape-generator to 2.0.1 --- package.json | 4 +-- src/__tests__/simulated.js | 32 ++++++++++++++++-------- src/gsd.js | 4 +-- src/post/__tests__/optimizePeaks.test.js | 12 +++++---- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index aae0fb1..3c8934b 100644 --- a/package.json +++ b/package.json @@ -68,11 +68,11 @@ "nodemon": "^2.0.7", "prettier": "^2.3.0", "rollup": "^2.50.1", - "spectrum-generator": "^4.7.1", + "spectrum-generator": "^5.0.0", "xy-parser": "^3.1.1" }, "dependencies": { - "ml-peak-shape-generator": "^1.0.0", + "ml-peak-shape-generator": "^2.0.1", "ml-savitzky-golay-generalized": "2.0.3", "ml-spectra-fitting": "^1.0.0", "ml-spectra-processing": "^6.6.0" diff --git a/src/__tests__/simulated.js b/src/__tests__/simulated.js index ca1e404..6ecb73c 100644 --- a/src/__tests__/simulated.js +++ b/src/__tests__/simulated.js @@ -10,10 +10,14 @@ describe('Global spectra deconvolution with simulated spectra', () => { ]; const data = generateSpectrum(peaks, { - from: -1, - to: 1, - nbPoints: 1001, - factor: 6, + generator: { + from: -1, + to: 1, + nbPoints: 1001, + }, + peaks: { + factor: 6, + }, }); let peakList = gsd(data, { @@ -49,7 +53,9 @@ describe('Global spectra deconvolution with simulated spectra', () => { { x: 0.5, y: 1, width: 0.1 }, ]; - const data = generateSpectrum(peaks, { from: -1, to: 1, nbPoints: 10001 }); + const data = generateSpectrum(peaks, { + generator: { from: -1, to: 1, nbPoints: 10001 }, + }); let peakList = gsd(data, { minMaxRatio: 0, @@ -84,7 +90,9 @@ describe('Global spectra deconvolution with simulated spectra', () => { { x: 0.5, y: 1, width: 0.1 }, ]; - const data = generateSpectrum(peaks, { from: -1, to: 1, nbPoints: 10001 }); + const data = generateSpectrum(peaks, { + generator: { from: -1, to: 1, nbPoints: 10001 }, + }); let peakList = gsd(data, { minMaxRatio: 0, @@ -116,11 +124,13 @@ describe('Global spectra deconvolution with simulated spectra', () => { const peaks = [{ x: 0, y: 1, width: 0.12 }]; const data = generateSpectrum(peaks, { - from: -0.5, - to: 0.5, - nbPoints: 10001, - shape: { - kind: 'gaussian', + generator: { + from: -0.5, + to: 0.5, + nbPoints: 10001, + shape: { + kind: 'gaussian', + }, }, }); diff --git a/src/gsd.js b/src/gsd.js index 3e5a64c..7c62f26 100644 --- a/src/gsd.js +++ b/src/gsd.js @@ -1,4 +1,4 @@ -import { getShapeGenerator } from 'ml-peak-shape-generator'; +import { getShape1D } from 'ml-peak-shape-generator'; import SG from 'ml-savitzky-golay-generalized'; /** @@ -172,7 +172,7 @@ export function gsd(data, options = {}) { } let widthProcessor = shape.kind - ? getShapeGenerator(shape.kind, shape.options).widthToFWHM + ? getShape1D(shape.kind, shape.options).widthToFWHM : (x) => x; let signals = []; diff --git a/src/post/__tests__/optimizePeaks.test.js b/src/post/__tests__/optimizePeaks.test.js index 7dfbfba..3e25e9f 100644 --- a/src/post/__tests__/optimizePeaks.test.js +++ b/src/post/__tests__/optimizePeaks.test.js @@ -10,11 +10,13 @@ describe('optimizePeaks', () => { const peaks = [{ x: 0, y: 1, width: 0.12 }]; const data = generateSpectrum(peaks, { - from: -0.5, - to: 0.5, - nbPoints: 101, - shape: { - kind: 'gaussian', + generator: { + from: -0.5, + to: 0.5, + nbPoints: 101, + shape: { + kind: 'gaussian', + }, }, });