{"action":"closed","issue":{"url":"https://api.github.com/repos/zarr-developers/zarr/issues/342","repository_url":"https://api.github.com/repos/zarr-developers/zarr","labels_url":"https://api.github.com/repos/zarr-developers/zarr/issues/342/labels{/name}","comments_url":"https://api.github.com/repos/zarr-developers/zarr/issues/342/comments","events_url":"https://api.github.com/repos/zarr-developers/zarr/issues/342/events","html_url":"https://github.com/zarr-developers/zarr/issues/342","id":383194093,"node_id":"MDU6SXNzdWUzODMxOTQwOTM=","number":342,"title":"OverflowError if using NaT as fill_value for mM dtypes","user":{"login":"thomascoquet","id":7583487,"node_id":"MDQ6VXNlcjc1ODM0ODc=","avatar_url":"https://avatars1.githubusercontent.com/u/7583487?v=4","gravatar_id":"","url":"https://api.github.com/users/thomascoquet","html_url":"https://github.com/thomascoquet","followers_url":"https://api.github.com/users/thomascoquet/followers","following_url":"https://api.github.com/users/thomascoquet/following{/other_user}","gists_url":"https://api.github.com/users/thomascoquet/gists{/gist_id}","starred_url":"https://api.github.com/users/thomascoquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomascoquet/subscriptions","organizations_url":"https://api.github.com/users/thomascoquet/orgs","repos_url":"https://api.github.com/users/thomascoquet/repos","events_url":"https://api.github.com/users/thomascoquet/events{/privacy}","received_events_url":"https://api.github.com/users/thomascoquet/received_events","type":"User","site_admin":false},"labels":[{"id":299957500,"node_id":"MDU6TGFiZWwyOTk5NTc1MDA=","url":"https://api.github.com/repos/zarr-developers/zarr/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/zarr-developers/zarr/milestones/7","html_url":"https://github.com/zarr-developers/zarr/milestone/7","labels_url":"https://api.github.com/repos/zarr-developers/zarr/milestones/7/labels","id":3229837,"node_id":"MDk6TWlsZXN0b25lMzIyOTgzNw==","number":7,"title":"v2.3","description":"","creator":{"login":"alimanfoo","id":703554,"node_id":"MDQ6VXNlcjcwMzU1NA==","avatar_url":"https://avatars1.githubusercontent.com/u/703554?v=4","gravatar_id":"","url":"https://api.github.com/users/alimanfoo","html_url":"https://github.com/alimanfoo","followers_url":"https://api.github.com/users/alimanfoo/followers","following_url":"https://api.github.com/users/alimanfoo/following{/other_user}","gists_url":"https://api.github.com/users/alimanfoo/gists{/gist_id}","starred_url":"https://api.github.com/users/alimanfoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alimanfoo/subscriptions","organizations_url":"https://api.github.com/users/alimanfoo/orgs","repos_url":"https://api.github.com/users/alimanfoo/repos","events_url":"https://api.github.com/users/alimanfoo/events{/privacy}","received_events_url":"https://api.github.com/users/alimanfoo/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":21,"state":"open","created_at":"2018-03-29T21:38:12Z","updated_at":"2018-12-10T15:17:20Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2018-11-21T16:19:11Z","updated_at":"2018-12-10T15:17:20Z","closed_at":"2018-12-10T15:17:19Z","author_association":"NONE","body":"#### Code sample\r\n\r\n```python\r\nimport zarr\r\nimport numpy as np\r\n\r\nz = zarr.full(dtype='m8[s]', \r\n              fill_value=np.timedelta64('nat'), \r\n              shape=10)\r\n```\r\nraises\r\n\r\n```\r\nOverflowError: int too big to convert\r\nThe above exception was the direct cause of the following exception:\r\nTraceback (most recent call last):\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/meta.py\", line 38, in decode_array_metadata\r\n    fill_value = decode_fill_value(meta['fill_value'], dtype)\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/meta.py\", line 159, in decode_fill_value\r\n    return np.array(v, dtype=dtype)[()]\r\nSystemError: <built-in function array> returned a result with an error set\r\nDuring handling of the above exception, another exception occurred:\r\nTraceback (most recent call last):\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py\", line 2963, in run_code\r\n    exec(code_obj, self.user_global_ns, self.user_ns)\r\n  File \"<ipython-input-156-d1f331fc15fd>\", line 6, in <module>\r\n    shape=10)\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/creation.py\", line 274, in full\r\n    return create(shape=shape, fill_value=fill_value, **kwargs)\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/creation.py\", line 123, in create\r\n    cache_metadata=cache_metadata, cache_attrs=cache_attrs, read_only=read_only)\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/core.py\", line 123, in __init__\r\n    self._load_metadata()\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/core.py\", line 140, in _load_metadata\r\n    self._load_metadata_nosync()\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/core.py\", line 155, in _load_metadata_nosync\r\n    meta = decode_array_metadata(meta_bytes)\r\n  File \"/home/tom/anaconda3/lib/python3.6/site-packages/zarr/meta.py\", line 50, in decode_array_metadata\r\n    raise MetadataError('error decoding metadata: %s' % e)\r\nzarr.errors.MetadataError: error decoding metadata: <built-in function array> returned a result with an error set\r\n```\r\n\r\n#### Analysis\r\nI think the serialization method for mM types does not allow to unserialize properly Not a Time fill values.\r\n\r\n```\r\nnp.array(int(np.datetime64('nat').view('u8')), dtype='M8[D]')[()]\r\n```\r\n\r\n#### Resolution\r\n\r\nIn `meta.py / encode_fill_value`:\r\n\r\n```\r\n    elif dtype.kind in 'mM':\r\n        if np.isnat(v):\r\n            return 'NaT'\r\n        else:\r\n            return int(v.view('u8'))\r\n```"}}
{"actor":{"display_login":"jakirkham"}}