Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions essm/variables/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ def collect_factor_and_basedimension(expr):
elif isinstance(expr, Function):
fds = {Variable.collect_factor_and_basedimension(
arg)[1] for arg in expr.args}
if fds != {Dimension(1)}:
raise ValueError(
'Arguments in function are not dimensionless, '
'but have dimensions of {0}'.format(fds))
# if fds != {Dimension(1)}:
# raise ValueError(
# 'Arguments in function are not dimensionless, '
# 'but have dimensions of {0}'.format(fds))
return expr, Dimension(1)
elif isinstance(expr, Dimension):
return 1, expr
Expand Down
11 changes: 10 additions & 1 deletion tests/test_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
derive_baseunit)
from essm.variables.utils import (extract_variables, replace_defaults,
replace_variables)
from sympy import cos, Derivative, exp, log, S, Symbol, solve, sqrt
from sympy import cos, Derivative, exp, Function, log, S, Symbol, solve, sqrt
from sympy.physics.units import Quantity, length, meter


Expand Down Expand Up @@ -288,6 +288,15 @@ class var_joule_base(Variable):
1 - exp(var_joule/var_joule_base)


def test_check_unit_function():
"""
Make sure that check_unit works with symbolic functions"""

f = Function('f')(demo_t)
assert Variable.check_unit(Derivative(f, demo_t)) == \
Derivative(f, demo_t)


def test_double_registration():
"""Check double registration warning."""

Expand Down