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

Method assertQuantityEqual

lantz/testsuite/test_dictfeat.py:26–43  ·  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

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

Callers 1

test_unitsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected