peaks-similarity
Version:
Peaks similarity - calculate the similarity between 2 ordered arrays of peaks
88 lines (82 loc) • 1.49 kB
JavaScript
import { test, expect } from 'vitest';
import { Comparator } from '..';
test('We check to test fast similarity common second', () => {
const comparator = new Comparator({
common: 'second',
widthBottom: 0.2,
widthTop: 0.1,
});
comparator.setPeaks1([
[],
[],
]);
expect(
comparator.fastSimilarity(
[
[],
[],
],
0.5,
4.5,
true,
),
).toBe(0.5);
expect(
comparator.fastSimilarity(
[
[],
[],
],
0.5,
4.5,
true,
),
).toBe(1);
});
test('We check to test fast similarity', () => {
const comparator = new Comparator({ widthBottom: 0.2, widthTop: 0.1 });
comparator.setPeaks1([
[],
[],
]);
expect(
comparator.fastSimilarity(
[
[],
[],
],
0.5,
2.5,
),
).toBe(1);
expect(
comparator.fastSimilarity(
[
[],
[],
],
-0.5,
2.5,
),
).toBe(0.5);
expect(
comparator.fastSimilarity(
[
[],
[],
],
0.5,
4.5,
),
).toBe(0.5);
expect(
comparator.fastSimilarity(
[
[],
[],
],
0.5,
4.5,
),
).toBe(0.5);
});