Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dgarcia:python312:numeric
python-numericalunits
tests.py
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File tests.py of Package python-numericalunits
# -*- coding: utf-8 -*- """ very basic tests on numericalunits """ import unittest import numericalunits as nu class TestStuff(unittest.TestCase): def setUp(self): pass def assert_almost_equal(self, a, b, rtol): """helper function to check if two floats are approximately equal, allowing for rounding errors etc. Similar to math.isclose in py3.""" self.assertTrue(abs(a-b) <= rtol * (abs(a) + abs(b))) def test_everything(self): """just some very basic smoke tests""" # example from README x = 5 * nu.mL self.assert_almost_equal(x, 5e21 * nu.nm**3, rtol=1e-9) # example from README Efield = 1e5 * (nu.V / nu.cm) force = nu.e * Efield accel = force / nu.me self.assert_almost_equal(accel, 1.75882002e18 * nu.m / nu.s**2, rtol=1e-6) # make sure reset_units('SI') works nu.reset_units('SI') self.assert_almost_equal(nu.G, 1e-4, rtol=1e-9) if __name__ == '__main__': unittest.main()
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor