Skip to content

Commit 998d276

Browse files
Copilot4n4nd
andcommitted
Address code review feedback
- Move math import to top of test file - Use np_array instead of query_values for percentile calculation for consistency Co-authored-by: 4n4nd <22333506+4n4nd@users.noreply.github.com>
1 parent 0559710 commit 998d276

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

prometheus_api_client/prometheus_connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def get_metric_aggregation(
612612
elif operation.startswith("percentile"):
613613
percentile = float(operation.split("_")[1])
614614
aggregated_values["percentile_" + str(percentile)] = numpy.nanpercentile(
615-
query_values, percentile
615+
np_array, percentile
616616
)
617617
elif operation == "deviation":
618618
aggregated_values["deviation"] = numpy.nanstd(np_array)

tests/test_prometheus_connect.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Test module for class PrometheusConnect."""
22

3+
import math
34
import unittest
45
import os
56
from datetime import datetime, timedelta
@@ -441,8 +442,6 @@ def test_get_metric_aggregation_with_nan_values(self): # noqa D102
441442
self.assertIn("percentile_50.0", aggregated_values)
442443

443444
# Verify that results are not NaN
444-
import math
445-
446445
self.assertFalse(math.isnan(aggregated_values["sum"]), "Sum should not be NaN")
447446
self.assertFalse(math.isnan(aggregated_values["max"]), "Max should not be NaN")
448447
self.assertFalse(math.isnan(aggregated_values["min"]), "Min should not be NaN")

0 commit comments

Comments
 (0)