[Numpy-discussion] datetime dtype possible regression

Travis Vaught travis at vaught.net
Fri Apr 27 16:52:03 EDT 2012


With NumPy 1.6.1 (from EPD 7.2-2) I get this behavior:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In [1]: import numpy as np

In [2]: schema = np.dtype({'names':['symbol', 'date', 'open', 'high', 'low',
   ...:                        'close', 'volume', 'adjclose'],
   ...:                    'formats':['S8', 'M8', float, float, float, float,
   ...:                        float, float]})

In [3]: data = [("AAPL", "2012-04-12", 600.0, 605.0, 598.0, 602.0, 50000000, 602.0),]

In [4]: recdata = np.array(data, dtype=schema)

In [5]: recdata
Out[5]: 
array([ ('AAPL', datetime.datetime(2012, 4, 12, 0, 0), 600.0, 605.0, 598.0, 602.0, 50000000.0, 602.0)], 
      dtype=[('symbol', '|S8'), ('date', ('<M8[us]', {})), ('open', '<f8'), ('high', '<f8'), ('low', '<f8'), ('close', '<f8'), ('volume', '<f8'), ('adjclose', '<f8')])


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


With numpy-1.7.0.dev_3cb783e I get this:

>>> import numpy as np

>>> schema = np.dtype({'names':['symbol','data','open','high','low','close','volume','adjclose'], 'formats':['S8','M8',float,float,float,float,float,float]})

>>> data =  [("AAPL", "2012-04-12", 600.0, 605.0, 598.0, 602.0, 50000000, 602.0),]

>>> recdata = np.array(data, dtype=schema)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Cannot create a NumPy datetime other than NaT with generic units

>>> np.version.version
'1.7.0.dev-3cb783e'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Any hints about a regression I can check for? Or perhaps I missed an api change for specifying datetime dtypes?

Best,

Travis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120427/4dcb368c/attachment.html>


More information about the NumPy-Discussion mailing list