Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: fix headtail recursion #121

Merged
merged 1 commit into from
Dec 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mapclassify/classifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ def _format_intervals(mc, fmt="{:.0f}"):
For some classifiers, it is possible that the upper bound of the first interval is less than the minimum value of the attribute that is being classified. In these cases `lower_open=True` and the lower bound of the interval is set to `np.NINF`.
"""


lowest = mc.y.min()
if hasattr(mc, 'lowest'):
if hasattr(mc, "lowest"):
if mc.lowest is not None:
lowest = mc.lowest
lower_open = False
Expand Down Expand Up @@ -182,6 +181,8 @@ def head_tail_breaks(values, cuts):
"""
values = np.array(values)
mean = np.mean(values)
if len(cuts) > 0 and cuts[-1] == mean: # fix floating point issue #117
return cuts
cuts.append(mean)
if len(set(values)) > 1:
return head_tail_breaks(values[values > mean], cuts)
Expand Down