Skip to content

Instantly share code, notes, and snippets.

@leonsas
Created May 18, 2017 01:12
Show Gist options
  • Save leonsas/be78e67aef8bae26efa4fb81452fa9a1 to your computer and use it in GitHub Desktop.
Save leonsas/be78e67aef8bae26efa4fb81452fa9a1 to your computer and use it in GitHub Desktop.
Custom Django/Python Assertions through Numpy
class NumpyAssertions:
def assertAlmostEqualNP(self, lval, rval, atol=None):
np.testing.assert_allclose(lval, rval, atol=atol)
class AlmostEqualityNumpyTest(TestCase, NumpyAssertions):
def test_numpy_almost_equal(self):
self.assertAlmostEqualNP(44.55, 44.75, atol=0.05)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment