|
59 | 59 |
|
60 | 60 | from numpy.testing import (assert_almost_equal, assert_array_equal)
|
61 | 61 |
|
62 |
| -from ..testing import data_path as DATA_PATH |
| 62 | +from ..testing import data_path as DATA_PATH, assert_dt_equal |
63 | 63 |
|
64 | 64 | from ..tmpdirs import InTemporaryDirectory
|
65 | 65 |
|
@@ -122,7 +122,7 @@ def validate_asarray(self, pmaker, params):
|
122 | 122 | prox, fio, hdr = pmaker()
|
123 | 123 | out = np.asarray(prox)
|
124 | 124 | assert_array_equal(out, params['arr_out'])
|
125 |
| - assert_equal(out.dtype.type, params['dtype_out']) |
| 125 | + assert_dt_equal(out.dtype, params['dtype_out']) |
126 | 126 | # Shape matches expected shape
|
127 | 127 | assert_equal(out.shape, params['shape'])
|
128 | 128 |
|
@@ -204,8 +204,8 @@ def obj_params(self):
|
204 | 204 | slopes,
|
205 | 205 | inters):
|
206 | 206 | n_els = np.prod(shape)
|
207 |
| - dt = np.dtype(dtype).newbyteorder(self.data_endian) |
208 |
| - arr = np.arange(n_els, dtype=dt).reshape(shape) |
| 207 | + dtype = np.dtype(dtype).newbyteorder(self.data_endian) |
| 208 | + arr = np.arange(n_els, dtype=dtype).reshape(shape) |
209 | 209 | data = arr.tostring(order=self.array_order)
|
210 | 210 | hdr = self.header_class()
|
211 | 211 | hdr.set_data_dtype(dtype)
|
@@ -264,6 +264,13 @@ def fname_func():
|
264 | 264 | params = params.copy()
|
265 | 265 | yield fname_func, params
|
266 | 266 |
|
| 267 | + def validate_dtype(self, pmaker, params): |
| 268 | + # Read-only dtype attribute |
| 269 | + prox, fio, hdr = pmaker() |
| 270 | + assert_dt_equal(prox.dtype, params['dtype']) |
| 271 | + assert_raises(AttributeError, |
| 272 | + prox.__setattr__, 'dtype', np.dtype(prox.dtype)) |
| 273 | + |
267 | 274 | def validate_slope_inter_offset(self, pmaker, params):
|
268 | 275 | # Check slope, inter, offset
|
269 | 276 | prox, fio, hdr = pmaker()
|
|
0 commit comments