home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 96085330

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/pull/401#issuecomment-96085330 https://api.github.com/repos/pydata/xarray/issues/401 96085330 MDEyOklzc3VlQ29tbWVudDk2MDg1MzMw 1217238 2015-04-24T22:34:15Z 2015-04-24T22:34:15Z MEMBER

This seems like a pragmatic choice -- but I agree, it's unfortunate that we can't roundtrip this faithfully.

One option would be to add the attribute dtype with the value 'bool' to the netCDF variable, and then teach xray to interpret that attribute when loading data. We already do some pretty similar things to handle datetime64 variables according to the CF conventions. If you're interested in doing this, the right place to put this would be conventions.py: https://github.com/xray/xray/blob/eed58d5cb4274f262e77277bc8fcf394a9fae77c/xray/conventions.py#L632 (for decode, put decoding dtypes after decoding times at the bottom) https://github.com/xray/xray/blob/eed58d5cb4274f262e77277bc8fcf394a9fae77c/xray/conventions.py#L603 (for encoding, write another little helper function and call it at the bottom here)

The other advantage of putting this in conventions is that then it works with all netCDF backends (including scipy and h5netcdf).

Also, this definitely needs tests :). This could be as simple as verifying that it works to roundtrip a Dataset with boolean data to disk and back. Here's an example of what those look like: https://github.com/xray/xray/blob/eed58d5cb4274f262e77277bc8fcf394a9fae77c/xray/test/test_backends.py#L156

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