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

ml-spectra-fitting

Package Overview
Dependencies
Maintainers
4
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 3.0.3 to 3.0.4

20

lib/index.js

@@ -7,3 +7,3 @@ 'use strict';

var mlPeakShapeGenerator = require('ml-peak-shape-generator');
var LM = require('ml-levenberg-marquardt');
var mlLevenbergMarquardt = require('ml-levenberg-marquardt');

@@ -13,3 +13,2 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var getMaxValue__default = /*#__PURE__*/_interopDefaultLegacy(getMaxValue);
var LM__default = /*#__PURE__*/_interopDefaultLegacy(LM);

@@ -113,3 +112,3 @@ /**

function checkInput(data, peaks, options) {
function checkInput(data, peakList, options) {
let {

@@ -122,2 +121,4 @@ shape = { kind: 'gaussian' },

let peaks = JSON.parse(JSON.stringify(peakList));
if (typeof shape.kind !== 'string') {

@@ -269,3 +270,3 @@ throw new Error('kind should be a string');

return {
algorithm: LM__default["default"],
algorithm: mlLevenbergMarquardt.levenbergMarquardt,
optimizationOptions: checkOptions(kind, options),

@@ -303,13 +304,2 @@ };

// const STATE_INIT = 0;
// const STATE_MIN = 1;
// const STATE_MAX = 2;
// const STATE_GRADIENT_DIFFERENCE = 3;
// const X = 0;
// const Y = 1;
// const WIDTH = 2;
// const MU = 3;
// const keys = ['x', 'y', 'width', 'mu'];
/**

@@ -316,0 +306,0 @@ * Fits a set of points to the sum of a set of bell functions.

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

@@ -48,19 +48,19 @@ "main": "lib/index.js",

"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.16.0",
"@types/jest": "^27.0.3",
"@babel/plugin-transform-modules-commonjs": "^7.16.8",
"@types/jest": "^27.4.0",
"cheminfo-build": "^1.1.11",
"eslint": "^8.3.0",
"eslint": "^8.7.0",
"eslint-config-cheminfo": "^7.2.1",
"esm": "^3.2.25",
"jest": "^27.3.1",
"prettier": "^2.5.0",
"rollup": "^2.60.1",
"jest": "^27.4.7",
"prettier": "^2.5.1",
"rollup": "^2.66.0",
"spectrum-generator": "^6.0.2"
},
"dependencies": {
"cheminfo-types": "^0.8.0",
"ml-array-max": "^1.2.3",
"ml-levenberg-marquardt": "^3.1.1",
"cheminfo-types": "^0.9.1",
"ml-array-max": "^1.2.4",
"ml-levenberg-marquardt": "^4.0.0",
"ml-peak-shape-generator": "^4.0.1"
}
}

@@ -17,10 +17,10 @@ import { optimize } from '../index';

let yData = sumOfLorentzians(pTrue);
let result = optimize(
{ x, y: x.map((i) => yData(i)) },
[
{ x: -0.5, y: 0.0009, fwhm: (xFactor * nbPoints) / 8 },
{ x: 0.52, y: 0.0009, fwhm: (xFactor * nbPoints) / 8 },
],
{ shape: { kind: 'lorentzian' } },
);
let peakList = [
{ x: -0.5, y: 0.0009, fwhm: (xFactor * nbPoints) / 8 },
{ x: 0.52, y: 0.0009, fwhm: (xFactor * nbPoints) / 8 },
];
let result = optimize({ x, y: x.map((i) => yData(i)) }, peakList, {
shape: { kind: 'lorentzian' },
});
let nL = pTrue.length / 3;

@@ -32,2 +32,6 @@ for (let i = 0; i < nL; i++) {

expect(pFit.fwhm).toBeCloseTo(pTrue[i + nL * 2], 2);
expect(peakList).toStrictEqual([
{ x: -0.5, y: 0.0009, fwhm: (xFactor * nbPoints) / 8 },
{ x: 0.52, y: 0.0009, fwhm: (xFactor * nbPoints) / 8 },
]);
}

@@ -34,0 +38,0 @@ });

import { checkInput } from './util/checkInput';
import { selectMethod } from './util/selectMethod';
// const STATE_INIT = 0;
// const STATE_MIN = 1;
// const STATE_MAX = 2;
// const STATE_GRADIENT_DIFFERENCE = 3;
// const X = 0;
// const Y = 1;
// const WIDTH = 2;
// const MU = 3;
// const keys = ['x', 'y', 'width', 'mu'];
/**

@@ -16,0 +5,0 @@ * Fits a set of points to the sum of a set of bell functions.

@@ -9,3 +9,3 @@ import getMaxValue from 'ml-array-max';

export function checkInput(data, peaks, options) {
export function checkInput(data, peakList, options) {
let {

@@ -18,2 +18,4 @@ shape = { kind: 'gaussian' },

let peaks = JSON.parse(JSON.stringify(peakList));
if (typeof shape.kind !== 'string') {

@@ -20,0 +22,0 @@ throw new Error('kind should be a string');

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

import LM from 'ml-levenberg-marquardt';
import { levenbergMarquardt } from 'ml-levenberg-marquardt';

@@ -11,3 +11,3 @@ const LEVENBERG_MARQUARDT = 1;

return {
algorithm: LM,
algorithm: levenbergMarquardt,
optimizationOptions: checkOptions(kind, options),

@@ -14,0 +14,0 @@ };

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