Skip to content
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
3 changes: 0 additions & 3 deletions .babelrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/documentationjs.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TypeDoc

on:
workflow_dispatch:
release:
types: [published]

jobs:
typedoc:
# Documentation: https://github.com/zakodium/workflows#typedoc
uses: zakodium/workflows/.github/workflows/typedoc.yml@typedoc-v1
with:
entry: 'src/index.ts'
secrets:
github-token: ${{ secrets.BOT_TOKEN }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ node_modules
# webstorm generated files
.idea

conrec.js
lib-esm
lib

.DS_Store

.claude
4 changes: 0 additions & 4 deletions babel.config.js

This file was deleted.

58 changes: 0 additions & 58 deletions benchmark/contour.mjs

This file was deleted.

54 changes: 54 additions & 0 deletions benchmark/contour.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// node --cpu-prof benchmark/contour.ts

import { readFileSync } from 'node:fs';
import { join } from 'node:path';

import type { NumberMatrix } from 'cheminfo-types';
import { convert } from 'jcampconverter';

import { Conrec } from '../src/index.ts';

const data = readFileSync(
join(import.meta.dirname, '../src/__tests__/data/zhmbc_0.jdx'),
'utf8',
);
const parsed = convert(data, { noContour: true }).flatten[0];

const rawMatrix = parsed.minMax?.z;
if (!rawMatrix) {
throw new Error('Failed to parse matrix from JCAMP file');
}

const matrix: NumberMatrix = rawMatrix.map((row) => Float64Array.from(row));

// eslint-disable-next-line no-console
console.log('Size: ', matrix[0].length, 'x', matrix.length);

const conrec = new Conrec(matrix);

const levels: number[] = [];
for (let level = -1e4; level <= 1e4; level += 2e2) {
levels.push(level);
}

// eslint-disable-next-line no-console
console.log(
`We calculate ${levels.length} levels close to zero to be close to noise`,
);

console.time('basic');

const result = conrec.drawContour({
contourDrawer: 'basic',
levels,
timeout: 100000,
});
// eslint-disable-next-line no-console
console.log(result.contours.length);
console.timeEnd('basic');
const totalNumberContours = result.contours.reduce(
(acc, contour) => acc + contour.lines.length,
0,
);
// eslint-disable-next-line no-console
console.log({ totalNumberContours });
4 changes: 4 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineConfig, globalIgnores } from 'eslint/config';
import cheminfo from 'eslint-config-cheminfo-typescript';

export default defineConfig(globalIgnores(['coverage', 'lib']), cheminfo);
47 changes: 22 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@
"name": "ml-conrec",
"version": "5.0.3",
"description": "JavaScript implementation of the CONREC contouring algorithm",
"main": "./lib/index.js",
"module": "./lib-esm/index.js",
"types": "./lib/index.d.ts",
"type": "module",
"exports": {
".": "./lib/index.js"
},
"files": [
"src",
"lib",
"lib-esm"
"src"
],
"scripts": {
"check-types": "tsc --noEmit",
"clean": "rimraf lib lib-esm",
"clean": "rimraf lib",
"eslint": "eslint src",
"eslint-fix": "npm run eslint -- --fix",
"prepack": "npm run tsc",
"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": "npm run test-only && npm run check-types && npm run eslint && npm run prettier",
"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"
"tsc": "npm run clean && npm run tsc-build",
"tsc-build": "tsc --project tsconfig.build.json"
},
"repository": {
"type": "git",
"url": "https://github.com/mljs/conrec.git"
"url": "git+https://github.com/mljs/conrec.git"
},
"keywords": [
"algorithm",
Expand All @@ -46,21 +45,19 @@
"url": "https://github.com/mljs/conrec/issues"
},
"homepage": "https://github.com/mljs/conrec#readme",
"dependencies": {
"cheminfo-types": "^1.10.0"
},
"devDependencies": {
"@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",
"@types/node": "^25.3.0",
"@vitest/coverage-v8": "^4.0.18",
"@zakodium/tsconfig": "^1.0.2",
"eslint": "^9.39.2",
"eslint-config-cheminfo-typescript": "^21.1.0",
"jcampconverter": "^9.6.4",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"typescript": "^5.6.2",
"vitest": "^2.1.0"
},
"dependencies": {
"cheminfo-types": "^1.8.0"
"prettier": "^3.8.1",
"rimraf": "^6.1.3",
"typescript": "^5.9.3",
"vitest": "^4.0.18"
}
}
1 change: 1 addition & 0 deletions src/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__tests__
.DS_Store
.npmignore
2 changes: 1 addition & 1 deletion src/BasicContourDrawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class BasicContourDrawer {
private contour: BasicContour[];
private swapAxes: boolean;

constructor(levels: Readonly<number[]>, swapAxes: boolean) {
constructor(levels: readonly number[], swapAxes: boolean) {
this.contour = [];
for (const level of levels) {
this.contour.push({
Expand Down
12 changes: 6 additions & 6 deletions src/ContourBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
Expand Down Expand Up @@ -80,12 +80,12 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
Expand Down
9 changes: 5 additions & 4 deletions src/ShapeContourDrawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
Expand Down Expand Up @@ -66,7 +66,8 @@
* MODIFICATIONS.
*/

import { ContourBuilder, Point, SequenceNode } from './ContourBuilder';
import type { Point, SequenceNode } from './ContourBuilder.ts';
import { ContourBuilder } from './ContourBuilder.ts';

export interface ShapeContour {
level: number;
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/conrec.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`conrec basic test > auto select levels 1`] = `
exports[`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[`auto select levels with swapAxes 1`] = `
[
182.66230795788022,
167.3376920421198,
Expand Down
Loading