diff --git a/eslint.config.mjs b/eslint.config.mjs index b905e35..98e4421 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,14 +1,9 @@ import cheminfo from 'eslint-config-cheminfo-typescript'; -import globals from 'globals'; export default [ ...cheminfo, { - languageOptions: { - globals: { - ...globals.node, - }, - }, + languageOptions: {}, rules: {} } ] \ No newline at end of file diff --git a/src/distances.ts b/src/distances.ts index 2f7acfa..01eac57 100644 --- a/src/distances.ts +++ b/src/distances.ts @@ -1,81 +1,81 @@ -export { euclidean, squaredEuclidean } from 'ml-distance-euclidean'; +export * from 'ml-distance-euclidean'; -export { default as additiveSymmetric } from './distances/additiveSymmetric'; +export * from './distances/additiveSymmetric'; -export { default as avg } from './distances/avg'; +export * from './distances/avg'; -export { default as bhattacharyya } from './distances/bhattacharyya'; +export * from './distances/bhattacharyya'; -export { default as canberra } from './distances/canberra'; +export * from './distances/canberra'; -export { default as chebyshev } from './distances/chebyshev'; +export * from './distances/chebyshev'; -export { default as clark } from './distances/clark'; +export * from './distances/clark'; -export { default as czekanowski } from './distances/czekanowski'; +export * from './distances/czekanowski'; -export { default as dice } from './distances/dice'; +export * from './distances/dice'; -export { default as divergence } from './distances/divergence'; +export * from './distances/divergence'; -export { default as fidelity } from './distances/fidelity'; +export * from './distances/fidelity'; -export { default as gower } from './distances/gower'; +export * from './distances/gower'; -export { default as harmonicMean } from './distances/harmonicMean'; +export * from './distances/harmonicMean'; -export { default as hellinger } from './distances/hellinger'; +export * from './distances/hellinger'; -export { default as innerProduct } from './distances/innerProduct'; +export * from './distances/innerProduct'; -export { default as intersection } from './distances/intersection'; +export * from './distances/intersection'; -export { default as jaccard } from './distances/jaccard'; +export * from './distances/jaccard'; -export { default as jeffreys } from './distances/jeffreys'; +export * from './distances/jeffreys'; -export { default as jensenDifference } from './distances/jensenDifference'; +export * from './distances/jensenDifference'; -export { default as jensenShannon } from './distances/jensenShannon'; +export * from './distances/jensenShannon'; -export { default as kdivergence } from './distances/kdivergence'; +export * from './distances/kdivergence'; -export { default as kulczynski } from './distances/kulczynski'; +export * from './distances/kulczynski'; -export { default as kullbackLeibler } from './distances/kullbackLeibler'; +export * from './distances/kullbackLeibler'; -export { default as kumarJohnson } from './distances/kumarJohnson'; +export * from './distances/kumarJohnson'; -export { default as lorentzian } from './distances/lorentzian'; +export * from './distances/lorentzian'; -export { default as manhattan } from './distances/manhattan'; +export * from './distances/manhattan'; -export { default as matusita } from './distances/matusita'; +export * from './distances/matusita'; -export { default as minkowski } from './distances/minkowski'; +export * from './distances/minkowski'; -export { default as motyka } from './distances/motyka'; +export * from './distances/motyka'; -export { default as neyman } from './distances/neyman'; +export * from './distances/neyman'; -export { default as pearson } from './distances/pearson'; +export * from './distances/pearson'; -export { default as probabilisticSymmetric } from './distances/probabilisticSymmetric'; +export * from './distances/probabilisticSymmetric'; -export { default as ruzicka } from './distances/ruzicka'; +export * from './distances/ruzicka'; -export { default as soergel } from './distances/soergel'; +export * from './distances/soergel'; -export { default as sorensen } from './distances/sorensen'; +export * from './distances/sorensen'; -export { default as squared } from './distances/squared'; +export * from './distances/squared'; -export { default as squaredChord } from './distances/squaredChord'; +export * from './distances/squaredChord'; -export { default as taneja } from './distances/taneja'; +export * from './distances/taneja'; -export { default as tanimoto } from './distances/tanimoto'; +export * from './distances/tanimoto'; -export { default as topsoe } from './distances/topsoe'; +export * from './distances/topsoe'; -export { default as waveHedges } from './distances/waveHedges'; +export * from './distances/waveHedges'; diff --git a/src/distances/additiveSymmetric.ts b/src/distances/additiveSymmetric.ts index be94731..1e1ffce 100644 --- a/src/distances/additiveSymmetric.ts +++ b/src/distances/additiveSymmetric.ts @@ -5,10 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function additiveSymmetric( - a: NumberArray, - b: NumberArray, -): number { +export function additiveSymmetric(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += ((a[i] - b[i]) * (a[i] - b[i]) * (a[i] + b[i])) / (a[i] * b[i]); diff --git a/src/distances/avg.ts b/src/distances/avg.ts index f6329f7..8434584 100644 --- a/src/distances/avg.ts +++ b/src/distances/avg.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function avg(a: NumberArray, b: NumberArray): number { +export function avg(a: NumberArray, b: NumberArray): number { let max = 0; let ans = 0; let aux = 0; diff --git a/src/distances/bhattacharyya.ts b/src/distances/bhattacharyya.ts index dc8fa09..5d3fc2e 100644 --- a/src/distances/bhattacharyya.ts +++ b/src/distances/bhattacharyya.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function bhattacharyya(a: NumberArray, b: NumberArray): number { +export function bhattacharyya(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += Math.sqrt(a[i] * b[i]); diff --git a/src/distances/canberra.ts b/src/distances/canberra.ts index 97067f2..718babb 100644 --- a/src/distances/canberra.ts +++ b/src/distances/canberra.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function canberra(a: NumberArray, b: NumberArray): number { +export function canberra(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += Math.abs(a[i] - b[i]) / (a[i] + b[i]); diff --git a/src/distances/chebyshev.ts b/src/distances/chebyshev.ts index 36efea4..2ff8f36 100644 --- a/src/distances/chebyshev.ts +++ b/src/distances/chebyshev.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function chebyshev(a: NumberArray, b: NumberArray): number { +export function chebyshev(a: NumberArray, b: NumberArray): number { let max = 0; let aux = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/clark.ts b/src/distances/clark.ts index f3e3d6a..e9499fe 100644 --- a/src/distances/clark.ts +++ b/src/distances/clark.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function clark(a: NumberArray, b: NumberArray): number { +export function clark(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += (Math.abs(a[i] - b[i]) / (a[i] + b[i])) ** 2; diff --git a/src/distances/czekanowski.ts b/src/distances/czekanowski.ts index 2834c35..807889b 100644 --- a/src/distances/czekanowski.ts +++ b/src/distances/czekanowski.ts @@ -1,15 +1,12 @@ import { NumberArray } from 'cheminfo-types'; -import czekanowskiSimilarity from '../similarities/czekanowski'; +import { czekanowski as czekanowskiSimilarity } from '../similarities/czekanowski'; /** *Returns the Czekanowski distance between vectors a and b * @link [Czekanowski algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector */ -export default function czekanowskiDistance( - a: NumberArray, - b: NumberArray, -): number { +export function czekanowski(a: NumberArray, b: NumberArray): number { return 1 - czekanowskiSimilarity(a, b); } diff --git a/src/distances/dice.ts b/src/distances/dice.ts index 6ce4ff4..3780274 100644 --- a/src/distances/dice.ts +++ b/src/distances/dice.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function dice(a: NumberArray, b: NumberArray): number { +export function dice(a: NumberArray, b: NumberArray): number { let a2 = 0; let b2 = 0; let prod2 = 0; diff --git a/src/distances/divergence.ts b/src/distances/divergence.ts index 7afcc8b..5c91725 100644 --- a/src/distances/divergence.ts +++ b/src/distances/divergence.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function divergence(a: NumberArray, b: NumberArray): number { +export function divergence(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i])); diff --git a/src/distances/fidelity.ts b/src/distances/fidelity.ts index af8fc91..7a4a041 100644 --- a/src/distances/fidelity.ts +++ b/src/distances/fidelity.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function fidelity(a: NumberArray, b: NumberArray): number { +export function fidelity(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += Math.sqrt(a[i] * b[i]); diff --git a/src/distances/gower.ts b/src/distances/gower.ts index 00a0916..42d7397 100644 --- a/src/distances/gower.ts +++ b/src/distances/gower.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function gower(a: NumberArray, b: NumberArray): number { +export function gower(a: NumberArray, b: NumberArray): number { const ii = a.length; let ans = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/harmonicMean.ts b/src/distances/harmonicMean.ts index 80f17d9..1b37b1d 100644 --- a/src/distances/harmonicMean.ts +++ b/src/distances/harmonicMean.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function harmonicMean(a: NumberArray, b: NumberArray): number { +export function harmonicMean(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += (a[i] * b[i]) / (a[i] + b[i]); diff --git a/src/distances/hellinger.ts b/src/distances/hellinger.ts index 9d0ac57..e25888c 100644 --- a/src/distances/hellinger.ts +++ b/src/distances/hellinger.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function hellinger(a: NumberArray, b: NumberArray): number { +export function hellinger(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += Math.sqrt(a[i] * b[i]); diff --git a/src/distances/innerProduct.ts b/src/distances/innerProduct.ts index 73807d1..861f595 100644 --- a/src/distances/innerProduct.ts +++ b/src/distances/innerProduct.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function innerProduct(a: NumberArray, b: NumberArray): number { +export function innerProduct(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += a[i] * b[i]; diff --git a/src/distances/intersection.ts b/src/distances/intersection.ts index 7efbf52..4d80f1e 100644 --- a/src/distances/intersection.ts +++ b/src/distances/intersection.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function intersection(a: NumberArray, b: NumberArray): number { +export function intersection(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += Math.min(a[i], b[i]); diff --git a/src/distances/jaccard.ts b/src/distances/jaccard.ts index 7287819..9543d1b 100644 --- a/src/distances/jaccard.ts +++ b/src/distances/jaccard.ts @@ -1,12 +1,12 @@ import { NumberArray } from 'cheminfo-types'; -import kumarHassebrook from '../similarities/kumarHassebrook'; +import { kumarHassebrook } from '../similarities/kumarHassebrook'; /** *Returns Jaccard distance between vectors a and b * @link [Jaccard algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector */ -export default function jaccard(a: NumberArray, b: NumberArray): number { +export function jaccard(a: NumberArray, b: NumberArray): number { return 1 - kumarHassebrook(a, b); } diff --git a/src/distances/jeffreys.ts b/src/distances/jeffreys.ts index 3fca58a..16e74ab 100644 --- a/src/distances/jeffreys.ts +++ b/src/distances/jeffreys.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function jeffreys(a: NumberArray, b: NumberArray): number { +export function jeffreys(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += (a[i] - b[i]) * Math.log(a[i] / b[i]); diff --git a/src/distances/jensenDifference.ts b/src/distances/jensenDifference.ts index e481b5a..9e51a8b 100644 --- a/src/distances/jensenDifference.ts +++ b/src/distances/jensenDifference.ts @@ -5,10 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function jensenDifference( - a: NumberArray, - b: NumberArray, -): number { +export function jensenDifference(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += diff --git a/src/distances/jensenShannon.ts b/src/distances/jensenShannon.ts index 215ae92..ecdcf41 100644 --- a/src/distances/jensenShannon.ts +++ b/src/distances/jensenShannon.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function jensenShannon(a: NumberArray, b: NumberArray): number { +export function jensenShannon(a: NumberArray, b: NumberArray): number { let p = 0; let q = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/kdivergence.ts b/src/distances/kdivergence.ts index 2a6728e..2c6ad42 100644 --- a/src/distances/kdivergence.ts +++ b/src/distances/kdivergence.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function kdivergence(a: NumberArray, b: NumberArray): number { +export function kdivergence(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += a[i] * Math.log((2 * a[i]) / (a[i] + b[i])); diff --git a/src/distances/kulczynski.ts b/src/distances/kulczynski.ts index 15b3eac..ff032c8 100644 --- a/src/distances/kulczynski.ts +++ b/src/distances/kulczynski.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function kulczynski(a: NumberArray, b: NumberArray): number { +export function kulczynski(a: NumberArray, b: NumberArray): number { let up = 0; let down = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/kullbackLeibler.ts b/src/distances/kullbackLeibler.ts index 91ccc7c..3784051 100644 --- a/src/distances/kullbackLeibler.ts +++ b/src/distances/kullbackLeibler.ts @@ -5,10 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function kullbackLeibler( - a: NumberArray, - b: NumberArray, -): number { +export function kullbackLeibler(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += a[i] * Math.log(a[i] / b[i]); diff --git a/src/distances/kumarJohnson.ts b/src/distances/kumarJohnson.ts index 6adf03e..370022f 100644 --- a/src/distances/kumarJohnson.ts +++ b/src/distances/kumarJohnson.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function kumarJohnson(a: NumberArray, b: NumberArray): number { +export function kumarJohnson(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += (a[i] * a[i] - b[i] * b[i]) ** 2 / (2 * (a[i] * b[i]) ** 1.5); diff --git a/src/distances/lorentzian.ts b/src/distances/lorentzian.ts index 19a0794..530c561 100644 --- a/src/distances/lorentzian.ts +++ b/src/distances/lorentzian.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function lorentzian(a: NumberArray, b: NumberArray): number { +export function lorentzian(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += Math.log(Math.abs(a[i] - b[i]) + 1); diff --git a/src/distances/manhattan.ts b/src/distances/manhattan.ts index e2da294..7fd339c 100644 --- a/src/distances/manhattan.ts +++ b/src/distances/manhattan.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param b - second vector */ -export default function manhattan(a: NumberArray, b: NumberArray): number { +export function manhattan(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += Math.abs(a[i] - b[i]); diff --git a/src/distances/matusita.ts b/src/distances/matusita.ts index fdaf343..abef480 100644 --- a/src/distances/matusita.ts +++ b/src/distances/matusita.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function matusita(a: NumberArray, b: NumberArray): number { +export function matusita(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += Math.sqrt(a[i] * b[i]); diff --git a/src/distances/minkowski.ts b/src/distances/minkowski.ts index bc79fc5..026d67c 100644 --- a/src/distances/minkowski.ts +++ b/src/distances/minkowski.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param b - second vector * @param p - number of order */ -export default function minkowski(a: NumberArray, b: NumberArray, p: number) { +export function minkowski(a: NumberArray, b: NumberArray, p: number) { let d = 0; for (let i = 0; i < a.length; i++) { d += Math.abs(a[i] - b[i]) ** p; diff --git a/src/distances/motyka.ts b/src/distances/motyka.ts index 3ddcfa5..6bb2d31 100644 --- a/src/distances/motyka.ts +++ b/src/distances/motyka.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function motyka(a: NumberArray, b: NumberArray): number { +export function motyka(a: NumberArray, b: NumberArray): number { let up = 0; let down = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/neyman.ts b/src/distances/neyman.ts index 35be0d5..8a64224 100644 --- a/src/distances/neyman.ts +++ b/src/distances/neyman.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function neyman(a: NumberArray, b: NumberArray): number { +export function neyman(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += ((a[i] - b[i]) * (a[i] - b[i])) / a[i]; diff --git a/src/distances/pearson.ts b/src/distances/pearson.ts index 0a0d900..890d0b3 100644 --- a/src/distances/pearson.ts +++ b/src/distances/pearson.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function pearson(a: NumberArray, b: NumberArray): number { +export function pearson(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += ((a[i] - b[i]) * (a[i] - b[i])) / b[i]; diff --git a/src/distances/probabilisticSymmetric.ts b/src/distances/probabilisticSymmetric.ts index 5a13ac1..9d8c70d 100644 --- a/src/distances/probabilisticSymmetric.ts +++ b/src/distances/probabilisticSymmetric.ts @@ -5,10 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function probabilisticSymmetric( - a: NumberArray, - b: NumberArray, -): number { +export function probabilisticSymmetric(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]); diff --git a/src/distances/ruzicka.ts b/src/distances/ruzicka.ts index 9fc835e..8622189 100644 --- a/src/distances/ruzicka.ts +++ b/src/distances/ruzicka.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function ruzicka(a: NumberArray, b: NumberArray): number { +export function ruzicka(a: NumberArray, b: NumberArray): number { let up = 0; let down = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/soergel.ts b/src/distances/soergel.ts index bb4202d..e58d470 100644 --- a/src/distances/soergel.ts +++ b/src/distances/soergel.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function soergel(a: NumberArray, b: NumberArray): number { +export function soergel(a: NumberArray, b: NumberArray): number { let up = 0; let down = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/sorensen.ts b/src/distances/sorensen.ts index 566afa2..6a962f5 100644 --- a/src/distances/sorensen.ts +++ b/src/distances/sorensen.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function sorensen(a: NumberArray, b: NumberArray): number { +export function sorensen(a: NumberArray, b: NumberArray): number { let up = 0; let down = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/distances/squared.ts b/src/distances/squared.ts index 10ec0b2..e609011 100644 --- a/src/distances/squared.ts +++ b/src/distances/squared.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function squared(a: NumberArray, b: NumberArray): number { +export function squared(a: NumberArray, b: NumberArray): number { let d = 0; for (let i = 0; i < a.length; i++) { d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]); diff --git a/src/distances/squaredChord.ts b/src/distances/squaredChord.ts index 0b23073..6dac5b3 100644 --- a/src/distances/squaredChord.ts +++ b/src/distances/squaredChord.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function squaredChord(a: NumberArray, b: NumberArray): number { +export function squaredChord(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += (Math.sqrt(a[i]) - Math.sqrt(b[i])) ** 2; diff --git a/src/distances/taneja.ts b/src/distances/taneja.ts index fafb67b..dc69365 100644 --- a/src/distances/taneja.ts +++ b/src/distances/taneja.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function taneja(a: NumberArray, b: NumberArray): number { +export function taneja(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += diff --git a/src/distances/tanimoto.ts b/src/distances/tanimoto.ts index 299a345..6906640 100644 --- a/src/distances/tanimoto.ts +++ b/src/distances/tanimoto.ts @@ -1,6 +1,6 @@ import { NumberArray } from 'cheminfo-types'; -import tanimotoS from '../similarities/tanimoto'; +import { tanimoto as tanimotoS } from '../similarities/tanimoto'; /** *Returns the Tanimoto distance between vectors p and q, and accepts the bitVector use, see the test case for an example * @link [Tanimoto algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) @@ -8,7 +8,7 @@ import tanimotoS from '../similarities/tanimoto'; * @param b - second vector * @param bitvector - bitVector */ -export default function tanimoto( +export function tanimoto( a: NumberArray, b: NumberArray, bitvector?: boolean, diff --git a/src/distances/topsoe.ts b/src/distances/topsoe.ts index 17a228a..eb61b07 100644 --- a/src/distances/topsoe.ts +++ b/src/distances/topsoe.ts @@ -5,7 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function topsoe(a: NumberArray, b: NumberArray): number { +export function topsoe(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += diff --git a/src/distances/waveHedges.ts b/src/distances/waveHedges.ts index 5d549c0..fb897d6 100644 --- a/src/distances/waveHedges.ts +++ b/src/distances/waveHedges.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param b - second vector * @param bitvector - bitVector */ -export default function waveHedges(a: NumberArray, b: NumberArray): number { +export function waveHedges(a: NumberArray, b: NumberArray): number { let ans = 0; for (let i = 0; i < a.length; i++) { ans += 1 - Math.min(a[i], b[i]) / Math.max(a[i], b[i]); diff --git a/src/similarities.ts b/src/similarities.ts index ce4197a..c14e6f9 100644 --- a/src/similarities.ts +++ b/src/similarities.ts @@ -1,22 +1,22 @@ -export { default as cosine } from './similarities/cosine'; +export * from './similarities/cosine'; -export { default as czekanowski } from './similarities/czekanowski'; +export * from './similarities/czekanowski'; -export { default as dice } from './similarities/dice'; +export * from './similarities/dice'; -export { default as intersection } from './similarities/intersection'; +export * from './similarities/intersection'; -export { default as kulczynski } from './similarities/kulczynski'; +export * from './similarities/kulczynski'; -export { default as motyka } from './similarities/motyka'; +export * from './similarities/motyka'; -export { default as pearson } from './similarities/pearson'; +export * from './similarities/pearson'; -export { default as squaredChord } from './similarities/squaredChord'; +export * from './similarities/squaredChord'; -export { default as tanimoto } from './similarities/tanimoto'; +export * from './similarities/tanimoto'; -export { default as kumarHassebrook } from './similarities/kumarHassebrook'; +export * from './similarities/kumarHassebrook'; // @ts-expect-error ml-tree-similarity is not typed export * as tree from 'ml-tree-similarity'; diff --git a/src/similarities/cosine.ts b/src/similarities/cosine.ts index 157b1a1..20ecb62 100644 --- a/src/similarities/cosine.ts +++ b/src/similarities/cosine.ts @@ -4,7 +4,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function cosine(a: NumberArray, b: NumberArray): number { +export function cosine(a: NumberArray, b: NumberArray): number { let p = 0; let p2 = 0; let q2 = 0; diff --git a/src/similarities/czekanowski.ts b/src/similarities/czekanowski.ts index 0d45b04..f42e3a8 100644 --- a/src/similarities/czekanowski.ts +++ b/src/similarities/czekanowski.ts @@ -5,10 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function czekanowskiSimilarity( - a: NumberArray, - b: NumberArray, -): number { +export function czekanowski(a: NumberArray, b: NumberArray): number { let up = 0; let down = 0; for (let i = 0; i < a.length; i++) { diff --git a/src/similarities/dice.ts b/src/similarities/dice.ts index efcdbeb..8e24d0b 100644 --- a/src/similarities/dice.ts +++ b/src/similarities/dice.ts @@ -1,12 +1,12 @@ import { NumberArray } from 'cheminfo-types'; -import diceD from '../distances/dice'; +import { dice as diceD } from '../distances/dice'; /** *Returns the Dice similarity between vectors a and b * @link [Dice similarity algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector */ -export default function dice(a: NumberArray, b: NumberArray): number { +export function dice(a: NumberArray, b: NumberArray): number { return 1 - diceD(a, b); } diff --git a/src/similarities/intersection.ts b/src/similarities/intersection.ts index 5ba97fb..1de0c8f 100644 --- a/src/similarities/intersection.ts +++ b/src/similarities/intersection.ts @@ -1,12 +1,12 @@ import { NumberArray } from 'cheminfo-types'; -import intersectionD from '../distances/intersection'; +import { intersection as intersectionD } from '../distances/intersection'; /** *Returns the Intersection similarity distance between vectors a and b * @link [Intersection similarity algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector */ -export default function intersection(a: NumberArray, b: NumberArray): number { +export function intersection(a: NumberArray, b: NumberArray): number { return 1 - intersectionD(a, b); } diff --git a/src/similarities/kulczynski.ts b/src/similarities/kulczynski.ts index e522f10..a169a4e 100644 --- a/src/similarities/kulczynski.ts +++ b/src/similarities/kulczynski.ts @@ -1,12 +1,12 @@ import { NumberArray } from 'cheminfo-types'; -import kulczynskiD from '../distances/kulczynski'; +import { kulczynski as kulczynskiD } from '../distances/kulczynski'; /** *Returns the Kulczynski similarity between vectors a and b * @link [Kulczinski algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector */ -export default function kulczynski(a: NumberArray, b: NumberArray): number { +export function kulczynski(a: NumberArray, b: NumberArray): number { return 1 / kulczynskiD(a, b); } diff --git a/src/similarities/kumarHassebrook.ts b/src/similarities/kumarHassebrook.ts index d8055ba..bb39b2a 100644 --- a/src/similarities/kumarHassebrook.ts +++ b/src/similarities/kumarHassebrook.ts @@ -5,10 +5,7 @@ import { NumberArray } from 'cheminfo-types'; * @param a - first vector * @param b - second vector */ -export default function kumarHassebrook( - a: NumberArray, - b: NumberArray, -): number { +export function kumarHassebrook(a: NumberArray, b: NumberArray): number { let p = 0; let p2 = 0; let q2 = 0; diff --git a/src/similarities/motyka.ts b/src/similarities/motyka.ts index 7b7d701..7f6e768 100644 --- a/src/similarities/motyka.ts +++ b/src/similarities/motyka.ts @@ -1,12 +1,12 @@ import { NumberArray } from 'cheminfo-types'; -import motykaD from '../distances/motyka'; +import { motyka as motykaD } from '../distances/motyka'; /** *Returns the Motyka similarity between vectors a and b * @link [Motyka algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector */ -export default function motyka(a: NumberArray, b: NumberArray): number { +export function motyka(a: NumberArray, b: NumberArray): number { return 1 - motykaD(a, b); } diff --git a/src/similarities/pearson.ts b/src/similarities/pearson.ts index e8d06f0..5be093e 100644 --- a/src/similarities/pearson.ts +++ b/src/similarities/pearson.ts @@ -1,9 +1,9 @@ import { NumberArray } from 'cheminfo-types'; import mean from 'ml-array-mean'; -import cosine from './cosine'; +import { cosine } from './cosine'; -export default function pearson(a: NumberArray, b: NumberArray): number { +export function pearson(a: NumberArray, b: NumberArray): number { const avgA = mean(a); const avgB = mean(b); diff --git a/src/similarities/squaredChord.ts b/src/similarities/squaredChord.ts index ea38acb..151d269 100644 --- a/src/similarities/squaredChord.ts +++ b/src/similarities/squaredChord.ts @@ -1,12 +1,12 @@ import { NumberArray } from 'cheminfo-types'; -import squaredChordD from '../distances/squaredChord'; +import { squaredChord as squaredChordD } from '../distances/squaredChord'; /** *Returns the Squared-chord distance between vectors a and b * @link [Squared-chord algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf) * @param a - first vector * @param b - second vector */ -export default function squaredChord(a: NumberArray, b: NumberArray): number { +export function squaredChord(a: NumberArray, b: NumberArray): number { return 1 - squaredChordD(a, b); } diff --git a/src/similarities/tanimoto.ts b/src/similarities/tanimoto.ts index 3b950e0..2526ddd 100644 --- a/src/similarities/tanimoto.ts +++ b/src/similarities/tanimoto.ts @@ -6,7 +6,7 @@ import { NumberArray } from 'cheminfo-types'; * @param b - second vector * @param bitvector - bitVector */ -export default function tanimoto( +export function tanimoto( a: NumberArray, b: NumberArray, bitvector?: boolean,