len() of unsized object - ks test

MRAB python at mrabarnett.plus.com
Fri Apr 25 11:13:28 EDT 2014


On 2014-04-25 15:07, Jamie Mitchell wrote:
> Hello all,
>
> I am trying to perform a Kolmogorov-Smirnov test in Python but I'm having a few difficulties.
>
> # My files are netCDF so I import them as follows:
>
> control=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/controlperiod/south_west/swhcontrol_swest_concatannavg_1D.nc','r')
>
A brief look at the documentation online says that 'control' is an
instance that _describes_ the dataset:

"""A netCDF Dataset is a collection of dimensions, groups, variables and 
attributes. Together they describe the meaning of data and relations 
among data fields stored in a netCDF file."""

So I don't think that it's the data itself.

> # The string is simply a 1D array
>
> # Then performing the ks test:
>
> kstest(control,'norm')
>
> # I then get the following error:
>
> File "<stdin>", line 1, in <module>
>    File "/usr/local/sci/lib/python2.7/site-packages/scipy/stats/stats.py", line 3413, in kstest
>      N = len(vals)
> TypeError: len() of unsized object
>
> Any ideas on why this isn't working would be great.
>




More information about the Python-list mailing list