Skip to content

Commit

Permalink
chore: update dependencies (#255)
Browse files Browse the repository at this point in the history
* chore: update dependencies

* chore: fix prettier
  • Loading branch information
lpatiny authored Aug 12, 2024
1 parent adcda29 commit ddf8fb9
Show file tree
Hide file tree
Showing 163 changed files with 414 additions and 338 deletions.
28 changes: 28 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import cheminfo from 'eslint-config-cheminfo-typescript';
import globals from 'globals';

export default [
...cheminfo,
{
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
"jsdoc/require-jsdoc": "off", // this would add automatically an empty bloc of JsDoc
"jsdoc/no-defaults": "off", // this would remove our default values https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-defaults.md#readme
"no-loss-of-precision": "off",
'@typescript-eslint/prefer-for-of': 'off',
"unicorn/import-style": [
"error",
{
"styles": {
"node:path": false
}
}
]
}
}
]

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,22 @@
},
"homepage": "https://github.com/mljs/spectra-processing#readme",
"devDependencies": {
"@vitest/coverage-v8": "^2.0.4",
"@vitest/coverage-v8": "^2.0.5",
"cheminfo-build": "^1.2.0",
"eslint": "^8.57.0",
"eslint-config-cheminfo-typescript": "^12.4.0",
"eslint-config-cheminfo-typescript": "^15.0.0",
"jest-matcher-deep-close-to": "^3.0.2",
"jscpd": "^3.5.10",
"jscpd": "^4.0.5",
"ml-spectra-fitting": "^4.2.3",
"prettier": "^3.3.3",
"rimraf": "^5.0.5",
"rimraf": "^6.0.1",
"spectrum-generator": "^8.0.11",
"typescript": "^5.5.4",
"vitest": "^2.0.4"
"vitest": "^2.0.5"
},
"dependencies": {
"binary-search": "^1.3.6",
"cheminfo-types": "^1.7.3",
"cheminfo-types": "^1.8.0",
"fft.js": "^4.0.4",
"is-any-array": "^2.0.1",
"ml-matrix": "^6.11.1",
Expand Down
4 changes: 1 addition & 3 deletions src/matrix/__tests__/matrixApplyNumericalDecoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ test('should return an array of numbers', () => {
dictCategoricalToNumerical,
);

const nonNumbers = matrix
.flat(2)
.filter((value) => typeof value !== 'number');
const nonNumbers = matrix.flat().filter((value) => typeof value !== 'number');
expect(nonNumbers).toHaveLength(0);
});
4 changes: 1 addition & 3 deletions src/matrix/__tests__/matrixNumericalEncoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { datasetForEncoding } from './fixtures/encoding';

test('should return a matrix of numbers', () => {
const { matrix } = matrixNumericalEncoding(datasetForEncoding);
const nonNumbers = matrix
.flat(2)
.filter((value) => typeof value !== 'number');
const nonNumbers = matrix.flat().filter((value) => typeof value !== 'number');
expect(nonNumbers).toHaveLength(0);
});
1 change: 1 addition & 0 deletions src/matrix/matrixAbsoluteMedian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { xMedian } from '../x';

/**

Check warning on line 4 in src/matrix/matrixAbsoluteMedian.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @returns declaration
* Returns the median of the absolute matrix.
* @param matrix

Check warning on line 6 in src/matrix/matrixAbsoluteMedian.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @param "matrix" description
*/
export function matrixAbsoluteMedian(matrix: DoubleMatrix): number {
const nbColumns = matrix[0].length;
Expand Down
4 changes: 3 additions & 1 deletion src/matrix/matrixBoxPlot.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DoubleArray } from 'cheminfo-types';

import { DoubleMatrix } from '../types';

