Skip to content

Commit

Permalink
docs: improve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Nov 15, 2022
1 parent 1b1f15b commit 914a846
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions chord_metadata_service/restapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,16 @@ def custom_binning_generator(field_props) -> Generator[Tuple[int, int, str], Non
yield minimum, bins[0], f"< {bins[0]}"

# Generate interstitial bins for the range.
# Range is semi-open: [1, len(bins))
# range() is semi-open: [1, len(bins))
# – so in terms of indices, we skip the first bin (we access it via i-1 for lhs)
# and generate [lhs, rhs) pairs for each pair of bins until the end.
# Values beyond the last bin gets handled separately.
for i in range(1, len(bins)):
lhs = bins[i - 1]
rhs = bins[i]
yield lhs, rhs, f"{lhs}-{rhs}"

# Then, handle values which surpass the last bin
# Then, handle values beyond the value of the last bin
if maximum is None or maximum != bins[-1]:
yield bins[-1], maximum, f"≥ {bins[-1]}"

Expand Down

0 comments on commit 914a846

Please sign in to comment.