diff --git a/eslint.config.mjs b/eslint.config.mjs index 791698e7..bb9cb33c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,27 +1,21 @@ import cheminfo from 'eslint-config-cheminfo-typescript'; -import globals from 'globals'; export default [ ...cheminfo, { - languageOptions: { - globals: { - ...globals.node, - }, - }, + languageOptions: {}, rules: { - "jsdoc/lines-before-block": "off", - "no-loss-of-precision": "off", + 'jsdoc/lines-before-block': 'off', + 'no-loss-of-precision': 'off', '@typescript-eslint/prefer-for-of': 'off', - "unicorn/import-style": [ - "error", + 'unicorn/import-style': [ + 'error', { - "styles": { - "node:path": false - } - } - ] - } - } -] - + styles: { + 'node:path': false, + }, + }, + ], + }, + }, +]; diff --git a/package.json b/package.json index dfddb0d2..ddc88e44 100644 --- a/package.json +++ b/package.json @@ -88,26 +88,26 @@ }, "homepage": "https://github.com/mljs/spectra-processing#readme", "devDependencies": { - "@vitest/coverage-v8": "^2.1.1", + "@vitest/coverage-v8": "^2.1.4", "cheminfo-build": "^1.2.0", - "eslint": "^8.57.0", - "eslint-config-cheminfo-typescript": "^15.0.1", + "eslint": "^9.14.0", + "eslint-config-cheminfo-typescript": "^16.0.0", "jest-matcher-deep-close-to": "^3.0.2", "jscpd": "^4.0.5", - "ml-spectra-fitting": "^4.2.3", + "ml-spectra-fitting": "^4.2.4", "prettier": "^3.3.3", "rimraf": "^6.0.1", "spectrum-generator": "^8.0.11", - "typescript": "^5.6.2", - "vitest": "^2.1.1" + "typescript": "^5.6.3", + "vitest": "^2.1.4" }, "dependencies": { "binary-search": "^1.3.6", - "cheminfo-types": "^1.8.0", + "cheminfo-types": "^1.8.1", "fft.js": "^4.0.4", "is-any-array": "^2.0.1", - "ml-matrix": "^6.11.1", - "ml-xsadd": "^2.0.0", + "ml-matrix": "^6.12.0", + "ml-xsadd": "^3.0.1", "spline-interpolator": "^1.0.0" } } diff --git a/src/reim/__tests__/reimPhaseCorrection.test.ts b/src/reim/__tests__/reimPhaseCorrection.test.ts index 6ff7e325..45e1802b 100644 --- a/src/reim/__tests__/reimPhaseCorrection.test.ts +++ b/src/reim/__tests__/reimPhaseCorrection.test.ts @@ -1,4 +1,4 @@ -import XSAdd from 'ml-xsadd'; +import { XSadd } from 'ml-xsadd'; import { expect, test } from 'vitest'; import { reimPhaseCorrection } from '../reimPhaseCorrection'; @@ -117,7 +117,7 @@ test('test reimPhaseCorrection even', () => { }); test('180 zero order phasing', () => { - const generator = new XSAdd(0); + const generator = new XSadd(0); const phased = reimPhaseCorrection(data, Math.PI, 0); const diff = data.re.map((e, i) => e + phased.re[i]); const index = Math.floor(generator.random() * data.x.length); diff --git a/src/utils/createRandomArray.ts b/src/utils/createRandomArray.ts index a62baded..50f715e3 100644 --- a/src/utils/createRandomArray.ts +++ b/src/utils/createRandomArray.ts @@ -1,4 +1,4 @@ -import XSAdd from 'ml-xsadd'; +import { XSadd } from 'ml-xsadd'; export interface CreateRandomArrayOptions { /** @@ -56,7 +56,7 @@ export function createRandomArray( distribution = 'normal', } = options; - const generator = new XSAdd(seed); + const generator = new XSadd(seed); const returnArray = new Float64Array(length); switch (distribution) { @@ -91,9 +91,9 @@ class GaussianGenerator { #mean: number; #standardDeviation: number; - #generator: XSAdd; + #generator: XSadd; - constructor(mean: number, standardDeviation: number, generator: XSAdd) { + constructor(mean: number, standardDeviation: number, generator: XSadd) { this.#mean = mean; this.#standardDeviation = standardDeviation; this.#generator = generator; diff --git a/src/x/__tests__/xHistogram.test.ts b/src/x/__tests__/xHistogram.test.ts index 531e5a6b..239b3a9d 100644 --- a/src/x/__tests__/xHistogram.test.ts +++ b/src/x/__tests__/xHistogram.test.ts @@ -1,4 +1,4 @@ -import XSAdd from 'ml-xsadd'; +import { XSadd } from 'ml-xsadd'; import { expect, test } from 'vitest'; import { createFromToArray } from '../../utils'; @@ -88,7 +88,7 @@ test('simple y log case', () => { }); test('256 slots', () => { - const generator = new XSAdd(0); + const generator = new XSadd(0); const array = new Float64Array(10000).map(() => generator.random()); const histogram = xHistogram(array); expect(histogram.y).toHaveLength(256); @@ -98,7 +98,7 @@ test('256 slots', () => { }); test('10 slots', () => { - const generator = new XSAdd(0); + const generator = new XSadd(0); const array = new Float64Array(100000).map(() => generator.random() * 900); const histogram = xHistogram(array, { nbSlots: 10, centerX: false }); expect(histogram.x).toMatchCloseTo( @@ -114,7 +114,7 @@ test('10 slots', () => { }); test('11 slots center X', () => { - const generator = new XSAdd(0); + const generator = new XSadd(0); const array = new Float64Array(110000).map( () => generator.random() * 1100 - 50, ); @@ -131,7 +131,7 @@ test('11 slots center X', () => { }); test('min -10, max 10', () => { - const generator = new XSAdd(0); + const generator = new XSadd(0); const array = new Float64Array(10000).map(() => generator.random()); const histogram = xHistogram(array, { nbSlots: 20, min: -10, max: 10 }); expect(histogram.y).toStrictEqual( diff --git a/src/x/__tests__/xMedian.test.ts b/src/x/__tests__/xMedian.test.ts index 6980fab1..0281ba76 100644 --- a/src/x/__tests__/xMedian.test.ts +++ b/src/x/__tests__/xMedian.test.ts @@ -1,9 +1,9 @@ -import XSAdd from 'ml-xsadd'; +import { XSadd } from 'ml-xsadd'; import { expect, test } from 'vitest'; import { xMedian } from '../xMedian'; -const generator = new XSAdd(0); +const generator = new XSadd(0); const data: number[] = []; for (let i = 0; i < 1000; i++) { data.push(generator.random()); diff --git a/src/xy/__tests__/xyGrowingX.test.ts b/src/xy/__tests__/xyGrowingX.test.ts index 768beac8..0927223e 100644 --- a/src/xy/__tests__/xyGrowingX.test.ts +++ b/src/xy/__tests__/xyGrowingX.test.ts @@ -13,6 +13,17 @@ test('test xyGrowingX do nothing', () => { }); }); +test('test xyGrowingX do nothing', () => { + const x = [1, 2, 3]; + const y = [1, 2, 3]; + const result = xyGrowingX({ x, y }); + + expect(result).toStrictEqual({ + x: [1, 2, 3], + y: [1, 2, 3], + }); +}); + test('test xyGrowingX reverse', () => { const x = [3, 2, 1, 0]; const y = [0, 1, 2, 3]; diff --git a/src/xy/xyGrowingX.ts b/src/xy/xyGrowingX.ts index 6f9efd50..51f7c58b 100644 --- a/src/xy/xyGrowingX.ts +++ b/src/xy/xyGrowingX.ts @@ -11,7 +11,7 @@ export function xyGrowingX(data: DataXY): DataXY { throw new TypeError('length of x and y must be identical'); } - if (x.length < 2 || x[0] < x[x.at(-1) as number]) return data; + if (x.length < 2 || x[0] < (x.at(-1) as number)) return data; return { x: x.slice(0).reverse(), diff --git a/src/xyArray/__tests__/xyArrayWeightedMerge.test.ts b/src/xyArray/__tests__/xyArrayWeightedMerge.test.ts index 50382d6a..ea6f45ad 100644 --- a/src/xyArray/__tests__/xyArrayWeightedMerge.test.ts +++ b/src/xyArray/__tests__/xyArrayWeightedMerge.test.ts @@ -1,5 +1,5 @@ import { DataXY } from 'cheminfo-types'; -import XSAdd from 'ml-xsadd'; +import { XSadd } from 'ml-xsadd'; import { expect, test } from 'vitest'; import { xyArrayWeightedMerge } from '../xyArrayWeightedMerge'; @@ -82,7 +82,7 @@ test('empty data', () => { test('large Data Set', () => { const data = []; const arraySize = 1e5; - const generator = new XSAdd(0); + const generator = new XSadd(0); for (let dataset = 0; dataset < 20; dataset++) { const datum = { x: new Float64Array(arraySize),