|
33 | 33 | oil_status = cbt.oil_status
|
34 | 34 | spill_type = cbt.spill_type
|
35 | 35 |
|
36 |
| -# seconds = cbt.seconds |
37 |
| - |
38 |
| -# numpy 1 did not have a long attribute -- but it matched int |
| 36 | +# Here we customize what a 'long' type is.... |
| 37 | +# NOTE: This is all so we can create numpy arrays that are compatible |
| 38 | +# with the structs in the C++ code -- most of which |
| 39 | +# use the old-style C types, e.g. int, short, long. |
| 40 | +# it turns out that with numpy1 `int` mapped to long on the |
| 41 | +# platform you were running on: int32 on *nix32, windows 32 and 64 and |
| 42 | +# int64 on *nix64 |
| 43 | +# but now it maps to int64 everywhere (or all 32 bit platforms anyway) |
| 44 | +# recent numpy 1 doesn't have a long attribute -- but it matched int |
| 45 | +# numpy 2 has a long attribute, which seems to match the C long. |
39 | 46 | if int(np.__version__.split(".")[0]) < 2:
|
40 | 47 | seconds = int
|
41 | 48 | np_long = int
|
42 | 49 | else:
|
43 | 50 | seconds = np.long
|
44 | 51 | np_long = np.long
|
45 | 52 |
|
46 |
| - |
47 | 53 | # this is a mapping of oil_status code to the meaningful name:
|
48 | 54 | oil_status_map = {num: name for name, num in oil_status.__members__.items()}
|
49 | 55 |
|
50 |
| - |
51 |
| -# Here we customize what a numpy 'long' type is.... |
52 |
| -# We do this because numpy does different things with a long |
53 |
| -# that can mismatch what Cython does with the numpy ctypes. |
54 |
| -# NOTE: This is all so we can create numpy arrays that are compatible |
55 |
| -# with the structs in the C++ code -- most of which |
56 |
| -# use the old-style C types, e.g. int, short, long. |
57 |
| -# In particular, long is defined differently on Windows and Linux |
58 |
| -# so we need to make sure that we are using the right type on each platform |
59 |
| -# note: numpy no longer HAS numpy.long or numpy.int |
60 |
| -# there is a numpy.compat.long, which maps to int (which is the Python int type) |
61 |
| -# however, I *think* that Python uses a C long for int, |
62 |
| -# and numpy figures it out for itself at run time, so I think we can |
63 |
| -# just do that: |
64 |
| - |
65 |
| -#np_long = int |
66 |
| - |
67 |
| -# THE REST OF THIS IS OUT OF DATE: |
68 |
| -# on OSX 64: |
69 |
| -# - numpy identifies np.long as int64, which is a Cython ctype 'long' |
70 |
| -# on OSX 32: |
71 |
| -# - numpy identifies np.long as int64, which is a Cython ctype 'long long' |
72 |
| -# on Win32: |
73 |
| -# - numpy identifies np.long as int64, which is a Cython ctype 'long long', |
74 |
| -# on Win64: |
75 |
| -# - unknown what numpy does |
76 |
| -# - Presumably an int64 would be a ctype 'long' ??? |
77 |
| -# we should clean this up! -- on Python3, I think np.compat.long == int |
78 |
| - |
79 |
| -######## |
80 |
| -# NOTE: all this below was essentially simply setting np_long to int |
81 |
| -# on all platforms anyway. |
82 |
| -# IF we have future problems, it might be as simple as: |
83 |
| -# if sys.platform == 'win32': |
84 |
| -# np_long = np.int32 |
85 |
| -# elif sys.platform in ('darwin', 'linux2', 'linux'): |
86 |
| -# np_long = np.int64 |
87 |
| -######## |
88 |
| - |
89 |
| -# if sys.platform == 'win32': |
90 |
| -# np_long = np.int |
91 |
| -# elif sys.platform in ('darwin', 'linux2', 'linux'): |
92 |
| -# if sys.maxsize > 2147483647: |
93 |
| -# np_long = np.compat.long |
94 |
| -# else: |
95 |
| -# np_long = int |
96 |
| -# else: |
97 |
| -# # untested platforms will just default to what numpy thinks it is. |
98 |
| -# np_long = np.compat.long |
99 |
| - |
100 | 56 | mover_type = np.float64
|
101 | 57 | world_point_type = np.float64
|
102 | 58 | windage_type = np.float64
|
|
0 commit comments