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

ValueError when initialising structured masked array having datetime64 #4583

Closed
gerritholl opened this issue Apr 4, 2014 · 2 comments
Closed

Comments

@gerritholl
Copy link
Contributor

When initialising a structured masked array with empty, zeros, or ones, in the numpy.ma module, a ValueError is raised, as illustrated below:

In [19]: E = numpy.ma.zeros(1, [("time", "M8[s]")])                                                                                                                                                  
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-fa42e8196770> in <module>()
----> 1 E = numpy.ma.zeros(1, [("time", "M8[s]")])

/home/gerrit/venv/python-3.4/lib/python3.4/site-packages/numpy/ma/core.py in __call__(self, a, *args, **params)
   7221             _extras[p] = params.pop(p)
   7222         # Get the result
-> 7223         result = self._func.__call__(a, *args, **params).view(MaskedArray)
   7224         if "fill_value" in common_params:
   7225             result.fill_value = _extras.get("fill_value", None)

/home/gerrit/venv/python-3.4/lib/python3.4/site-packages/numpy/ma/core.py in __array_finalize__(self, obj)
   2798         if self.dtype.names:
   2799             if self._fill_value is None:
-> 2800                 self._fill_value = _check_fill_value(None, self.dtype)
   2801         return
   2802 

/home/gerrit/venv/python-3.4/lib/python3.4/site-packages/numpy/ma/core.py in _check_fill_value(fill_value, ndtype)
    400             descr = ndtype.descr
    401             fill_value = np.array(_recursive_set_default_fill_value(descr),
--> 402                                   dtype=ndtype,)
    403         else:
    404             fill_value = default_fill_value(ndtype)

ValueError: Error parsing datetime string "?" at position 0
@jjhelmus
Copy link
Contributor

This issue was fixed in 4bfcf48 part of PR #5455 which also closed gh-4476, a similar issue to this one. This issue can be closed.

@charris
Copy link
Member

charris commented Oct 21, 2015

Thanks for the heads up.

@charris charris closed this as completed Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants