JuliaRheology / RHEOS.jl

RHEOS - Open Source Rheology data analysis software
MIT License
40 stars 9 forks source link

Reconsider the use of @assert #81

Open akabla opened 4 years ago

akabla commented 4 years ago

Are we using @assert properly? the doc suggests that this should be for debugging rather than validating inputs: https://docs.julialang.org/en/v1/base/base/#Base.@assert

It may be best to move towards the 'error' function or throwing proper exceptions that could be caught by the program. https://scls.gitbooks.io/ljthw/content/_chapters/11-ex8.html

moustachio-belvedere commented 4 years ago

Sounds good to me. Yes I think things weren't quite as clear in 0.6 so I got into the wrong habit! The nice thing about assert is (was) that we could have a very clear message about what was wrong, in plain english. So if we want to replace then throwing a custom ErrorException with a clear message, or defining our own clear custom exception is probably the way to go.

Edit: Also, related to the above docs on @assert, we should consider doing testing and benchmarking at higher optimisation levels to see how much of a difference that makes to us (could be significant for example in computation of Mittag-Leffler). If the -O3 flag is beneficial, we should document it. I did play around with it a bit in older versions but I don't remember it having much effect then though.

akabla commented 4 years ago

I agree that we should set our own Exception class just for clarity. To get a message out, the 'error' function should also do the job though.