home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

101 rows where author_association = "CONTRIBUTOR" and user = 4806877 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: issue_url, reactions, created_at (date), updated_at (date)

issue 25

  • Html repr 25
  • added to_dict function for xarray objects 11
  • Adding data kwarg to copy to create new objects with same structure as original 9
  • Make `dim` optional on unstack 7
  • Include filename or path in open_mfdataset 7
  • expanded HTML repr when opening notebook 7
  • Adding mask to open_rasterio 6
  • jupyterlab dark theme 5
  • Tools for converting between xray.Dataset and nested dictionaries/JSON 3
  • WIP: html repr 3
  • Clarify difference between `.load()` and `.compute()` 3
  • upstream-dev CI fails on import of dask.array 2
  • catch numpy arrays in attrs before converting to dict 1
  • Rasterio missing _FillValue in DataArray 1
  • Escaping dtypes 1
  • Add entrypoint for plotting backends 1
  • Turn on html repr by default 1
  • provide set_option `collapse_html` to control HTML repr collapsed state 1
  • xr.DataArray.from_dask_dataframe feature 1
  • Extracting `formatting_html` as a standalone library? 1
  • Fix lag in Jupyter caused by CSS in `_repr_html_` 1
  • Raise an error if you pass an invalid key in `chunks` 1
  • bad conda solve with pandas 2 1
  • `pandas=2.0` support 1
  • Continue to use nanosecond-precision Timestamps in precision-sensitive areas 1

user 1

  • jsignell · 101 ✖

author_association 1

  • CONTRIBUTOR · 101 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1503671262 https://github.com/pydata/xarray/pull/7724#issuecomment-1503671262 https://api.github.com/repos/pydata/xarray/issues/7724 IC_kwDOAMm_X85ZoDPe jsignell 4806877 2023-04-11T15:58:48Z 2023-04-11T15:58:48Z CONTRIBUTOR

Is there anything I can do to help out on this? It sounds like the blocker is mypy?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  `pandas=2.0` support 1655782486
1499079927 https://github.com/pydata/xarray/pull/7731#issuecomment-1499079927 https://api.github.com/repos/pydata/xarray/issues/7731 IC_kwDOAMm_X85ZWiT3 jsignell 4806877 2023-04-06T13:38:38Z 2023-04-06T13:38:38Z CONTRIBUTOR

to properly test this, I guess we'd need to merge #7724 first?

Otherwise the env in the upstream test will never solve right?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Continue to use nanosecond-precision Timestamps in precision-sensitive areas 1657396474
1498164858 https://github.com/pydata/xarray/issues/7716#issuecomment-1498164858 https://api.github.com/repos/pydata/xarray/issues/7716 IC_kwDOAMm_X85ZTC56 jsignell 4806877 2023-04-05T21:09:59Z 2023-04-05T21:09:59Z CONTRIBUTOR

In that case it could be reasonable to mimic the pattern in test_groupby and mark the failing tests with a @pytest.mark.skipif(not has_pandas_version_two, reason="Tests a scenario that only raises when pandas <= 2")

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  bad conda solve with pandas 2 1654022522
1398534837 https://github.com/pydata/xarray/pull/4659#issuecomment-1398534837 https://api.github.com/repos/pydata/xarray/issues/4659 IC_kwDOAMm_X85TW_K1 jsignell 4806877 2023-01-20T15:11:13Z 2023-01-20T15:11:13Z CONTRIBUTOR

My understanding is that indexes have come a long way since this PR was last touched. Maybe now is the right time to rewrite this in a way that is more performant?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xr.DataArray.from_dask_dataframe feature 758606082
1197325700 https://github.com/pydata/xarray/issues/6837#issuecomment-1197325700 https://api.github.com/repos/pydata/xarray/issues/6837 IC_kwDOAMm_X85HXb2E jsignell 4806877 2022-07-27T20:21:36Z 2022-07-27T20:21:36Z CONTRIBUTOR

I should say that there might very well be other uses of load that I am not aware of. The inplace vs not is just the only difference that I noticed in the context of dask-backed xarray objects.

From this discussion I think for dask-backed objects we should recommend using compute. Maybe that is enough of a decision.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Clarify difference between `.load()` and `.compute()` 1319621859
1197078424 https://github.com/pydata/xarray/issues/6837#issuecomment-1197078424 https://api.github.com/repos/pydata/xarray/issues/6837 IC_kwDOAMm_X85HWfeY jsignell 4806877 2022-07-27T17:27:43Z 2022-07-27T17:27:43Z CONTRIBUTOR

I can imagine a scenario where load is de-emphasized in the narrative docs, and compute is used instead. It wouldn't have to be a formal deprecation, but it could be that compute is best practice.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Clarify difference between `.load()` and `.compute()` 1319621859
1196874535 https://github.com/pydata/xarray/issues/6837#issuecomment-1196874535 https://api.github.com/repos/pydata/xarray/issues/6837 IC_kwDOAMm_X85HVtsn jsignell 4806877 2022-07-27T15:00:43Z 2022-07-27T15:00:43Z CONTRIBUTOR

Thanks for engaging with this! I think removing load probably makes the most sense. Making load an alias for compute would just continue the confusion since there wouldn't be a clear right way to do things.

I somehow assumed compute would only work with dask while load would also load our lazy array implementation into memory. Not sure how I got that impression, but maybe that's another argument to remove / align load?

I'm not quite sure I follow. Are there lazy array implementations other than dask in xarray?

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Clarify difference between `.load()` and `.compute()` 1319621859
1186318422 https://github.com/pydata/xarray/pull/6792#issuecomment-1186318422 https://api.github.com/repos/pydata/xarray/issues/6792 IC_kwDOAMm_X85GtchW jsignell 4806877 2022-07-16T22:58:06Z 2022-07-16T22:58:06Z CONTRIBUTOR

I think this might break open_mfdataset where some dimensions only exist in some files but we want to chunk along them

ah. So maybe there isn't anything interesting to do here? It's not very important.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Raise an error if you pass an invalid key in `chunks` 1306543211
927892524 https://github.com/pydata/xarray/pull/3640#issuecomment-927892524 https://api.github.com/repos/pydata/xarray/issues/3640 IC_kwDOAMm_X843ToQs jsignell 4806877 2021-09-27T13:48:08Z 2021-09-27T13:48:08Z CONTRIBUTOR

