home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 388847354

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/2127#issuecomment-388847354 https://api.github.com/repos/pydata/xarray/issues/2127 388847354 MDEyOklzc3VlQ29tbWVudDM4ODg0NzM1NA== 6628425 2018-05-14T14:56:46Z 2018-05-14T14:56:46Z MEMBER

Huh...my test is still triggering some failures due to this issue in #2128. Oddly on my laptop the original bug doesn't appear to exist if I use python version 3.6.5 and numpy version 1.14.3 (the versions on Travis where I'm getting a failure): ``` $ python Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13:44:09) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import numpy as np np.version '1.14.3' import datetime np.array([datetime.timedelta(7)], dtype='timedelta64[D]') array([7], dtype='timedelta64[D]') and not surprisingly the test passes: $ pytest -vv test_coding_times.py -k test_infer_cftime_datetime_units ========================================================= test session starts ========================================================== platform darwin -- Python 3.6.5, pytest-3.5.1, py-1.5.3, pluggy-0.6.0 -- //anaconda/envs/xarray-docs/bin/python cachedir: ../../.pytest_cache rootdir: /Users/spencerclark/xarray-dev/xarray, inifile: setup.cfg collected 269 items / 268 deselected

test_coding_times.py::test_infer_cftime_datetime_units PASSED [100%] So it appears to be platform dependent. Trying this out on a linux machine with these versions I can reproduce the issue (which seems to persist even for individual timedeltas, explaining the test failure): $ python Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13:39:56) [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux Type "help", "copyright", "credits" or "license" for more information.

import numpy as np np.version '1.14.3' import datetime np.array([datetime.timedelta(7)], dtype='timedelta64[D]') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Cannot cast datetime.timedelta object from metadata [Y] to [D] according to the rule 'same_kind' np.timedelta64(datetime.timedelta(7), 'D') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Cannot cast datetime.timedelta object from metadata [Y] to [D] according to the rule 'same_kind' np.timedelta64(datetime.timedelta(1), 'D') numpy.timedelta64(1,'D') It's not ideal, but should we try to go with pandas to do the type conversion? It seems to work on the linux platform: import pandas as pd pd.to_timedelta([datetime.timedelta(7)]) TimedeltaIndex(['7 days'], dtype='timedelta64[ns]', freq=None) pd.to_timedelta([datetime.timedelta(7)]).values array([604800000000000], dtype='timedelta64[ns]') ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  322591813
Powered by Datasette · Queries took 79.4ms · About: xarray-datasette