[Numpy-discussion] Suggestion for recarray.view
Stéfan van der Walt
stefan at sun.ac.za
Fri Sep 19 04:13:39 EDT 2008
2008/9/19 Travis E. Oliphant <oliphant at enthought.com>:
>> #---------------
>> def view(self, dtype=None, type=None):
>> if dtype is None:
>> return ndarray.view(self, type)
>> elif type is None:
>> try:
>> if issubclass(dtype, ndarray):
>> return ndarray.view(self, dtype)
>> except TypeError:
>> pass
>> dtype = sb.dtype(dtype)
>> if dtype.fields is None:
>> return self.__array__().view(dtype)
>> return ndarray.view(self, dtype)
>> else:
>> return ndarray.view(self, dtype, type)
>> #---------------
>>
> This looks pretty good to me.
>
> +1 for adding it.
+1 and another +1 to your karma for requesting peer review. Let me
know if you need me to whip up a couple of tests for verifying the
different usage cases.
Cheers
Stéfan
More information about the NumPy-Discussion
mailing list