I'm sorry I missed pings on this. I am happy to join the dev meeting if that'd be helpful or I can just start paying better attention :roll_eyes:

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Add entrypoint for plotting backends 539394615
867648515 https://github.com/pydata/xarray/pull/2618#issuecomment-867648515 https://api.github.com/repos/pydata/xarray/issues/2618 MDEyOklzc3VlQ29tbWVudDg2NzY0ODUxNQ== jsignell 4806877 2021-06-24T13:44:33Z 2021-06-24T13:44:33Z CONTRIBUTOR

I'm fine with this being closed. TBH I had totally forgotten about it :grimacing:

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding mask to open_rasterio 392361367
824848681 https://github.com/pydata/xarray/pull/5201#issuecomment-824848681 https://api.github.com/repos/pydata/xarray/issues/5201 MDEyOklzc3VlQ29tbWVudDgyNDg0ODY4MQ== jsignell 4806877 2021-04-22T13:37:08Z 2021-04-22T13:37:08Z CONTRIBUTOR

I didn't manage to reproduce the lag, but this change seems totally reasonable to me!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Fix lag in Jupyter caused by CSS in `_repr_html_` 863506023
796749794 https://github.com/pydata/xarray/issues/5022#issuecomment-796749794 https://api.github.com/repos/pydata/xarray/issues/5022 MDEyOklzc3VlQ29tbWVudDc5Njc0OTc5NA== jsignell 4806877 2021-03-11T13:51:37Z 2021-03-11T13:51:37Z CONTRIBUTOR

I'm glad you like it! @benbovy really did all the work on writing it. I think there was some talk of extracting it to a separate library, but I'm not sure if it was obvious how to generalize it. It depends whether you would want it to be a standalone library (like pprint) or whether you'd want the libraries to integrate with it (probably using entrypoints).

I would start by thinking about one or two other classes that you'd like to see represented this way and try to see how well what currently exists generalizes.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Extracting `formatting_html` as a standalone library? 828805728
661877612 https://github.com/pydata/xarray/pull/4230#issuecomment-661877612 https://api.github.com/repos/pydata/xarray/issues/4230 MDEyOklzc3VlQ29tbWVudDY2MTg3NzYxMg== jsignell 4806877 2020-07-21T13:57:19Z 2020-07-21T13:57:29Z CONTRIBUTOR

I'm looking at the relevant test function:

python def test_repr_of_dataarray(dataarray): formatted = fh.array_repr(dataarray) assert "dim_0" in formatted # has an expanded data section assert formatted.count("class='xr-array-in' type='checkbox' checked>") == 1 # coords and attrs don't have an items so they'll be be disabled and collapsed assert ( formatted.count("class='xr-section-summary-in' type='checkbox' disabled >") == 2 )

does this only check on the number of collapsed sections?

Yes, that test counts expanded data sections and collapsed summary sections

How could I check specifically if the data section is collapsed based on the OPTION setting?

Use set_option as a context manager and do a test much like the one above.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  provide set_option `collapse_html` to control HTML repr collapsed state 657792526
641587033 https://github.com/pydata/xarray/issues/4124#issuecomment-641587033 https://api.github.com/repos/pydata/xarray/issues/4124 MDEyOklzc3VlQ29tbWVudDY0MTU4NzAzMw== jsignell 4806877 2020-06-09T21:18:42Z 2020-06-09T21:18:42Z CONTRIBUTOR

I think dask is going to release today.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  upstream-dev CI fails on import of dask.array 631860723
640703229 https://github.com/pydata/xarray/issues/4124#issuecomment-640703229 https://api.github.com/repos/pydata/xarray/issues/4124 MDEyOklzc3VlQ29tbWVudDY0MDcwMzIyOQ== jsignell 4806877 2020-06-08T15:30:55Z 2020-06-08T15:31:18Z CONTRIBUTOR

Working on a fix now. I think https://github.com/dask/dask/pull/6299 should do it.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  upstream-dev CI fails on import of dask.array 631860723
626905024 https://github.com/pydata/xarray/issues/4041#issuecomment-626905024 https://api.github.com/repos/pydata/xarray/issues/4041 MDEyOklzc3VlQ29tbWVudDYyNjkwNTAyNA== jsignell 4806877 2020-05-11T19:19:51Z 2020-05-11T19:19:51Z CONTRIBUTOR

Yes that seems like the explanation. Thanks @benbovy! I would expect dask to have the same behavior then since they pass in the style tag in the same way.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  expanded HTML repr when opening notebook 613579881
626869393 https://github.com/pydata/xarray/issues/4041#issuecomment-626869393 https://api.github.com/repos/pydata/xarray/issues/4041 MDEyOklzc3VlQ29tbWVudDYyNjg2OTM5Mw== jsignell 4806877 2020-05-11T18:16:36Z 2020-05-11T18:16:36Z CONTRIBUTOR

Hmm. Ok. I'm still not sure why the html would get messed up under that scenario though.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  expanded HTML repr when opening notebook 613579881
626860177 https://github.com/pydata/xarray/issues/4041#issuecomment-626860177 https://api.github.com/repos/pydata/xarray/issues/4041 MDEyOklzc3VlQ29tbWVudDYyNjg2MDE3Nw== jsignell 4806877 2020-05-11T17:59:49Z 2020-05-11T17:59:49Z CONTRIBUTOR

Does it seem possible that you had originally run it in jlab and then opened it in notebook or vice versa? I've seen html output get kind of messed up under those conditions, but I've never really stopped to debug it thoroughly.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  expanded HTML repr when opening notebook 613579881
626848249 https://github.com/pydata/xarray/issues/4041#issuecomment-626848249 https://api.github.com/repos/pydata/xarray/issues/4041 MDEyOklzc3VlQ29tbWVudDYyNjg0ODI0OQ== jsignell 4806877 2020-05-11T17:39:12Z 2020-05-11T17:39:12Z CONTRIBUTOR

It seems like the auto-update thing works for css, but not for icons.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  expanded HTML repr when opening notebook 613579881
626846717 https://github.com/pydata/xarray/issues/4041#issuecomment-626846717 https://api.github.com/repos/pydata/xarray/issues/4041 MDEyOklzc3VlQ29tbWVudDYyNjg0NjcxNw== jsignell 4806877 2020-05-11T17:36:33Z 2020-05-11T17:36:33Z CONTRIBUTOR

Huh and if you re-run cell 69 does it render correctly? I'm on chrome 80, but if you were seeing this in firefox as well it seems like it's more likely to be a jupyterlab thing.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  expanded HTML repr when opening notebook 613579881
626721909 https://github.com/pydata/xarray/issues/4041#issuecomment-626721909 https://api.github.com/repos/pydata/xarray/issues/4041 MDEyOklzc3VlQ29tbWVudDYyNjcyMTkwOQ== jsignell 4806877 2020-05-11T14:04:31Z 2020-05-11T14:04:31Z CONTRIBUTOR

