usemask kwd in timeseries.tsfromtxt missing?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

usemask kwd in timeseries.tsfromtxt missing?

jseabold
The docs say that usemask is a kwd arg, but it's not implemented.  Is
this an oversight or are the docs wrong and the TimeSeries object must
be a masked array?

Using recent trunk.

In [1]: import scikits.timeseries as ts

In [2]: ts.__version__
Out[2]: '0.91.3'

Skipper
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: usemask kwd in timeseries.tsfromtxt missing?

Timmie
Administrator
> The docs say that usemask is a kwd arg, but it's not implemented.  Is
> this an oversight or are the docs wrong and the TimeSeries object must
> be a masked array?
do you have masked data?

I suggest to omit the argument.

To my experience:
If you load data with missing values (missing_values) a masked array is
created automatically. If not, the array will be regular.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: usemask kwd in timeseries.tsfromtxt missing?

jseabold
On Sat, Mar 13, 2010 at 3:55 AM, Tim Michelsen
<[hidden email]> wrote:

>> The docs say that usemask is a kwd arg, but it's not implemented.  Is
>> this an oversight or are the docs wrong and the TimeSeries object must
>> be a masked array?
> do you have masked data?
>
> I suggest to omit the argument.
>
> To my experience:
> If you load data with missing values (missing_values) a masked array is
> created automatically. If not, the array will be regular.
>

from StringIO import StringIO
import scikits.timeseries as ts
s = '"dates","GDP","CONS","INV","GOVT"\n"1947-I",100.2,33.4,33.4,33.4\n"1947-II",100.2,33.4,33.4,33.4'
s = StringIO(s)

romans = {"I":1,"II":2,"III":3,"IV":4}
dateconverter = lambda x: ts.Date(freq='Q',
year=int(x.split("-")[0].strip("\"")),
quarter=romans[x.split("-")[1].strip("\"")])

data = ts.tsfromtxt(s, delimiter=",", dtype=None,
dateconverter=dateconverter, names=True, usemask=True)
#TypeError: tsfromtxt() got an unexpected keyword argument 'usemask'

data = ts.tsfromtxt(s, delimiter=",", dtype=None,
dateconverter=dateconverter, names=True)
hasattr(data,'mask')
# True

print ts.tsfromtxt.__doc__
<snip>
    usemask : bool, optional
        If True, return a masked array.
        If False, return a regular array.
<snip>

Skipper
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: usemask kwd in timeseries.tsfromtxt missing?

Timmie
Administrator
> data = ts.tsfromtxt(s, delimiter=",", dtype=None,
> dateconverter=dateconverter, names=True, usemask=True)
> #TypeError: tsfromtxt() got an unexpected keyword argument 'usemask'
>
> data = ts.tsfromtxt(s, delimiter=",", dtype=None,
> dateconverter=dateconverter, names=True)
> hasattr(data,'mask')
> # True
>
> print ts.tsfromtxt.__doc__
> <snip>
>     usemask : bool, optional
>         If True, return a masked array.
>         If False, return a regular array.
> <snip>
I never really cared about whether a masked array is created or not.
Does this really make a difference in your work?
Let's wait for a comment from Pierre GM?

you may also check:
data.data
data.series

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: usemask kwd in timeseries.tsfromtxt missing?

Pierre GM-2
On Mar 14, 2010, at 6:32 PM, Tim Michelsen wrote:

>> data = ts.tsfromtxt(s, delimiter=",", dtype=None,
>> dateconverter=dateconverter, names=True, usemask=True)
>> #TypeError: tsfromtxt() got an unexpected keyword argument 'usemask'
>>
>> data = ts.tsfromtxt(s, delimiter=",", dtype=None,
>> dateconverter=dateconverter, names=True)
>> hasattr(data,'mask')
>> # True
>>
>> print ts.tsfromtxt.__doc__
>> <snip>
>>    usemask : bool, optional
>>        If True, return a masked array.
>>        If False, return a regular array.
>> <snip>
> I never really cared about whether a masked array is created or not.
> Does this really make a difference in your work?
> Let's wait for a comment from Pierre GM?


All,
I only have episodic connectability these days, sorry for the lag in answers.
In np.genfromtxt, `usemask` lets you choose whether you want a standard ndarray (False) or a MaskedArray (True).
In `scikits.timeseries.tsfromtxt`, the output is always a TimeSeries, which is a subclass of MaskedArray. Therefore, `usemask` would always be True. No need for a keyword argument that you can't modify, hence the error message.
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: usemask kwd in timeseries.tsfromtxt missing?

Timmie
Administrator
> which is a subclass of MaskedArray. Therefore, `usemask` would always
> be True. No need for a keyword argument that you can't modify, hence
> the error message.
Then, why is this argument not removed?
Because of the inheritance from genfromtxt?

Maybe it's worth mentioning this in the docstring.

_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: usemask kwd in timeseries.tsfromtxt missing?

Pierre GM-2
On Mar 15, 2010, at 6:25 PM, Tim Michelsen wrote:
>> which is a subclass of MaskedArray. Therefore, `usemask` would always
>> be True. No need for a keyword argument that you can't modify, hence
>> the error message.
> Then, why is this argument not removed?

I don't follow you. The `usemask` argument is not a valid argument for `tsfromtxt` (check the function signature), that's why it's not recognized. There's nothing to remove.

> Because of the inheritance from genfromtxt?

In practice, genfromtxt has more arguments than tsfromtxt.

>
> Maybe it's worth mentioning this in the docstring.


Ah OK. The docstring is wrong. I'll correct that
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user