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

ml-spectra-processing

Package Overview
Dependencies
Maintainers
6
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-spectra-processing - npm Package Compare versions

Comparing version 11.13.0 to 11.13.1

8

lib-esm/matrix/matrixHistogram.js

@@ -12,3 +12,3 @@ import { xHistogram } from '../x/xHistogram';

export function matrixHistogram(matrix, options = {}) {
const { logBaseY, logBaseX, absolute } = options;
const { logBaseY, logBaseX, absolute, min, max } = options;
options = JSON.parse(JSON.stringify(options));

@@ -19,7 +19,7 @@ delete options.logBaseY;

}
if (options.min === undefined || options.max === undefined) {
if (min === undefined || max === undefined) {
const minMax = absolute
? matrixMinMaxAbsoluteZ(matrix)
: matrixMinMaxZ(matrix);
if (options.min === undefined) {
if (min === undefined) {
options.min =

@@ -30,3 +30,3 @@ logBaseX && minMax.min

}
if (options.max === undefined) {
if (max === undefined) {
options.max =

@@ -33,0 +33,0 @@ logBaseX && minMax.max

@@ -42,3 +42,3 @@ import XSAdd from 'ml-xsadd';

} while (s >= 1 || s === 0);
s = Math.sqrt((-2.0 * Math.log(s)) / s);
s = Math.sqrt((-2 * Math.log(s)) / s);
spare = v * s;

@@ -45,0 +45,0 @@ hasSpare = true;

@@ -150,3 +150,3 @@ /* eslint-disable @typescript-eslint/no-loss-of-precision */

if (Number.isNaN(x)) {
return NaN;
return Number.NaN;
}

@@ -153,0 +153,0 @@ // x not on the interval: [0,2]

@@ -13,3 +13,3 @@ /**

const fct = new Function(variableLabel, `return Number(${fctString
.replace(/(?:^|\W)(?:[a-z]{2,})/g, '$1Math.$2')
.replace(/(?<before>^|\W)(?<after>[\da-z]{2,}\()/g, '$<before>Math.$<after>')
.replace(/Math\.Math/g, 'Math')})`);

@@ -19,4 +19,4 @@ const toReturn = Float64Array.from(array);

toReturn[i] = fct(array[i]);
if (isNaN(toReturn[i])) {
throw Error(`The callback ${fctString} does not return a number: ${array[i]}`);
if (Number.isNaN(toReturn[i])) {
throw new Error(`The callback ${fctString} does not return a number: ${array[i]}`);
}

@@ -23,0 +23,0 @@ }

@@ -9,8 +9,8 @@ /**

if (array.length < 5) {
throw Error('xBoxPlot: can not calculate info if array contains less than 3 elements');
throw new Error('xBoxPlot: can not calculate info if array contains less than 3 elements');
}
let info = {
q1: 0.0,
median: 0.0,
q3: 0.0,
q1: 0,
median: 0,
q3: 0,
min: array[0],

@@ -17,0 +17,0 @@ max: array[array.length - 1],

@@ -12,3 +12,3 @@ import { isAnyArray } from 'is-any-array';

let newArray = new Float64Array(array.length);
if (array.length < 1)
if (array.length === 0)
return newArray;

@@ -15,0 +15,0 @@ newArray[0] = array[0];

@@ -5,5 +5,5 @@ /**

*/
export declare function hilbertTransform(input: number[], options?: {
export declare function xHilbertTransform(input: number[], options?: {
inClockwise?: boolean;
}): Float64Array;
//# sourceMappingURL=xHilbertTransform.d.ts.map

@@ -5,3 +5,3 @@ /**

*/
export function hilbertTransform(input, options = {}) {
export function xHilbertTransform(input, options = {}) {
const { inClockwise = true } = options;

@@ -8,0 +8,0 @@ const array = [0, ...input, 0];

@@ -37,6 +37,6 @@ import { createFromToArray } from '../utils/createFromToArray';

: histogram.x;
array.forEach((element) => {
for (const element of array) {
const index = Math.max(Math.min(((element - min - Number.EPSILON) / slotSize) >> 0, nbSlots - 1), 0);
y[index]++;
});
}
if (logBaseY) {

@@ -43,0 +43,0 @@ const logOfBase = Math.log10(logBaseY);

@@ -159,5 +159,5 @@ import SplineInterpolator from 'spline-interpolator';

let kiSqrt = 0;
elementsOfCutOff.forEach((element) => {
for (const element of elementsOfCutOff) {
kiSqrt += Math.pow(element[1] - averageValue, 2);
});
}
if (kiSqrt < minKi) {

@@ -164,0 +164,0 @@ minKi = kiSqrt;

@@ -10,7 +10,7 @@ /**

let result = 0;
array.forEach((element) => {
for (const element of array) {
result += element ** 2;
});
}
return Math.sqrt(result);
}
//# sourceMappingURL=xNorm.js.map

@@ -52,3 +52,3 @@ import { xCheck } from './xCheck';

default:
throw Error('xPadding: unknown algorithm');
throw new Error('xPadding: unknown algorithm');
}

@@ -55,0 +55,0 @@ return result;

@@ -13,3 +13,3 @@ import { xCheck } from './xCheck';

if (typeof fct !== 'function')
throw Error('fct has to be a function');
throw new Error('fct has to be a function');
const { window = 5, padding = {} } = options;

@@ -16,0 +16,0 @@ const { size = window - 1, algorithm, value } = padding;

@@ -10,3 +10,3 @@ /** Function that sorts arrays or Float64Arrays in ascending order

}
else if (array instanceof Array) {
else if (Array.isArray(array)) {
return array.sort((a, b) => a - b);

@@ -24,3 +24,3 @@ }

}
else if (array instanceof Array) {
else if (Array.isArray(array)) {
return array.sort((a, b) => b - a);

@@ -27,0 +27,0 @@ }

@@ -44,5 +44,2 @@ import integral from './integral';

let j = 0; // index of output
function getSlope(x0, y0, x1, y1) {
return (y1 - y0) / (x1 - x0);
}
let add = 0;

@@ -85,2 +82,5 @@ main: while (true) {

}
function getSlope(x0, y0, x1, y1) {
return (y1 - y0) / (x1 - x0);
}
//# sourceMappingURL=equallySpacedSmooth.js.map

@@ -15,8 +15,6 @@ import { isAnyArray } from 'is-any-array';

}
if (minLength) {
if (data.x.length < minLength) {
throw new Error(`data.x must have a length of at least ${minLength}`);
}
if (minLength && data.x.length < minLength) {
throw new Error(`data.x must have a length of at least ${minLength}`);
}
}
//# sourceMappingURL=xyCheck.js.map

@@ -13,3 +13,3 @@ /**

if (x.length === 0) {
return NaN;
return Number.NaN;
}

@@ -31,4 +31,4 @@ if (x.length === 1) {

}
return NaN;
return Number.NaN;
}
//# sourceMappingURL=xyMedian.js.map

@@ -23,6 +23,4 @@ import { xFindClosestIndex } from '../x/xFindClosestIndex';

let { targetIndex, target } = options;
if (targetIndex === undefined) {
if (target !== undefined) {
targetIndex = xFindClosestIndex(x, target);
}
if (targetIndex === undefined && target !== undefined) {
targetIndex = xFindClosestIndex(x, target);
}

@@ -29,0 +27,0 @@ if (targetIndex === undefined) {

@@ -11,3 +11,3 @@ /**

let possibleXs = Float64Array.from([].concat(...data.map((spectrum) => spectrum.x))).sort();
if (possibleXs.length < 1) {
if (possibleXs.length === 0) {
throw new Error('xyArrayMerge can not process empty arrays');

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

@@ -14,3 +14,3 @@ import { xyArrayWeightedMerge } from '../xyArrayWeightedMerge';

// we first create the slots based on the first spectrum
firstXs.forEach((element) => {
for (const element of firstXs) {
let currentDelta = deltaIsFunction ? delta(element) : delta;

@@ -22,3 +22,3 @@ slots.push({

});
});
}
let otherXs = xyArrayWeightedMerge(data.slice(1), options).x;

@@ -25,0 +25,0 @@ let currentPosition = 0;

@@ -28,3 +28,3 @@ /**

};
while (data.length !== 0) {
while (data.length > 0) {
nextValue(data, positions, point);

@@ -43,7 +43,5 @@ let sameSlot = point.x <= slot.maxX;

slot.maxX = point.x + delta(point.x);
if (data.length === 0) {
if (slot.sumY > 0) {
x.push(slot.sumXY / slot.sumY);
y.push(slot.sumY);
}
if (data.length === 0 && slot.sumY > 0) {
x.push(slot.sumXY / slot.sumY);
y.push(slot.sumY);
}

@@ -50,0 +48,0 @@ }

@@ -9,3 +9,3 @@ import { xyObjectCheck } from './xyObjectCheck';

xyObjectCheck(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -12,0 +12,0 @@ let current = {

@@ -9,3 +9,3 @@ import { xyObjectCheck } from './xyObjectCheck';

xyObjectCheck(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -12,0 +12,0 @@ let current = {

@@ -9,3 +9,3 @@ import { xyObjectCheck } from './xyObjectCheck';

xyObjectCheck(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -12,0 +12,0 @@ let current = {

@@ -9,3 +9,3 @@ import { xyObjectCheck } from './xyObjectCheck';

xyObjectCheck(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -12,0 +12,0 @@ let current = {

@@ -24,3 +24,3 @@ /**

}
zones.forEach((zone) => {
for (const zone of zones) {
if (from > zone.from)

@@ -30,3 +30,3 @@ zone.from = from;

zone.to = to;
});
}
zones = zones.filter((zone) => zone.from <= zone.to);

@@ -33,0 +33,0 @@ if (zones.length === 0)

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

function matrixHistogram(matrix, options = {}) {
const { logBaseY, logBaseX, absolute } = options;
const { logBaseY, logBaseX, absolute, min, max } = options;
options = JSON.parse(JSON.stringify(options));

@@ -22,7 +22,7 @@ delete options.logBaseY;

}
if (options.min === undefined || options.max === undefined) {
if (min === undefined || max === undefined) {
const minMax = absolute
? (0, matrixMinMaxAbsoluteZ_1.matrixMinMaxAbsoluteZ)(matrix)
: (0, matrixMinMaxZ_1.matrixMinMaxZ)(matrix);
if (options.min === undefined) {
if (min === undefined) {
options.min =

@@ -33,3 +33,3 @@ logBaseX && minMax.min

}
if (options.max === undefined) {
if (max === undefined) {
options.max =

@@ -36,0 +36,0 @@ logBaseX && minMax.max

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

} while (s >= 1 || s === 0);
s = Math.sqrt((-2.0 * Math.log(s)) / s);
s = Math.sqrt((-2 * Math.log(s)) / s);
spare = v * s;

@@ -52,0 +52,0 @@ hasSpare = true;

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

if (Number.isNaN(x)) {
return NaN;
return Number.NaN;
}

@@ -155,0 +155,0 @@ // x not on the interval: [0,2]

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

const fct = new Function(variableLabel, `return Number(${fctString
.replace(/(?:^|\W)(?:[a-z]{2,})/g, '$1Math.$2')
.replace(/(?<before>^|\W)(?<after>[\da-z]{2,}\()/g, '$<before>Math.$<after>')
.replace(/Math\.Math/g, 'Math')})`);

@@ -22,4 +22,4 @@ const toReturn = Float64Array.from(array);

toReturn[i] = fct(array[i]);
if (isNaN(toReturn[i])) {
throw Error(`The callback ${fctString} does not return a number: ${array[i]}`);
if (Number.isNaN(toReturn[i])) {
throw new Error(`The callback ${fctString} does not return a number: ${array[i]}`);
}

@@ -26,0 +26,0 @@ }

@@ -12,8 +12,8 @@ "use strict";

if (array.length < 5) {
throw Error('xBoxPlot: can not calculate info if array contains less than 3 elements');
throw new Error('xBoxPlot: can not calculate info if array contains less than 3 elements');
}
let info = {
q1: 0.0,
median: 0.0,
q3: 0.0,
q1: 0,
median: 0,
q3: 0,
min: array[0],

@@ -20,0 +20,0 @@ max: array[array.length - 1],

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

let newArray = new Float64Array(array.length);
if (array.length < 1)
if (array.length === 0)
return newArray;

@@ -18,0 +18,0 @@ newArray[0] = array[0];

@@ -5,5 +5,5 @@ /**

*/
export declare function hilbertTransform(input: number[], options?: {
export declare function xHilbertTransform(input: number[], options?: {
inClockwise?: boolean;
}): Float64Array;
//# sourceMappingURL=xHilbertTransform.d.ts.map

@@ -7,4 +7,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.hilbertTransform = void 0;
function hilbertTransform(input, options = {}) {
exports.xHilbertTransform = void 0;
function xHilbertTransform(input, options = {}) {
const { inClockwise = true } = options;

@@ -29,3 +29,3 @@ const array = [0, ...input, 0];

}
exports.hilbertTransform = hilbertTransform;
exports.xHilbertTransform = xHilbertTransform;
//# sourceMappingURL=xHilbertTransform.js.map

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

: histogram.x;
array.forEach((element) => {
for (const element of array) {
const index = Math.max(Math.min(((element - min - Number.EPSILON) / slotSize) >> 0, nbSlots - 1), 0);
y[index]++;
});
}
if (logBaseY) {

@@ -46,0 +46,0 @@ const logOfBase = Math.log10(logBaseY);

@@ -166,5 +166,5 @@ "use strict";

let kiSqrt = 0;
elementsOfCutOff.forEach((element) => {
for (const element of elementsOfCutOff) {
kiSqrt += Math.pow(element[1] - averageValue, 2);
});
}
if (kiSqrt < minKi) {

@@ -171,0 +171,0 @@ minKi = kiSqrt;

@@ -13,5 +13,5 @@ "use strict";

let result = 0;
array.forEach((element) => {
for (const element of array) {
result += element ** 2;
});
}
return Math.sqrt(result);

@@ -18,0 +18,0 @@ }

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

default:
throw Error('xPadding: unknown algorithm');
throw new Error('xPadding: unknown algorithm');
}

@@ -58,0 +58,0 @@ return result;

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

if (typeof fct !== 'function')
throw Error('fct has to be a function');
throw new Error('fct has to be a function');
const { window = 5, padding = {} } = options;

@@ -19,0 +19,0 @@ const { size = window - 1, algorithm, value } = padding;

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

}
else if (array instanceof Array) {
else if (Array.isArray(array)) {
return array.sort((a, b) => a - b);

@@ -28,3 +28,3 @@ }

}
else if (array instanceof Array) {
else if (Array.isArray(array)) {
return array.sort((a, b) => b - a);

@@ -31,0 +31,0 @@ }

@@ -49,5 +49,2 @@ "use strict";

let j = 0; // index of output
function getSlope(x0, y0, x1, y1) {
return (y1 - y0) / (x1 - x0);
}
let add = 0;

@@ -91,2 +88,5 @@ main: while (true) {

exports.default = equallySpacedSmooth;
function getSlope(x0, y0, x1, y1) {
return (y1 - y0) / (x1 - x0);
}
//# sourceMappingURL=equallySpacedSmooth.js.map

@@ -18,6 +18,4 @@ "use strict";

}
if (minLength) {
if (data.x.length < minLength) {
throw new Error(`data.x must have a length of at least ${minLength}`);
}
if (minLength && data.x.length < minLength) {
throw new Error(`data.x must have a length of at least ${minLength}`);
}

@@ -24,0 +22,0 @@ }

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

if (x.length === 0) {
return NaN;
return Number.NaN;
}

@@ -34,5 +34,5 @@ if (x.length === 1) {

}
return NaN;
return Number.NaN;
}
exports.xyMedian = xyMedian;
//# sourceMappingURL=xyMedian.js.map

@@ -26,6 +26,4 @@ "use strict";

let { targetIndex, target } = options;
if (targetIndex === undefined) {
if (target !== undefined) {
targetIndex = (0, xFindClosestIndex_1.xFindClosestIndex)(x, target);
}
if (targetIndex === undefined && target !== undefined) {
targetIndex = (0, xFindClosestIndex_1.xFindClosestIndex)(x, target);
}

@@ -32,0 +30,0 @@ if (targetIndex === undefined) {

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

let possibleXs = Float64Array.from([].concat(...data.map((spectrum) => spectrum.x))).sort();
if (possibleXs.length < 1) {
if (possibleXs.length === 0) {
throw new Error('xyArrayMerge can not process empty arrays');

@@ -17,0 +17,0 @@ }

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

// we first create the slots based on the first spectrum
firstXs.forEach((element) => {
for (const element of firstXs) {
let currentDelta = deltaIsFunction ? delta(element) : delta;

@@ -25,3 +25,3 @@ slots.push({

});
});
}
let otherXs = (0, xyArrayWeightedMerge_1.xyArrayWeightedMerge)(data.slice(1), options).x;

@@ -28,0 +28,0 @@ let currentPosition = 0;

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

};
while (data.length !== 0) {
while (data.length > 0) {
nextValue(data, positions, point);

@@ -46,7 +46,5 @@ let sameSlot = point.x <= slot.maxX;

slot.maxX = point.x + delta(point.x);
if (data.length === 0) {
if (slot.sumY > 0) {
x.push(slot.sumXY / slot.sumY);
y.push(slot.sumY);
}
if (data.length === 0 && slot.sumY > 0) {
x.push(slot.sumXY / slot.sumY);
y.push(slot.sumY);
}

@@ -53,0 +51,0 @@ }

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

(0, xyObjectCheck_1.xyObjectCheck)(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -15,0 +15,0 @@ let current = {

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

(0, xyObjectCheck_1.xyObjectCheck)(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -15,0 +15,0 @@ let current = {

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

(0, xyObjectCheck_1.xyObjectCheck)(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -15,0 +15,0 @@ let current = {

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

(0, xyObjectCheck_1.xyObjectCheck)(points);
if (points.length < 1)
if (points.length === 0)
return { x: 0, y: 0 };

@@ -15,0 +15,0 @@ let current = {

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

}
zones.forEach((zone) => {
for (const zone of zones) {
if (from > zone.from)

@@ -33,3 +33,3 @@ zone.from = from;

zone.to = to;
});
}
zones = zones.filter((zone) => zone.from <= zone.to);

@@ -36,0 +36,0 @@ if (zones.length === 0)

{
"name": "ml-spectra-processing",
"version": "11.13.0",
"version": "11.13.1",
"description": "Various method to process spectra",

@@ -41,18 +41,11 @@ "main": "./lib/index.js",

"homepage": "https://github.com/mljs/spectra-processing#readme",
"prettier": {
"arrowParens": "always",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
},
"devDependencies": {
"@types/jest": "^29.1.1",
"@types/jest": "^29.2.0",
"cheminfo-build": "^1.1.11",
"eslint": "^8.24.0",
"eslint": "^8.26.0",
"eslint-config-cheminfo-typescript": "^11.1.0",
"esm": "^3.2.25",
"jest": "^29.1.2",
"jest": "^29.2.2",
"jest-matcher-deep-close-to": "^3.0.2",
"jscpd": "^3.5.0",
"jscpd": "^3.5.1",
"ml-spectra-fitting": "^4.2.0",

@@ -62,3 +55,3 @@ "prettier": "^2.7.1",

"ts-jest": "^29.0.3",
"typedoc": "^0.23.15",
"typedoc": "^0.23.18",
"typescript": "^4.8.4"

@@ -65,0 +58,0 @@ },

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

): DataXY {
const { logBaseY, logBaseX, absolute } = options;
const { logBaseY, logBaseX, absolute, min, max } = options;
options = JSON.parse(JSON.stringify(options));

@@ -67,7 +67,7 @@ delete options.logBaseY;

if (options.min === undefined || options.max === undefined) {
if (min === undefined || max === undefined) {
const minMax: { min?: number; max?: number } = absolute
? matrixMinMaxAbsoluteZ(matrix)
: matrixMinMaxZ(matrix);
if (options.min === undefined) {
if (min === undefined) {
options.min =

@@ -78,3 +78,3 @@ logBaseX && minMax.min

}
if (options.max === undefined) {
if (max === undefined) {
options.max =

@@ -81,0 +81,0 @@ logBaseX && minMax.max

@@ -90,3 +90,3 @@ import XSAdd from 'ml-xsadd';

s = Math.sqrt((-2.0 * Math.log(s)) / s);
s = Math.sqrt((-2 * Math.log(s)) / s);

@@ -93,0 +93,0 @@ spare = v * s;

@@ -166,3 +166,3 @@ /* eslint-disable @typescript-eslint/no-loss-of-precision */

if (Number.isNaN(x)) {
return NaN;
return Number.NaN;
}

@@ -169,0 +169,0 @@ // x not on the interval: [0,2]

@@ -33,3 +33,6 @@ /* eslint-disable @typescript-eslint/no-implied-eval */

`return Number(${fctString
.replace(/(?:^|\W)(?:[a-z]{2,})/g, '$1Math.$2')
.replace(
/(?<before>^|\W)(?<after>[\da-z]{2,}\()/g,
'$<before>Math.$<after>',
)
.replace(/Math\.Math/g, 'Math')})`,

@@ -40,4 +43,4 @@ );

toReturn[i] = fct(array[i]);
if (isNaN(toReturn[i])) {
throw Error(
if (Number.isNaN(toReturn[i])) {
throw new Error(
`The callback ${fctString} does not return a number: ${array[i]}`,

@@ -44,0 +47,0 @@ );

@@ -11,3 +11,3 @@ import { DoubleArray } from 'cheminfo-types';

if (array.length < 5) {
throw Error(
throw new Error(
'xBoxPlot: can not calculate info if array contains less than 3 elements',

@@ -17,5 +17,5 @@ );

let info = {
q1: 0.0,
median: 0.0,
q3: 0.0,
q1: 0,
median: 0,
q3: 0,
min: array[0],

@@ -22,0 +22,0 @@ max: array[array.length - 1],

@@ -15,3 +15,3 @@ import { DoubleArray } from 'cheminfo-types';

let newArray = new Float64Array(array.length);
if (array.length < 1) return newArray;
if (array.length === 0) return newArray;

@@ -18,0 +18,0 @@ newArray[0] = array[0];

@@ -6,3 +6,3 @@ /**

export function hilbertTransform(
export function xHilbertTransform(
input: number[],

@@ -9,0 +9,0 @@ options: { inClockwise?: boolean } = {},

@@ -94,3 +94,3 @@ import { DoubleArray, DataXY } from 'cheminfo-types';

array.forEach((element) => {
for (const element of array) {
const index = Math.max(

@@ -101,3 +101,3 @@ Math.min(((element - min - Number.EPSILON) / slotSize) >> 0, nbSlots - 1),

y[index]++;
});
}

@@ -104,0 +104,0 @@ if (logBaseY) {

@@ -257,5 +257,5 @@ import { DataXY, FromTo, DoubleArray } from 'cheminfo-types';

let kiSqrt = 0;
elementsOfCutOff.forEach((element) => {
for (const element of elementsOfCutOff) {
kiSqrt += Math.pow(element[1] - averageValue, 2);
});
}

@@ -262,0 +262,0 @@ if (kiSqrt < minKi) {

@@ -12,6 +12,6 @@ import { DoubleArray } from 'cheminfo-types';

let result = 0;
array.forEach((element) => {
for (const element of array) {
result += element ** 2;
});
}
return Math.sqrt(result);
}

@@ -78,3 +78,3 @@ import { DoubleArray } from 'cheminfo-types';

default:
throw Error('xPadding: unknown algorithm');
throw new Error('xPadding: unknown algorithm');
}

@@ -81,0 +81,0 @@

@@ -45,3 +45,3 @@ import { DoubleArray } from 'cheminfo-types';

xCheck(array);
if (typeof fct !== 'function') throw Error('fct has to be a function');
if (typeof fct !== 'function') throw new Error('fct has to be a function');

@@ -48,0 +48,0 @@ const { window = 5, padding = {} } = options;

@@ -11,3 +11,3 @@ import { DoubleArray } from 'cheminfo-types';

return array.sort();
} else if (array instanceof Array) {
} else if (Array.isArray(array)) {
return array.sort((a, b) => a - b);

@@ -25,5 +25,5 @@ }

return array.sort().reverse();
} else if (array instanceof Array) {
} else if (Array.isArray(array)) {
return array.sort((a, b) => b - a);
}
}

@@ -54,6 +54,2 @@ import integral from './integral';

function getSlope(x0: number, y0: number, x1: number, y1: number) {
return (y1 - y0) / (x1 - x0);
}
let add = 0;

@@ -102,1 +98,5 @@ main: while (true) {

}
function getSlope(x0: number, y0: number, x1: number, y1: number) {
return (y1 - y0) / (x1 - x0);
}

@@ -22,7 +22,5 @@ import { isAnyArray } from 'is-any-array';

}
if (minLength) {
if (data.x.length < minLength) {
throw new Error(`data.x must have a length of at least ${minLength}`);
}
if (minLength && data.x.length < minLength) {
throw new Error(`data.x must have a length of at least ${minLength}`);
}
}

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

if (x.length === 0) {
return NaN;
return Number.NaN;
}

@@ -37,3 +37,3 @@

}
return NaN;
return Number.NaN;
}

@@ -29,6 +29,4 @@ import { DataXY } from 'cheminfo-types';

let { targetIndex, target } = options;
if (targetIndex === undefined) {
if (target !== undefined) {
targetIndex = xFindClosestIndex(x, target);
}
if (targetIndex === undefined && target !== undefined) {
targetIndex = xFindClosestIndex(x, target);
}

@@ -35,0 +33,0 @@

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

if (possibleXs.length < 1) {
if (possibleXs.length === 0) {
throw new Error('xyArrayMerge can not process empty arrays');

@@ -35,0 +35,0 @@ }

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

// we first create the slots based on the first spectrum
firstXs.forEach((element) => {
for (const element of firstXs) {
let currentDelta = deltaIsFunction ? delta(element) : delta;

@@ -34,3 +34,3 @@ slots.push({

});
});
}

@@ -37,0 +37,0 @@ let otherXs = xyArrayWeightedMerge(data.slice(1), options).x;

@@ -45,3 +45,3 @@ import { DataXY, NumberArray } from 'cheminfo-types';

while (data.length !== 0) {
while (data.length > 0) {
nextValue(data, positions, point);

@@ -62,7 +62,5 @@ let sameSlot = point.x <= slot.maxX;

if (data.length === 0) {
if (slot.sumY > 0) {
x.push(slot.sumXY / slot.sumY);
y.push(slot.sumY);
}
if (data.length === 0 && slot.sumY > 0) {
x.push(slot.sumXY / slot.sumY);
y.push(slot.sumY);
}

@@ -69,0 +67,0 @@ }

@@ -12,3 +12,3 @@ import { Point } from '../types/Point';

if (points.length < 1) return { x: 0, y: 0 };
if (points.length === 0) return { x: 0, y: 0 };

@@ -15,0 +15,0 @@ let current = {

@@ -12,3 +12,3 @@ import { Point } from '../types/Point';

if (points.length < 1) return { x: 0, y: 0 };
if (points.length === 0) return { x: 0, y: 0 };

@@ -15,0 +15,0 @@ let current: Point = {

@@ -13,3 +13,3 @@ import { Point } from '../types/Point';

if (points.length < 1) return { x: 0, y: 0 };
if (points.length === 0) return { x: 0, y: 0 };

@@ -16,0 +16,0 @@ let current = {

@@ -13,3 +13,3 @@ import { Point } from '../types/Point';

if (points.length < 1) return { x: 0, y: 0 };
if (points.length === 0) return { x: 0, y: 0 };

@@ -16,0 +16,0 @@ let current: Point = {

@@ -49,6 +49,6 @@ import { FromTo } from 'cheminfo-types';

zones.forEach((zone) => {
for (const zone of zones) {
if (from > zone.from) zone.from = from;
if (to < zone.to) zone.to = to;
});
}

@@ -55,0 +55,0 @@ zones = zones.filter((zone) => zone.from <= zone.to);

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

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

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

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

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

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