[Numpy-discussion] anyway to check a ndarray is a mased array or not?

Chao YUE chaoyuejoy@gmail....
Tue Oct 18 08:40:56 CDT 2011


really cool, thanks.

Chao

2011/10/18 Olivier Delalleau <shish@keba.be>

> if hasattr(a, 'mask'):  # or if isinstance(a, numpy.ma.core.MaskedArray.)
>
>      code 1
> else
>      code 2
>
> -=- Olivier
>
>
> 2011/10/18 Chao YUE <chaoyuejoy@gmail.com>
>
>> Thanks Olivier. but I don't know how can I check it in the code (not in an
>> interactive mode)?
>> I would like:
>>
>> if ndarray a is a mased array:
>>       code 1
>> else
>>      code 2
>>
>> thanks again,
>>
>> Chao
>>
>>
>> 2011/10/18 Olivier Delalleau <shish@keba.be>
>>
>>> You could simply check if it has a 'mask' attribute. You can also check
>>> if it is an instance of numpy.ma.core.MaskedArray.
>>>
>>> -=- Olivier
>>>
>>> Le 18 octobre 2011 08:49, Chao YUE <chaoyuejoy@gmail.com> a écrit :
>>>
>>>> Just one more question, how can I check a ndarray is a masked array or
>>>> not?
>>>>
>>>> Chao
>>>> --
>>>>
>>>> ***********************************************************************************
>>>> Chao YUE
>>>> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
>>>> UMR 1572 CEA-CNRS-UVSQ
>>>> Batiment 712 - Pe 119
>>>> 91191 GIF Sur YVETTE Cedex
>>>> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
>>>>
>>>> ************************************************************************************
>>>>
>>>>
>>>> _______________________________________________
>>>> NumPy-Discussion mailing list
>>>> NumPy-Discussion@scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>>
>>>>
>>>
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>>
>>
>>
>> --
>>
>> ***********************************************************************************
>> Chao YUE
>> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
>> UMR 1572 CEA-CNRS-UVSQ
>> Batiment 712 - Pe 119
>> 91191 GIF Sur YVETTE Cedex
>> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
>>
>> ************************************************************************************
>>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20111018/42037998/attachment.html 


More information about the NumPy-Discussion mailing list