Skip to content

Commit 1a4873e

Browse files
committed
This bug prevent the use of pyFAI with numpy 1.12 or older.
Described elswhere in: pandas-dev/pandas#16358 Recent versions of numpy/cython solve the issue.
1 parent 9e89d21 commit 1a4873e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

pyFAI/ext/regrid_common.pxi

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Some are defined in the associated header file .pxd
3232

3333
__author__ = "Jerome Kieffer"
3434
__contact__ = "[email protected]"
35-
__date__ = "03/12/2018"
35+
__date__ = "21/01/2019"
3636
__status__ = "stable"
3737
__license__ = "MIT"
3838

@@ -42,6 +42,12 @@ include "numpy_common.pxi"
4242
# Imports at the Python level
4343
import cython
4444
import numpy
45+
import sys
46+
47+
# Work around for issue similar to : https://github.com/pandas-dev/pandas/issues/16358
48+
49+
_numpy_1_12_py2_bug = ((sys.version_info.major == 2) and
50+
([1, 12] <= [int(i) for i in numpy.version.version.split(".", 2)[:2]]))
4551

4652
# Imports at the C level
4753
from .isnan cimport isnan
@@ -66,10 +72,16 @@ ctypedef cnumpy.int8_t mask_t
6672
mask_d = numpy.int8
6773

6874
# Type used for propagating variance
69-
prop_d = numpy.dtype([('signal', acc_d),
70-
('variance', acc_d),
71-
('norm', acc_d),
72-
('count', acc_d)])
75+
if _numpy_1_12_py2_bug:
76+
prop_d = numpy.dtype([(b'signal', acc_d),
77+
(b'variance', acc_d),
78+
(b'norm', acc_d),
79+
(b'count', acc_d)])
80+
else:
81+
prop_d = numpy.dtype([('signal', acc_d),
82+
('variance', acc_d),
83+
('norm', acc_d),
84+
('count', acc_d)])
7385

7486
ctypedef fused any_int_t:
7587
cnumpy.uint8_t

0 commit comments

Comments
 (0)