Followup to previous changes in math_utils; have the code use
authorScott Gasch <[email protected]>
Wed, 12 Oct 2022 22:59:03 +0000 (15:59 -0700)
committerScott Gasch <[email protected]>
Wed, 12 Oct 2022 22:59:03 +0000 (15:59 -0700)
its own len.

src/pyutils/math_utils.py

index ce9940d085ff8935a5f2a451d6398faa6608b4b4..6f042907d47764d34c2b83d3def98f41080058e8 100644 (file)
@@ -89,7 +89,7 @@ class NumericPopulation(object):
     def get_mean(self) -> float:
         """Returns the mean (arithmetic mean) so far in O(1) time."""
 
     def get_mean(self) -> float:
         """Returns the mean (arithmetic mean) so far in O(1) time."""
 
-        count = len(self.lowers) + len(self.highers)
+        count = len(self)
         return self.aggregate / count
 
     def get_mode(self) -> Tuple[float, int]:
         return self.aggregate / count
 
     def get_mode(self) -> Tuple[float, int]:
@@ -133,7 +133,7 @@ class NumericPopulation(object):
         """
         if n == 50:
             return self.get_median()
         """
         if n == 50:
             return self.get_median()
-        count = len(self.lowers) + len(self.highers)
+        count = len(self)
         self._create_sorted_copy_if_needed(count)
         assert self.sorted_copy
         index = round(count * (n / 100.0))
         self._create_sorted_copy_if_needed(count)
         assert self.sorted_copy
         index = round(count * (n / 100.0))