Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime and record arrays/masked arrays (Trac #1912) #5710

Closed
numpy-gitbot opened this issue Oct 16, 2012 · 4 comments
Closed

datetime and record arrays/masked arrays (Trac #1912) #5710

numpy-gitbot opened this issue Oct 16, 2012 · 4 comments

Comments

@numpy-gitbot
Copy link
Collaborator

Original ticket http://projects.scipy.org/numpy/ticket/1912 on 2011-07-18 by atmention:chrisjordansquire, assigned to unknown.

I'm using the 2.0.0 development version of numpy on ububtu 10.10 .

When string arguments for the dtype are given for a record array, and one of the individual dtypes is datetime64[D], the day part is lost and the datetime become generic. This makes it impossible to assign anything to it.

For example, look at
np.zeros(4, dtype = ','.join(['datetime64[D]', 'i4']))

This gives an array with dtype dtype=[('f0', <M8), ('f1', '<i4')], where the <M8 should be <M8[D].

A different bug happens when putting datetimes into masked arrays. For example,
np.ma.zeros(4,dtype= 'datetime64[D],i4')
gives a ValueError: mismatch in size of old and new data-descriptor with traceback

/home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in call(self, a, _args, *_params)
7142 _extras[p] = params.pop(p)
7143 # Get the result

-> 7144 result = self._func.call(a, _args, *_params).view(MaskedArray)
7145 if "fill_value" in common_params:
7146 result.fill_value = _extras.get("fill_value", None)

/home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in array_finalize(self, obj)
2794 if self.dtype.names:
2795 if self._fill_value is None:
-> 2796 self._fill_value = _check_fill_value(None, self.dtype)
2797 return
2798

/home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in _check_fill_value(fill_value, ndtype)
392 if fields:
393 descr = ndtype.descr
--> 394 fill_value = np.array(_recursive_set_default_fill_value(descr),
395 dtype=ndtype,)
396 else:

/home/intern/my26/lib/python2.6/site-packages/numpy/ma/core.pyc in _recursive_set_default_fill_value(dtypedescr)
360 deflist.append(tuple(_recursive_set_default_fill_value(currenttype)))
361 else:
--> 362 deflist.append(default_fill_value(np.dtype(currenttype)))
363 return tuple(deflist)
364

ValueError: mismatch in size of old and new data-descriptor

@numpy-gitbot
Copy link
Collaborator Author

atmention:mwiebe wrote on 2011-07-22

This bug is fixed in the pull request:

numpy/numpy#116

@numpy-gitbot
Copy link
Collaborator Author

Milestone changed to NumPy 2.0 by atmention:mwiebe on 2011-07-22

@numpy-gitbot
Copy link
Collaborator Author

atmention:mwiebe wrote on 2011-07-27

The pull request has been merged, both failures work for me now.

@numpy-gitbot
Copy link
Collaborator Author

Milestone changed to NumPy 1.7 by atmention:charris on 2012-04-30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant