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/2330#issuecomment-424499776,https://api.github.com/repos/pydata/xarray/issues/2330,424499776,MDEyOklzc3VlQ29tbWVudDQyNDQ5OTc3Ng==,5635139,2018-09-25T21:00:12Z,2018-09-25T21:00:12Z,MEMBER,"Yes, I agree - given the reluctance on the principle around ""calling a constructor on an object of the same type needs to work"" - it's right not to make this change. Thanks for holding that principle.
I'll close this; let me know if there's any change around this I make in its place.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-422458598,https://api.github.com/repos/pydata/xarray/issues/2330,422458598,MDEyOklzc3VlQ29tbWVudDQyMjQ1ODU5OA==,1217238,2018-09-18T16:23:00Z,2018-09-18T16:23:00Z,MEMBER,"Sorry for taking so long here.
I'm still not entirely comfortable with this change -- it adds some additional complexity to the `Dataset` constructor that seems unnecessary. There's no inherit reason why calling a constructor on an object of the same type needs to work. If anything, I would like to deprecate/remove this behavior on `DataArray` (e.g., in favor of using a more explicit call to `DataArray.copy(data=new_data)`).
> To answer your question though, we hit this when inheriting from a Dataset: the object is initialized with a dataset, which is super-ed up to the Dataset constructor
If I understand this correctly, you've written something like:
```python
class MyDataset(xarray.Dataset):
def __init__(self, dataset):
super().__init__(dataset)
```
Is there any reason why you couldn't just write:
```python
class MyDataset(xarray.Dataset):
def __init__(self, dataset):
super().__init__(dataset.data_vars, dataset.coords, dataset.attrs)
```
> I think we should do something here, rather than change behavior by coincidence.
I don't think it's *quite* a coincidence here -- we are changing the behavior of `Dataset.__iter__`/`Dataset.keys()`, and this is a logical consequence of interpreting a Dataset as a mapping of its data variables :).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-421494628,https://api.github.com/repos/pydata/xarray/issues/2330,421494628,MDEyOklzc3VlQ29tbWVudDQyMTQ5NDYyOA==,5635139,2018-09-14T21:55:33Z,2018-09-14T21:55:33Z,MEMBER,"Any votes?
I think the current version dominates the current master (i.e. it doesn't disable any useful functionality, it adds some clarity). So I would vote to merge unless anyone has any alternative suggestions (which I will gladly implement)
Thanks team","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-414397606,https://api.github.com/repos/pydata/xarray/issues/2330,414397606,MDEyOklzc3VlQ29tbWVudDQxNDM5NzYwNg==,5635139,2018-08-20T17:27:27Z,2018-08-20T17:27:27Z,MEMBER,"I think we should do _something_ here, rather than change behavior by coincidence.
@shoyer do you want to make the decision?
I would vote +0.1 for the current version in the PR. V happy to be outweighed!","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-411461794,https://api.github.com/repos/pydata/xarray/issues/2330,411461794,MDEyOklzc3VlQ29tbWVudDQxMTQ2MTc5NA==,5635139,2018-08-08T16:08:36Z,2018-08-08T16:08:36Z,MEMBER,"@fmaussion good question
The main reason I think this is worthwhile is the change in behavior between 0.10.x and 0.11.0, when iterating over a Dataset will iterate only over its `data_vars`, and so will change `Dataset(ds)` from `ds` to `Dataset(ds.data_vars)`.
I don't have a strong view on which option we choose, but I do think we should have a deliberate decision rather than making a breaking-change-by-coincidence.
To answer your question though, we hit this when inheriting from a Dataset: the object is initialized with a dataset, which is super-ed up to the Dataset constructor. (I realize this is narrow!). Alternatively, there is another repo that linked to the issue [here](https://github.com/jupyter-widgets/ipyleaflet/pull/178)
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-411320940,https://api.github.com/repos/pydata/xarray/issues/2330,411320940,MDEyOklzc3VlQ29tbWVudDQxMTMyMDk0MA==,10050469,2018-08-08T07:57:57Z,2018-08-08T07:57:57Z,MEMBER,From https://github.com/pydata/xarray/issues/2056 and this discussion I don't really understand the use case for this constructor - maybe an example of a real use case that could be added to the doc would help?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-411258309,https://api.github.com/repos/pydata/xarray/issues/2330,411258309,MDEyOklzc3VlQ29tbWVudDQxMTI1ODMwOQ==,1217238,2018-08-08T01:56:04Z,2018-08-08T01:56:04Z,MEMBER,"Now I'm having second thoughts. It does make me a little nervous to add special cases that distinguish between `xr.Dataset(ds, coords=some_coords)` and `xr.Dataset(ds.data_vars, coords=some_coords)`.
Maybe my proposed solution above is too complex, and it would be better simply to default the `coords` and `attrs` argument to those arguments from a passed Dataset object. This is basically what we do for DataArray.
That said, I do think we should try to resist the notion that every class constructor must also work for coercion to that class. This tends to result in a slightly confused interface. A separate `as_dataset()` function (even in user code) could give exactly the desired result in only be a few lines of code.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-411249697,https://api.github.com/repos/pydata/xarray/issues/2330,411249697,MDEyOklzc3VlQ29tbWVudDQxMTI0OTY5Nw==,6815844,2018-08-08T00:59:26Z,2018-08-08T00:59:26Z,MEMBER,"> `xr.Dataset(ds, coords=some_coords).coords != some_coords`
I thought that `xr.Dataset(ds, coords=some_coords).coords == some_coords`.
I think Dataset should be regarded as a dict of dataarrays (data_vars), and thus
`xr.Dataset(ds, coords=some_coords)` should be equivalent to `xr.Dataset(ds.data_vars, coords=some_coords)`.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-411114049,https://api.github.com/repos/pydata/xarray/issues/2330,411114049,MDEyOklzc3VlQ29tbWVudDQxMTExNDA0OQ==,5635139,2018-08-07T16:14:57Z,2018-08-07T16:14:57Z,MEMBER,"> And, to confirm, you think it's OK that :
Moving ahead with this, please let me know any objections from anyone","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-410122566,https://api.github.com/repos/pydata/xarray/issues/2330,410122566,MDEyOklzc3VlQ29tbWVudDQxMDEyMjU2Ng==,5635139,2018-08-03T02:09:02Z,2018-08-03T02:09:02Z,MEMBER,"OK good!
And, to confirm, you think it's OK that :
`xr.Dataset(ds, coords=some_coords).coords != some_coords`","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-410046100,https://api.github.com/repos/pydata/xarray/issues/2330,410046100,MDEyOklzc3VlQ29tbWVudDQxMDA0NjEwMA==,1217238,2018-08-02T19:46:57Z,2018-08-02T19:46:57Z,MEMBER,"> An alternative approach - more friendly but less explicit - is for any other argument (coords, attrs) supplied to overwrite the Dataset's
I think this would be slightly preferred, and also more consistent with the model of a Dataset as only iterating over `data_vars`. This suggests that at the very least, `Dataset(ds)` and `Dataset(ds.data_vars)` should be consistent after we finish the changes described in https://github.com/pydata/xarray/issues/884. Note that `ds.data_vars` will pull in coordinates associated with the DataArray objects.
To be more precise, I would probably make:
```
ds2 = Dataset(ds1, coords, attrs)
```
equivalent to
```
ds2 = ds1.copy()
ds2.coords.update(coords)
ds2.attrs.update(attrs)
```","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369
https://github.com/pydata/xarray/pull/2330#issuecomment-409618343,https://api.github.com/repos/pydata/xarray/issues/2330,409618343,MDEyOklzc3VlQ29tbWVudDQwOTYxODM0Mw==,5635139,2018-08-01T15:35:53Z,2018-08-01T15:35:53Z,MEMBER,"> Do we want to raise if coords / attrs are passed in addition to a Dataset? Do we want to warn for a couple versions first?
An alternative approach - more friendly but less explicit - is for any other argument (coords, attrs) supplied to overwrite the Dataset's","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,346294369