I've done some comparisons of 1.6.1 and 1.7 (master), and written up some key differences in a pull request here:
https://github.com/numpy/numpy/pull/264/files#diff-0 What you've discovered here looks like an interaction between the automatic unit detection and struct dtypes, it's a bug to do with how flexible types work. To match how the struct dtypes work with flexible string dtypes, it should raise an error when trying to create a dtype with just 'M8' and no unit specified, at In [4]. -Mark On Fri, Apr 27, 2012 at 3:52 PM, Travis Vaught <[email protected]> wrote: > 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 > > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