I can't reproduce:

Tried on chrome and firefox on linux. Can you inspect the element in your browser console and see if there is a <style></style> section for the repr? It seems like that might not be getting in properly

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  expanded HTML repr when opening notebook 613579881
626712595 https://github.com/pydata/xarray/issues/4041#issuecomment-626712595 https://api.github.com/repos/pydata/xarray/issues/4041 MDEyOklzc3VlQ29tbWVudDYyNjcxMjU5NQ== jsignell 4806877 2020-05-11T13:47:44Z 2020-05-11T13:47:44Z CONTRIBUTOR

Yeah I can take a look now.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  expanded HTML repr when opening notebook 613579881
593620505 https://github.com/pydata/xarray/pull/3812#issuecomment-593620505 https://api.github.com/repos/pydata/xarray/issues/3812 MDEyOklzc3VlQ29tbWVudDU5MzYyMDUwNQ== jsignell 4806877 2020-03-02T21:03:58Z 2020-03-02T21:03:58Z CONTRIBUTOR

I am fairly confident that the failures are not related to the changes in this PR

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Turn on html repr by default 573007307
547153085 https://github.com/pydata/xarray/pull/3443#issuecomment-547153085 https://api.github.com/repos/pydata/xarray/issues/3443 MDEyOklzc3VlQ29tbWVudDU0NzE1MzA4NQ== jsignell 4806877 2019-10-28T21:25:57Z 2019-10-28T21:25:57Z CONTRIBUTOR

Is this ready to merge?

Yeah I think so.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  jupyterlab dark theme 512071129
547152981 https://github.com/pydata/xarray/pull/3443#issuecomment-547152981 https://api.github.com/repos/pydata/xarray/issues/3443 MDEyOklzc3VlQ29tbWVudDU0NzE1Mjk4MQ== jsignell 4806877 2019-10-28T21:25:41Z 2019-10-28T21:25:41Z CONTRIBUTOR

Right I don't think jlab works in IE. But this won't work in regular notebook in IE either.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  jupyterlab dark theme 512071129
546475647 https://github.com/pydata/xarray/pull/3443#issuecomment-546475647 https://api.github.com/repos/pydata/xarray/issues/3443 MDEyOklzc3VlQ29tbWVudDU0NjQ3NTY0Nw== jsignell 4806877 2019-10-25T19:06:51Z 2019-10-25T19:06:51Z CONTRIBUTOR

I don't really like the hover-background anyways if those rows aren't clickable and other things are.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  jupyterlab dark theme 512071129
546114316 https://github.com/pydata/xarray/pull/3444#issuecomment-546114316 https://api.github.com/repos/pydata/xarray/issues/3444 MDEyOklzc3VlQ29tbWVudDU0NjExNDMxNg== jsignell 4806877 2019-10-24T21:38:42Z 2019-10-24T21:38:42Z CONTRIBUTOR

I think this can be merged as is.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Escaping dtypes 512162755
546089446 https://github.com/pydata/xarray/pull/3425#issuecomment-546089446 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NjA4OTQ0Ng== jsignell 4806877 2019-10-24T20:29:22Z 2019-10-24T20:29:22Z CONTRIBUTOR

Besides variable names, we probably need to somehow handle overflow for variables that have a long list of dimension labels.

These are handled in the same way as long variable names, they truncate with an ellipsis and then expand on hover.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
546088350 https://github.com/pydata/xarray/pull/3425#issuecomment-546088350 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NjA4ODM1MA== jsignell 4806877 2019-10-24T20:26:17Z 2019-10-24T20:26:17Z CONTRIBUTOR

I opened a PR and included a small test. It can probably go in while we work on a more complete testing infrastructure.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
546082146 https://github.com/pydata/xarray/pull/3425#issuecomment-546082146 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NjA4MjE0Ng== jsignell 4806877 2019-10-24T20:09:44Z 2019-10-24T20:09:44Z CONTRIBUTOR

I looks like we'll need to fix a couple of issues (the channel coordinate looks weird), but maybe it is not related to the front-end.

I am opening a PR. I didn't escape dtypes and this dtype is <U5 which html does terribly with

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
546023436 https://github.com/pydata/xarray/pull/3443#issuecomment-546023436 https://api.github.com/repos/pydata/xarray/issues/3443 MDEyOklzc3VlQ29tbWVudDU0NjAyMzQzNg== jsignell 4806877 2019-10-24T17:35:03Z 2019-10-24T17:35:03Z CONTRIBUTOR

@benbovy in case you have ideas about which colors to use.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  jupyterlab dark theme 512071129
546018788 https://github.com/pydata/xarray/pull/3443#issuecomment-546018788 https://api.github.com/repos/pydata/xarray/issues/3443 MDEyOklzc3VlQ29tbWVudDU0NjAxODc4OA== jsignell 4806877 2019-10-24T17:22:46Z 2019-10-24T17:22:46Z CONTRIBUTOR

Note that this won't work in IE https://caniuse.com/#feat=css-variables

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  jupyterlab dark theme 512071129
546004493 https://github.com/pydata/xarray/pull/3425#issuecomment-546004493 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NjAwNDQ5Mw== jsignell 4806877 2019-10-24T16:44:55Z 2019-10-24T16:44:55Z CONTRIBUTOR

It isn't too hard to get it working with dark theme, but requires slight tweaks to the colors to align with those provided as vars by jlab.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545986160 https://github.com/pydata/xarray/pull/3425#issuecomment-545986160 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTk4NjE2MA== jsignell 4806877 2019-10-24T15:59:31Z 2019-10-24T15:59:31Z CONTRIBUTOR

Ok I think it's fixed now

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545979852 https://github.com/pydata/xarray/pull/3425#issuecomment-545979852 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTk3OTg1Mg== jsignell 4806877 2019-10-24T15:45:19Z 2019-10-24T15:45:19Z CONTRIBUTOR

I'm on 1.1.4 in chrome. Let me check firefox

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545978093 https://github.com/pydata/xarray/pull/3425#issuecomment-545978093 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTk3ODA5Mw== jsignell 4806877 2019-10-24T15:41:17Z 2019-10-24T15:41:17Z CONTRIBUTOR

Yeah to make it work with the dark theme we'll need to use the jlab css variables I imagine. I think it can be merged with dark mode not supported.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545977030 https://github.com/pydata/xarray/pull/3425#issuecomment-545977030 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTk3NzAzMA== jsignell 4806877 2019-10-24T15:38:48Z 2019-10-24T15:38:48Z CONTRIBUTOR

Fixed the jlab alignment issue. The issue was that jlab has different default css.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545973962 https://github.com/pydata/xarray/pull/3425#issuecomment-545973962 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTk3Mzk2Mg== jsignell 4806877 2019-10-24T15:32:08Z 2019-10-24T15:32:08Z CONTRIBUTOR

I've noticed an issue with the alignment of attributes in jupyterlab (1.1.4) (Firefox 69.0.3):

I'm taking a look at the jlab css.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545928015 https://github.com/pydata/xarray/pull/3425#issuecomment-545928015 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTkyODAxNQ== jsignell 4806877 2019-10-24T13:51:45Z 2019-10-24T13:51:45Z CONTRIBUTOR

@benbovy just to make double sure, you are happy with this new feature being off by default right?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545916227 https://github.com/pydata/xarray/pull/3425#issuecomment-545916227 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTkxNjIyNw== jsignell 4806877 2019-10-24T13:24:45Z 2019-10-24T13:24:45Z CONTRIBUTOR

So maybe one more rebase will do it?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545648937 https://github.com/pydata/xarray/pull/3425#issuecomment-545648937 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTY0ODkzNw== jsignell 4806877 2019-10-23T21:43:02Z 2019-10-23T21:43:02Z CONTRIBUTOR

Well, I rebased. Hopefully it'll pass now. I consider this done unless someone wants more docs or more tests.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545647958 https://github.com/pydata/xarray/pull/3425#issuecomment-545647958 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTY0Nzk1OA== jsignell 4806877 2019-10-23T21:39:52Z 2019-10-23T21:39:52Z CONTRIBUTOR

I am 90% sure this failure is unrelated. Maybe I should rebase now that #3436 has landed?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545637867 https://github.com/pydata/xarray/pull/3425#issuecomment-545637867 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTYzNzg2Nw== jsignell 4806877 2019-10-23T21:10:33Z 2019-10-23T21:10:33Z CONTRIBUTOR

Oh. The dask version in ci doesn't have _repr_html_. I'll add a version checker to the test.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545605598 https://github.com/pydata/xarray/pull/3425#issuecomment-545605598 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTYwNTU5OA== jsignell 4806877 2019-10-23T19:43:54Z 2019-10-23T19:43:54Z CONTRIBUTOR

Otherwise I think all that is left is adding docs. Also I want to confirm that this should be an experimental feature (off by default).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545597657 https://github.com/pydata/xarray/pull/3425#issuecomment-545597657 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTU5NzY1Nw== jsignell 4806877 2019-10-23T19:23:16Z 2019-10-23T19:23:16Z CONTRIBUTOR

I added some tests. I can add more if anyone has a test case that they want to be sure is covered.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545545019 https://github.com/pydata/xarray/pull/3425#issuecomment-545545019 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTU0NTAxOQ== jsignell 4806877 2019-10-23T17:11:51Z 2019-10-23T17:11:51Z CONTRIBUTOR

Ok I am going to write some tests now. I updated the gist. Do people like the names "classic" and "html" for the display_style options? Another option would be "classic" and "rich".

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545542947 https://github.com/pydata/xarray/pull/3425#issuecomment-545542947 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTU0Mjk0Nw== jsignell 4806877 2019-10-23T17:07:33Z 2019-10-23T17:08:56Z CONTRIBUTOR

~~Oh I was looking at bytes not len.~~ I didn't have .encode('utf8')

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545539785 https://github.com/pydata/xarray/pull/3425#issuecomment-545539785 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTUzOTc4NQ== jsignell 4806877 2019-10-23T16:59:38Z 2019-10-23T16:59:38Z CONTRIBUTOR

I'm still worried about size, but minifying the css and even minifying the html did not make a big difference. It looks like the html_repr for rasm is 38kb .

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545177297 https://github.com/pydata/xarray/pull/3425#issuecomment-545177297 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTE3NzI5Nw== jsignell 4806877 2019-10-22T22:08:49Z 2019-10-22T22:08:49Z CONTRIBUTOR

Ok I think I've addressed all the comments. I just updated the gist with the latest output. Tomorrow I'll start adding tests. The css is now ~300 lines and it gets injected everytime the dataset is rendered. I'm not sure if that is considered too long and if it is I don't quite know what to do about it.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
545074728 https://github.com/pydata/xarray/pull/3425#issuecomment-545074728 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NTA3NDcyOA== jsignell 4806877 2019-10-22T17:42:03Z 2019-10-22T17:42:03Z CONTRIBUTOR

Is there ever a situation in which dimensions would be expandable? It seems like it is hard-coded to collapsed.

I am trying to generalize the css to reduce the length.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
544980677 https://github.com/pydata/xarray/pull/3425#issuecomment-544980677 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NDk4MDY3Nw== jsignell 4806877 2019-10-22T14:08:00Z 2019-10-22T14:08:00Z CONTRIBUTOR

I just updated the gist with these changes: - got rid of alternating data colors in preview - fixed icon alignment in row, and rest of data in row - got rid of some not-useful spans - changed from underline to bold for index coords

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
544957163 https://github.com/pydata/xarray/pull/3425#issuecomment-544957163 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NDk1NzE2Mw== jsignell 4806877 2019-10-22T13:17:28Z 2019-10-22T13:17:28Z CONTRIBUTOR

Yeah the data preview is also shifted vertically.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
544768411 https://github.com/pydata/xarray/pull/3425#issuecomment-544768411 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NDc2ODQxMQ== jsignell 4806877 2019-10-22T01:01:22Z 2019-10-22T01:01:22Z CONTRIBUTOR

Yeah I agree that is a strange part of the original PR. The version in the fiddle doesn't do that, so I'd really like to hear back from @benbovy about whether the fiddle css is more uptodate.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
544731859 https://github.com/pydata/xarray/pull/3425#issuecomment-544731859 https://api.github.com/repos/pydata/xarray/issues/3425 MDEyOklzc3VlQ29tbWVudDU0NDczMTg1OQ== jsignell 4806877 2019-10-21T22:18:14Z 2019-10-21T22:18:14Z CONTRIBUTOR

I don't really like how the attrs look without the alignment of keys and values. I will think about how to make that more legible

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Html repr 510294810
544676254 https://github.com/pydata/xarray/pull/1820#issuecomment-544676254 https://api.github.com/repos/pydata/xarray/issues/1820 MDEyOklzc3VlQ29tbWVudDU0NDY3NjI1NA== jsignell 4806877 2019-10-21T19:44:52Z 2019-10-21T19:44:52Z CONTRIBUTOR

The last fiddle and this PR seem fairly different. Does the fiddle have the most up-to-date hierarchy or is it just somewhere where people were playing around with ideas (in which case I should see what is improved and try to pull those bits of css)?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  WIP: html repr 287844110
543363463 https://github.com/pydata/xarray/pull/1820#issuecomment-543363463 https://api.github.com/repos/pydata/xarray/issues/1820 MDEyOklzc3VlQ29tbWVudDU0MzM2MzQ2Mw== jsignell 4806877 2019-10-17T21:10:56Z 2019-10-17T21:10:56Z CONTRIBUTOR

Ok thanks! I'll get cracking :)

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  WIP: html repr 287844110
542766063 https://github.com/pydata/xarray/pull/1820#issuecomment-542766063 https://api.github.com/repos/pydata/xarray/issues/1820 MDEyOklzc3VlQ29tbWVudDU0Mjc2NjA2Mw== jsignell 4806877 2019-10-16T15:45:56Z 2019-10-16T15:45:56Z CONTRIBUTOR

Is there anything that I can do to help get this PR in? Are the items on the TODO list prioritized? One minor comment is that in terms of style for overflow, it might be more legible if the var_names were bolded on hover (fiddle), although that might make them look clickable.

{
    "total_count": 4,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 4,
    "rocket": 0,
    "eyes": 0
}
  WIP: html repr 287844110
487052582 https://github.com/pydata/xarray/pull/2618#issuecomment-487052582 https://api.github.com/repos/pydata/xarray/issues/2618 MDEyOklzc3VlQ29tbWVudDQ4NzA1MjU4Mg== jsignell 4806877 2019-04-26T13:15:40Z 2019-04-26T13:15:40Z CONTRIBUTOR

I think it would be good to write the dataset to a netcdf, and read it back in with xarray.open_dataset to ensure everything encodes/decides properly.

Do you mean write a test to do this, or just check it locally?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding mask to open_rasterio 392361367
487046879 https://github.com/pydata/xarray/pull/2618#issuecomment-487046879 https://api.github.com/repos/pydata/xarray/issues/2618 MDEyOklzc3VlQ29tbWVudDQ4NzA0Njg3OQ== jsignell 4806877 2019-04-26T12:56:10Z 2019-04-26T12:56:10Z CONTRIBUTOR

Yeah I have some time to finish it up. Looking back at it now it seems like masked would be a better kwarg for open_rasterio. Is there anything else that should be changed?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding mask to open_rasterio 392361367
448641329 https://github.com/pydata/xarray/pull/2618#issuecomment-448641329 https://api.github.com/repos/pydata/xarray/issues/2618 MDEyOklzc3VlQ29tbWVudDQ0ODY0MTMyOQ== jsignell 4806877 2018-12-19T15:45:04Z 2018-12-19T15:45:04Z CONTRIBUTOR

I did as @snowman2 suggested but filled the mask with nans at the end. Since it is now using rasterio directly this should address @fmaussion's concern about nodata (which I think was ending up in the nodatavals attr anyways). I also moved the nodatavals from attrs to encoding when mask==True, but I didn't set it to true by default since I didn't want to break backwards compatibility.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding mask to open_rasterio 392361367
448633729 https://github.com/pydata/xarray/pull/2618#issuecomment-448633729 https://api.github.com/repos/pydata/xarray/issues/2618 MDEyOklzc3VlQ29tbWVudDQ0ODYzMzcyOQ== jsignell 4806877 2018-12-19T15:24:28Z 2018-12-19T15:24:28Z CONTRIBUTOR

Hmm. Do we really want a np.masked_array or do we just want an array with np.Nans in it? I prefer nans, but I guess the downside is type conversion for ints?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding mask to open_rasterio 392361367
448629146 https://github.com/pydata/xarray/pull/2618#issuecomment-448629146 https://api.github.com/repos/pydata/xarray/issues/2618 MDEyOklzc3VlQ29tbWVudDQ0ODYyOTE0Ng== jsignell 4806877 2018-12-19T15:11:49Z 2018-12-19T15:11:49Z CONTRIBUTOR

I was wondering if we should just pass the mask option to rasterio like that. I'll try it out.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding mask to open_rasterio 392361367
447882917 https://github.com/pydata/xarray/issues/1736#issuecomment-447882917 https://api.github.com/repos/pydata/xarray/issues/1736 MDEyOklzc3VlQ29tbWVudDQ0Nzg4MjkxNw== jsignell 4806877 2018-12-17T15:22:27Z 2018-12-17T15:22:27Z CONTRIBUTOR

Is there still interest in implementing the mask option as outlined in this issue?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Rasterio missing _FillValue in DataArray 276131376
440002135 https://github.com/pydata/xarray/issues/2550#issuecomment-440002135 https://api.github.com/repos/pydata/xarray/issues/2550 MDEyOklzc3VlQ29tbWVudDQ0MDAwMjEzNQ== jsignell 4806877 2018-11-19T18:53:27Z 2018-11-19T18:53:27Z CONTRIBUTOR

Having started writing a test, I now think that encoding['source'] is backend specific. Here it is implemented in netcdf4: https://github.com/pydata/xarray/blob/70e9eb8fc834e4aeff42c221c04c9713eb465b8a/xarray/backends/netCDF4_.py#L386 but I don't see it for pynio for instance: https://github.com/pydata/xarray/blob/70e9eb8fc834e4aeff42c221c04c9713eb465b8a/xarray/backends/pynio_.py#L77-L81

Is this something that we want to mandate that backends provide?

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Include filename or path in open_mfdataset 378898407
439913493 https://github.com/pydata/xarray/issues/2550#issuecomment-439913493 https://api.github.com/repos/pydata/xarray/issues/2550 MDEyOklzc3VlQ29tbWVudDQzOTkxMzQ5Mw== jsignell 4806877 2018-11-19T14:36:37Z 2018-11-19T14:36:37Z CONTRIBUTOR

Should I add a test that expects .encoding['source'] to ensure its continued presence?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Include filename or path in open_mfdataset 378898407
439742167 https://github.com/pydata/xarray/issues/2550#issuecomment-439742167 https://api.github.com/repos/pydata/xarray/issues/2550 MDEyOklzc3VlQ29tbWVudDQzOTc0MjE2Nw== jsignell 4806877 2018-11-19T00:52:03Z 2018-11-19T00:52:03Z CONTRIBUTOR

Ah I don't think I understood that adding source to encoding was a new addition. In latest master ('0.11.0+3.g70e9eb8) this works fine:

```python def func(ds): var = next(var for var in ds) return ds.assign(path=ds[var].encoding['source'])

ds = xr.open_mfdataset(['./air_1.nc', './air_2.nc'], concat_dim='path', preprocess=func) ```

I do think it is misleading though that after you've concatenated the data, the encoding['source'] on a concatenated var seems to be the first path.

```python

ds['air'].encoding['source'] '~/air_1.nc' ```

I'll close this one though since there is a clear way to access the filename. Thanks for the tip @jhamman!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Include filename or path in open_mfdataset 378898407
437464067 https://github.com/pydata/xarray/issues/2550#issuecomment-437464067 https://api.github.com/repos/pydata/xarray/issues/2550 MDEyOklzc3VlQ29tbWVudDQzNzQ2NDA2Nw== jsignell 4806877 2018-11-09T19:11:38Z 2018-11-09T19:11:38Z CONTRIBUTOR

A dirty fix would be to add an attribute to each dataset.

I thought @jhamman was suggesting that already exists, but I couldn't find it: https://github.com/pydata/xarray/issues/2550#issuecomment-437157299

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Include filename or path in open_mfdataset 378898407
437433736 https://github.com/pydata/xarray/issues/2550#issuecomment-437433736 https://api.github.com/repos/pydata/xarray/issues/2550 MDEyOklzc3VlQ29tbWVudDQzNzQzMzczNg== jsignell 4806877 2018-11-09T17:29:05Z 2018-11-09T17:29:05Z CONTRIBUTOR

Maybe we can inspect the preprocess function like this:

```python

preprocess = lambda a, b: print(a, b) preprocess .code.co_varnames ('a', 'b') ```

This response is ordered, so the first one can always be ds regardless of its name and then we can look for special names (like filename) in the rest.

From this answer: https://stackoverflow.com/a/4051447/4021797

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Include filename or path in open_mfdataset 378898407
437161279 https://github.com/pydata/xarray/issues/2550#issuecomment-437161279 https://api.github.com/repos/pydata/xarray/issues/2550 MDEyOklzc3VlQ29tbWVudDQzNzE2MTI3OQ== jsignell 4806877 2018-11-08T21:24:45Z 2018-11-08T21:24:45Z CONTRIBUTOR

@jhamman that looks pretty good, but I'm not seeing the source in the encoding dict. Is this what you were expecting?

```python def func(ds): var = next(var for var in ds) return ds.assign(path=ds[var].encoding['source'])

xr.open_mfdataset(['./ST4.2018092500.01h', './ST4.2018092501.01h'], engine='pynio', concat_dim='path', preprocess=func) python-traceback


KeyError Traceback (most recent call last) <ipython-input-49-184da62ce353> in <module>() ----> 1 ds = xr.open_mfdataset(['./ST4.2018092500.01h', './ST4.2018092501.01h'], engine='pynio', concat_dim='path', preprocess=func)

/opt/conda/lib/python3.6/site-packages/xarray/backends/api.py in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, lock, data_vars, coords, autoclose, parallel, **kwargs) 612 file_objs = [getattr_(ds, '_file_obj') for ds in datasets] 613 if preprocess is not None: --> 614 datasets = [preprocess(ds) for ds in datasets] 615 616 if parallel:

/opt/conda/lib/python3.6/site-packages/xarray/backends/api.py in <listcomp>(.0) 612 file_objs = [getattr_(ds, '_file_obj') for ds in datasets] 613 if preprocess is not None: --> 614 datasets = [preprocess(ds) for ds in datasets] 615 616 if parallel:

<ipython-input-48-fd450fa1393a> in func(ds) 1 def func(ds): 2 var = next(var for var in ds) ----> 3 return ds.assign(path=ds[var].encoding['source'])

KeyError: 'source' ```

xarray version: '0.11.0+1.g575e97ae'

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Include filename or path in open_mfdataset 378898407
437156317 https://github.com/pydata/xarray/issues/2550#issuecomment-437156317 https://api.github.com/repos/pydata/xarray/issues/2550 MDEyOklzc3VlQ29tbWVudDQzNzE1NjMxNw== jsignell 4806877 2018-11-08T21:07:48Z 2018-11-08T21:07:48Z CONTRIBUTOR

There is a preprocess argument. You provide a function and it is run on every file.

Yes but the input to that function is just the ds, I couldn't figure out a way to get the filename from within a preprocess function. This is what I was doing to poke around in there:

