Open Beriefing opened 4 years ago
Hi,
Thanks for raising this issue :-) Yep I will try to do that soon. It is actually due to the fact that the method expects a list of int as input.
Regards, Robin
For those still waiting, you can fix it by simply casting the max and min values to int's (as range expects int values not floats). By doing something like:
def plot_distrib(nn_intervals, bin_length: int = 8):
"""
Function plotting histogram distribution of the NN Intervals. Useful for geometrical features.
Arguments
---------
nn_intervals : list
list of Normal to Normal Interval.
bin_length : int
size of the bin for histogram in ms, by default = 8.
"""
max_nn_i = max(nn_intervals)
min_nn_i = min(nn_intervals)
style.use("seaborn-darkgrid")
plt.figure(figsize=(12, 8))
plt.title("Distribution of Rr Intervals", fontsize=20)
plt.xlabel("Time (s)", fontsize=15)
plt.ylabel("Number of Rr Interval per bin", fontsize=15)
#Range expects an integer rather than a float
plt.hist(nn_intervals, bins=range(int(min_nn_i) - 10, int(max_nn_i) + 10, bin_length), rwidth=0.8)
plt.show()
When I run
plot.plot_distrib(rr)
, whererr
is a float list or a numpy array, I get the following error:Possible fix: Just cast
max_nn_i
andmax_nn_i
toint
or usenp.arange
.