iamlikeme / rainflow

Implementation of the rainflow-counting algorythm in Python
MIT License
105 stars 34 forks source link

New BUG #60

Closed Kyle6699 closed 2 years ago

Kyle6699 commented 2 years ago

Hi,

I found a bug in this module: image

iamlikeme commented 2 years ago

Hi, I am not sure if I see the bug. Let's take for example:

max(series) == 10
min(series) == 0
nbins == 2

binsize = (max(series) - min(series)) / nbins  # == 5.0
rng = max(series) - min(series)  # == 10

If I plug in these numbers into formula for n in line 160 I get n == 2 and not nbins + 1 == 3 as you suggest:

n = int(math.ceil(10 / 5.0)) # == 2

Can you provide an example case which demonstrated the error?

Kyle6699 commented 2 years ago

image max_series = 3517.860166127188 min_series = -3093.4966492094213 nbins = 100 binsize = (max_series - min_series) / nbins int(math.ceil((max_series - min_series) / binsize))

Kyle6699 commented 2 years ago

image

I think the reason is floating-point accuracy from python.

iamlikeme commented 2 years ago

Thank you for reporting the bug and providing a test case :clap::clap: New version 3.1.1 with a bugfix is now available on PyPI.