Properly implemnt skip check on check
This commit is contained in:
@@ -201,7 +201,7 @@ def check(ureg, *args):
|
|||||||
:raises:
|
:raises:
|
||||||
:class:`DimensionalityError` if the parameters don't match dimensions
|
:class:`DimensionalityError` if the parameters don't match dimensions
|
||||||
"""
|
"""
|
||||||
dimensions = [ureg.get_dimensionality(dim) for dim in args]
|
dimensions = [ureg.get_dimensionality(dim) if dim is not None else None for dim in args]
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
assigned = tuple(attr for attr in functools.WRAPPER_ASSIGNMENTS if hasattr(func, attr))
|
assigned = tuple(attr for attr in functools.WRAPPER_ASSIGNMENTS if hasattr(func, attr))
|
||||||
@@ -210,8 +210,12 @@ def check(ureg, *args):
|
|||||||
@functools.wraps(func, assigned=assigned, updated=updated)
|
@functools.wraps(func, assigned=assigned, updated=updated)
|
||||||
def wrapper(*values, **kwargs):
|
def wrapper(*values, **kwargs):
|
||||||
for dim, value in zip_longest(dimensions, values):
|
for dim, value in zip_longest(dimensions, values):
|
||||||
|
|
||||||
|
if dim is None:
|
||||||
|
continue
|
||||||
|
|
||||||
val_dim = ureg.get_dimensionality(value)
|
val_dim = ureg.get_dimensionality(value)
|
||||||
if dim is not None and val_dim != dim:
|
if val_dim != dim:
|
||||||
raise DimensionalityError(value, 'a quantity of',
|
raise DimensionalityError(value, 'a quantity of',
|
||||||
val_dim, dim)
|
val_dim, dim)
|
||||||
return func(*values, **kwargs)
|
return func(*values, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user