raphaelvallat / antropy

AntroPy: entropy and complexity of (EEG) time-series in Python
https://raphaelvallat.com/antropy/
BSD 3-Clause "New" or "Revised" License
292 stars 52 forks source link

sample_entropy not matching data types #27

Open fstinner opened 1 year ago

fstinner commented 1 year ago

I always get error messages with the function "sample_entropy" that the types at _numba_sampen are not the correct ones: "No matching definition for argument type(s) readonly array(float64, 1d, C), int64, float64".

I was able to fix the error by hard specifying the data types: Old: if metric == "chebyshev" and x.size < 5000: return _numba_sampen(x, order=order, r=0.2 * x.std(ddof=0))

New: if metric == "chebyshev" and x.size < 5000: return _numba_sampen(x.astype(np.float64), order=np.int32(order), r=np.float64(0.2 * x.std(ddof=0)))

raphaelvallat commented 1 year ago

Hi @fstinner,

  1. Can you share an example code that would produce the error?
  2. That's surprising because we already enforce that x is a float64. But better safe than sorry, please feel free to submit the above modifications as a PR!
sderooij commented 1 year ago

I had the same issue @fstinner's solution solved it for me.