|
| 1 | +From dd0b10c7e31ea136632bfcfd46c925adcf4c4af6 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Robert Bradshaw < [email protected]> |
| 3 | +Date: Tue, 24 Jan 2017 15:53:43 -0800 |
| 4 | +Subject: [PATCH] Work around numpy build formatting differences. |
| 5 | + |
| 6 | +--- |
| 7 | + tests/run/numpy_test.pyx | 22 ++++++++++++---------- |
| 8 | + 1 file changed, 12 insertions(+), 10 deletions(-) |
| 9 | + |
| 10 | +diff --git a/tests/run/numpy_test.pyx b/tests/run/numpy_test.pyx |
| 11 | +index a813085f3..5fca12574 100644 |
| 12 | +--- a/tests/run/numpy_test.pyx |
| 13 | ++++ b/tests/run/numpy_test.pyx |
| 14 | +@@ -4,6 +4,7 @@ |
| 15 | + cimport numpy as np |
| 16 | + cimport cython |
| 17 | + |
| 18 | ++import re |
| 19 | + import sys |
| 20 | + |
| 21 | + from libc.stdlib cimport malloc |
| 22 | +@@ -133,7 +134,7 @@ try: |
| 23 | + Traceback (most recent call last): |
| 24 | + ... |
| 25 | + ValueError: ndarray is not C...contiguous |
| 26 | +- |
| 27 | ++ |
| 28 | + >>> test_dtype('b', inc1_byte) |
| 29 | + >>> test_dtype('B', inc1_ubyte) |
| 30 | + >>> test_dtype('h', inc1_short) |
| 31 | +@@ -142,7 +143,7 @@ try: |
| 32 | + >>> test_dtype('I', inc1_uint) |
| 33 | + >>> test_dtype('l', inc1_long) |
| 34 | + >>> test_dtype('L', inc1_ulong) |
| 35 | +- |
| 36 | ++ |
| 37 | + >>> test_dtype('f', inc1_float) |
| 38 | + >>> test_dtype('d', inc1_double) |
| 39 | + >>> test_dtype('g', inc1_longdouble) |
| 40 | +@@ -172,11 +173,11 @@ try: |
| 41 | + Traceback (most recent call last): |
| 42 | + ... |
| 43 | + ValueError: ... |
| 44 | +- |
| 45 | ++ |
| 46 | + |
| 47 | + |
| 48 | + >>> test_recordarray() |
| 49 | +- |
| 50 | ++ |
| 51 | + >>> print(test_nested_dtypes(np.zeros((3,), dtype=np.dtype([\ |
| 52 | + ('a', np.dtype('i,i')),\ |
| 53 | + ('b', np.dtype('i,i'))\ |
| 54 | +@@ -198,12 +199,12 @@ try: |
| 55 | + |
| 56 | + The output changed in Python 3: |
| 57 | + >> print(test_unpacked_align(np.zeros((1,), dtype=np.dtype('b,i', align=True)))) |
| 58 | +- array([(22, 23)], |
| 59 | ++ array([(22, 23)], |
| 60 | + dtype=[('f0', '|i1'), ('', '|V3'), ('f1', '!i4')]) |
| 61 | + |
| 62 | + -> |
| 63 | + |
| 64 | +- array([(22, 23)], |
| 65 | ++ array([(22, 23)], |
| 66 | + dtype={'names':['f0','f1'], 'formats':['i1','!i4'], 'offsets':[0,4], 'itemsize':8, 'aligned':True}) |
| 67 | + |
| 68 | + |
| 69 | +@@ -234,7 +235,7 @@ try: |
| 70 | + 8,16 |
| 71 | + |
| 72 | + >>> test_point_record() |
| 73 | +- array([(0.0, 0.0), (1.0, -1.0), (2.0, -2.0)], |
| 74 | ++ array([(0., 0.), (1., -1.), (2., -2.)], |
| 75 | + dtype=[('x', '!f8'), ('y', '!f8')]) |
| 76 | + |
| 77 | + """ |
| 78 | +@@ -352,7 +353,7 @@ def inc1_clongdouble(np.ndarray[long double complex] arr): arr[1] = arr[1] + (1 |
| 79 | + def inc1_cfloat_struct(np.ndarray[np.cfloat_t] arr): |
| 80 | + arr[1].real += 1 |
| 81 | + arr[1].imag += 1 |
| 82 | +- |
| 83 | ++ |
| 84 | + def inc1_cdouble_struct(np.ndarray[np.cdouble_t] arr): |
| 85 | + arr[1].real += 1 |
| 86 | + arr[1].imag += 1 |
| 87 | +@@ -382,7 +383,7 @@ def inc1_uintp_t(np.ndarray[np.uintp_t] arr): arr[1] += 1 |
| 88 | + def inc1_int32_t(np.ndarray[np.int32_t] arr): arr[1] += 1 |
| 89 | + def inc1_float64_t(np.ndarray[np.float64_t] arr): arr[1] += 1 |
| 90 | + |
| 91 | +- |
| 92 | ++ |
| 93 | + def test_dtype(dtype, inc1): |
| 94 | + if dtype in ("g", np.longdouble, |
| 95 | + "G", np.clongdouble): |
| 96 | +@@ -518,7 +519,8 @@ def test_point_record(): |
| 97 | + for i in range(3): |
| 98 | + test[i].x = i |
| 99 | + test[i].y = -i |
| 100 | +- print repr(test).replace('<', '!').replace('>', '!') |
| 101 | ++ print re.sub( |
| 102 | ++ r'\.0+\b', '.', repr(test).replace('<', '!').replace('>', '!')) |
| 103 | + |
| 104 | + # Test fused np.ndarray dtypes and runtime dispatch |
| 105 | + @testcase |
0 commit comments