1
0

Accepting request 724152 from devel:languages:python:numeric

Update to 3.1.2

OBS-URL: https://build.opensuse.org/request/show/724152
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-uncertainties?expand=0&rev=7
This commit is contained in:
Dominique Leuenberger 2019-08-19 19:38:18 +00:00 committed by Git OBS Bridge
commit 02f9afe299
6 changed files with 17 additions and 204 deletions

View File

@ -1,57 +0,0 @@
From 8f301bfa55479eca824b3294d610f9c1240ec19c Mon Sep 17 00:00:00 2001
From: Paul Romano <paul.k.romano@gmail.com>
Date: Tue, 30 Jul 2019 21:39:38 -0500
Subject: [PATCH] Workaround for getting numpy.linalg.pinv argument default
with numpy 1.17
---
uncertainties/unumpy/core.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/uncertainties/unumpy/core.py b/uncertainties/unumpy/core.py
index 6896ba8..91d0c5b 100644
--- a/uncertainties/unumpy/core.py
+++ b/uncertainties/unumpy/core.py
@@ -532,7 +532,13 @@ def pinv_with_derivatives(arr, input_type, derivatives, rcond):
yield term1+term2+term3
# Default rcond argument for the generalization of numpy.linalg.pinv:
-pinv_default = numpy.linalg.pinv.__defaults__[0] # Python 1, 2.6+:
+try:
+ pinv_default = numpy.linalg.pinv.__defaults__[0] # Python 1, 2.6+:
+except TypeError:
+ # In numpy 1.17+, pinv is wrapped using a decorator which unfortunately
+ # results in the metadata (argument defaults) being lost. However, we can
+ # still get at the original function using the __wrapped__ attribute.
+ pinv_default = numpy.linalg.pinv.__wrapped__.__defaults__[0]
pinv_with_uncert = func_with_deriv_to_uncert_func(pinv_with_derivatives)
From 293a027c8510c0994b2ad095d444c4318b0fe7a4 Mon Sep 17 00:00:00 2001
From: Paul Romano <paul.k.romano@gmail.com>
Date: Wed, 31 Jul 2019 21:30:59 -0500
Subject: [PATCH] Fix unumpy test to account for new behavior of numpy 1.17
---
uncertainties/unumpy/test_unumpy.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/uncertainties/unumpy/test_unumpy.py b/uncertainties/unumpy/test_unumpy.py
index cacb3d9..5923dfd 100644
--- a/uncertainties/unumpy/test_unumpy.py
+++ b/uncertainties/unumpy/test_unumpy.py
@@ -62,8 +62,11 @@ def test_numpy():
# Equivalent with an array of AffineScalarFunc objects:
try:
numpy.exp(arr + ufloat(0, 0))
- except AttributeError:
- pass # ! This is usual (but could be avoided)
+ except (AttributeError, TypeError):
+ # In numpy<1.17, an AttributeError is raised in this situation. This was
+ # considered a bug however, and in numpy 1.17 it was changed to a
+ # TypeError (see PR #12700 in numpy repository)
+ pass
else:
raise Exception("numpy.exp unexpectedly worked")

View File

