Skip to content

Commit

Permalink
removing explicit casts to float for divisions (no longer supporting …
Browse files Browse the repository at this point in the history
…python 2). Closes #236
  • Loading branch information
stringertheory committed Feb 4, 2024
1 parent 632915c commit 594d1a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions traces/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def total(self):
def _prepare_for_stats(self):
"""Removes None values and calculates total."""
clean = self._discard_value(None)
total = float(clean.total())
total = clean.total()
return clean, total

def mean(self):
Expand Down Expand Up @@ -109,10 +109,10 @@ def normalized(self):
result = Histogram()
for value, count in self.items():
try:
result[value] = count / float(total)
result[value] = count / total
except UnorderableElements:
result = Histogram.from_dict(dict(result), key=hash)
result[value] = count / float(total)
result[value] = count / total
return result

def _discard_value(self, value):
Expand Down Expand Up @@ -195,7 +195,7 @@ def function(q):
x2 = inverse.keys()[previous_index + 1]
y1 = inverse[x1]
y2 = inverse[x2]
result = (y2 - y1) * (q - x1) / float(x2 - x1) + y1
result = (y2 - y1) * (q - x1) / (x2 - x1) + y1

else:
if q in inverse:
Expand All @@ -210,7 +210,7 @@ def function(q):
x1 = inverse.keys()[previous_index]
result = inverse[x1]

return float(result)
return result

return function

Expand Down
4 changes: 2 additions & 2 deletions traces/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _get_linear_interpolate(self, time):
if isinstance(dt_interval, datetime.timedelta):
dt_interval = dt_interval.total_seconds()
dt_start = dt_start.total_seconds()
slope = float(right_value - left_value) / dt_interval
slope = (right_value - left_value) / dt_interval
value = slope * dt_start + left_value
return value

Expand Down Expand Up @@ -692,7 +692,7 @@ def n_points(
count += end_count - start_count

if normalized:
count /= float(self.n_measurements())
count /= self.n_measurements()

return count

Expand Down

0 comments on commit 594d1a9

Please sign in to comment.