From f13db13c08d419f70dc3c40c5ecbb87ed34297b1 Mon Sep 17 00:00:00 2001 From: Francesco Colista Date: Sat, 21 Nov 2015 11:40:30 +0000 Subject: testing/py-numpy: upgrade to 1.10.1 --- testing/py-numpy/APKBUILD | 24 +++-- testing/py-numpy/numpy-1.10.0-musl.patch | 19 ++++ testing/py-numpy/numpy-1.10.1-backport-1.patch | 127 +++++++++++++++++++++++++ testing/py-numpy/numpy-1.10.1-backport-2.patch | 73 ++++++++++++++ 4 files changed, 237 insertions(+), 6 deletions(-) create mode 100644 testing/py-numpy/numpy-1.10.0-musl.patch create mode 100644 testing/py-numpy/numpy-1.10.1-backport-1.patch create mode 100644 testing/py-numpy/numpy-1.10.1-backport-2.patch (limited to 'testing') diff --git a/testing/py-numpy/APKBUILD b/testing/py-numpy/APKBUILD index 360c8443ba..0bff22d5f5 100644 --- a/testing/py-numpy/APKBUILD +++ b/testing/py-numpy/APKBUILD @@ -1,8 +1,8 @@ -# Contributor: Francesco Colista -# Maintainer: Francesco Colista +# Contributor: Francesco Colista +# Maintainer: Francesco Colista pkgname=py-numpy _pkgname=numpy -pkgver=1.9.2 +pkgver=1.10.1 pkgrel=0 pkgdesc="Scientific tools for Python" url="http://numpy.scipy.org/" @@ -14,6 +14,9 @@ makedepends="$depends_dev" install="" subpackages="$pkgname-dev $pkgname-doc" source="http://downloads.sourceforge.net/$_pkgname/$_pkgname-$pkgver.tar.gz + numpy-1.10.0-musl.patch + numpy-1.10.1-backport-1.patch + numpy-1.10.1-backport-2.patch site.cfg" _builddir="$srcdir"/$_pkgname-$pkgver @@ -43,9 +46,18 @@ package() { install -m644 LICENSE.txt "$pkgdir"/usr/share/licenses/custom/$pkgname/LICENSE } -md5sums="a1ed53432dbcd256398898d35bc8e645 numpy-1.9.2.tar.gz +md5sums="3fed2b50906bc19018cec5fa26168aa5 numpy-1.10.1.tar.gz +e00075bed14f650030a8704db7fda6ee numpy-1.10.0-musl.patch +aaa44b6c8af4abd24c286179c9b8e3c5 numpy-1.10.1-backport-1.patch +89cac7e57396369d802c9e696b7bd801 numpy-1.10.1-backport-2.patch 6f15bb8fe3d12faa8983a9e18bbea2a9 site.cfg" -sha256sums="325e5f2b0b434ecb6e6882c7e1034cc6cdde3eeeea87dbc482575199a6aeef2a numpy-1.9.2.tar.gz +sha256sums="8b9f453f29ce96a14e625100d3dcf8926301d36c5f622623bf8820e748510858 numpy-1.10.1.tar.gz +e4a84dab5561833299bb506acba2d1a5feea929af69bde56a10558612405f8ec numpy-1.10.0-musl.patch +386920fcba91099aedfe0c8105aa53f10f596f62d300684d802397769ba9b1e1 numpy-1.10.1-backport-1.patch +ec6faad4e0105f3f291a43defed5c0f33ca669832589372a0b6ae92d9f5e4dd1 numpy-1.10.1-backport-2.patch 8aa71c1aec2a9fdf6ab6167c92e86bdaf27f9a263b6b9849097ec7dcdf6d91a3 site.cfg" -sha512sums="70470ebb9afef5dfd0c83ceb7a9d5f1b7a072b1a9b54b04f04f5ed50fbaedd5b4906bd500472268d478f94df9e749a88698b1ff30f2d80258e7f3fec040617d9 numpy-1.9.2.tar.gz +sha512sums="ea717bac913a8e63bf93822bddbfe7701a3de00051bf3c7020f5e22756987becb5a2f96a6a52a36fc7c2b856815a782e450099688ce86b21fa94b0076b9ef376 numpy-1.10.1.tar.gz +9f97a3f3e9890598444d78418cbc4aac75d06df8a10634bc94e8c346a70d3fb7efb45004cf0d5840646c7e72e2886234988ed01021b36ca87ed727470e44be75 numpy-1.10.0-musl.patch +359076cdf1962744f1e0381d6e690422787307400db6ca51fb8f759f6af459666e9b4aad278bf4e89848fea5277204eab9459edb092fc2d9aa8dab14096eefe9 numpy-1.10.1-backport-1.patch +8e1db75cd00209762b49f636549a4afccea1467f93b4ce94e02f3ada2f8be78a70fdfea51eb98a12690ef67b84734eb24d5a647def8022a4fddfc22cda4cb512 numpy-1.10.1-backport-2.patch 21ca8db304cbbf5949f07702f2a42bb5e5a0d641921e36649555a41b0e48f04e96f53760417823177ac27f6de24b2191e6e1d5f0eb393beafa29f7484e23284f site.cfg" diff --git a/testing/py-numpy/numpy-1.10.0-musl.patch b/testing/py-numpy/numpy-1.10.0-musl.patch new file mode 100644 index 0000000000..36dec388f7 --- /dev/null +++ b/testing/py-numpy/numpy-1.10.0-musl.patch @@ -0,0 +1,19 @@ +--- a/numpy/core/src/private/npy_config.h.orig 2015-08-11 19:03:43.000000000 +0200 ++++ b/numpy/core/src/private/npy_config.h 2015-10-08 08:20:25.489203036 +0200 +@@ -71,7 +71,7 @@ + + + /* Disable broken gnu trig functions on linux */ +-#if defined(__linux__) && defined(__GNUC__) ++#if defined(__linux__) && defined(__GLIBC__) + + #if defined(HAVE_FEATURES_H) + #include +@@ -96,6 +96,6 @@ + #endif + #undef TRIG_OK + +-#endif /* defined(__linux__) && defined(__GNUC__) */ ++#endif /* defined(__linux__) && defined(__GLIBC__) */ + + #endif diff --git a/testing/py-numpy/numpy-1.10.1-backport-1.patch b/testing/py-numpy/numpy-1.10.1-backport-1.patch new file mode 100644 index 0000000000..77a3c01037 --- /dev/null +++ b/testing/py-numpy/numpy-1.10.1-backport-1.patch @@ -0,0 +1,127 @@ +From 3a816a4db9b498eb64eb837fdcca0fa8ddbe063e Mon Sep 17 00:00:00 2001 +From: Allan Haldane +Date: Sat, 17 Oct 2015 14:00:36 -0400 +Subject: [PATCH] BUG: recarrays viewed as subarrays don't convert to np.record + type + +Record array views were updated in #5943 to return np.record dtype +where possible, but forgot about the case of sub-arrays. + +That's fixed here, so accessing subarray fields by attribute or index +works sensibly, as well as viewing a record array as a subarray dtype, +and printing subarrays. + +This also happens to fix #6459, since it affects the same lines. + +Fixes #6497 #6459 +--- + numpy/core/records.py | 30 +++++++++++++++++++----------- + numpy/core/tests/test_records.py | 23 +++++++++++++++++++++++ + 2 files changed, 42 insertions(+), 11 deletions(-) + +diff --git a/numpy/core/records.py b/numpy/core/records.py +index 4a99553..4ce3fe9 100644 +--- a/numpy/core/records.py ++++ b/numpy/core/records.py +@@ -448,12 +448,14 @@ def __getattribute__(self, attr): + + # At this point obj will always be a recarray, since (see + # PyArray_GetField) the type of obj is inherited. Next, if obj.dtype is +- # non-structured, convert it to an ndarray. If obj is structured leave +- # it as a recarray, but make sure to convert to the same dtype.type (eg +- # to preserve numpy.record type if present), since nested structured +- # fields do not inherit type. ++ # non-structured, convert it to an ndarray. Then if obj is structured ++ # with void type convert it to the same dtype.type (eg to preserve ++ # numpy.record type if present), since nested structured fields do not ++ # inherit type. Don't do this for non-void structures though. + if obj.dtype.fields: +- return obj.view(dtype=(self.dtype.type, obj.dtype.fields)) ++ if issubclass(obj.dtype.type, nt.void): ++ return obj.view(dtype=(self.dtype.type, obj.dtype)) ++ return obj + else: + return obj.view(ndarray) + +@@ -463,8 +465,9 @@ def __getattribute__(self, attr): + # Thus, you can't create attributes on-the-fly that are field names. + def __setattr__(self, attr, val): + +- # Automatically convert (void) dtypes to records. +- if attr == 'dtype' and issubclass(val.type, nt.void): ++ # Automatically convert (void) structured types to records ++ # (but not non-void structures, subarrays, or non-structured voids) ++ if attr == 'dtype' and issubclass(val.type, nt.void) and val.fields: + val = sb.dtype((record, val)) + + newattr = attr not in self.__dict__ +@@ -499,7 +502,9 @@ def __getitem__(self, indx): + # we might also be returning a single element + if isinstance(obj, ndarray): + if obj.dtype.fields: +- return obj.view(dtype=(self.dtype.type, obj.dtype.fields)) ++ if issubclass(obj.dtype.type, nt.void): ++ return obj.view(dtype=(self.dtype.type, obj.dtype)) ++ return obj + else: + return obj.view(type=ndarray) + else: +@@ -519,11 +524,14 @@ def __repr__(self): + # If this is a full record array (has numpy.record dtype), + # or if it has a scalar (non-void) dtype with no records, + # represent it using the rec.array function. Since rec.array +- # converts dtype to a numpy.record for us, use only dtype.descr, +- # not repr(dtype). ++ # converts dtype to a numpy.record for us, convert back ++ # to non-record before printing ++ plain_dtype = self.dtype ++ if plain_dtype.type is record: ++ plain_dtype = sb.dtype((nt.void, plain_dtype)) + lf = '\n'+' '*len("rec.array(") + return ('rec.array(%s, %sdtype=%s)' % +- (lst, lf, repr(self.dtype.descr))) ++ (lst, lf, plain_dtype)) + else: + # otherwise represent it using np.array plus a view + # This should only happen if the user is playing +diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py +index 7a18f29..290bc4f 100644 +--- a/numpy/core/tests/test_records.py ++++ b/numpy/core/tests/test_records.py +@@ -121,6 +121,23 @@ def test_recarray_views(self): + assert_equal(type(rv), np.recarray) + assert_equal(rv.dtype.type, np.record) + ++ # check that accessing nested structures keep record type, but ++ # not for subarrays, non-void structures, non-structured voids ++ test_dtype = [('a', 'f4,f4'), ('b', 'V8'), ('c', ('f4',2)), ++ ('d', ('i8', 'i4,i4'))] ++ r = np.rec.array([((1,1), b'11111111', [1,1], 1), ++ ((1,1), b'11111111', [1,1], 1)], dtype=test_dtype) ++ assert_equal(r.a.dtype.type, np.record) ++ assert_equal(r.b.dtype.type, np.void) ++ assert_equal(r.c.dtype.type, np.float32) ++ assert_equal(r.d.dtype.type, np.int64) ++ # check the same, but for views ++ r = np.rec.array(np.ones(4, dtype='i4,i4')) ++ assert_equal(r.view('f4,f4').dtype.type, np.record) ++ assert_equal(r.view(('i4',2)).dtype.type, np.int32) ++ assert_equal(r.view('V8').dtype.type, np.void) ++ assert_equal(r.view(('i8', 'i4,i4')).dtype.type, np.int64) ++ + #check that we can undo the view + arrs = [np.ones(4, dtype='f4,i4'), np.ones(4, dtype='f8')] + for arr in arrs: +@@ -135,6 +152,12 @@ def test_recarray_repr(self): + a = np.array(np.ones(4, dtype='f8')) + assert_(repr(np.rec.array(a)).startswith('rec.array')) + ++ # check that the 'np.record' part of the dtype isn't shown ++ a = np.rec.array(np.ones(3, dtype='i4,i4')) ++ assert_equal(repr(a).find('numpy.record'), -1) ++ a = np.rec.array(np.ones(3, dtype='i4')) ++ assert_(repr(a).find('dtype=int32') != -1) ++ + def test_recarray_from_names(self): + ra = np.rec.array([ + (1, 'abc', 3.7000002861022949, 0), diff --git a/testing/py-numpy/numpy-1.10.1-backport-2.patch b/testing/py-numpy/numpy-1.10.1-backport-2.patch new file mode 100644 index 0000000000..9c33704f8e --- /dev/null +++ b/testing/py-numpy/numpy-1.10.1-backport-2.patch @@ -0,0 +1,73 @@ +From 0d25dc4175e00cdaf9545e8b1b1a5b879cf67248 Mon Sep 17 00:00:00 2001 +From: Ethan Kruse +Date: Mon, 19 Oct 2015 13:29:01 -0700 +Subject: [PATCH 1/2] Potential fix for #6462 + +--- + numpy/lib/function_base.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py +index 555d083..fef69df 100644 +--- a/numpy/lib/function_base.py ++++ b/numpy/lib/function_base.py +@@ -3339,7 +3339,7 @@ def _median(a, axis=None, out=None, overwrite_input=False): + indexer[axis] = slice(index-1, index+1) + + # Check if the array contains any nan's +- if np.issubdtype(a.dtype, np.inexact): ++ if np.issubdtype(a.dtype, np.inexact) and sz > 0: + # warn and return nans like mean would + rout = mean(part[indexer], axis=axis, out=out) + part = np.rollaxis(part, axis, part.ndim) + +From 59d859fb2160950ac93267d7461ad952145c8724 Mon Sep 17 00:00:00 2001 +From: Ethan Kruse +Date: Tue, 20 Oct 2015 11:40:49 -0700 +Subject: [PATCH 2/2] Added tests for median of empty arrays + +--- + numpy/lib/tests/test_function_base.py | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py +index 4516c92..aa41c1f 100644 +--- a/numpy/lib/tests/test_function_base.py ++++ b/numpy/lib/tests/test_function_base.py +@@ -2597,6 +2597,36 @@ def test_nan_behavior(self): + assert_equal(np.median(a, (0, 2)), b) + assert_equal(len(w), 1) + ++ def test_empty(self): ++ # empty arrays ++ a = np.array([], dtype=float) ++ with warnings.catch_warnings(record=True) as w: ++ warnings.filterwarnings('always', '', RuntimeWarning) ++ assert_equal(np.median(a), np.nan) ++ assert_(w[0].category is RuntimeWarning) ++ ++ # multiple dimensions ++ a = np.array([], dtype=float, ndmin=3) ++ # no axis ++ with warnings.catch_warnings(record=True) as w: ++ warnings.filterwarnings('always', '', RuntimeWarning) ++ assert_equal(np.median(a), np.nan) ++ assert_(w[0].category is RuntimeWarning) ++ ++ # axis 0 and 1 ++ b = np.array([], dtype=float, ndmin=2) ++ with warnings.catch_warnings(record=True) as w: ++ warnings.filterwarnings('always', '', RuntimeWarning) ++ assert_equal(np.median(a, axis=0), b) ++ assert_equal(np.median(a, axis=1), b) ++ ++ # axis 2 ++ b = np.array(np.nan, dtype=float, ndmin=2) ++ with warnings.catch_warnings(record=True) as w: ++ warnings.filterwarnings('always', '', RuntimeWarning) ++ assert_equal(np.median(a, axis=2), b) ++ assert_(w[0].category is RuntimeWarning) ++ + def test_object(self): + o = np.arange(7.) + assert_(type(np.median(o.astype(object))), float) -- cgit v1.2.3