Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-spectra-fitting

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-spectra-fitting - npm Package Compare versions

Comparing version 4.2.3 to 4.2.4

8

lib-esm/util/internalPeaks/DefaultParameters.d.ts

@@ -1,2 +0,2 @@

import { Shape1DInstance, PseudoVoigt } from 'ml-peak-shape-generator';
import { Shape1DInstance, PseudoVoigt, GeneralizedLorentzian } from 'ml-peak-shape-generator';
import { Peak } from '../../index';

@@ -28,3 +28,9 @@ export declare const DefaultParameters: {

};
gamma: {
init: (peak: Peak, peakShape: GeneralizedLorentzian) => number;
min: () => number;
max: () => number;
gradientDifference: () => number;
};
};
//# sourceMappingURL=DefaultParameters.d.ts.map

@@ -26,3 +26,9 @@ export const DefaultParameters = {

},
gamma: {
init: (peak, peakShape) => peakShape.gamma || 0.5,
min: () => -1,
max: () => 2,
gradientDifference: () => 0.01,
},
};
//# sourceMappingURL=DefaultParameters.js.map

2

lib-esm/util/internalPeaks/getInternalPeaks.d.ts
import { Shape1D, Shape1DInstance } from 'ml-peak-shape-generator';
import { Peak, OptimizeOptions } from '../../index';
type Parameter = 'x' | 'y' | 'fwhm' | 'mu';
type Parameter = 'x' | 'y' | 'fwhm' | 'mu' | 'gamma';
type Property = 'init' | 'min' | 'max' | 'gradientDifference';

