Skip to content

Commit

Permalink
chore: remove internal default to simplify the reexport and ensure fu…
Browse files Browse the repository at this point in the history
…nction name = filename
  • Loading branch information
lpatiny committed Oct 17, 2024
1 parent c1a80bc commit 86731fb
Show file tree
Hide file tree
Showing 53 changed files with 111 additions and 137 deletions.
7 changes: 1 addition & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import cheminfo from 'eslint-config-cheminfo-typescript';
import globals from 'globals';

export default [
...cheminfo,
{
languageOptions: {
globals: {
...globals.node,
},
},
languageOptions: {},
rules: {}
}
]
82 changes: 41 additions & 41 deletions src/distances.ts
Original file line number Diff line number Diff line change
@@ -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';
5 changes: 1 addition & 4 deletions src/distances/additiveSymmetric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/avg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/distances/bhattacharyya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/canberra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/chebyshev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/distances/clark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions src/distances/czekanowski.ts
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion src/distances/dice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/distances/divergence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down
2 changes: 1 addition & 1 deletion src/distances/fidelity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/gower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/distances/harmonicMean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/hellinger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/innerProduct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/distances/intersection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions src/distances/jaccard.ts
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion src/distances/jeffreys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
5 changes: 1 addition & 4 deletions src/distances/jensenDifference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 +=
Expand Down
2 changes: 1 addition & 1 deletion src/distances/jensenShannon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/distances/kdivergence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down
2 changes: 1 addition & 1 deletion src/distances/kulczynski.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
5 changes: 1 addition & 4 deletions src/distances/kullbackLeibler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/kumarJohnson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/lorentzian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/manhattan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/distances/matusita.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Loading

0 comments on commit 86731fb

Please sign in to comment.