@ -1,137 +0,0 @@
From be00513d2e5a333b128eb670ded8bc82635f0f18 Mon Sep 17 00:00:00 2001
From: Oliver Papst <oliver.papst@mailbox.org>
Date: Sat, 22 Jun 2019 18:10:10 +0200
Subject: [PATCH] Use raw strings for strings with backslashes
Python currently ignores unrecognized escape sequences such as '\m'.
Since Python3.6, unrecognized escape sequences produce a
DeprecationWarning. In some future version of Python they will be a
SyntaxError (see the Docs, section 2.4.1). This commit fixes this by
using raw strings instead. This also applies to docstrings (see
PEP0257).
---
uncertainties/core.py | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/uncertainties/core.py b/uncertainties/core.py
index 58e60d4..cfba907 100644
--- a/uncertainties/core.py
+++ b/uncertainties/core.py
@@ -1019,13 +1019,13 @@ def from_superscript(number_str):
# parentheses. This has the side effect of making the part between
# the parentheses non-breakable (the text inside parentheses in a
# LaTeX math expression $...$ can be broken).
- 'latex': ('\left(', r'\right)'),
+ 'latex': (r'\left(', r'\right)'),
'default': ('(', ')') # Basic text mode
}
def format_num(nom_val_main, error_main, common_exp,
fmt_parts, prec, main_pres_type, options):
- '''
+ r'''
Return a formatted number with uncertainty.
Null errors (error_main) are displayed as the integer 0, with
@@ -1166,10 +1166,10 @@ def format_num(nom_val_main, error_main, common_exp,
elif isnan(error_main):
uncert_str = robust_format(error_main, main_pres_type)
if 'L' in options:
- uncert_str = '\mathrm{%s}' % uncert_str
+ uncert_str = r'\mathrm{%s}' % uncert_str
elif isinf(error_main):
if 'L' in options:
- uncert_str = '\infty'
+ uncert_str = r'\infty'
else:
uncert_str = robust_format(error_main, main_pres_type)
else: # Error with a meaningful first digit (not 0, and real number)
@@ -1239,13 +1239,13 @@ def format_num(nom_val_main, error_main, common_exp,
if 'L' in options:
if isnan(nom_val_main):
- nom_val_str = '\mathrm{%s}' % nom_val_str
+ nom_val_str = r'\mathrm{%s}' % nom_val_str
elif isinf(nom_val_main):
# !! It is wasteful, in this case, to replace
# nom_val_str: could this be avoided while avoiding to
# duplicate the formula for nom_val_str for the common
# case (robust_format(...))?
- nom_val_str = '%s\infty' % ('-' if nom_val_main < 0 else '')
+ nom_val_str = r'%s\infty' % ('-' if nom_val_main < 0 else '')
value_str = nom_val_str+value_end
@@ -1364,14 +1364,14 @@ def format_num(nom_val_main, error_main, common_exp,
if 'L' in options:
if isnan(nom_val_main):
- nom_val_str = '\mathrm{%s}' % nom_val_str
+ nom_val_str = r'\mathrm{%s}' % nom_val_str
elif isinf(nom_val_main):
- nom_val_str = '%s\infty' % ('-' if nom_val_main < 0 else '')
+ nom_val_str = r'%s\infty' % ('-' if nom_val_main < 0 else '')
if isnan(error_main):
- error_str = '\mathrm{%s}' % error_str
+ error_str = r'\mathrm{%s}' % error_str
elif isinf(error_main):
- error_str = '\infty'
+ error_str = r'\infty'
if nom_has_exp:
nom_val_str += exp_str
@@ -1405,7 +1405,7 @@ def format_num(nom_val_main, error_main, common_exp,
# Unicode-compatible LaTeX source can use ±:
pm_symbol = u'±'
elif 'L' in options:
- pm_symbol = ' \pm '
+ pm_symbol = r' \pm '
else:
pm_symbol = '+/-'
@@ -1954,7 +1954,7 @@ def __format__(self, format_spec):
# Format specification parsing:
- match = re.match('''
+ match = re.match(r'''
(?P<fill>[^{}]??)(?P<align>[<>=^]?) # fill cannot be { or }
(?P<sign>[-+ ]?)
(?P<zero>0?)
@@ -2923,7 +2923,7 @@ def correlation_matrix(nums_with_uncert):
# Regexp for a number with uncertainty (e.g., "-1.234(2)e-6"), where
# the uncertainty is optional (in which case the uncertainty is
# implicit). The uncertainty can also be nan or NAN:
-NUMBER_WITH_UNCERT_RE_STR = u'''
+NUMBER_WITH_UNCERT_RE_STR = ur'''
([+-])? # Sign
%s # Main number
(?:\(%s\))? # Optional uncertainty
@@ -2940,7 +2940,7 @@ def correlation_matrix(nums_with_uncert):
# Number with uncertainty with a factored exponent (e.g., of the form
# (... +/- ...)e10): this is a loose matching, so as to accommodate
# for multiple formats:
-NUMBER_WITH_UNCERT_GLOBAL_EXP_RE_MATCH = re.compile(u'''
+NUMBER_WITH_UNCERT_GLOBAL_EXP_RE_MATCH = re.compile(ur'''
\(
(?P<simple_num_with_uncert>.*)
\)
@@ -3012,7 +3012,7 @@ def parse_error_in_parentheses(representation):
return (value, uncert_value)
# Regexp for catching the two variable parts of -1.2×10⁻¹²:
-PRETTY_PRINT_MATCH = re.compile(u'(.*?)\s*×\s*10(.*)').match
+PRETTY_PRINT_MATCH = re.compile(ur'(.*?)\s*×\s*10(.*)').match
def to_float(value_str):
'''
@@ -3089,7 +3089,7 @@ def str_to_number_with_uncert(representation):
else:
factor = 1 # No global exponential factor
- match = re.match(u'(.*)(?:\+/-|±)(.*)', representation)
+ match = re.match(ur'(.*)(?:\+/-|±)(.*)', representation)
if match:
(nom_value, uncert) = match.groups()

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri Aug 16 15:57:12 UTC 2019 - Todd R <toddrme2178@gmail.com>
- Update to 3.1.2
* Starting with NumPy 1.17, numpy.linalg.pinv has a None
__defaults__ attribute, for which the code made no provision.
This is fixed.
- Remove upstream-included patches:
fix_raw_strings.patch
fix_numpy_1_17.patch
-------------------------------------------------------------------
Wed Jul 31 21:12:28 UTC 2019 - Todd R <toddrme2178@gmail.com>

View File

@ -18,23 +18,18 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-uncertainties
Version: 3.1.1
Version: 3.1.2
Release: 0
Summary: Uncertainties on the Quantities Involved (aka "Error Propagation")
License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/lebigot/uncertainties/
Source: https://files.pythonhosted.org/packages/source/u/uncertainties/uncertainties-%{version}.tar.gz
# PATCH-FIX-UPSTREAM fix_raw_strings.patch - gh#lebigot/uncertainties#98
Patch0: fix_raw_strings.patch
# PATCH-FIX-UPSTREAM fix_numpy_1_17.patch - gh#lebigot/uncertainties#89
Patch1: fix_numpy_1_17.patch
BuildRequires: %{python_module nose}
BuildRequires: %{python_module numpy}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
# Package uses 2to3 to generate python3 compatible code
BuildRequires: python3-testsuite
BuildRequires: python3-tools
BuildArch: noarch
@ -53,7 +48,8 @@ involving numbers with uncertainties can also be evaluated directly.
# crazy directory layout
rm -r uncertainties-py23
mv uncertainties-py27 uncertainties
%autopatch -p1
sed -i -e '/^#!\//, 1d' uncertainties/1to2.py
sed -i -e '/^#!\//, 1d' uncertainties/lib1to2/test_1to2.py
%build
%python_build

View File

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

View File

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