[Numpy-discussion] recarray fun

Travis E. Oliphant oliphant at enthought.com
Thu May 1 16:03:17 EDT 2008


Stéfan van der Walt wrote:
> 2008/5/1 Travis E. Oliphant <oliphant at enthought.com>:
>   
>>  > OK, I see your point.  I'm working on a patch that does the following:
>>  >
>>  > def view(type_or_dtype=None, dtype=None, type=None):
>>  >     if type_or_dtype:
>>  >          if dtype:
>>  >              raise ValueError("Cannot specify dtype twice")
>>  >          if type:
>>  >              raise ValueError("Cannot specify type twice")
>>  >
>>  >         if isinstance(type_or_dtype,py_type):
>>  >             type = type_or_dtype
>>  >
>>  >         if isinstance(type_or_dtype,numpy_dtype):
>>  >             dtype = type_or_dtype
>>  >
>>  >     return x.view(type=type).view(dtype=dtype)
>>  >
>>  > Would that be a satisfying solution?  I'll be back around 21:00 SAST
>>  > to attend to the matter.
>>  >
>>
>>  Yes, I think that would work.   You need to do some checking for
>>  type=None and dtype=None as well, though.
>>
>>  That way, the first argument would continue to work as now but be
>>  labeled correctly, but it would also support dtype= and type= keywords.
>>     
>
> Please review http://projects.scipy.org/scipy/numpy/changeset/5117.
>
>   
Check out

http://projects.scipy.org/scipy/numpy/changeset/5119

-Travis







More information about the NumPy-Discussion mailing list