1
0

Accepting request 704278 from devel:languages:python:numeric

OBS-URL: https://build.opensuse.org/request/show/704278
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-numericalunits?expand=0&rev=3
This commit is contained in:
Dominique Leuenberger 2019-05-21 08:41:14 +00:00 committed by Git OBS Bridge
commit 37b016bec8
5 changed files with 56 additions and 13 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:76c95de0a72fed26e40758bb45b610610abc0102770620c749b3222dc55a63e3
size 13065

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bfbdaba9226b6439df4a9a3bae93c36b201ec8d4cb5ae4d561ee9b2797d0391f
size 13180

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon May 20 01:13:20 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Use GitHub tagged archive and post-release tests.py to add
%doc and %check
-------------------------------------------------------------------
Sat Dec 22 02:03:50 UTC 2018 - Todd R <toddrme2178@gmail.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-numericalunits
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -24,9 +24,9 @@ Summary: Python module for defining quantities with units
License: MIT
Group: Development/Languages/Python
Url: http://pypi.python.org/pypi/numericalunits
Source: https://files.pythonhosted.org/packages/py2.py3/n/numericalunits/numericalunits-%{version}-py2.py3-none-any.whl
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pip}
Source: https://github.com/sbyrnes321/numericalunits/archive/numericalunits-%{version}.tar.gz#/numericalunits-%{version}.tar.gz
Source1: https://raw.githubusercontent.com/sbyrnes321/numericalunits/master/tests/tests.py
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
@ -44,21 +44,23 @@ way with unique advantages:
* Zero calculation overhead
%prep
%setup -T -c -n numericalunits-%{version}
%setup -q -n numericalunits-numericalunits-%{version}
cp %{SOURCE1} .
%build
# Not needed
%python_build
%install
%python_expand pip%{$python_bin_suffix} install --root %{buildroot} %{SOURCE0}
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
# todo
%python_exec setup.py test --test-suite=tests
%files %{python_files}
%license %{python_sitelib}/numericalunits-%{version}.dist-info/LICENSE.txt
%{python_sitelib}/numericalunits-%{version}.dist-info/
%license LICENSE.txt
%doc Changes.txt README.rst
%{python_sitelib}/numericalunits-%{version}*egg-info/
%{python_sitelib}/numericalunits.py*
%pycache_only %{python_sitelib}/__pycache__/numericalunits.*

35
tests.py Normal file
View File

@ -0,0 +1,35 @@
# -*- 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()