home / github

Menu
  • GraphQL API
  • Search all tables

issue_comments

Table actions
  • GraphQL API for issue_comments

5 rows where author_association = "NONE" and issue = 173494017 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 2

  • joonro 4
  • darothen 1

issue 1

  • Return a scalar instead of DataArray when the return value is a scalar · 5 ✖

author_association 1

  • NONE · 5 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
242953090 https://github.com/pydata/xarray/issues/987#issuecomment-242953090 https://api.github.com/repos/pydata/xarray/issues/987 MDEyOklzc3VlQ29tbWVudDI0Mjk1MzA5MA== joonro 1063143 2016-08-28T02:58:24Z 2016-08-28T02:58:24Z NONE

@shoyer I think I saw ... a long time ago and must have forgotten about it. Thank you so much for reminding me - I was really hoping for something like ... for a while.

Btw, I must say not only that xarray is just so useful for many of my research, but also the devs' responses on the issues have been superb. Definitely one of the most pleasant experiences I have had with developers. Thank you.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Return a scalar instead of DataArray when the return value is a scalar 173494017
242940333 https://github.com/pydata/xarray/issues/987#issuecomment-242940333 https://api.github.com/repos/pydata/xarray/issues/987 MDEyOklzc3VlQ29tbWVudDI0Mjk0MDMzMw== joonro 1063143 2016-08-27T20:55:59Z 2016-08-27T20:59:09Z NONE

Sure. My actual usage is usually much more complicated, but basically, with

python import numpy as np import xarray as xr X = xr.DataArray(np.random.normal(size=(10, 10)), coords=[range(10), range(10)],)

if I want to choose only values larger than 0 from X, it seems I cannot do X[X > 0], I have to do X.values[X.values > 0]. You can see how this thing can quickly get long if I'm doing this for assignment with multidimensional xarrays - something like

python X.loc[:, :, :, 'variable'].values[X.loc[:, :, :, 'variable'].values > 0] = Y.loc[:, :, :, 'variable'].values[Y.loc[:, :, :, 'variable'].values > 0]

Maybe I'm mistaken and there is a way to do this more nicely, but I haven't been able to figure it out.

Thank you!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Return a scalar instead of DataArray when the return value is a scalar 173494017
242937958 https://github.com/pydata/xarray/issues/987#issuecomment-242937958 https://api.github.com/repos/pydata/xarray/issues/987 MDEyOklzc3VlQ29tbWVudDI0MjkzNzk1OA== joonro 1063143 2016-08-27T20:06:12Z 2016-08-27T20:06:12Z NONE

Thanks a lot for the discussions. I agree it is very important to be consistent and explicit. Another thing was that sometimes .values makes a line of code really long - especially when I want to index a DataArray with another DataArray with some conditions, as I often have to use .values for each of them.

Currently I do not have a good idea about how to improve this - I will report back if one occurs to me. Thanks again!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Return a scalar instead of DataArray when the return value is a scalar 173494017
242912131 https://github.com/pydata/xarray/issues/987#issuecomment-242912131 https://api.github.com/repos/pydata/xarray/issues/987 MDEyOklzc3VlQ29tbWVudDI0MjkxMjEzMQ== darothen 4992424 2016-08-27T11:34:28Z 2016-08-27T11:34:28Z NONE

@joonro, I think there's a strong case to be made about returning a DataArray with some metadata appended. Referring to the latest draft of the CF Metadata Conventions, there is a clear way to indicate when operations such as mean, max, or min have been applied to a variable by using the cell_methods attribute.

It might be more prudent to add this attribute whenever we apply these operations to a DataArray (or perhaps variable-wise when applied to a Dataset). That way, there is a clear reason to not return a scalar - the documentation of what operations were applied to produce that final result.

I can whip up a working example/pull request if people think this is a direction to go. I'd probably build a decorator which handles inspection of the operator name and arguments and uses that to add the cell_methods attribute, that way people can add the same functionality to homegrown methods/operators.

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Return a scalar instead of DataArray when the return value is a scalar 173494017
242796865 https://github.com/pydata/xarray/issues/987#issuecomment-242796865 https://api.github.com/repos/pydata/xarray/issues/987 MDEyOklzc3VlQ29tbWVudDI0Mjc5Njg2NQ== joonro 1063143 2016-08-26T17:22:06Z 2016-08-26T17:22:06Z NONE

I see - thanks a lot for the quick response. I knew there was a good reason for this.

I wonder if it is reasonable to return a scalar when there is neither coords nor attrs associated with the return value, or it would be too much ad-hoc thing. For example, in the original example the return value was <xarray.DataArray ()>, which does not have any useful information.

I think this might be reasonable because I only get into this issue when I'm doing an array-wide operation and I know I'm going to get an aggregate scalar and forget to use .values.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Return a scalar instead of DataArray when the return value is a scalar 173494017

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.531ms · About: xarray-datasette
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows