commit python-quantities for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-quantities for openSUSE:Factory checked in at 2021-11-28 21:30:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-quantities (Old) and /work/SRC/openSUSE:Factory/.python-quantities.new.1895 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-quantities" Sun Nov 28 21:30:24 2021 rev:5 rq:934422 version:0.12.5 Changes: -------- --- /work/SRC/openSUSE:Factory/python-quantities/python-quantities.changes 2021-04-23 17:50:59.186831394 +0200 +++ /work/SRC/openSUSE:Factory/.python-quantities.new.1895/python-quantities.changes 2021-11-28 21:31:42.705768474 +0100 @@ -1,0 +2,12 @@ +Sat Nov 27 20:40:23 UTC 2021 - Arun Persaud <arun@gmx.de> + +- specfile: + * be more specific in %files section + +- update to version 0.12.5: + * Added preferred units support for .rescale + * Added dimensionless unit 'lsb' (least significant bit) + * Added SI multiples for Kelvin + * Fixed invalid escape sequence + +------------------------------------------------------------------- Old: ---- python-quantities-0.12.4.tar.gz New: ---- python-quantities-0.12.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-quantities.spec ++++++ --- /var/tmp/diff_new_pack.xUgQvu/_old 2021-11-28 21:31:43.145767066 +0100 +++ /var/tmp/diff_new_pack.xUgQvu/_new 2021-11-28 21:31:43.149767053 +0100 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python36 1 Name: python-quantities -Version: 0.12.4 +Version: 0.12.5 Release: 0 Summary: Package for physical quantities with units License: BSD-3-Clause @@ -58,6 +58,8 @@ %files %{python_files} %doc CHANGES.txt README.rst %license doc/user/license.rst -%{python_sitelib}/* +%dir %{python_sitelib}/quantities +%{python_sitelib}/quantities/* +%{python_sitelib}/quantities-%{version}-py*.egg-info %changelog ++++++ python-quantities-0.12.4.tar.gz -> python-quantities-0.12.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/.travis.yml new/python-quantities-0.12.5/.travis.yml --- old/python-quantities-0.12.4/.travis.yml 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/.travis.yml 2021-08-16 23:02:54.000000000 +0200 @@ -19,6 +19,8 @@ env: NUMPY_VERSION="1.13.3" - python: "2.7" env: NUMPY_VERSION="1.14.5" + - python: "2.7" + env: NUMPY_VERSION="1.15.1" - python: "3.4" env: NUMPY_VERSION="1.8.2" - python: "3.4" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/CHANGES.txt new/python-quantities-0.12.5/CHANGES.txt --- old/python-quantities-0.12.4/CHANGES.txt 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/CHANGES.txt 2021-08-16 23:02:54.000000000 +0200 @@ -3,6 +3,20 @@ ======= ------ +0.12.5 +------ + +- Added preferred units support for .rescale +- Added dimensionless unit 'lsb' (least significant bit) +- Added SI multiples for Kelvin +- Fixed invalid escape sequence + +All changes +*********** + +https://github.com/python-quantities/python-quantities/issues?utf8=���&q=is%3Aclosed+closed%3A2020-01-08..2021-08-16 + +------ 0.12.4 ------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/quantities/__init__.py new/python-quantities-0.12.5/quantities/__init__.py --- old/python-quantities-0.12.4/quantities/__init__.py 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/quantities/__init__.py 2021-08-16 23:02:54.000000000 +0200 @@ -220,7 +220,7 @@ >>> mass = 50 * pq.kg >>> weight = mass*g >>> print weight.dimensionality.latex - $\mathrm{\\frac{kg{\\cdot}m}{s^{2}}}$ + $\\mathrm{\\frac{kg{\\cdot}m}{s^{2}}}$ >>> weight.units = pq.N >>> print weight.dimensionality.latex $\\mathrm{N}$ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/quantities/_version.py new/python-quantities-0.12.5/quantities/_version.py --- old/python-quantities-0.12.4/quantities/_version.py 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/quantities/_version.py 2021-08-16 23:02:54.000000000 +0200 @@ -23,9 +23,9 @@ # setup.py/versioneer.py will grep for the variable names, so they must # each be defined on a line of their own. _version.py will just call # get_keywords(). - git_refnames = " (tag: v0.12.4)" - git_full = "1a0b45052158df92fbe60b73470fafa609ee138c" - git_date = "2020-01-08 17:22:26 +0100" + git_refnames = " (tag: v0.12.5)" + git_full = "4992796c8209e8358432ef97c0de0c9e7d5cae81" + git_date = "2021-08-16 22:02:54 +0100" keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} return keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/quantities/markup.py new/python-quantities-0.12.5/quantities/markup.py --- old/python-quantities-0.12.4/quantities/markup.py 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/quantities/markup.py 2021-08-16 23:02:54.000000000 +0200 @@ -99,7 +99,7 @@ 'mathit', 'mathsf', and 'mathtt'. Multiplication (*) are replaced with the symbol specified by the mult argument. - By default this is the latex \cdot symbol. Other useful + By default this is the latex \\cdot symbol. Other useful options may be '' or '*'. If paren=True, encapsulate the string in '\left(' and '\right)' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/quantities/quantity.py new/python-quantities-0.12.5/quantities/quantity.py --- old/python-quantities-0.12.4/quantities/quantity.py 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/quantities/quantity.py 2021-08-16 23:02:54.000000000 +0200 @@ -13,6 +13,10 @@ from .registry import unit_registry from .decorators import with_doc +PREFERRED = [] # List of preferred quanitities for each symbol, + # e.g. PREFERRED = [pq.mV, pq.pA, pq.UnitQuantity('femtocoulomb', 1e-15*pq.C, 'fC')] + # Intended to be overwritten in down-stream packages + if sys.version.startswith('3'): unicode = str @@ -195,10 +199,17 @@ mag *= cf self._dimensionality = to_u.dimensionality - def rescale(self, units): + def rescale(self, units=None): """ - Return a copy of the quantity converted to the specified units + Return a copy of the quantity converted to the specified units. + If `units` is `None`, an attempt will be made to rescale the quantity + to preferred units (see `rescale_preferred`). """ + if units is None: + try: + return self.rescale_preferred() + except Exception as e: + raise Exception('No argument passed to `.rescale` and %s' % e) to_dims = validate_dimensionality(units) if self.dimensionality == to_dims: return self.astype(self.dtype) @@ -212,7 +223,27 @@ %(from_u._dimensionality, to_u._dimensionality) ) return Quantity(cf*self.magnitude, to_u) - + + def rescale_preferred(self): + """ + Return a copy of the quantity converted to the preferred units and scale. + These will be identified from among the compatible units specified in the + list PREFERRED in this module. For example, a voltage quantity might be + converted to `mV`: + ``` + import quantities as pq + pq.quantity.PREFERRED = [pq.mV, pq.pA] + old = 3.1415 * pq.V + new = old.rescale_preferred() # `new` will be 3141.5 mV. + ``` + """ + units_str = str(self.simplified.dimensionality) + for preferred in PREFERRED: + if units_str == str(preferred.simplified.dimensionality): + return self.rescale(preferred) + raise Exception(("Preferred units for '%s' (or equivalent) not specified in " + "quantites.quantity.PREFERRED." % self.dimensionality)) + @with_doc(np.ndarray.astype) def astype(self, dtype=None, **kwargs): '''Scalars are returned as scalar Quantity arrays.''' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/quantities/tests/test_conversion.py new/python-quantities-0.12.5/quantities/tests/test_conversion.py --- old/python-quantities-0.12.4/quantities/tests/test_conversion.py 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/quantities/tests/test_conversion.py 2021-08-16 23:02:54.000000000 +0200 @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- +import unittest from .. import units as pq +from .. import quantity from .common import TestCase @@ -15,6 +17,44 @@ def test_rescale(self): for u in ('ft', 'feet', pq.ft): self.assertQuantityEqual((10*pq.m).rescale(u), 32.80839895 * pq.ft) + + def test_rescale_preferred(self): + quantity.PREFERRED = [pq.mV, pq.pA] + q = 10*pq.V + self.assertQuantityEqual(q.rescale_preferred(), q.rescale(pq.mV)) + q = 5*pq.A + self.assertQuantityEqual(q.rescale_preferred(), q.rescale(pq.pA)) + quantity.PREFERRED = [] + + def test_rescale_preferred_failure(self): + quantity.PREFERRED = [pq.pA] + q = 10*pq.V + try: + self.assertQuantityEqual(q.rescale_preferred(), q.rescale(pq.mV)) + except: + self.assertTrue(True) + else: + self.assertTrue(False) + quantity.PREFERRED = [] + + def test_rescale_noargs(self): + quantity.PREFERRED = [pq.mV, pq.pA] + q = 10*pq.V + self.assertQuantityEqual(q.rescale(), q.rescale(pq.mV)) + q = 5*pq.A + self.assertQuantityEqual(q.rescale(), q.rescale(pq.pA)) + quantity.PREFERRED = [] + + def test_rescale_noargs_failure(self): + quantity.PREFERRED = [pq.pA] + q = 10*pq.V + try: + self.assertQuantityEqual(q.rescale_preferred(), q.rescale(pq.mV)) + except: + self.assertTrue(True) + else: + self.assertTrue(False) + quantity.PREFERRED = [] def test_compound_reduction(self): pc_per_cc = pq.CompoundUnit("pc/cm**3") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/quantities/units/dimensionless.py new/python-quantities-0.12.5/quantities/units/dimensionless.py --- old/python-quantities-0.12.4/quantities/units/dimensionless.py 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/quantities/units/dimensionless.py 2021-08-16 23:02:54.000000000 +0200 @@ -17,4 +17,11 @@ aliases=['cts', 'counts'] ) +lsb = UnitQuantity( + 'least_significant_bit', + 1*dimensionless, + symbol='lsb', + aliases=['lsbs'] +) + del UnitQuantity diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-quantities-0.12.4/quantities/units/temperature.py new/python-quantities-0.12.5/quantities/units/temperature.py --- old/python-quantities-0.12.4/quantities/units/temperature.py 2020-01-08 17:22:26.000000000 +0100 +++ new/python-quantities-0.12.5/quantities/units/temperature.py 2021-08-16 23:02:54.000000000 +0200 @@ -11,6 +11,35 @@ symbol='K', aliases=['degK', 'kelvin'] ) +for prefix, symbolprefix, magnitude in ( + ('yotta', 'Y', 1e24), + ('zetta', 'Z', 1e21), + ('exa', 'E', 1e18), + ('peta', 'P', 1e15), + ('tera', 'T', 1e12), + ('giga', 'G', 1e9), + ('mega', 'M', 1e6), + ('kilo', 'k', 1e3), + ('hecto', 'h', 1e2), + ('deka', 'da', 1e1), + ('deci', 'd', 1e-1), + ('centi', 'c', 1e-2), + ('milli', 'm', 1e-3), + ('micro', 'u', 1e-6), + ('nano', 'n', 1e-9), + ('pico', 'p', 1e-12), + ('femto', 'f', 1e-15), + ('atto', 'a', 1e-18), + ('zepto', 'z', 1e-21), + ('yocto', 'y', 1e-24), +): + symbol = symbolprefix +'K' + globals()[symbol] = UnitTemperature( + prefix + 'kelvin', + K*magnitude, + symbol=symbol + ) + degR = rankine = Rankine = UnitTemperature( 'Rankine', K/1.8,
participants (1)
-
Source-Sync