diff --git a/core/opl/data.py b/core/opl/data.py index 5852514..19c6705 100644 --- a/core/opl/data.py +++ b/core/opl/data.py @@ -142,7 +142,7 @@ def percentile(data, percent): if not data: return None - data = sorted(data) + data.sort() k = (len(data) - 1) * percent / 100 # Python 2.x returns float for floor an ceil, so cast to int f = int(math.floor(k)) @@ -226,7 +226,6 @@ def data_stats(data): else 0.0, "stdev": statistics.stdev(data) if len(data) > 1 else 0.0, "range": max(data) - min(data), - "change": data[-1] - data[0], "percentile25": q25, "percentile75": q75, "percentile90": q90, @@ -241,7 +240,6 @@ def data_stats(data): "max": max(data), "mean": (max(data) - min(data)) / len(data), "range": max(data) - min(data), - "change": data[-1] - data[0], } else: raise Exception(f"Do not know how to get stats for list of {type(data[0])}") diff --git a/opl/data.py b/opl/data.py index 5852514..19c6705 100644 --- a/opl/data.py +++ b/opl/data.py @@ -142,7 +142,7 @@ def percentile(data, percent): if not data: return None - data = sorted(data) + data.sort() k = (len(data) - 1) * percent / 100 # Python 2.x returns float for floor an ceil, so cast to int f = int(math.floor(k)) @@ -226,7 +226,6 @@ def data_stats(data): else 0.0, "stdev": statistics.stdev(data) if len(data) > 1 else 0.0, "range": max(data) - min(data), - "change": data[-1] - data[0], "percentile25": q25, "percentile75": q75, "percentile90": q90, @@ -241,7 +240,6 @@ def data_stats(data): "max": max(data), "mean": (max(data) - min(data)) / len(data), "range": max(data) - min(data), - "change": data[-1] - data[0], } else: raise Exception(f"Do not know how to get stats for list of {type(data[0])}") diff --git a/tests/test_data.py b/tests/test_data.py index 7281500..0006863 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -14,7 +14,6 @@ def test_data_stats(self): self.assertEqual(stats["mean"], 1) self.assertEqual(stats["max"], 2) self.assertEqual(stats["range"], 2) - self.assertEqual(stats["change"], 0) self.assertEqual(stats["percentile25"], 0.75) self.assertEqual(stats["percentile75"], 1.25) self.assertEqual(stats["iqr"], 0.5) @@ -47,7 +46,6 @@ def test_data_stats_datetime(self): datetime.datetime.fromisoformat("2021-03-22T11:00:00.000000+00:00"), ) self.assertEqual(stats["range"].total_seconds(), 3600) - self.assertEqual(stats["change"].total_seconds(), -3600) def test_data_stats_strange(self): data = [ @@ -101,11 +99,3 @@ def test_get_rps(self): rps_vals = opl.data.get_rps([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) self.assertEqual(len(rps_vals), 5) self.assertEqual(sum(rps_vals) / len(rps_vals), 1.0) - - def test_percentile(self): - data = [0, 1, 1, 2, 2, 1, 1, 0] - perc25 = opl.data.percentile(data, 25) - perc75 = opl.data.percentile(data, 75) - self.assertEqual(data, [0, 1, 1, 2, 2, 1, 1, 0]) # make sure data is not reordered - self.assertEqual(perc25, 0.75) - self.assertEqual(perc75, 1.25)