Skip to content
Snippets Groups Projects
Commit 920cb9d3 authored by Bert Palm's avatar Bert Palm 🎇
Browse files

refactored assertScalar

parent 119875ce
No related branches found
No related tags found
1 merge request!462More tests
......@@ -31,10 +31,15 @@ T = TypeVar("T", str, float, int)
def assertScalar(name, value, optional=False):
if (not np.isscalar(value)) and (value is not None) and (optional is True):
raise ValueError(f"'{name}' needs to be a scalar or 'None'")
elif (not np.isscalar(value)) and optional is False:
raise ValueError(f"'{name}' needs to be a scalar")
if optional and value is None:
return
if np.isscalar(value):
return
msg = f"'{name}' needs to be a scalar"
if optional:
msg += " or 'None'"
raise ValueError(msg)
def toSequence(value: T | Sequence[T]) -> List[T]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment