@@ -44,16 +44,16 @@ cdef class Variable:
44
44
45
45
"""
46
46
47
- def __init__ (self , file , name , nc_dtype , dimensions = (), **kwargs ):
47
+ def __init__ (self , file , name , datatype , dimensions = (), **kwargs ):
48
48
"""
49
- __init__(self, file, name, nc_dtype , dimensions=(), **kwargs)
49
+ __init__(self, file, name, datatype , dimensions=(), **kwargs)
50
50
51
51
The constructor for :class:`pnetcdf.Variable`.
52
52
53
53
:param varname: Name of the new variable.
54
54
:type varname: str
55
55
56
- :param nc_dtype : The datatype of the new variable. Can be specified by providing a NC module constant,
56
+ :param datatype : The datatype of the new variable. Can be specified by providing a NC module constant,
57
57
or numpy dtype object, or a string that describes a numpy dtype object. Supported specifiers are:
58
58
59
59
- ``pnetcdf.NC_CHAR`` or ``S1`` for 1-character string
@@ -71,7 +71,7 @@ cdef class Variable:
71
71
- ``pnetcdf.NC_INT64`` or ``i8`` for signed 8-byte integer
72
72
- ``pnetcdf.NC_UINT64`` or ``u8`` for unsigned 8-byte integer
73
73
74
- :type nc_dtype : int
74
+ :type datatype : int
75
75
:param dimensions: [Optional] The dimensions of the new variable. Can be either dimension names
76
76
or dimension class instances. Default is an empty tuple which means the variable is
77
77
a scalar (and therefore has no dimensions).
@@ -104,17 +104,17 @@ cdef class Variable:
104
104
self ._file = file
105
105
_file_id = self ._file_id
106
106
# TODO: decide whether we need to check xtype at python-level
107
- if isinstance (nc_dtype , str ): # conver to numpy datatype object
108
- nc_dtype = np.dtype(nc_dtype )
109
- if isinstance (nc_dtype , np.dtype):
110
- if nc_dtype .str[1 :] in _supportedtypes:
111
- xtype = _nptonctype[nc_dtype .str[1 :]]
107
+ if isinstance (datatype , str ): # conver to numpy datatype object
108
+ datatype = np.dtype(datatype )
109
+ if isinstance (datatype , np.dtype):
110
+ if datatype .str[1 :] in _supportedtypes:
111
+ xtype = _nptonctype[datatype .str[1 :]]
112
112
else :
113
- raise TypeError (' illegal data type, must be one of %s , got %s ' % (_supportedtypes, nc_dtype .str[1 :]))
114
- elif isinstance (nc_dtype , int ):
115
- xtype = nc_dtype
113
+ raise TypeError (' illegal data type, must be one of %s , got %s ' % (_supportedtypes, datatype .str[1 :]))
114
+ elif isinstance (datatype , int ):
115
+ xtype = datatype
116
116
else :
117
- raise TypeError (' illegal data type, must be an int, got %s ' % (nc_dtype .str[1 :]))
117
+ raise TypeError (' illegal data type, must be an int, got %s ' % (datatype .str[1 :]))
118
118
self .xtype = xtype
119
119
self .dtype = np.dtype(_nctonptype[xtype])
120
120
0 commit comments