From d009f0f5f67dc4bad97560487d61fc399cb23c06 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Mon, 6 Aug 2012 16:05:41 -0700 Subject: [PATCH 1/4] Allow long numbers in numpy.rec.array formats string --- numpy/core/_internal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 92ab0c8b08ff..103418fa2202 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -133,7 +133,7 @@ def _reconstruct(subtype, shape, dtype): format_re = re.compile(asbytes( r'(?P[<>|=]?)' - r'(?P *[(]?[ ,0-9]*[)]? *)' + r'(?P *[(]?[ ,0-9L]*[)]? *)' r'(?P[<>|=]?)' r'(?P[A-Za-z0-9.]*(?:\[[a-zA-Z0-9,.]+\])?)')) sep_re = re.compile(asbytes(r'\s*,\s*')) From 1079fa42597e2a8900110f7498236e9f034d1179 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Mon, 6 Aug 2012 17:04:33 -0700 Subject: [PATCH 2/4] Add test for long numbers in numpy.rec.array formats string --- numpy/core/tests/test_records.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py index 87c6619386bc..7b1f9cd55a69 100644 --- a/numpy/core/tests/test_records.py +++ b/numpy/core/tests/test_records.py @@ -1,3 +1,4 @@ +import sys from os import path import numpy as np from numpy.testing import * @@ -111,6 +112,13 @@ def test_fromrecords_with_explicit_dtype(self): assert_equal(a.b, ['a', 'bbb']) assert_equal(a[-1].b, 'bbb') + @dec.skipif(sys.version_info[0] > 2) + def test_recarray_from_long_formats(self): + # Pull request #376 + a = [[1]] + ra = np.rec.array(a, shape=1, formats='(1L, 1L)i4') + assert_equal(a, ra.f0[0]) + class TestRecord(TestCase): def setUp(self): From e391a4461507b1ba89a7ee1167d23fc13a308795 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Tue, 7 Aug 2012 19:13:33 -0700 Subject: [PATCH 3/4] Add test for long number in shape specifier of dtype string --- numpy/core/tests/test_dtype.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py index 246ebba6b635..5645a0824a2a 100644 --- a/numpy/core/tests/test_dtype.py +++ b/numpy/core/tests/test_dtype.py @@ -413,6 +413,11 @@ def test_complex_dtype_repr(self): assert_equal(repr(dt), "dtype([('a', ' 2) + def test_dtype_str_with_long_in_shape(self): + # Pull request #376 + dt = np.dtype('(1L,)i4') + class TestDtypeAttributeDeletion(object): From 1e7979fecc787eed295e82002ee3c7c339c5a09d Mon Sep 17 00:00:00 2001 From: cgohlke Date: Tue, 7 Aug 2012 19:15:08 -0700 Subject: [PATCH 4/4] Remove test_recarray_from_long_formats --- numpy/core/tests/test_records.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py index 7b1f9cd55a69..87c6619386bc 100644 --- a/numpy/core/tests/test_records.py +++ b/numpy/core/tests/test_records.py @@ -1,4 +1,3 @@ -import sys from os import path import numpy as np from numpy.testing import * @@ -112,13 +111,6 @@ def test_fromrecords_with_explicit_dtype(self): assert_equal(a.b, ['a', 'bbb']) assert_equal(a[-1].b, 'bbb') - @dec.skipif(sys.version_info[0] > 2) - def test_recarray_from_long_formats(self): - # Pull request #376 - a = [[1]] - ra = np.rec.array(a, shape=1, formats='(1L, 1L)i4') - assert_equal(a, ra.f0[0]) - class TestRecord(TestCase): def setUp(self):