-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: tuple indices must be integers or slices, not str #43
Comments
Thank you for reporting this, I suspect this might be due to artefacts close to each other, can you share the data you are using so I can reproduce the error? |
My code is failing because the output of the import pandas as pd
from systole.correction import correct_rr
df = pd.read_csv('data.csv')
correct = correct_rr(df['R-R']) with version 0.2.2: print(correct)
{'clean_rr': array([565., 560., 560., ..., 507., 512., 509.]), 'ectopic': 66, 'short': 40, 'long': 11, 'extra': 17, 'missed': 0}
print(correct['clean_rr'])
[565. 560. 560. ... 507. 512. 509.] with version 0.2.3: print(correct)
(array([565., 560., 560., ..., 507., 512., 509.]), (0, 17, 21, 30, 10))
print(correct['clean_rr'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: tuple indices must be integers or slices, not str |
It looks like the function is working correctly but the way it returns the results have changed: It is now returning a tuple like:
If you use the code above it should work. Sorry for this refactoring, the function has been completely rewritten in this release. |
There's no need to be sorry. Thanks for your work and support. Much appreciated. 👍 Not sure whether I'm misreading the docs... but I can't get arguments to work. correct = correct_rr(df['R-R'], extra_correction=False)
Cleaning the RR interval time series.
... correcting 21 ectopic interval(s).
... correcting 30 short interval(s).
... correcting 12 long interval(s).
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/systole/correction.py", line 363, in correct_rr
return _correct_rr(
File "/usr/lib/python3.10/site-packages/systole/correction.py", line 263, in _correct_rr
return clean_rr, (nMissed, nExtra, nEctopic, nShort, nLong)
UnboundLocalError: local variable 'nExtra' referenced before assignment correct = correct_rr(df['R-R'], n_iterations=2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: correct_rr() got an unexpected keyword argument 'n_iterations' |
I see the error comes from the absence of extra correction that is not correctly accounted for in the code, I will fix that as soon as possible. Thank you for pointing that out. For the second example, the |
After updating to
v0.2.3 (September 2022)
I get the following error when calling
correct_rr(rr)
:While trying to disable things one by one to debug (eg.
correct_rr(rr, missed_correction=False
) I got:correct_rr(rr, n_iterations=2)
doesn't work either:With version 0.2.2
correct_rr(rr, n_iterations=2, missed_correction=False)
works as expected without errors.The text was updated successfully, but these errors were encountered: