From 438aef8744231ed2b5a4de89eb1a2729efc5e1e6 Mon Sep 17 00:00:00 2001 From: Smoren Date: Mon, 20 May 2024 15:07:04 +0300 Subject: [PATCH] Type renamed to StatSummary. --- src/lib/analysis/compounds.ts | 16 ++++++++-------- src/lib/types/analysis.ts | 18 +++++++++--------- tests/analysis/compounds.test.ts | 18 +++++++++--------- tests/analysis/helpers.ts | 4 ++-- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/lib/analysis/compounds.ts b/src/lib/analysis/compounds.ts index 1efd947..746aa22 100644 --- a/src/lib/analysis/compounds.ts +++ b/src/lib/analysis/compounds.ts @@ -3,7 +3,7 @@ import type { Compound, CompoundsAnalyzerSummary, CompoundsCollectorInterface, - CompoundsSummary, + StatSummary, } from '../types/analysis'; import { createFilledArray, createVector, round } from '../math'; @@ -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, )); @@ -135,17 +135,17 @@ export class CompoundsAnalyzer implements CompoundsAnalyzerSummary { return this.convertMapToArray(typesMap); } - private getItemLengthSummary(compounds: Array, atoms: Array): CompoundsSummary { + private getItemLengthSummary(compounds: Array, atoms: Array): StatSummary { const sizes = compounds.map((compound) => compound.size); return this.extractSummary(sizes, atoms.length); } - private getItemSpeedSummary(compounds: Array): CompoundsSummary { + private getItemSpeedSummary(compounds: Array): 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 diff --git a/src/lib/types/analysis.ts b/src/lib/types/analysis.ts index 6c3f21d..ccaadd2 100644 --- a/src/lib/types/analysis.ts +++ b/src/lib/types/analysis.ts @@ -71,7 +71,7 @@ export interface SummaryManagerInterface { export type Compound = Set; -export type CompoundsSummary = { +export type StatSummary = { size: number; frequency: number; min: number; @@ -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 = { @@ -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; } diff --git a/tests/analysis/compounds.test.ts b/tests/analysis/compounds.test.ts index 1449e86..cf6b9da 100644 --- a/tests/analysis/compounds.test.ts +++ b/tests/analysis/compounds.test.ts @@ -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"; @@ -13,8 +13,8 @@ describe.each([ Set[], number, number[], - CompoundsSummary, - CompoundsSummary[], + StatSummary, + StatSummary[], ]>)( 'Compounds Collector Test', ( @@ -23,8 +23,8 @@ describe.each([ compoundsExpected: Set[], lengthExpected: number, lengthByTypesExpected: number[], - itemSizeSummaryExpected: CompoundsSummary, - itemSizeSummaryByTypesExpected: CompoundsSummary[], + itemSizeSummaryExpected: StatSummary, + itemSizeSummaryByTypesExpected: StatSummary[], ) => { it('', () => { const collector = new CompoundsCollector(); @@ -55,8 +55,8 @@ function dataProviderForCompounds(): Array<[ Set[], number, number[], - CompoundsSummary, - CompoundsSummary[], + StatSummary, + StatSummary[], ]> { const s = createCompoundsSummary; const r = (value: number) => round(value, 4); @@ -66,8 +66,8 @@ function dataProviderForCompounds(): Array<[ number[][], number, number[], - CompoundsSummary, - CompoundsSummary[] + StatSummary, + StatSummary[] ]> = [ [ [0, 0, 1, 1, 2, 2, 0], diff --git a/tests/analysis/helpers.ts b/tests/analysis/helpers.ts index 82bcdcf..7e79bee 100644 --- a/tests/analysis/helpers.ts +++ b/tests/analysis/helpers.ts @@ -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'; @@ -46,7 +46,7 @@ export function createCompoundsSummary( max: number, mean: number, median: number, -): CompoundsSummary { +): StatSummary { return { size: size, frequency: frequency,