Returns a view of the mrecarray.
(self, dtype=None, type=None)
| 360 | return str("\n".join(reprstr)) |
| 361 | |
| 362 | def view(self, dtype=None, type=None): |
| 363 | """ |
| 364 | Returns a view of the mrecarray. |
| 365 | |
| 366 | """ |
| 367 | # OK, basic copy-paste from MaskedArray.view. |
| 368 | if dtype is None: |
| 369 | if type is None: |
| 370 | output = ndarray.view(self) |
| 371 | else: |
| 372 | output = ndarray.view(self, type) |
| 373 | # Here again. |
| 374 | elif type is None: |
| 375 | try: |
| 376 | if issubclass(dtype, ndarray): |
| 377 | output = ndarray.view(self, dtype) |
| 378 | else: |
| 379 | output = ndarray.view(self, dtype) |
| 380 | # OK, there's the change |
| 381 | except TypeError: |
| 382 | dtype = np.dtype(dtype) |
| 383 | # we need to revert to MaskedArray, but keeping the possibility |
| 384 | # of subclasses (eg, TimeSeriesRecords), so we'll force a type |
| 385 | # set to the first parent |
| 386 | if dtype.fields is None: |
| 387 | basetype = self.__class__.__bases__[0] |
| 388 | output = self.__array__().view(dtype, basetype) |
| 389 | output._update_from(self) |
| 390 | else: |
| 391 | output = ndarray.view(self, dtype) |
| 392 | output._fill_value = None |
| 393 | else: |
| 394 | output = ndarray.view(self, dtype, type) |
| 395 | # Update the mask, just like in MaskedArray.view |
| 396 | if (getattr(output, '_mask', nomask) is not nomask): |
| 397 | mdtype = ma.make_mask_descr(output.dtype) |
| 398 | output._mask = self._mask.view(mdtype, ndarray) |
| 399 | output._mask.shape = output.shape |
| 400 | return output |
| 401 | |
| 402 | def harden_mask(self): |
| 403 | """ |
no test coverage detected