forked from pool/python-numericalunits
Compare commits
4 Commits
Author | SHA256 | Date | |
---|---|---|---|
110fbdc1f1 | |||
493b21586b | |||
de695e6d71 | |||
38141e9108 |
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c32a482adae818a1a8d6c799bf9fb153326461d490c0de9deab9c694a6537eec
|
||||
size 16027
|
3
numericalunits-1.26.tar.gz
Normal file
3
numericalunits-1.26.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8a0b69945dd65eacf6eef8c868bcd3298d7439f5882f507bb6060ec20c723e12
|
||||
size 18263
|
@@ -1,3 +1,17 @@
|
||||
-------------------------------------------------------------------
|
||||
Sat Jul 5 10:51:28 UTC 2025 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- update to 1.26:
|
||||
* version 1.26, 2024-11-26 -- update to latest CODATA (and add
|
||||
CODATA URLs), add debye unit of dyipole moment, add
|
||||
README_appendix about how to do parallel processing,
|
||||
modernize build / packaging
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri May 9 05:12:15 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
- Switch to pyproject macros.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue May 25 10:43:16 UTC 2021 - pgajdos@suse.com
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-numericalunits
|
||||
#
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -16,18 +16,17 @@
|
||||
#
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
%define skip_python2 1
|
||||
Name: python-numericalunits
|
||||
Version: 1.25
|
||||
Version: 1.26
|
||||
Release: 0
|
||||
Summary: Python module for defining quantities with units
|
||||
License: MIT
|
||||
Group: Development/Languages/Python
|
||||
URL: https://github.com/sbyrnes321/numericalunits
|
||||
Source: https://files.pythonhosted.org/packages/source/n/numericalunits/numericalunits-%{version}.tar.gz
|
||||
Source1: https://raw.githubusercontent.com/sbyrnes321/numericalunits/master/tests/tests.py
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: dos2unix
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
@@ -50,10 +49,10 @@ dos2unix numericalunits.py
|
||||
cp %{SOURCE1} .
|
||||
|
||||
%build
|
||||
%python_build
|
||||
%pyproject_wheel
|
||||
|
||||
%install
|
||||
%python_install
|
||||
%pyproject_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
|
||||
%check
|
||||
@@ -62,8 +61,8 @@ cp %{SOURCE1} .
|
||||
%files %{python_files}
|
||||
%license LICENSE.txt
|
||||
%doc Changes.txt README.rst
|
||||
%{python_sitelib}/numericalunits-%{version}*egg-info/
|
||||
%{python_sitelib}/numericalunits.py*
|
||||
%pycache_only %{python_sitelib}/__pycache__/numericalunits.*
|
||||
%{python_sitelib}/numericalunits.py
|
||||
%pycache_only %{python_sitelib}/__pycache__/numericalunits*.pyc
|
||||
%{python_sitelib}/numericalunits-%{version}.dist-info
|
||||
|
||||
%changelog
|
||||
|
19
tests.py
19
tests.py
@@ -4,32 +4,33 @@ very basic tests on numericalunits
|
||||
"""
|
||||
import unittest
|
||||
import numericalunits as nu
|
||||
from math import isclose
|
||||
|
||||
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)
|
||||
self.assertTrue(isclose(5 * nu.mL, 5e21 * nu.nm**3, rel_tol=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)
|
||||
self.assertTrue(isclose(accel, 1.75882002e18 * nu.m / nu.s**2, rel_tol=1e-6))
|
||||
|
||||
# check nu_eval()
|
||||
self.assertTrue(isclose(nu.nu_eval('kg'), nu.kg, rel_tol=1e-9))
|
||||
self.assertTrue(isclose(nu.nu_eval('kg * m / s**2'), nu.kg * nu.m / nu.s**2, rel_tol=1e-9))
|
||||
self.assertTrue(isclose(nu.nu_eval('kg**-3.6'), nu.kg**-3.6, rel_tol=1e-9))
|
||||
|
||||
# make sure reset_units('SI') works
|
||||
nu.reset_units('SI')
|
||||
self.assert_almost_equal(nu.G, 1e-4, rtol=1e-9)
|
||||
self.assertTrue(isclose(nu.G, 1e-4, rel_tol=1e-9))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user