export interface MatrixBoxPlot {
Expand All @@ -22,7 +24,7 @@ export function matrixBoxPlot(matrix: DoubleMatrix): MatrixBoxPlot {
median: new Float64Array(nbColumns),
q3: new Float64Array(nbColumns),
min: Float64Array.from(matrix[0]),
max: Float64Array.from(matrix[matrix.length - 1]),
max: Float64Array.from(matrix.at(-1) as DoubleArray),
};

const columnArray = new Float64Array(matrix.length);
Expand Down
1 change: 0 additions & 1 deletion src/matrix/matrixCenterZMean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { matrixCreateEmpty } from './matrixCreateEmpty';

/**

Check warning on line 5 in src/matrix/matrixCenterZMean.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @returns declaration
* Center mean of matrix columns.
*
* @param matrix - matrix [rows][cols]
*/
export function matrixCenterZMean(matrix: DoubleMatrix): Float64Array[] {
Expand Down
1 change: 1 addition & 0 deletions src/matrix/matrixClone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**

Check warning on line 1 in src/matrix/matrixClone.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @returns declaration
* Clone a matrix.
* @param matrix

Check warning on line 3 in src/matrix/matrixClone.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @param "matrix" description
*/
export function matrixClone<ValueType>(matrix: ValueType[][]): ValueType[][] {
return matrix.map((row) => row.slice(0));
Expand Down
1 change: 0 additions & 1 deletion src/matrix/matrixColumnsCorrelation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { xCorrelation } from '../x';

/**

Check warning on line 6 in src/matrix/matrixColumnsCorrelation.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @returns declaration
* Calculates a correlation matrix based on the columns of the initial matrix.
*
* @param A - matrix [rows][cols]
*/
export function matrixColumnsCorrelation(A: DoubleMatrix): Float64Array[] {
Expand Down
4 changes: 4 additions & 0 deletions src/matrix/matrixCreateEmpty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ export interface MatrixCreateEmptyOptions<
* Matrix from which to extract nbRows and nbColumns
*/
matrix?: DoubleMatrix;

/**
* Matrix from which to extract nbRows and nbColumns
* @default matrix.length || 1
*/
nbRows?: number;

/**
* Matrix from which to extract nbRows and nbColumns
* @default matrix[0].length || 1
*/
nbColumns?: number;

/**
* Allows to specify the type of array to use
* @default Float64Array
Expand All @@ -31,6 +34,7 @@ export interface MatrixCreateEmptyOptions<

/**

Check warning on line 35 in src/matrix/matrixCreateEmpty.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @returns declaration
* Create a new matrix based on the size of the current one or by using specific dimensions.
* @param options

Check warning on line 37 in src/matrix/matrixCreateEmpty.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Missing JSDoc @param "options" description
*/
export function matrixCreateEmpty<
ArrayConstructorType extends NumberArrayConstructor = Float64ArrayConstructor,
Expand Down
26 changes: 16 additions & 10 deletions src/matrix/matrixHistogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,50 @@ export interface MatrixHistogramOptions {
/**

Check warning on line 10 in src/matrix/matrixHistogram.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Required 1 line(s) before JSDoc block
* Center the X value. We will enlarge the first and
* @default true
* */
*/
centerX?: boolean;

/**
* histogram
* */
*/
histogram?: DataXY;

/**
* Number of slots
* @default 256
* */
*/
nbSlots?: number;

/**
* We can first apply a log on the x-axis.
* */
*/
logBaseX?: number;

/**
* We can apply a log on the resulting histogram
*/
logBaseY?: number;

/**
* Take the absolute value
*/
absolute?: boolean;

/**
* Maximal value to calculate used to calculate slot size
* @default maxValue
* */
*/
max?: number;

/**
* Minimum value to calculate used to calculate slot size
* @default minValue
* */
*/
min?: number;
}

/**
* Calculates a histogram of defined number of slots.
*
* @param matrix - matrix [rows][cols].
* @param options - options
* @returns - Result of the histogram.
Expand All @@ -63,17 +69,17 @@ export function matrixHistogram(
throw new Error('matrix must have at least one column and one row');
}

if (typeof min === 'undefined' || typeof max === 'undefined') {
if (min === undefined || max === undefined) {
const minMax = absolute
? matrixMinMaxAbsoluteZ(matrix)
: matrixMinMaxZ(matrix);
if (typeof min === 'undefined') {
if (min === undefined) {
min =
logBaseX && minMax.min
? Math.log(minMax.min) / Math.log(logBaseX)
: minMax.min;
}
if (typeof max === 'undefined') {
if (max === undefined) {
max =
logBaseX && minMax.max
? Math.log(minMax.max) / Math.log(logBaseX)
Expand Down
1 change: 0 additions & 1 deletion src/matrix/matrixMaxAbsoluteZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { NumberArray } from 'cheminfo-types';

/**
* Returns the max absolute values of Z.
*
* @param matrix - matrix [rows][cols].
*/
export function matrixMaxAbsoluteZ(matrix: NumberArray[]): number {
Expand Down
1 change: 1 addition & 0 deletions src/matrix/matrixMedian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { matrixToArray } from './matrixToArray';

/**
* Returns the median of the matrix.
* @param matrix
*/
export function matrixMedian(matrix: DoubleMatrix): number {
return xMedian(matrixToArray(matrix));
Expand Down
1 change: 0 additions & 1 deletion src/matrix/matrixMinMaxAbsoluteZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DoubleMatrix } from '../types';

/**
* Get min and max of the absolute values of Z.
*
* @param matrix - matrix [rows][cols].
*/
export function matrixMinMaxAbsoluteZ(matrix: DoubleMatrix): {
Expand Down
1 change: 0 additions & 1 deletion src/matrix/matrixMinMaxZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { matrixCheck } from './matrixCheck';

/**
* Get min and max Z.
*
* @param matrix - matrix [rows][cols].
*/
export function matrixMinMaxZ(matrix: DoubleMatrix): {
Expand Down
4 changes: 2 additions & 2 deletions src/matrix/matrixPQN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export interface MatrixPQNOptions {
/**
* Normalization integral constant.
* @default 100
* */
*/
max?: number;

/**
* min
*/
Expand All @@ -19,7 +20,6 @@ export interface MatrixPQNOptions {
* Performs a Probabilistic quotient normalization (PQN) over the dataset to account dilution based in median spectrum.
* Dieterle, F., Ross, A., Schlotterbeck, G., & Senn, H. (2006). Probabilistic quotient normalization as robust method to account for dilution of complex biological mixtures. Application in 1H NMR metabonomics. Analytical chemistry, 78(13), 4281-4290.
* DOI: 10.1021/ac051632c
*
* @param matrix - matrix [rows][cols].
* @param options - options
* @returns - {data: Normalized dataset, medianOfQuotients: The median of quotients of each variables}
Expand Down
4 changes: 2 additions & 2 deletions src/matrix/matrixZPivotRescale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export interface MatrixZPivotRescaleOptions<
/**
* max
* @default 1
* */
*/
max?: number;

/**
* Allows to specify the type of array to use
* @default Float64Array
Expand All @@ -22,7 +23,6 @@ export interface MatrixZPivotRescaleOptions<

/**
* Rescale a matrix around 0 taking into account the absolute max value.
*
* @param matrix - matrix [rows][cols].
* @param options - Options.
*/
Expand Down
7 changes: 4 additions & 3 deletions src/matrix/matrixZRescale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ export interface MatrixZRescaleOptions<
/**
* min
* @default 0
* */
*/
min?: number;

/**
* max
* @default 1
* */
*/
max?: number;

/**
* Allows to specify the type of array to use.
* @default Float64Array
Expand All @@ -26,7 +28,6 @@ export interface MatrixZRescaleOptions<

/**
* Rescale a matrix between min and max values.
*
* @param matrix - matrix [rows][cols].
* @param options - Options.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/matrix/matrixZRescalePerColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ export interface MatrixZRescalePerColumnOptions {
/**
* min
* @default 0
* */
*/
min?: number;

/**
* max
* @default 1
* */
*/
max?: number;
}

/**
* Rescale the matrix per column for which we get the min and max values.
*
* @param matrix - matrix [rows][cols].
* @param options - Options.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/reim/__tests__/reimAutoPhaseCorrection.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync } from 'node:fs';
import { join } from 'path';
import { join } from 'node:path';

import { expect, test } from 'vitest';

Expand Down
3 changes: 1 addition & 2 deletions src/reim/reimAbsolute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DataReIm } from '../types';

/**
* Calculates reimAbsolute value of a complex spectrum.
*
* @param data - complex spectrum
* @returns - reimAbsolute value
*/
Expand All @@ -12,7 +11,7 @@ export function reimAbsolute(data: DataReIm): Float64Array {
const im = data.im;
const newArray = new Float64Array(length);
for (let i = 0; i < length; i++) {
newArray[i] = Math.sqrt(re[i] ** 2 + im[i] ** 2);
newArray[i] = Math.hypot(re[i], im[i]);
}

return newArray;
Expand Down
Loading

0 comments on commit ddf8fb9

Please sign in to comment.