Skip to content

Commit

Permalink
Type renamed to StatSummary.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed May 20, 2024
1 parent fd98946 commit 438aef8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions src/lib/analysis/compounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
Compound,
CompoundsAnalyzerSummary,
CompoundsCollectorInterface,
CompoundsSummary,
StatSummary,
} from '../types/analysis';
import { createFilledArray, createVector, round } from '../math';

Expand Down Expand Up @@ -74,22 +74,22 @@ export class CompoundsAnalyzer implements CompoundsAnalyzerSummary {
return this.compoundsTypesMap.map((compounds) => compounds.length);
}

get itemLengthSummary(): CompoundsSummary {
get itemLengthSummary(): StatSummary {
return this.getItemLengthSummary(this.compounds, this.atoms);
}

get itemLengthByTypesSummary(): CompoundsSummary[] {
get itemLengthByTypesSummary(): StatSummary[] {
return this.compoundsTypesMap.map((compounds, type) => this.getItemLengthSummary(
compounds,
this.atomsTypesMap[type],
));
}

get itemSpeedSummary(): CompoundsSummary {
get itemSpeedSummary(): StatSummary {
return this.getItemSpeedSummary(this.compounds);
}

get itemSpeedByTypesSummary(): CompoundsSummary[] {
get itemSpeedByTypesSummary(): StatSummary[] {
return this.compoundsTypesMap.map((compounds, type) => this.getItemSpeedSummary(
compounds,
));
Expand Down Expand Up @@ -135,17 +135,17 @@ export class CompoundsAnalyzer implements CompoundsAnalyzerSummary {
return this.convertMapToArray(typesMap);
}

private getItemLengthSummary(compounds: Array<Compound>, atoms: Array<AtomInterface>): CompoundsSummary {
private getItemLengthSummary(compounds: Array<Compound>, atoms: Array<AtomInterface>): StatSummary {
const sizes = compounds.map((compound) => compound.size);
return this.extractSummary(sizes, atoms.length);
}

private getItemSpeedSummary(compounds: Array<Compound>): CompoundsSummary {
private getItemSpeedSummary(compounds: Array<Compound>): StatSummary {
const speeds = compounds.map((compound) => this.getCompoundSpeed(compound));
return this.extractSummary(speeds);
}

private extractSummary(values: number[], totalLength: number = 0): CompoundsSummary {
private extractSummary(values: number[], totalLength: number = 0): StatSummary {
values = values.sort((a, b) => a - b);

const result = values
Expand Down
18 changes: 9 additions & 9 deletions src/lib/types/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export interface SummaryManagerInterface {

export type Compound = Set<AtomInterface>;

export type CompoundsSummary = {
export type StatSummary = {
size: number;
frequency: number;
min: number;
Expand All @@ -89,10 +89,10 @@ export interface CompoundsCollectorInterface {
export type CompoundsAnalyzerSummary = {
size: number;
sizeByTypes: number[];
itemLengthSummary: CompoundsSummary;
itemLengthByTypesSummary: CompoundsSummary[];
itemSpeedSummary: CompoundsSummary;
itemSpeedByTypesSummary: CompoundsSummary[];
itemLengthSummary: StatSummary;
itemLengthByTypesSummary: StatSummary[];
itemSpeedSummary: StatSummary;
itemSpeedByTypesSummary: StatSummary[];
}

export type TotalSummary = {
Expand All @@ -110,8 +110,8 @@ export type TotalSummaryWeights = {
LINKS_TYPE_DELETED_MEAN: number;
COMPOUNDS_PER_ATOM: number;
COMPOUNDS_PER_ATOM_BY_TYPES: number;
COMPOUND_LENGTH_SUMMARY: CompoundsSummary;
COMPOUND_LENGTH_BY_TYPES_SUMMARY: CompoundsSummary;
COMPOUND_SPEED_SUMMARY: CompoundsSummary;
COMPOUND_SPEED_BY_TYPES_SUMMARY: CompoundsSummary;
COMPOUND_LENGTH_SUMMARY: StatSummary;
COMPOUND_LENGTH_BY_TYPES_SUMMARY: StatSummary;
COMPOUND_SPEED_SUMMARY: StatSummary;
COMPOUND_SPEED_BY_TYPES_SUMMARY: StatSummary;
}
18 changes: 9 additions & 9 deletions tests/analysis/compounds.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from '@jest/globals'
import type { AtomInterface, LinkInterface } from '../../src/lib/types/atomic';
import type { CompoundsSummary } from "../../src/lib/types/analysis";
import type { StatSummary } from "../../src/lib/types/analysis";
import { CompoundsAnalyzer, CompoundsCollector } from '../../src/lib/analysis/compounds';
import { createCompoundsSummary, expectSameArraysOfSets, prepareCompoundsData } from './helpers';
import { round } from "../../src/lib/math";
Expand All @@ -13,8 +13,8 @@ describe.each([
Set<AtomInterface>[],
number,
number[],
CompoundsSummary,
CompoundsSummary[],
StatSummary,
StatSummary[],
]>)(
'Compounds Collector Test',
(
Expand All @@ -23,8 +23,8 @@ describe.each([
compoundsExpected: Set<AtomInterface>[],
lengthExpected: number,
lengthByTypesExpected: number[],
itemSizeSummaryExpected: CompoundsSummary,
itemSizeSummaryByTypesExpected: CompoundsSummary[],
itemSizeSummaryExpected: StatSummary,
itemSizeSummaryByTypesExpected: StatSummary[],
) => {
it('', () => {
const collector = new CompoundsCollector();
Expand Down Expand Up @@ -55,8 +55,8 @@ function dataProviderForCompounds(): Array<[
Set<AtomInterface>[],
number,
number[],
CompoundsSummary,
CompoundsSummary[],
StatSummary,
StatSummary[],
]> {
const s = createCompoundsSummary;
const r = (value: number) => round(value, 4);
Expand All @@ -66,8 +66,8 @@ function dataProviderForCompounds(): Array<[
number[][],
number,
number[],
CompoundsSummary,
CompoundsSummary[]
StatSummary,
StatSummary[]
]> = [
[
[0, 0, 1, 1, 2, 2, 0],
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@jest/globals'
import type { AtomInterface, LinkInterface } from '../../src/lib/types/atomic';
import type { CompoundsSummary } from "../../src/lib/types/analysis";
import type { StatSummary } from "../../src/lib/types/analysis";
import { createAtom } from '../../src/lib/utils/functions';
import { Link } from '../../src/lib/atomic';

Expand Down Expand Up @@ -46,7 +46,7 @@ export function createCompoundsSummary(
max: number,
mean: number,
median: number,
): CompoundsSummary {
): StatSummary {
return {
size: size,
frequency: frequency,
Expand Down

0 comments on commit 438aef8

Please sign in to comment.