has2k1 / mizani

A scales package for python
https://mizani.readthedocs.io
BSD 3-Clause "New" or "Revised" License
49 stars 14 forks source link

breaks.log_breaks errors for narrow range if base=2 #17

Closed CallanNoble1 closed 3 years ago

CallanNoble1 commented 3 years ago

The following code:

x = [
    1.768712, 1.7549, 1.836442, 1.79616, 1.57543, 1.519078, 1.861349, 1.905086,
    1.86907, 1.818797, 0.588072, 0.723217, 0.636356, 0.707729, 0.681214, 0.79747, 
    0.961983, 0.985598, 1.027589, 1.102333
]
limits = min(x), max(x)
breaks = breaks.log_breaks(base = 2)(limits)

correctly falls through to _log_sub_breaks but errors due to lines 223-224:

if self.base == 2:
    return base ** np.arange(_min, _max+1)

as dtype is not specified as float.

Hence, there is also no way for base=2 to fall through to the extended_breaks function. Should this be the case?

has2k1 commented 3 years ago

@CallanNoble1, do you have anything to say about the solution.

CallanNoble1 commented 3 years ago

dtype is assigned on line 204, making the new line 224 redundant.

This looks good though, thanks.

has2k1 commented 3 years ago

dtype is assigned on line 204, making the new line 224 redundant.

This looks good though, thanks.

Thanks for catching that.