home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

6 rows where issue = 1318173644 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 5

  • gabicca 2
  • dcherian 1
  • Illviljan 1
  • rhkleijn 1
  • TomNicholas 1

author_association 3

  • MEMBER 3
  • NONE 2
  • CONTRIBUTOR 1

issue 1

  • xarray.concat for datasets fails when object is a child class of Dataset · 6 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
1382154696 https://github.com/pydata/xarray/issues/6827#issuecomment-1382154696 https://api.github.com/repos/pydata/xarray/issues/6827 IC_kwDOAMm_X85SYgHI TomNicholas 35968931 2023-01-13T17:14:33Z 2023-01-13T17:14:33Z MEMBER

@gabicca given that we do say in our docs that we don't recommend subclassing xarray objects, I'm going to close this issue as a downstream "subclass at your own risk" problem. If you would like it to be easier to subclass, we would welcome your input here.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.concat for datasets fails when object is a child class of Dataset 1318173644
1220524864 https://github.com/pydata/xarray/issues/6827#issuecomment-1220524864 https://api.github.com/repos/pydata/xarray/issues/6827 IC_kwDOAMm_X85Iv7tA gabicca 33315687 2022-08-19T10:39:58Z 2022-08-19T10:39:58Z NONE

I'll leave that with you guys to decide. I've reported it, it's been looked at, and it has a record of it. So if the code is as you intended, I don't mind if the issue is closed.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.concat for datasets fails when object is a child class of Dataset 1318173644
1215314423 https://github.com/pydata/xarray/issues/6827#issuecomment-1215314423 https://api.github.com/repos/pydata/xarray/issues/6827 IC_kwDOAMm_X85IcDn3 dcherian 2448579 2022-08-15T16:32:43Z 2022-08-15T16:32:43Z MEMBER

Shall we close? It seems like the current code is what we want.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.concat for datasets fails when object is a child class of Dataset 1318173644
1198556515 https://github.com/pydata/xarray/issues/6827#issuecomment-1198556515 https://api.github.com/repos/pydata/xarray/issues/6827 IC_kwDOAMm_X85HcIVj Illviljan 14371165 2022-07-28T19:39:41Z 2022-07-28T19:40:08Z MEMBER

Because we want to get out the same type of Dataset (subclassed or not) as we input. That's what the T_Dataset type implies. And since we forced a Dataset at the end that wasn't the case.

{
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.concat for datasets fails when object is a child class of Dataset 1318173644
1196538785 https://github.com/pydata/xarray/issues/6827#issuecomment-1196538785 https://api.github.com/repos/pydata/xarray/issues/6827 IC_kwDOAMm_X85HUbuh gabicca 33315687 2022-07-27T10:15:16Z 2022-07-27T10:15:16Z NONE

In the example the naming and meaning of the arguments of the __init__ method are different from the Dataset base class.

Subclassing is often more reliable when it adheres to the Liskov Substitution Principle which states that objects of a superclass should be replaceable with objects of its subclasses and in other words: a subclass should only add functionality and not reduce it.

There are some other workarounds though:

If all you need is a convenient custom constructor then you could add a classmethod factory method to your subclass or even just use a plain function which returns a Dataset.

Another option is to convert your MyDataset instances to plain Dataset instances before passing them into xarray.concat, e.g. xarray.concat([ds.to_dataset() for ds in [ds1, ds2, ds3]], dim="coord1")

where your subclass may define as a convenience method:

def to_dataset(self): """Convert to plain Dataset.""" return xarray.Dataset(self, attrs=self.attrs)

Thank you for the answer. I'll look into implementing one of your suggestions (they're much better than what I had in mind).

I still don't understand the change that causes the error, though. If you want to instantiate a Dataset object, which you clearly do according to the args you pass in, why did that line have to be changed from explicitly calling Dataset? (By "you" I don't mean you personally, unless you actually made the change :) )

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.concat for datasets fails when object is a child class of Dataset 1318173644
1195752253 https://github.com/pydata/xarray/issues/6827#issuecomment-1195752253 https://api.github.com/repos/pydata/xarray/issues/6827 IC_kwDOAMm_X85HRbs9 rhkleijn 32801740 2022-07-26T17:10:02Z 2022-07-26T18:15:38Z CONTRIBUTOR

In the example the naming and meaning of the arguments of the __init__ method are different from the Dataset base class.

Subclassing is often more reliable when it adheres to the Liskov Substitution Principle which states that objects of a superclass should be replaceable with objects of its subclasses and in other words: a subclass should only add functionality and not reduce it.

There are some other workarounds though:

If all you need is a convenient custom constructor then you could add a classmethod factory method to your subclass or even just use a plain function which returns a Dataset.

Another option is to convert your MyDataset instances to plain Dataset instances before passing them into xarray.concat, e.g. xarray.concat([ds.to_dataset() for ds in [ds1, ds2, ds3]], dim="coord1")

where your subclass may define as a convenience method: ``` def to_dataset(self): """Convert to plain Dataset.""" return xarray.Dataset(self, attrs=self.attrs) ````

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  xarray.concat for datasets fails when object is a child class of Dataset 1318173644

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 13.061ms · About: xarray-datasette