Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024 09 13 12 43 #27

Merged
merged 5 commits into from
Sep 13, 2024
Merged
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
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"prettier": "prettier --check src",
"prettier-write": "prettier --write src",
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
"test-only": "jest --coverage",
"test-only": "vitest run --coverage",
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
"tsc-cjs": "tsc --project tsconfig.cjs.json",
"tsc-esm": "tsc --project tsconfig.esm.json"
Expand Down Expand Up @@ -47,19 +47,20 @@
},
"homepage": "https://github.com/mljs/conrec#readme",
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.21.2",
"@babel/preset-typescript": "^7.21.4",
"@types/jest": "^29.5.1",
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
"@babel/preset-typescript": "^7.24.7",
"@types/node": "^22.5.4",
"@vitest/coverage-v8": "^2.1.0",
"eslint": "^8.38.0",
"eslint-config-cheminfo-typescript": "^11.3.1",
"esm": "^3.2.25",
"jcampconverter": "^9.1.1",
"jest": "^29.5.0",
"prettier": "^2.8.7",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
"jcampconverter": "^9.6.4",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"typescript": "^5.6.2",
"vitest": "^2.1.0"
},
"dependencies": {
"cheminfo-types": "^1.7.1"
"cheminfo-types": "^1.8.0"
}
}
6 changes: 3 additions & 3 deletions src/__tests__/__snapshots__/conrec.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`conrec basic test auto select levels 1`] = `
exports[`conrec basic test > auto select levels 1`] = `
[
167.3376920421198,
182.66230795788022,
Expand Down Expand Up @@ -37,7 +37,7 @@ exports[`conrec basic test auto select levels 1`] = `
]
`;

exports[`conrec basic test auto select levels with swapAxes 1`] = `
exports[`conrec basic test > auto select levels with swapAxes 1`] = `
[
182.66230795788022,
167.3376920421198,
Expand Down
16 changes: 15 additions & 1 deletion src/__tests__/conrec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs';

import { NumberMatrix } from 'cheminfo-types';
import { convert } from 'jcampconverter';
import { describe, it, expect } from 'vitest';

import { Conrec } from '..';

Expand Down Expand Up @@ -36,6 +37,19 @@ describe('conrec basic test', () => {
expect(contours[1].lines).toHaveLength(119720);
});

it('no levels', () => {
const conrec = new Conrec(matrix);
const start = Date.now();
const { contours, timeout } = conrec.drawContour({
contourDrawer: 'basic',
levels: [],
timeout: 10000,
});
expect(Date.now() - start).toBeLessThan(25);
expect(timeout).toBeFalsy();
expect(contours).toHaveLength(0);
});

it('auto select levels', () => {
const conrec = new Conrec(matrix);
const { contours, timeout } = conrec.drawContour({
Expand Down Expand Up @@ -75,7 +89,7 @@ describe('conrec basic test', () => {
const { contours, timeout } = conrec.drawContour({
contourDrawer: 'basic',
nbLevels: 10,
timeout: 100,
timeout: 10,
});
expect(timeout).toBeTruthy();
expect(contours).toHaveLength(10);
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/shape.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { Conrec } from '..';

describe('shape', () => {
Expand Down
1 change: 1 addition & 0 deletions src/calculateContour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function calculateContour(
jlb = 0,
jub = matrix[0].length - 1,
} = options;
if (z.length === 0) return false;
const h = new Array<number>(5);
const sh = new Array<number>(5);
const xh = new Array<number>(5);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"esModuleInterop": true,
"moduleResolution": "node",
"outDir": "lib",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es2020"
Expand Down