Skip to content

Commit 8a5d8aa

Browse files
authored
Merge pull request #37 from wkliao/build_warning
fix 2 build warnings
2 parents d59226c + b1f9148 commit 8a5d8aa

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/pnetcdf/_Variable.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ from ._utils cimport _strencode, _check_err, _set_att, _get_att, _get_att_names,
2323
from ._utils import chartostring
2424
from ._utils cimport _nptonctype, _notcdf2dtypes, _nctonptype, _nptompitype, _supportedtypes, _supportedtypescdf2, \
2525
default_fillvals, _StartCountStride, _out_array_shape, _private_atts
26-
import_array()
26+
27+
cimport numpy
28+
numpy.import_array()
2729

2830

2931
ctypedef MPI.Datatype Datatype
@@ -109,8 +111,10 @@ cdef class Variable:
109111
xtype = _nptonctype[nc_dtype.str[1:]]
110112
else:
111113
raise TypeError('illegal data type, must be one of %s, got %s' % (_supportedtypes, nc_dtype.str[1:]))
112-
if isinstance(nc_dtype, int):
114+
elif isinstance(nc_dtype, int):
113115
xtype = nc_dtype
116+
else:
117+
raise TypeError('illegal data type, must be an int, got %s' % (nc_dtype.str[1:]))
114118
self.xtype = xtype
115119
self.dtype = np.dtype(_nctonptype[xtype])
116120

src/pnetcdf/_utils.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ MPI_Datatype MPI_UNSIGNED64 = MPI.UINT64
2828
MPI_Datatype MPI_FLOAT = MPI.FLOAT
2929
MPI_Datatype MPI_DOUBLE = MPI.DOUBLE"""
3030

31-
import_array()
31+
cimport numpy
32+
numpy.import_array()
3233

3334
# np data type <--> netCDF data type mapping.
3435
_nptonctype = {'S1' : NC_CHAR_C,

0 commit comments

Comments
 (0)