8000 BUG: Fix #4476 by adding datetime64 and timedelta64 types by gerritholl · Pull Request #5455 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix #4476 by adding datetime64 and timedelta64 types #5455

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

Merged
merged 2 commits into from
Jan 17, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
TST: Add testcase for the fix to bug #4476.
Add a testcase `test_fillvalue_datetime_timedelta` to class
`TestFillingValues` for the fix to bug #4476.  See commit
216fd17 and pull request #5455.
  • Loading branch information
Gerrit Holl committed Jan 15, 2015
commit 00ee332e9d95362a3d487f784cdc8fc06cf0832c
15 changes: 15 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,21 @@ def test_fillvalue_exotic_dtype(self):
control = np.array((0, 0, 0), dtype="int, float, float").astype(ndtype)
assert_equal(_check_fill_value(0, ndtype), control)

def test_fillvalue_datetime_timedelta(self):
# Test default fillvalue for datetime64 and timedelta64 types.
# See issue #4476, this would return '?' which would cause errors
# elsewhere

for timecode in ("as", "fs", "ps", "ns", "us", "ms", "s", "m",
"h", "D", "W", "M", "Y"):
control = numpy.datetime64("NaT", timecode)
test = default_fill_value(numpy.dtype("<M8[" + timecode + "]"))
assert_equal(test, control)

control = numpy.timedelta64("NaT", timecode)
test = default_fill_value(numpy.dtype("<m8[" + timecode + "]"))
assert_equal(test, control)

def test_extremum_fill_value(self):
# Tests extremum fill values for flexible type.
a = array([(1, (2, 3)), (4, (5, 6))],
Expand Down
0