```python def func(ds): import pdb; pdb.set_trace()

xr.open_mfdataset(['./ST4.2018092500.01h', './ST4.2018092501.01h'], engine='pynio', concat_dim='path', preprocess=func) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Include filename or path in open_mfdataset 378898407
422457576 https://github.com/pydata/xarray/pull/2384#issuecomment-422457576 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQyMjQ1NzU3Ng== jsignell 4806877 2018-09-18T16:19:30Z 2018-09-18T16:19:30Z CONTRIBUTOR

Is this good to go?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
421407370 https://github.com/pydata/xarray/pull/2384#issuecomment-421407370 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQyMTQwNzM3MA== jsignell 4806877 2018-09-14T16:09:54Z 2018-09-14T16:09:54Z CONTRIBUTOR

I added some examples on copy for each of the object types and I decided to let Datasets do this too. I just require that the user pass a dict where keys are contained in data_vars and each value has the same shape as the corresponding data_var.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
420626485 https://github.com/pydata/xarray/pull/2384#issuecomment-420626485 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQyMDYyNjQ4NQ== jsignell 4806877 2018-09-12T12:16:00Z 2018-09-12T12:16:00Z CONTRIBUTOR

I made the docs changes and added an example.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
420393391 https://github.com/pydata/xarray/pull/2384#issuecomment-420393391 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQyMDM5MzM5MQ== jsignell 4806877 2018-09-11T19:26:42Z 2018-09-11T19:26:42Z CONTRIBUTOR

I think this is good to merge

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
419486238 https://github.com/pydata/xarray/pull/2384#issuecomment-419486238 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQxOTQ4NjIzOA== jsignell 4806877 2018-09-07T16:01:31Z 2018-09-07T16:01:31Z CONTRIBUTOR

👍 for xarray.structured_like(new_data, template)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
419478223 https://github.com/pydata/xarray/pull/2384#issuecomment-419478223 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQxOTQ3ODIyMw== jsignell 4806877 2018-09-07T15:34:52Z 2018-09-07T15:34:52Z CONTRIBUTOR

That said. I think with_data is better than anything replace. I would worry about confusion with the pandas replace which replaces specific values.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
419477495 https://github.com/pydata/xarray/pull/2384#issuecomment-419477495 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQxOTQ3NzQ5NQ== jsignell 4806877 2018-09-07T15:32:22Z 2018-09-07T15:32:22Z CONTRIBUTOR

I don't like it being a method on an existing object. I think the syntax is clearer if the template object is an argument and the second argument is the data. I think that conveys the concept of creating a new object that is just using the structure of another object.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
419472466 https://github.com/pydata/xarray/pull/2384#issuecomment-419472466 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQxOTQ3MjQ2Ng== jsignell 4806877 2018-09-07T15:16:47Z 2018-09-07T15:16:47Z CONTRIBUTOR

Or what about xr.DataArray.like and xr.Variable.like? My main worry is that it kind of feels like these should return bools. Another option would be xr.DataArray.from_dataarray and xr.Variable.from_variable, but that is maybe also confusing...

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
419082605 https://github.com/pydata/xarray/pull/2384#issuecomment-419082605 https://api.github.com/repos/pydata/xarray/issues/2384 MDEyOklzc3VlQ29tbWVudDQxOTA4MjYwNQ== jsignell 4806877 2018-09-06T12:55:37Z 2018-09-06T12:55:37Z CONTRIBUTOR

Any thoughts on this one?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Adding data kwarg to copy to create new objects with same structure as original 354324342
417430252 https://github.com/pydata/xarray/pull/2375#issuecomment-417430252 https://api.github.com/repos/pydata/xarray/issues/2375 MDEyOklzc3VlQ29tbWVudDQxNzQzMDI1Mg== jsignell 4806877 2018-08-30T18:58:35Z 2018-08-30T18:58:35Z CONTRIBUTOR

Great! Thanks so much for all the feedback :)

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Make `dim` optional on unstack 352677925
415493314 https://github.com/pydata/xarray/pull/2375#issuecomment-415493314 https://api.github.com/repos/pydata/xarray/issues/2375 MDEyOklzc3VlQ29tbWVudDQxNTQ5MzMxNA== jsignell 4806877 2018-08-23T17:02:15Z 2018-08-23T17:02:15Z CONTRIBUTOR

Thanks for the context!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Make `dim` optional on unstack 352677925
415490818 https://github.com/pydata/xarray/pull/2375#issuecomment-415490818 https://api.github.com/repos/pydata/xarray/issues/2375 MDEyOklzc3VlQ29tbWVudDQxNTQ5MDgxOA== jsignell 4806877 2018-08-23T16:56:07Z 2018-08-23T16:56:07Z CONTRIBUTOR

I can change it. I guess I was looking at Dataset.transpose: https://github.com/pydata/xarray/blob/master/xarray/core/dataset.py#L2498

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Make `dim` optional on unstack 352677925
415473341 https://github.com/pydata/xarray/pull/2375#issuecomment-415473341 https://api.github.com/repos/pydata/xarray/issues/2375 MDEyOklzc3VlQ29tbWVudDQxNTQ3MzM0MQ== jsignell 4806877 2018-08-23T16:06:51Z 2018-08-23T16:06:51Z CONTRIBUTOR

I chose to use *dims rather than a list of dims so that this change will have a very small impact on people. Most people probably do something like unstack('z') right now, and that will still work.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Make `dim` optional on unstack 352677925
415437261 https://github.com/pydata/xarray/pull/2375#issuecomment-415437261 https://api.github.com/repos/pydata/xarray/issues/2375 MDEyOklzc3VlQ29tbWVudDQxNTQzNzI2MQ== jsignell 4806877 2018-08-23T14:29:01Z 2018-08-23T14:29:01Z CONTRIBUTOR

Ok so in this PR I will make unstack accept multiple dims like xr.DataFrame.unstack(*dims). The order of the dims will only be roundtripped if all dims are stacked into one, but I think that is reasonable.

In a follow on PR I will make xarray.label_like(array, other). I think that notation speaks more to what we are trying to convey, but I do think the position of the arguments isn't intuitive.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Make `dim` optional on unstack 352677925
415099271 https://github.com/pydata/xarray/pull/2375#issuecomment-415099271 https://api.github.com/repos/pydata/xarray/issues/2375 MDEyOklzc3VlQ29tbWVudDQxNTA5OTI3MQ== jsignell 4806877 2018-08-22T16:44:47Z 2018-08-22T17:46:24Z CONTRIBUTOR

we have similar method reset_index. Do we also want to make dim optional?

I don't have an opinion on that except to say that reset_index takes an iter of dims so it is at least slightly different. So to me it seems fine to only make dim optional on unstack.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Make `dim` optional on unstack 352677925
415053454 https://github.com/pydata/xarray/pull/2375#issuecomment-415053454 https://api.github.com/repos/pydata/xarray/issues/2375 MDEyOklzc3VlQ29tbWVudDQxNTA1MzQ1NA== jsignell 4806877 2018-08-22T14:32:51Z 2018-08-22T15:23:27Z CONTRIBUTOR

what should be done if DataArray or Dataset has multiple MultiIndexes. Maybe do we unstack all the MultiIndexes?

I like the idea of unstacking all the MultiIndexes, but in that case should we allow passing in multiple dims? It seems weird to do a recursive unstack in the case of no argument passed without allowing the user to specifically choose multiple dims along which to unstack.

I think it is probably better to just choose a default dim to unstack like this PR does. But maybe it is better to choose the first dim that is MultiIndex rather than the first dim. That way if you do a stack().unstack() you will roundtrip your data since the stacked index gets added to the end of dims. And if you just pass an object with one MultiIndex (probably the most common scenario) unstack will do the right thing. And if you pass an object with multiple MultiIndexes and unstack repeatedly, you will get your original data out.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Make `dim` optional on unstack 352677925
254875759 https://github.com/pydata/xarray/pull/1052#issuecomment-254875759 https://api.github.com/repos/pydata/xarray/issues/1052 MDEyOklzc3VlQ29tbWVudDI1NDg3NTc1OQ== jsignell 4806877 2016-10-19T17:01:15Z 2016-10-19T17:01:37Z CONTRIBUTOR

Are the names time_check and np_check specific enough for core/utils.py?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  catch numpy arrays in attrs before converting to dict 183792892
254304733 https://github.com/pydata/xarray/pull/917#issuecomment-254304733 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDI1NDMwNDczMw== jsignell 4806877 2016-10-17T19:15:16Z 2016-10-17T19:15:16Z CONTRIBUTOR

@shoyer is this something I should be working on? I am happy to, just don't know how this normally goes.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
254226023 https://github.com/pydata/xarray/pull/917#issuecomment-254226023 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDI1NDIyNjAyMw== jsignell 4806877 2016-10-17T14:37:15Z 2016-10-17T14:39:04Z CONTRIBUTOR

@shoyer that makes sense. @kwilcox, so times should be strings if decode_times=False? Should I do a new pull request?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
254220827 https://github.com/pydata/xarray/pull/917#issuecomment-254220827 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDI1NDIyMDgyNw== jsignell 4806877 2016-10-17T14:19:38Z 2016-10-17T14:20:16Z CONTRIBUTOR

@kwilcox, I hadn't thought much about this. I guess the intention was to have only python scalars/lists, but I don't know if we want to get in the business of converting attribute values since there are so many options for what they could be. What do you think makes the most sense?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
239262906 https://github.com/pydata/xarray/pull/917#issuecomment-239262906 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzOTI2MjkwNg== jsignell 4806877 2016-08-11T19:18:28Z 2016-08-11T19:18:28Z CONTRIBUTOR

Done!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
239252023 https://github.com/pydata/xarray/pull/917#issuecomment-239252023 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzOTI1MjAyMw== jsignell 4806877 2016-08-11T18:40:00Z 2016-08-11T18:40:00Z CONTRIBUTOR

I made the docs locally and they look how I expect.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
239185552 https://github.com/pydata/xarray/pull/917#issuecomment-239185552 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzOTE4NTU1Mg== jsignell 4806877 2016-08-11T14:52:52Z 2016-08-11T14:52:52Z CONTRIBUTOR

Ok, so I merged with the current master and added documentation and a what's-new note. I hope I did that right. @shoyer I am really new to contributing so thanks for all your help. Let me know if anything needs changing.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
238386033 https://github.com/pydata/xarray/pull/917#issuecomment-238386033 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzODM4NjAzMw== jsignell 4806877 2016-08-08T21:38:46Z 2016-08-08T21:38:46Z CONTRIBUTOR

Ok, I made the little changes. I will start working on the docs.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
236053258 https://github.com/pydata/xarray/pull/917#issuecomment-236053258 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzNjA1MzI1OA== jsignell 4806877 2016-07-28T23:18:45Z 2016-07-28T23:19:00Z CONTRIBUTOR

@shoyer I think I have done all the things that you mentioned and I added DataArray.from_dict().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
235694195 https://github.com/pydata/xarray/pull/917#issuecomment-235694195 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzNTY5NDE5NQ== jsignell 4806877 2016-07-27T19:30:49Z 2016-07-27T19:43:20Z CONTRIBUTOR

Ok, I made the changes that you suggested. I still need to work on the from_dict validation to prompt users to give more specific dicts.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
235575744 https://github.com/pydata/xarray/pull/917#issuecomment-235575744 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzNTU3NTc0NA== jsignell 4806877 2016-07-27T12:53:53Z 2016-07-27T14:50:13Z CONTRIBUTOR

Ok, I wrote a Dataset.from_dict class method. I imagine the DataArray one will look pretty similar, so I just wanted to see what you think. The main issue that I see is that time doesn't round trip. I wasn't sure if the user should need to set a parse_date flag with the dim name or something or whether the function should try to convert to time any dim with the string 'time' in it?

``` @classmethod def from_dict(cls, d): """ Convert a dictionary into an xarray.Dataset. """ obj = cls()

    dims=OrderedDict([(k, d['coords'][k]) for k in d['dims']])
    for dim, dim_d in dims.items():
        obj[dim] = (dim_d['dims'], dim_d['data'], dim_d['attrs'])

    for var, var_d in d['data_vars'].items():
        obj[var] = (var_d['dims'], var_d['data'], var_d['attrs'])

    # what it coords aren't dims?
    coords = (set(d['coords'].keys()) - set(d['dims']))
    for coord in coords:
        coord_d = d['coords'][coord]
        obj[coord] = (coord_d['dims'], coord_d['data'], coord_d['attrs'])
    obj = obj.set_coords(coords)

    obj.attrs.update(d['attrs'])

    return(obj)

```

Regarding unit tests, I haven't ever written one before but I would be happy to try (I know they are an important part of good development).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
235606954 https://github.com/pydata/xarray/pull/917#issuecomment-235606954 https://api.github.com/repos/pydata/xarray/issues/917 MDEyOklzc3VlQ29tbWVudDIzNTYwNjk1NA== jsignell 4806877 2016-07-27T14:42:12Z 2016-07-27T14:42:12Z CONTRIBUTOR

Ok, I have committed a first pass at unit tests. I purposefully wrote a failing time test.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  added to_dict function for xarray objects 167091064
234598308 https://github.com/pydata/xarray/issues/432#issuecomment-234598308 https://api.github.com/repos/pydata/xarray/issues/432 MDEyOklzc3VlQ29tbWVudDIzNDU5ODMwOA== jsignell 4806877 2016-07-22T17:00:29Z 2016-07-22T17:16:16Z CONTRIBUTOR

Ok. That makes sense. I added a function to common and submitted a pull request: #917

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Tools for converting between xray.Dataset and nested dictionaries/JSON 88075523
234540415 https://github.com/pydata/xarray/issues/432#issuecomment-234540415 https://api.github.com/repos/pydata/xarray/issues/432 MDEyOklzc3VlQ29tbWVudDIzNDU0MDQxNQ== jsignell 4806877 2016-07-22T13:14:43Z 2016-07-22T13:14:43Z CONTRIBUTOR

I agree.

.3. Couldn't this make the dict blow up for large datasets? Maybe there could be a flag that lets the user decide whether to leave the data in its current form (could use self.data in case it is a dask array) 6. The trouble with xarray.DataArray is that it doesn't require a name but it can have one. Is that something that we would want to preserve? If not, then maybe it would look more like this.

``` tolist=True

d = {'coords': {}, 'attrs': dict(self.attrs), 'dims': self.dims}

def func(x, tolist): if tolist: return x.tolist() return x

for k in self.coords: d['coords'].update({k: {'data': func(self[k].data, tolist), 'dims': list(self[k].dims), 'attrs': dict(self[k].attrs)}}) if hasattr(self, 'data_vars'): d.update({'data_vars': {}}) for k in self.data_vars: d['data_vars'].update({k: {'data': func(self[k].data, tolist), 'dims': list(self[k].dims), 'attrs': dict(self[k].attrs)}}) else: d.update({'data': func(self.data, tolist)}) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Tools for converting between xray.Dataset and nested dictionaries/JSON 88075523

Next page

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 21.712ms · About: xarray-datasette