Skip to content

Commit

Permalink
doctest bugfix in utils.decorators: use +FLOAT_CMP
Browse files Browse the repository at this point in the history
  • Loading branch information
bwinkel committed Feb 6, 2018
1 parent 95d2164 commit 9e73d9d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pycraf/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def func(a, b):
... def func(a):
... return a ** 2
>>> func(0.5 * u.m)
>>> func(0.5 * u.m) # doctest: +FLOAT_CMP
<Quantity 0.25 m2>
>>> func(2 * u.m)
Expand All @@ -109,7 +109,7 @@ def func(a, b):
... def func(a):
... return a ** 2
>>> func(2 * u.m)
>>> func(2 * u.m) # doctest: +FLOAT_CMP
<Quantity 4.0 m2>
Often one wants to add units support to third-party functions,
Expand All @@ -136,7 +136,7 @@ def func(a, b):
>>> # a=(0, 1, u.m), strip_input_units=True
>>> # )(_func)
>>> func(0.5 * u.m)
>>> func(0.5 * u.m) # doctest: +FLOAT_CMP
0.25
However, by doing this there are still no units for the output.
Expand All @@ -150,7 +150,7 @@ def func(a, b):
... def func(a):
... return _func(a)
>>> func(0.5 * u.m)
>>> func(0.5 * u.m) # doctest: +FLOAT_CMP
<Quantity 0.25 m2>
If you have several return values (tuple), just provide a tuple
Expand All @@ -162,7 +162,7 @@ def func(a, b):
... def func(a=0.5 * u.m):
... return a ** 2
>>> func()
>>> func() # doctest: +FLOAT_CMP
<Quantity 0.25 m2>
However, sometimes one wants to use `None` as default, which will
Expand All @@ -186,7 +186,7 @@ def func(a, b):
... a = 0.5
... return a ** 2
>>> func()
>>> func() # doctest: +FLOAT_CMP
0.25
and of course, the unit check still works, if a something other
Expand Down

0 comments on commit 9e73d9d

Please sign in to comment.