MCPcopy Create free account
hub / github.com/LabPy/lantz / assertQuantityEqual

Method assertQuantityEqual

lantz/testsuite/test_feat.py:25–47  ·  view source on GitHub ↗

Make sure q1 and q2 are the same quantities to within the given precision.

(self, q1, q2, msg=None, delta=None)

Source from the content-addressed store, hash-verified

23
24 # Modified from python quantities test suite
25 def assertQuantityEqual(self, q1, q2, msg=None, delta=None):
26 """
27 Make sure q1 and q2 are the same quantities to within the given
28 precision.
29 """
30
31 if isinstance(q1, (list, tuple)):
32 for first, second in zip(q1, q2):
33 self.assertQuantityEqual(first, second)
34 return
35
36 delta = 1e-5 if delta is None else delta
37 msg = '' if msg is None else ' (%s)' % msg
38
39 q1 = Q_(q1)
40 q2 = Q_(q2)
41
42 d1 = getattr(q1, '_dimensionality', None)
43 d2 = getattr(q2, '_dimensionality', None)
44 if (d1 or d2) and not (d1 == d2):
45 raise self.failureException(
46 "Dimensionalities are not equal (%s vs %s)%s" % (d1, d2, msg)
47 )
48
49 def test_readonly(self):
50

Callers 2

test_unitsMethod · 0.95
test_units_tupleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected