MPBA / pyphysio

GNU General Public License v3.0
47 stars 13 forks source link

Bug in the definition of instants in UnevenlySignal #29

Closed andbiz closed 7 years ago

andbiz commented 7 years ago
# create a signal

## create fake data
x = np.arange(100)
idx = np.arange(100)
idx[-1] = 125

## set the sampling frequency
fsamp = 100 # Hz

## set the starting time
tstart = 100 # s

## create the Evenly signal
s_fake = UnevenlySignal(values = x, sampling_freq = fsamp, signal_nature = 'fake', start_time = tstart, x_values = idx, x_type = 'indices')

Should create Unevenly signal starting from 100 Returns:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-42-30498dfacc96> in <module>()
     14 ## create the Evenly signal
     15 s_fake = UnevenlySignal(values = x, sampling_freq = fsamp, signal_nature = 'fake', start_time = tstart,
---> 16                        x_values = idx, x_type = 'indices')

/home/andrea/Trento/CODICE/workspaces/pyHRV/pyHRV/pyphysio/Signal.pyc in __new__(cls, values, sampling_freq, signal_nature, start_time, x_values, x_type)
    301                 start_time = 0
    302             else:
--> 303                 assert start_time < x_values[1] / sampling_freq, "More than one sample at or before start_time"
    304         else:
    305             if start_time is None:

AssertionError: More than one sample at or before start_time
Alebat commented 7 years ago

That assertion comes from c3f1069074288ff217f0fbfc10476fba71cc94a1, I assumed that the first sample could be at start time

However, WIP with new rules

andbiz commented 7 years ago

Sorry :/ Now I think this is the final idea :D