rbo icon indicating copy to clipboard operation
rbo copied to clipboard

Replace asserts with Exceptions where applicable

Open itsmartinhi opened this issue 1 year ago • 0 comments

Many value checks in rbo.py use assertions instead of raising exceptions. As stated in the official python docs asserts can be disabled at runtime, which would lead to unexpected behaviour.

My Recommendation: I'd propose to change the asserts to actual value check with if-conditions that raise ValueErrors or TypeErrors depending on what the condition is supposed to check.

Example: I would change

assert type(S) in [list, np.ndarray]

to

if type(S) not in [list, np.ndarray]:
    raise TypeError("S is not of type list or np.ndarray")

itsmartinhi avatar Oct 10 '24 15:10 itsmartinhi