Skip to content

Commit

Permalink
[ML] Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Aug 8, 2022
1 parent 35c5021 commit 64fff29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import type { HistogramItem } from '../../../../../common/correlations/types';

import { replaceHistogramDotsWithBars } from '.';
import { replaceHistogramZerosWithMinimumDomainValue } from '.';

describe('TransactionDistributionChart', () => {
describe('replaceHistogramDotsWithBars', () => {
it('does the thing', () => {
describe('replaceHistogramZerosWithMinimumDomainValue', () => {
it('replaces zeroes', () => {
const mockHistogram = [
{ doc_count: 10 },
{ doc_count: 10 },
Expand All @@ -25,15 +25,17 @@ describe('TransactionDistributionChart', () => {
{ doc_count: 10 },
] as HistogramItem[];

expect(replaceHistogramDotsWithBars(mockHistogram)).toEqual([
expect(
replaceHistogramZerosWithMinimumDomainValue(mockHistogram)
).toEqual([
{ doc_count: 10 },
{ doc_count: 10 },
{ doc_count: 0.0001 },
{ doc_count: 0.0001 },
{ doc_count: 0.0001 },
{ doc_count: 0.5 },
{ doc_count: 0.5 },
{ doc_count: 0.5 },
{ doc_count: 10 },
{ doc_count: 10 },
{ doc_count: 0.0001 },
{ doc_count: 0.5 },
{ doc_count: 10 },
{ doc_count: 10 },
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const getAnnotationsStyle = (color = 'gray'): LineAnnotationStyle => ({
// This is just to visually fix the line, for tooltips, that number will be again rounded down to 0.
const Y_AXIS_MIN_DOMAIN = 0.5;

export const replaceHistogramZeroesWithMinimumDomainValue = (
export const replaceHistogramZerosWithMinimumDomainValue = (
histogramItems: HistogramItem[]
) =>
histogramItems.reduce((histogramItem, _, i) => {
Expand Down Expand Up @@ -275,7 +275,7 @@ export function DurationDistributionChart({
id={d.id}
xScaleType={ScaleType.Log}
yScaleType={ScaleType.Log}
data={replaceHistogramZeroesWithMinimumDomainValue(d.histogram)}
data={replaceHistogramZerosWithMinimumDomainValue(d.histogram)}
curve={CurveType.CURVE_STEP_AFTER}
xAccessor="key"
yAccessors={['doc_count']}
Expand Down

0 comments on commit 64fff29

Please sign in to comment.