[SciPy-User] Scikits.timeseries, bug converting list to DateArray

Robert Ferrell ferrell@diablotech....
Sun Dec 27 23:00:32 CST 2009


I've encountered a possible bug converting a list of datetime numbers  
to a DateArray.  What's odd is I'm pretty sure this worked until  
recently, but I don't recall changing anything on my system.  So,  
before I file a bug report, maybe somebody can confirm this is a  
timeseries problem and not my own install problem.  I'm on OS X 10.6,  
Python 2.6.1, numpy 1.4.0.dev7542, timeseries 0.91.3.

In [1]: import scikits.timeseries as ts

In [2]: x = [731694.0]

In [3]: [ts.Date('d', dt) for dt in x]
Out[3]: [<D : 23-Apr-2004>]

In [4]: ts.date_array([ts.Date('d', y) for y in x])
Out[4]:
DateArray([23-Apr-2004],
           freq='D')

That all works fine.  But, if I hand x to date_array as the dlist  
argument, I get a date_array, but I can't print it.

In [11]: y = ts.date_array(dlist=x, freq='d')

In [13]: type(y)
Out[13]: <class 'scikits.timeseries.tdates.DateArray'>

In [14]: y
Out[14]:  
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call  
last)

/Users/Shared/Develop/Financial/Lakshmi/<ipython console> in <module>()

/Library/Python/2.6/site-packages/IPython/Prompts.pyc in  
__call__(self, arg)
     550
     551             # and now call a possibly user-defined print  
mechanism

--> 552             manipulated_val = self.display(arg)
     553
     554             # user display hooks can change the variable to  
be stored in


/Library/Python/2.6/site-packages/IPython/Prompts.pyc in  
_display(self, arg)
     576             return IPython.generics.result_display(arg)
     577         except TryNext:
--> 578             return self.shell.hooks.result_display(arg)
     579
     580     # Assign the default display method:


/Library/Python/2.6/site-packages/IPython/hooks.pyc in __call__(self,  
*args, **kw)
     139             #print "prio",prio,"cmd",cmd #dbg

     140             try:
--> 141                 ret = cmd(*args, **kw)
     142                 return ret
     143             except ipapi.TryNext, exc:

/Library/Python/2.6/site-packages/IPython/hooks.pyc in  
result_display(self, arg)
     169
     170     if self.rc.pprint:
--> 171         out = pformat(arg)
     172         if '\n' in out:
     173             # So that multi-line strings line up with the  
left column of


/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ 
pprint.pyc in pformat(self, object)
     109     def pformat(self, object):
     110         sio = _StringIO()
--> 111         self._format(object, sio, 0, 0, {}, 0)
     112         return sio.getvalue()
     113

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ 
pprint.pyc in _format(self, object, stream, indent, allowance,  
context, level)
     127             self._readable = False
     128             return
--> 129         rep = self._repr(object, context, level - 1)
     130         typ = _type(object)
     131         sepLines = _len(rep) > (self._width - 1 - indent -  
allowance)

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ 
pprint.pyc in _repr(self, object, context, level)
     221     def _repr(self, object, context, level):
     222         repr, readable, recursive = self.format(object,  
context.copy(),
--> 223                                                 self._depth,  
level)
     224         if not readable:
     225             self._readable = False

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ 
pprint.pyc in format(self, object, context, maxlevels, level)
     233         and whether the object represents a recursive  
construct.
     234         """
--> 235         return _safe_repr(object, context, maxlevels, level)
     236
     237

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ 
pprint.pyc in _safe_repr(object, context, maxlevels, level)
     318         return format % _commajoin(components), readable,  
recursive
     319
--> 320     rep = repr(object)
     321     return rep, (rep and not rep.startswith('<')), False
     322

/Library/Python/2.6/site-packages/scikits.timeseries-0.91.3-py2.6- 
macosx-10.6-universal.egg/scikits/timeseries/tdates.pyc in  
__repr__(self)
     334
     335     def __repr__(self):
--> 336         return ndarray.__repr__(self)[:-1] + \
     337                ",\n          freq='%s')" % self.freqstr
     338

/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542-py2.6- 
macosx-10.6-universal.egg/numpy/core/numeric.pyc in array_repr(arr,  
max_line_width, precision, suppress_small)
    1334     if arr.size > 0 or arr.shape==(0,):
    1335         lst = array2string(arr, max_line_width, precision,  
suppress_small,
-> 1336                            ', ', "array(")
    1337     else: # show zero-length shape unless it is (0,)
    1338         lst = "[], shape=%s" % (repr(arr.shape),)

/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542-py2.6- 
macosx-10.6-universal.egg/numpy/core/arrayprint.pyc in array2string(a,  
max_line_width, precision, suppress_small, separator, prefix, style)
     298     else:
     299         lst = _array2string(a, max_line_width, precision,  
suppress_small,
--> 300                             separator, prefix)
     301     return lst
     302

/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542-py2.6- 
macosx-10.6-universal.egg/numpy/core/arrayprint.pyc in  
_array2string(a, max_line_width, precision, suppress_small, separator,  
prefix)
     220     lst = _formatArray(a, format_function, len(a.shape),  
max_line_width,
     221                        next_line_prefix, separator,
--> 222                        _summaryEdgeItems, summary_insert)[:-1]
     223
     224     return lst

/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542-py2.6- 
macosx-10.6-universal.egg/numpy/core/arrayprint.pyc in _formatArray(a,  
format_function, rank, max_line_len, next_line_prefix, separator,  
edge_items, summary_insert)
     344             s, line = _extendLine(s, line, word,  
max_line_len, next_line_prefix)
     345
--> 346         word = format_function(a[-1])
     347         s, line = _extendLine(s, line, word, max_line_len,  
next_line_prefix)
     348         s += line + "]\n"

/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542-py2.6- 
macosx-10.6-universal.egg/numpy/core/arrayprint.pyc in __call__(self,  
x, strip_zeros)
     436
     437     def __call__(self, x, strip_zeros=True):
--> 438         if isnan(x):
     439             return self.special_fmt % (_nan_str,)
     440         elif isinf(x):

TypeError: function not supported for these types, and can't coerce  
safely to supported types




More information about the SciPy-User mailing list