Comparing version 6.6.2 to 6.6.3
# Changelog | ||
### [6.6.3](https://www.github.com/mljs/global-spectral-deconvolution/compare/v6.6.2...v6.6.3) (2021-06-18) | ||
### Bug Fixes | ||
* maxCriteria=false gives more consistent results ([2652ec2](https://www.github.com/mljs/global-spectral-deconvolution/commit/2652ec265193207ff128348c8d0207d74e1b0c0c)) | ||
### [6.6.2](https://www.github.com/mljs/global-spectral-deconvolution/compare/v6.6.1...v6.6.2) (2021-05-11) | ||
@@ -4,0 +11,0 @@ |
@@ -60,17 +60,14 @@ 'use strict'; | ||
if (maxCriteria === false) { | ||
for (let i = 0; i < y.length; i++) { | ||
y[i] *= -1; | ||
} | ||
} | ||
if (noiseLevel === undefined) { | ||
noiseLevel = equalSpaced ? getNoiseLevel(y) : 0; | ||
} | ||
const yCorrection = { m: 1, b: noiseLevel }; | ||
if (!maxCriteria) { | ||
yCorrection.m = -1; | ||
yCorrection.b *= -1; | ||
} | ||
for (let i = 0; i < y.length; i++) { | ||
y[i] = yCorrection.m * y[i] - yCorrection.b; | ||
y[i] -= noiseLevel; | ||
} | ||
for (let i = 0; i < y.length; i++) { | ||
@@ -224,3 +221,5 @@ if (y[i] < 0) { | ||
x: frequency, | ||
y: (yData[minddY[j]] + yCorrection.b) / yCorrection.m, | ||
y: maxCriteria | ||
? yData[minddY[j]] + noiseLevel | ||
: -yData[minddY[j]] - noiseLevel, | ||
width: widthProcessor(width), | ||
@@ -227,0 +226,0 @@ soft: broadMask[j], |
{ | ||
"name": "ml-gsd", | ||
"version": "6.6.2", | ||
"version": "6.6.3", | ||
"description": "Global Spectra Deconvolution", | ||
@@ -61,6 +61,6 @@ "main": "lib/index.js", | ||
"cheminfo-build": "^1.1.10", | ||
"eslint": "^7.26.0", | ||
"eslint": "^7.27.0", | ||
"eslint-config-cheminfo": "^5.2.4", | ||
"esm": "^3.2.25", | ||
"jest": "^26.6.3", | ||
"jest": "^27.0.1", | ||
"jest-matcher-deep-close-to": "^2.0.1", | ||
@@ -71,3 +71,3 @@ "mf-global": "^1.3.6", | ||
"prettier": "^2.3.0", | ||
"rollup": "^2.47.0", | ||
"rollup": "^2.50.1", | ||
"spectrum-generator": "^4.7.1", | ||
@@ -80,4 +80,4 @@ "xy-parser": "^3.1.1" | ||
"ml-spectra-fitting": "^1.0.0", | ||
"ml-spectra-processing": "^6.5.0" | ||
"ml-spectra-processing": "^6.6.0" | ||
} | ||
} |
@@ -10,9 +10,13 @@ import { toMatchCloseTo } from 'jest-matcher-deep-close-to'; | ||
let y = []; | ||
let negY = []; | ||
for (let i = 0; i < 10; i++) { | ||
x.push(x.length); | ||
y.push(0); | ||
negY.push(0); | ||
} | ||
for (let i = 0; i <= 10; i++) { | ||
x.push(x.length); | ||
y.push(i > 5 ? 10 - i : i); | ||
let newY = i > 5 ? 10 - i : i; | ||
y.push(newY); | ||
negY.push(-newY); | ||
} | ||
@@ -22,2 +26,3 @@ for (let i = 0; i < 10; i++) { | ||
y.push(0); | ||
negY.push(0); | ||
} | ||
@@ -43,2 +48,20 @@ | ||
it('gsd negative peak', () => { | ||
let peaks = gsd( | ||
{ x, y: negY }, | ||
{ | ||
realTopDetection: false, | ||
maxCriteria: false, | ||
smoothY: true, | ||
sgOptions: { | ||
windowSize: 5, | ||
polynomial: 3, | ||
}, | ||
}, | ||
); | ||
expect(peaks[0].y).toBeCloseTo(-4.657, 3); | ||
expect(peaks[0].base).toBeCloseTo(1.1956, 3); | ||
expect(peaks[0].x).toStrictEqual(15); | ||
}); | ||
it('gsd not realtop asymetric', () => { | ||
@@ -45,0 +68,0 @@ let Y2 = y.slice(0); |
@@ -50,17 +50,14 @@ import { getShapeGenerator } from 'ml-peak-shape-generator'; | ||
if (maxCriteria === false) { | ||
for (let i = 0; i < y.length; i++) { | ||
y[i] *= -1; | ||
} | ||
} | ||
if (noiseLevel === undefined) { | ||
noiseLevel = equalSpaced ? getNoiseLevel(y) : 0; | ||
} | ||
const yCorrection = { m: 1, b: noiseLevel }; | ||
if (!maxCriteria) { | ||
yCorrection.m = -1; | ||
yCorrection.b *= -1; | ||
} | ||
for (let i = 0; i < y.length; i++) { | ||
y[i] = yCorrection.m * y[i] - yCorrection.b; | ||
y[i] -= noiseLevel; | ||
} | ||
for (let i = 0; i < y.length; i++) { | ||
@@ -214,3 +211,5 @@ if (y[i] < 0) { | ||
x: frequency, | ||
y: (yData[minddY[j]] + yCorrection.b) / yCorrection.m, | ||
y: maxCriteria | ||
? yData[minddY[j]] + noiseLevel | ||
: -yData[minddY[j]] - noiseLevel, | ||
width: widthProcessor(width), | ||
@@ -217,0 +216,0 @@ soft: broadMask[j], |
@@ -0,1 +1,2 @@ | ||
import { toMatchCloseTo } from 'jest-matcher-deep-close-to'; | ||
import { generateSpectrum } from 'spectrum-generator'; | ||
@@ -5,2 +6,4 @@ | ||
expect.extend({ toMatchCloseTo }); | ||
describe('optimizePeaks', () => { | ||
@@ -19,2 +22,12 @@ it('Should throw because execution time is over timeout', () => { | ||
let result = optimizePeaks(data, [{ x: 0.01, y: 0.9, width: 0.11 }]); | ||
expect(result).toMatchCloseTo([ | ||
{ | ||
x: -3.419674049814014e-8, | ||
y: 0.999994064595118, | ||
width: 0.12000070163648587, | ||
group: 0, | ||
}, | ||
]); | ||
const options = { | ||
@@ -21,0 +34,0 @@ optimization: { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5869127
32
1894
- Removedcheminfo-types@0.5.0(transitive)
- Removedml-gsd@6.9.2(transitive)
- Removedml-peak-shape-generator@2.0.2(transitive)
Updatedml-spectra-processing@^6.6.0