rbo
rbo copied to clipboard
Replace asserts with Exceptions where applicable
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")