Skip to content

Commit

Permalink
fix: remove zone if no points in xyEquallySpaced
Browse files Browse the repository at this point in the history
* chore: add failing test case

* 

---------

Co-authored-by: Luc Patiny <luc@patiny.com>
  • Loading branch information
jobo322 and lpatiny authored Jul 30, 2024
1 parent 39336cd commit 443887f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,25 @@
},
"homepage": "https://github.com/mljs/spectra-processing#readme",
"devDependencies": {
"@vitest/coverage-v8": "^1.5.3",
"@vitest/coverage-v8": "^2.0.4",
"cheminfo-build": "^1.2.0",
"eslint": "^8.57.0",
"eslint-config-cheminfo-typescript": "^12.4.0",
"jest-matcher-deep-close-to": "^3.0.2",
"jscpd": "^3.5.10",
"ml-spectra-fitting": "^4.2.3",
"prettier": "^3.2.5",
"prettier": "^3.3.3",
"rimraf": "^5.0.5",
"spectrum-generator": "^8.0.11",
"typescript": "^5.4.5",
"vitest": "^1.5.3"
"typescript": "^5.5.4",
"vitest": "^2.0.4"
},
"dependencies": {
"binary-search": "^1.3.6",
"cheminfo-types": "^1.7.3",
"fft.js": "^4.0.4",
"is-any-array": "^2.0.1",
"ml-matrix": "^6.11.0",
"ml-matrix": "^6.11.1",
"ml-xsadd": "^2.0.0",
"spline-interpolator": "^1.0.0"
}
Expand Down
21 changes: 21 additions & 0 deletions src/xy/__tests__/xyEquallySpaced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,29 @@ import { join } from 'path';

import { expect, test } from 'vitest';

import { xSequentialFillFromTo } from '../../x/xSequentialFillFromTo';
import { xyEquallySpaced } from '../xyEquallySpaced';

test('one zone with zero point', () => {
const size = 256;
const x = xSequentialFillFromTo({ from: 0, to: 100, size });
const y = x.slice();

const from = x[size / 2];
const to = x[size / 2 + 1];
const ans = xyEquallySpaced(
{ x, y },
{
numberOfPoints: 64,
zones: [
{ from, to },
{ from: 0, to: 50 },
],
},
);
expect(ans.x).toHaveLength(64);
});

test('testing 1 points', () => {
const x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const y = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
Expand Down
3 changes: 1 addition & 2 deletions src/xy/xyEquallySpaced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ export function xyEquallySpaced(
}

const normalizedZones = zonesNormalize(zones, { from, to, exclusions });

const zonesWithPointsRes = zonesWithPoints(normalizedZones, numberOfPoints, {
from,
to,
});
}).filter((zone) => zone.numberOfPoints);

let xResult: number[] = [];
let yResult: number[] = [];
Expand Down

0 comments on commit 443887f

Please sign in to comment.