neuromodulation / py_neuromodulation

Real-time analysis of intracranial neurophysiology recordings.
https://neuromodulation.github.io/py_neuromodulation/
MIT License
47 stars 11 forks source link

Replace assertions with errors #347

Open toni-neurosc opened 5 months ago

toni-neurosc commented 5 months ago

We should remove all assertions from the codebase and replace them with raise RuntimeError or similar.

Rationale: Assertions are meant for testing purposes and with optimizations enabled (python -O) they are ignored. This is something uncommon in Python as optimizations do almost nothing and no-one uses them, but for example in C all assertions are removed in release compilation mode. So we should get rid of them to future-proof ourselves, in case Python becomes a JIT-compiled language in the future as it's looking like with Python 3.13 and this becomes an issue.

timonmerk commented 5 months ago

Agree! Tbh I wasn't sure when implementing them if it should be used for that purpose. But now I understand it's only for testing.