@@ -5,0 +5,0 @@ export interface InternalPeak {

@@ -15,5 +15,5 @@ import { levenbergMarquardt } from 'ml-levenberg-marquardt';

} | {
epsilon?: number | undefined;
tolerance?: number | undefined;
tolerance2?: number | undefined;
epsilon?: number;
tolerance?: number;
tolerance2?: number;
initialState?: any;

@@ -24,3 +24,3 @@ maxIterations: number;

} | {
timeout?: number | undefined;
timeout?: number;
damping: number;

@@ -43,9 +43,9 @@ errorTolerance: number;

initialState: any;
maxIterations?: number | undefined;
maxIterations?: number;
iterations: number;
} | {
timeout?: number | undefined;
damping?: number | undefined;
errorTolerance?: number | undefined;
maxIterations?: number | undefined;
timeout?: number;
damping?: number;
errorTolerance?: number;
maxIterations?: number;
iterations: number;

@@ -52,0 +52,0 @@ epsilon: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.optimize = void 0;
exports.optimize = optimize;
const ml_spectra_processing_1 = require("ml-spectra-processing");

@@ -73,3 +73,2 @@ const getSumOfShapes_1 = require("./shapes/getSumOfShapes");

}
exports.optimize = optimize;
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSumOfShapes = void 0;
exports.getSumOfShapes = getSumOfShapes;
/**

@@ -26,3 +26,2 @@ * This function returns the sumOfShapes function

}
exports.getSumOfShapes = getSumOfShapes;
//# sourceMappingURL=getSumOfShapes.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assert = void 0;
exports.assert = assert;
/**

@@ -15,3 +15,2 @@ * Asserts that value is truthy.

}
exports.assert = assert;
//# sourceMappingURL=assert.js.map

@@ -1,2 +0,2 @@

import { Shape1DInstance, PseudoVoigt } from 'ml-peak-shape-generator';
import { Shape1DInstance, PseudoVoigt, GeneralizedLorentzian } from 'ml-peak-shape-generator';
import { Peak } from '../../index';

@@ -28,3 +28,9 @@ export declare const DefaultParameters: {

};
gamma: {
init: (peak: Peak, peakShape: GeneralizedLorentzian) => number;
min: () => number;
max: () => number;
gradientDifference: () => number;
};
};
//# sourceMappingURL=DefaultParameters.d.ts.map

@@ -29,3 +29,9 @@ "use strict";

},
gamma: {
init: (peak, peakShape) => peakShape.gamma || 0.5,
min: () => -1,
max: () => 2,
gradientDifference: () => 0.01,
},
};
//# sourceMappingURL=DefaultParameters.js.map
import { Shape1D, Shape1DInstance } from 'ml-peak-shape-generator';
import { Peak, OptimizeOptions } from '../../index';
type Parameter = 'x' | 'y' | 'fwhm' | 'mu';
type Parameter = 'x' | 'y' | 'fwhm' | 'mu' | 'gamma';
type Property = 'init' | 'min' | 'max' | 'gradientDifference';

@@ -5,0 +5,0 @@ export interface InternalPeak {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInternalPeaks = void 0;
exports.getInternalPeaks = getInternalPeaks;
const ml_peak_shape_generator_1 = require("ml-peak-shape-generator");

@@ -80,3 +80,2 @@ const assert_1 = require("../assert");

}
exports.getInternalPeaks = getInternalPeaks;
function getNormalizedValue(value, parameter, property, minMaxY, baseline) {

@@ -83,0 +82,0 @@ if (parameter === 'y') {

@@ -15,5 +15,5 @@ import { levenbergMarquardt } from 'ml-levenberg-marquardt';

} | {
epsilon?: number | undefined;
tolerance?: number | undefined;
tolerance2?: number | undefined;
epsilon?: number;
tolerance?: number;
tolerance2?: number;
initialState?: any;

@@ -24,3 +24,3 @@ maxIterations: number;

} | {
timeout?: number | undefined;
timeout?: number;
damping: number;

@@ -43,9 +43,9 @@ errorTolerance: number;

initialState: any;
maxIterations?: number | undefined;
maxIterations?: number;
iterations: number;
} | {
timeout?: number | undefined;
damping?: number | undefined;
errorTolerance?: number | undefined;
maxIterations?: number | undefined;
timeout?: number;
damping?: number;
errorTolerance?: number;
maxIterations?: number;
iterations: number;

@@ -52,0 +52,0 @@ epsilon: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.selectMethod = void 0;
exports.selectMethod = selectMethod;
const ml_levenberg_marquardt_1 = require("ml-levenberg-marquardt");

@@ -41,3 +41,2 @@ const directOptimization_1 = require("./wrappers/directOptimization");

}
exports.selectMethod = selectMethod;
//# sourceMappingURL=selectMethod.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.directOptimization = void 0;
exports.directOptimization = directOptimization;
const ml_direct_1 = __importDefault(require("ml-direct"));

@@ -26,3 +26,2 @@ function directOptimization(data, sumOfShapes, options) {

}
exports.directOptimization = directOptimization;
function getObjectiveFunction(data, sumOfShapes) {

@@ -29,0 +28,0 @@ const { x, y } = data;

{
"name": "ml-spectra-fitting",
"version": "4.2.3",
"version": "4.2.4",
"description": "Fit spectra using gaussian or lorentzian",

@@ -66,5 +66,5 @@ "main": "./lib/index.js",

"ml-levenberg-marquardt": "^4.1.3",
"ml-peak-shape-generator": "^4.1.2",
"ml-peak-shape-generator": "^4.1.4",
"ml-spectra-processing": "^14.2.0"
}
}

@@ -115,4 +115,4 @@ import type { DataXY } from 'cheminfo-types';

const guess = JSON.parse(JSON.stringify(peaks));
guess.forEach((peak: any) => (peak.x += Math.random() / 10));
const guess = structuredClone(peaks);
guess.forEach((peak: { x: number }) => (peak.x += Math.random() / 10));

@@ -119,0 +119,0 @@ const result = optimize(data, guess, {

@@ -112,2 +112,50 @@ import type { DataXY } from 'cheminfo-types';

});
it('generalized Lorentzian', () => {
const peaks = [
{
x: 0,
y: 0.001,
shape: { kind: 'lorentzian' as const, fwhm: 0.31 },
},
];
const data: DataXY = generateSpectrum(peaks, {
generator: {
from: -10,
to: 10,
nbPoints: 256,
},
});
const result = optimize(
data,
[
{
x: 0.001,
y: 0.0009,
shape: {
kind: 'generalizedLorentzian',
fwhm: 0.25,
gamma: 0.5,
},
},
],
{
optimization: {
kind: 'lm',
options: {
damping: 0.1,
maxIterations: 10,
errorTolerance: 1e-8,
},
},
},
);
expect(result.peaks[0].shape.fwhm).toBeCloseTo(0.31, 4);
expect(result.peaks[0].x).toBeCloseTo(0, 5);
expect(result.peaks[0].y).toBeCloseTo(0.001, 5);
expect(result.peaks[0].shape.fwhm).toBeCloseTo(0.31, 1);
//@ts-expect-error should exists
expect(result.peaks[0].shape.gamma).toBeCloseTo(0, 1);
});
});

@@ -139,8 +139,5 @@ import type { DataXY } from 'cheminfo-types';

for (let i = 0; i < 2; i++) {
expect(result.peaks[i]).toMatchCloseTo(
JSON.parse(JSON.stringify(peaks[i])),
3,
);
expect(result.peaks[i]).toMatchCloseTo(structuredClone(peaks[i]), 3);
}
});
});

@@ -53,3 +53,3 @@ import type { DataXY } from 'cheminfo-types';

it('shifted baseline up by two', () => {
const shiftedPeaks = JSON.parse(JSON.stringify(peaks));
const shiftedPeaks = structuredClone(peaks);
for (const shiftedPeak of shiftedPeaks) {

@@ -80,3 +80,3 @@ shiftedPeak.y = shiftedPeak.y + 2;

it('negative maxima peaks', () => {
const shiftedPeaks = JSON.parse(JSON.stringify(peaks));
const shiftedPeaks = structuredClone(peaks);
for (const shiftedPeak of shiftedPeaks) {

@@ -147,3 +147,3 @@ shiftedPeak.y = shiftedPeak.y - 2;

it('negative maxima peaks', () => {
const shiftedPeaks = JSON.parse(JSON.stringify(peaks));
const shiftedPeaks = structuredClone(peaks);
for (const shiftedPeak of shiftedPeaks) {

@@ -150,0 +150,0 @@ shiftedPeak.y = shiftedPeak.y - 2;

@@ -1,2 +0,6 @@

import { Shape1DInstance, PseudoVoigt } from 'ml-peak-shape-generator';
import {
Shape1DInstance,
PseudoVoigt,
GeneralizedLorentzian,
} from 'ml-peak-shape-generator';

@@ -34,2 +38,9 @@ import { Peak } from '../../index';

},
gamma: {
init: (peak: Peak, peakShape: GeneralizedLorentzian) =>
peakShape.gamma || 0.5,
min: () => -1,
max: () => 2,
gradientDifference: () => 0.01,
},
};

@@ -8,3 +8,3 @@ import { getShape1D, Shape1D, Shape1DInstance } from 'ml-peak-shape-generator';

type Parameter = 'x' | 'y' | 'fwhm' | 'mu';
type Parameter = 'x' | 'y' | 'fwhm' | 'mu' | 'gamma';

@@ -11,0 +11,0 @@ type Property = 'init' | 'min' | 'max' | 'gradientDifference';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc