Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lactame-head.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main

env:
NODE_VERSION: 20.x
NODE_VERSION: 24.x

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lactame.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [published]

env:
NODE_VERSION: 20.x
NODE_VERSION: 24.x

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
types: [published]

env:
NODE_VERSION: 20.x
NODE_VERSION: 24.x
ENTRY_FILE: 'src/index.ts'

jobs:
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## [14.14.1](https://github.com/mljs/spectra-processing/compare/v14.14.0...v14.14.1) (2025-08-06)


### Bug Fixes

* support TypeScript 5.9 TypedArray changes ([18ac5a6](https://github.com/mljs/spectra-processing/commit/18ac5a6a003506ee47d20d9b8cb8f3c4fd215e7a))
* **xWhittakerSmoother:** ensure baseline is initialized as Float64Array ([18ac5a6](https://github.com/mljs/spectra-processing/commit/18ac5a6a003506ee47d20d9b8cb8f3c4fd215e7a))
* **xWhittakerSmoother:** use correct name to whittaker smoother ([#311](https://github.com/mljs/spectra-processing/issues/311)) ([18ac5a6](https://github.com/mljs/spectra-processing/commit/18ac5a6a003506ee47d20d9b8cb8f3c4fd215e7a))

## [14.14.0](https://github.com/mljs/spectra-processing/compare/v14.13.0...v14.14.0) (2025-07-23)


### Features

* add matrixTranspose function ([#309](https://github.com/mljs/spectra-processing/issues/309)) ([0b00126](https://github.com/mljs/spectra-processing/commit/0b001263d25ca966a676360f7e54807232b6cc02))

## [14.13.0](https://github.com/mljs/spectra-processing/compare/v14.12.0...v14.13.0) (2025-07-09)


### Features

* implement reimZeroFilling function ([#306](https://github.com/mljs/spectra-processing/issues/306)) ([9f02d91](https://github.com/mljs/spectra-processing/commit/9f02d9130e243e4948c718931e26771df7d1105e))


### Bug Fixes

* remove non-existent "zone" export ([#308](https://github.com/mljs/spectra-processing/issues/308)) ([d1d5777](https://github.com/mljs/spectra-processing/commit/d1d57776170777bcb5c79f924efff523f16720a7))

## [14.12.0](https://github.com/mljs/spectra-processing/compare/v14.11.0...v14.12.0) (2025-04-27)


Expand Down
3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cheminfo from 'eslint-config-cheminfo-typescript';
import { defineConfig } from 'eslint/config';
import cheminfo from 'eslint-config-cheminfo-typescript';

export default defineConfig([
...cheminfo,
Expand All @@ -9,6 +9,7 @@ export default defineConfig([
'jsdoc/lines-before-block': 'off',
'no-loss-of-precision': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'unicorn/no-array-reverse': 'off',
'unicorn/import-style': [
'error',
{
Expand Down
20 changes: 8 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ml-spectra-processing",
"version": "14.12.0",
"version": "14.14.1",
"description": "Various method to process spectra",
"main": "./lib/index.js",
"module": "./lib-esm/index.js",
Expand Down Expand Up @@ -46,10 +46,6 @@
"node": "./lib/xyObject/index.js",
"default": "./lib-esm/xyObject/index.js"
},
"./zone": {
"node": "./lib/zone/index.js",
"default": "./lib-esm/zone/index.js"
},
"./zones": {
"node": "./lib/zones/index.js",
"default": "./lib-esm/zones/index.js"
Expand Down Expand Up @@ -88,19 +84,19 @@
},
"homepage": "https://github.com/mljs/spectra-processing#readme",
"devDependencies": {
"@types/node": "^22.15.2",
"@vitest/coverage-v8": "^3.1.2",
"@types/node": "^24.2.0",
"@vitest/coverage-v8": "^3.2.4",
"cheminfo-build": "^1.2.1",
"eslint": "^9.25.1",
"eslint-config-cheminfo-typescript": "^18.0.0",
"eslint": "^9.32.0",
"eslint-config-cheminfo-typescript": "^19.0.0",
"jest-matcher-deep-close-to": "^3.0.2",
"jscpd": "^4.0.5",
"ml-spectra-fitting": "^4.2.4",
"prettier": "^3.5.3",
"prettier": "^3.6.2",
"rimraf": "^6.0.1",
"spectrum-generator": "^8.1.0",
"typescript": "^5.8.3",
"vitest": "^3.1.2"
"typescript": "^5.9.2",
"vitest": "^3.2.4"
},
"dependencies": {
"binary-search": "^1.3.6",
Expand Down
4 changes: 4 additions & 0 deletions src/__tests__/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports[`test existence of exported functions 1`] = `
"reimAutoPhaseCorrection",
"reimFFT",
"reimPhaseCorrection",
"reimZeroFilling",
"getOutputArray",
"xAbsolute",
"xAbsoluteMedian",
Expand Down Expand Up @@ -73,6 +74,7 @@ exports[`test existence of exported functions 1`] = `
"xSum",
"xUniqueSorted",
"xVariance",
"xWhittakerSmoother",
"xWhitakerSmoother",
"xyReduce",
"xyAlign",
Expand Down Expand Up @@ -132,6 +134,7 @@ exports[`test existence of exported functions 1`] = `
"xyObjectMinMaxValues",
"xyObjectMinXPoint",
"xyObjectMinYPoint",
"xyObjectNormedY",
"xyObjectSlotX",
"xyObjectSortX",
"xyObjectSumY",
Expand Down Expand Up @@ -164,6 +167,7 @@ exports[`test existence of exported functions 1`] = `
"matrixZPivotRescale",
"matrixZRescale",
"matrixZRescalePerColumn",
"matrixTranspose",
"createNumberArray",
"createDoubleArray",
"createFromToArray",
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, it } from 'vitest';
import { expect, test } from 'vitest';

import * as SpectraProcessing from '../index';

it('test existence of exported functions', () => {
test('test existence of exported functions', () => {
const exports = Object.keys(SpectraProcessing);

expect(exports).toMatchSnapshot();
});
1 change: 1 addition & 0 deletions src/matrix/__tests__/matrixAbsoluteMedian.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ test('matrixAbsoluteMedian', () => {
[1, 2, 3],
];
const absoluteMedian = matrixAbsoluteMedian(matrix);

expect(absoluteMedian).toBe(2);
});
1 change: 1 addition & 0 deletions src/matrix/__tests__/matrixApplyNumericalDecoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ test('should return an array of numbers', () => {
);

const nonNumbers = matrix.flat().filter((value) => typeof value !== 'number');

expect(nonNumbers).toHaveLength(0);
});
2 changes: 2 additions & 0 deletions src/matrix/__tests__/matrixAutoCorrelation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ test('simple', () => {
[3, 1],
];
const result = matrixAutoCorrelation(matrix);

expect(result[0]).toBeCloseTo(1, 10);
expect(result[1]).toBeCloseTo(-1, 10);
});

test('test matrixAutoCorrelation too small', () => {
const matrix = [[0]];

expect(() => matrixAutoCorrelation(matrix)).toThrow(
'can not calculate info if matrix contains less than 2 rows',
);
Expand Down
5 changes: 5 additions & 0 deletions src/matrix/__tests__/matrixBoxPlot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test('test matrixBoxPlot even', () => {
[10, 100],
[11, 110],
];

expect(matrixBoxPlot(matrix)).toStrictEqual({
q1: Float64Array.from([2.5, 25]),
median: Float64Array.from([5.5, 55]),
Expand All @@ -28,6 +29,7 @@ test('test matrixBoxPlot even', () => {

test('test matrixBoxPlot even small', () => {
const matrix = [[0], [1], [2], [3], [4], [5]];

expect(matrixBoxPlot(matrix)).toStrictEqual({
q1: Float64Array.from([1]),
median: Float64Array.from([2.5]),
Expand All @@ -39,6 +41,7 @@ test('test matrixBoxPlot even small', () => {

test('test matrixBoxPlot odd', () => {
const matrix = [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]];

expect(matrixBoxPlot(matrix)).toStrictEqual({
q1: Float64Array.from([2]),
median: Float64Array.from([5]),
Expand All @@ -50,6 +53,7 @@ test('test matrixBoxPlot odd', () => {

test('test matrixBoxPlot odd small', () => {
const matrix = [[0], [1], [2], [3], [4]];

expect(matrixBoxPlot(matrix)).toStrictEqual({
q1: Float64Array.from([0.5]),
median: Float64Array.from([2]),
Expand All @@ -61,6 +65,7 @@ test('test matrixBoxPlot odd small', () => {

test('test matrixBoxPlot too small', () => {
const matrix = [[0], [1], [2], [4]];

expect(() => matrixBoxPlot(matrix)).toThrow(
'can not calculate info if matrix contains less than 5 rows',
);
Expand Down
1 change: 1 addition & 0 deletions src/matrix/__tests__/matrixCenterZMean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test('matrixCenterZMean', () => {
[3, 1, 3, 1],
];
const result = matrixCenterZMean(data);

expect(result).toStrictEqual([
Float64Array.from([-1, 1, 0, 0]),
Float64Array.from([0, 0, -1, 1]),
Expand Down
11 changes: 10 additions & 1 deletion src/matrix/__tests__/matrixCholeskySolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { matrixCholeskySolver } from '../matrixCholeskySolver';
import { matrixCuthillMckee } from '../matrixCuthillMckee';

type Func = (b: NumberArray) => NumberArray;

test('solve a least square system', () => {
const x = xSequentialFillFromTo({ from: 0, to: Math.PI, size: 101 });
const noise = x.map(() => Math.random() * 0.1 - 0.05);
Expand All @@ -22,17 +23,23 @@ test('solve a least square system', () => {
const weighted = addWeights(upperTriangularNonZeros, y, weights);

const cho = matrixCholeskySolver(weighted.leftHandSide, dimension) as Func;

expect(cho).not.toBeNull();

const smoothed = cho(weighted.rightHandSide);

expect(smoothed[50]).toBeLessThan(0.2);
expect(smoothed[50]).toBeGreaterThan(-0.2);

//ignore the outlier, it implicates the smooth should pass closer to zero.
weights[50] = 0;
const weighted2 = addWeights(upperTriangularNonZeros, y, weights);
const cho2 = matrixCholeskySolver(weighted.leftHandSide, dimension) as Func;

expect(cho2).not.toBeNull();

const smoothed2 = cho2(weighted2.rightHandSide);

expect(smoothed2[50]).toBeLessThan(smoothed[50]);

const permutationEncodedArray = matrixCuthillMckee(
Expand All @@ -46,6 +53,8 @@ test('solve a least square system', () => {
) as Func;

expect(cho3).not.toBeNull();

const smoothed3 = cho2(weighted2.rightHandSide);
expect(smoothed3[50]).toEqual(smoothed3[50]);

expect(smoothed3[50]).toStrictEqual(smoothed3[50]);
});
1 change: 1 addition & 0 deletions src/matrix/__tests__/matrixClone.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { datasetForEncoding } from './fixtures/encoding';

test('should return an array of numbers', () => {
const matrix = matrixClone(datasetForEncoding);

expect(matrix).toStrictEqual(datasetForEncoding);
expect(matrix).not.toBe(datasetForEncoding);
});
1 change: 1 addition & 0 deletions src/matrix/__tests__/matrixColumnsCorrelation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test('matrixColumnsCorrelation', () => {
[3, 1, 3, 1],
];
const result = matrixColumnsCorrelation(data);

expect(result).toMatchCloseTo([
Float64Array.from([1, -1, 1, -1]),
Float64Array.from([-1, 1, -1, 1]),
Expand Down
5 changes: 4 additions & 1 deletion src/matrix/__tests__/matrixCreateEmpty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test('matrixCreateEmpty with default constructor', () => {
nbColumns: 2,
nbRows: 3,
});

expect(matrix).toHaveLength(3);
expect(matrix[0]).toHaveLength(2);
expect(matrix[0]).toBeInstanceOf(Float64Array);
Expand All @@ -24,11 +25,12 @@ test('matrixCreateEmpty with Array constructor', () => {
nbRows: 3,
ArrayConstructor: Array,
});

expect(matrix).toHaveLength(3);
expect(matrix[0]).toHaveLength(2);
expect(matrix[0]).toBeInstanceOf(Array);

expect(matrix).toEqual([
expect(matrix).toStrictEqual([
[0, 0],
[0, 0],
[0, 0],
Expand All @@ -41,6 +43,7 @@ test('matrixCreateEmpty with Int16Array constructor', () => {
nbRows: 3,
ArrayConstructor: Int16Array,
});

expect(matrix).toHaveLength(3);
expect(matrix[0]).toHaveLength(2);
expect(matrix[0]).toBeInstanceOf(Int16Array);
Expand Down
1 change: 1 addition & 0 deletions src/matrix/__tests__/matrixCuthillMckee.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test('permutation to reduce bandwidth', () => {
permutationEncodedArray,
dimension,
);

expect(bandwidth(reducedBandwidthMatrix)).toBeLessThan(bandwidth(matrix));
});

Expand Down
8 changes: 6 additions & 2 deletions src/matrix/__tests__/matrixGetSubMatrix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ test('should extract submatrix correctly without duplication', () => {

const subMatrix = matrixGetSubMatrix(matrix, options);
const expectedResult = [new Float64Array([2, 3]), new Float64Array([5, 6])];
expect(subMatrix).toEqual(expectedResult);

expect(subMatrix).toStrictEqual(expectedResult);

subMatrix[0][0] = 10;

expect(matrix[0][1]).toBe(10);
});

Expand All @@ -40,9 +42,11 @@ test('should extract submatrix correctly with duplication', () => {

const subMatrix = matrixGetSubMatrix(matrix, options);
const expectedResult = [new Float64Array([2, 3]), new Float64Array([5, 6])];
expect(subMatrix).toEqual(expectedResult);

expect(subMatrix).toStrictEqual(expectedResult);

subMatrix[0][0] = 10;

expect(matrix[0][1]).toBe(2);
});

Expand Down
4 changes: 4 additions & 0 deletions src/matrix/__tests__/matrixHistogram.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test('simple case', () => {
];
const histogram = matrixHistogram(matrix, { nbSlots: 10, centerX: false });
histogram.y = Array.from(histogram.y);

expect(histogram.x).toStrictEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
expect(histogram.y).toStrictEqual([1, 1, 2, 3, 3, 3, 3, 2, 1, 1]);
});
Expand All @@ -26,6 +27,7 @@ test('absolute values', () => {
absolute: true,
});
histogram.y = Array.from(histogram.y);

expect(histogram.x).toStrictEqual([0, 1, 2, 3, 4]);
expect(histogram.y).toStrictEqual([2, 2, 2, 2, 2]);
});
Expand All @@ -42,6 +44,7 @@ test('logBaseX', () => {
absolute: true,
});
histogram.y = Array.from(histogram.y);

expect(histogram.x).toStrictEqual([1, 2, 3, 4, 5]);
expect(histogram.y).toStrictEqual([2, 2, 2, 2, 2]);
});
Expand All @@ -58,6 +61,7 @@ test('simple y log case', () => {
centerX: false,
});
histogram.y = Array.from(histogram.y);

expect(histogram.x).toStrictEqual([1, 2, 3, 4, 5, 6]);
expect(histogram.y).toMatchCloseTo([
1, 0.3010299956639812, 0.3010299956639812, 0.3010299956639812, 0,
Expand Down
Loading