-
Notifications
You must be signed in to change notification settings - Fork 1
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
Using assert
in airo-mono
#67
Comments
for me that is actually a feature, not an issue assert statements are afaik used in the codebase to throw errors with a descriptive message before python throws a runtime error that can be hard to debug. If you really need the speed (but still want to use python), you can then run with the -O flag and all asserts will be skipped. Do you foresee issues with this @adverley? |
I did not phrase my question accurately. When are we using These checks are an This also checks matrix formats but does it with an I've always viewed assert statements in Python more as a development tool and exception throwing something more of library building thing. It is not my intention to start this type of discussion, I'm actually just interested whether there is a rational here. In case there is, is it documented and shared by all the devs here? |
yes I agree, asserts are also sanity checks for me, but in ML frameworks I also use them to validate inputs (e.g. is this batch well-formed), because I know it is easy to disable them if you need that extra speed.
In this case, I agree Exceptions would be more appropriate! But until now I haven't really thought this true very well. Long story short, there are no explicit conventions we use. No clue how the python community does this usually. But I agree with the sentiment dat asserts are more like debug sanity checks and not to validate user input. a valid exception for me is if you expect something to run multiple times, in which case a user can do a check first and then run it in optimized mode (though I've never done that myself). |
If python is called with the optimized flag
python -O
, assert statements are disabled. Is this problematic the way assert statements are currently used in the codebase?The text was updated successfully, but these errors were encountered: