From 4a2bb9b8357da69f36c24c286197e2ee99a9b3b4 Mon Sep 17 00:00:00 2001 From: joseph-sentry <136376984+joseph-sentry@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:27:40 -0500 Subject: [PATCH] fix: make inf percent change result null (#990) --- graphql_api/types/flake_aggregates/flake_aggregates.py | 6 +++++- .../test_results_aggregates/test_results_aggregates.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/graphql_api/types/flake_aggregates/flake_aggregates.py b/graphql_api/types/flake_aggregates/flake_aggregates.py index 3d54ccae78..4b6d8603e4 100644 --- a/graphql_api/types/flake_aggregates/flake_aggregates.py +++ b/graphql_api/types/flake_aggregates/flake_aggregates.py @@ -42,7 +42,11 @@ def flake_aggregates_with_percentage( merged_results: pl.DataFrame = pl.concat([past_aggregates, curr_aggregates]) merged_results = merged_results.with_columns( - pl.all().pct_change().fill_nan(0).name.suffix("_percent_change") + pl.all() + .pct_change() + .replace([float("inf"), float("-inf")], None) + .fill_nan(0) + .name.suffix("_percent_change") ) aggregates = merged_results.row(1, named=True) diff --git a/graphql_api/types/test_results_aggregates/test_results_aggregates.py b/graphql_api/types/test_results_aggregates/test_results_aggregates.py index 47b73d9866..da99787e3c 100644 --- a/graphql_api/types/test_results_aggregates/test_results_aggregates.py +++ b/graphql_api/types/test_results_aggregates/test_results_aggregates.py @@ -71,7 +71,11 @@ def test_results_aggregates_with_percentage( # with_columns upserts the new columns, so if the name already exists it get overwritten # otherwise it's just added merged_results = merged_results.with_columns( - pl.all().pct_change().fill_nan(0).name.suffix("_percent_change") + pl.all() + .pct_change() + .replace([float("inf"), float("-inf")], None) + .fill_nan(0) + .name.suffix("_percent_change") ) aggregates = merged_results.row(1, named=True)