Re: [Numpy-discussion] how to count Nan occurrence in a ndarray?

2011-10-07 Thread Chao YUE
Thanks Olivier.

Chao

2011/10/7 Olivier Delalleau 

> You can use numpy.isnan(array).sum()
>
> -=- Olivier
>
> 2011/10/7 Chao YUE 
>
>> The data is read from a .mat file.
>>
>> 2011/10/7 Chao YUE 
>>
>>> Dear all,
>>>
>>> I have an ndarray with dimension of 4X62500. is there anyway I can count
>>> the number of missing value (NaN)? because I want to know how many
>>> observations are missing?
>>>
>>> Thanks for any idea,
>>>
>>> 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
>>>
>>> 
>>>
>>>
>>
>>
>> --
>>
>> ***
>> 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


Re: [Numpy-discussion] how to count Nan occurrence in a ndarray?

2011-10-07 Thread Olivier Delalleau
You can use numpy.isnan(array).sum()

-=- Olivier

2011/10/7 Chao YUE 

> The data is read from a .mat file.
>
> 2011/10/7 Chao YUE 
>
>> Dear all,
>>
>> I have an ndarray with dimension of 4X62500. is there anyway I can count
>> the number of missing value (NaN)? because I want to know how many
>> observations are missing?
>>
>> Thanks for any idea,
>>
>> 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
>>
>> 
>>
>>
>
>
> --
>
> ***
> 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


Re: [Numpy-discussion] how to count Nan occurrence in a ndarray?

2011-10-07 Thread Chao YUE
The data is read from a .mat file.

2011/10/7 Chao YUE 

> Dear all,
>
> I have an ndarray with dimension of 4X62500. is there anyway I can count
> the number of missing value (NaN)? because I want to know how many
> observations are missing?
>
> Thanks for any idea,
>
> 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
>
> 
>
>


-- 
***
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] how to count Nan occurrence in a ndarray?

2011-10-07 Thread Chao YUE
Dear all,

I have an ndarray with dimension of 4X62500. is there anyway I can count the
number of missing value (NaN)? because I want to know how many observations
are missing?

Thanks for any idea,

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


Re: [Numpy-discussion] Crash on (un-orthodox) __import__

2011-10-07 Thread Christoph Gohlke


On 10/6/2011 9:33 PM, Robert Kern wrote:
> On Thu, Oct 6, 2011 at 17:25, Paul Ivanov  wrote:
>> Hi Andrea,
>>
>> On Tue, Oct 4, 2011 at 3:04 AM, Andrea Gavana  
>> wrote:
>>> Hi All,
>>>  I was fiddling here and there with some code doing dynamic import of
>>> stuff, and I noticed that this code:
>>> import os
>>> import sys
>>> init_name = r"C:\Python27\Lib\site-packages\numpy\__init__.py"
>>> directory, module_name = os.path.split(init_name)
>>> main = os.path.splitext(module_name)[0]
>>> sys.path.insert(0, os.path.normpath(directory))
>>> # Crash here...
>>> mainmod = __import__(main)
>>
>>
>> in this case, your main is '__init__' and your directory is
>> 'C:\Python27\Lib\site-packages\numpy' which is probably not what you
>> intended. You should make directory 'C:\Python27\Lib\site-packages'
>> and main into 'numpy'
>
> Still, it shouldn't segfault, and it's worth figuring out why it does.
> gdb has been mostly unenlightening for me since gdb won't let me
> navigate the traceback.
>


This is the same crash that occurs when running `python -v -c"import 
__init__"` from within the site-packages/numpy directory. Several numpy 
Python and C extension modules are imported/executed twice. Besides 
fixing the segfault it might be worth preventing this type of import in 
numpy/__init__.py, for example:


import sys as _sys
if '__init__' in _sys.modules and _sys.modules['__init__'].__file__ == 
__file__:
 _sys.stderr.write("Use `import numpy` ... .\n")  # or raise 
ImportError()
else:
...
del _sys


The faulthandler output is:

   File "core\numerictypes.py", line 226 in _evalname
   File "core\numerictypes.py", line 247 in bitname
   File "core\numerictypes.py", line 307 in _add_aliases
   File "core\numerictypes.py", line 330 in 
   File "core\__init__.py", line 8 in 
   File "__init__.py", line 146 in 
   File "", line 1 in 


The function call that crashes during the second import of 
core/numerictypes.py is `int("64")`.

Christoph
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion