home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 289923078

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/issues/1092#issuecomment-289923078 https://api.github.com/repos/pydata/xarray/issues/1092 289923078 MDEyOklzc3VlQ29tbWVudDI4OTkyMzA3OA== 1217238 2017-03-28T22:22:31Z 2017-03-28T22:24:31Z MEMBER

@lamorton Thanks for explaining the use case here. This makes more sense to me now. I like your idea of groups as syntactic sugar around flat datasets with named keys.

With an appropriate naming convention, we might even be able to put this into xarray.Dataset proper. Tuples like ('flux', 'poloidal', 'perturbed') would be more appropriate than a string based convention, because they are easier to use programmatically.

  • In Python syntax, ds[x, y] is equivalent to ds[(x, y)]. Thus ds['flux', 'poloidal', 'perturbed'] works to pull out a named variable.
  • If no variable with the name flux is found, ds['flux'] or ds.flux would return a Dataset with all variables with names given by tuples starting with 'flux', removing the prefix 'flux' from each name (e.g., ('poloidal', 'perturbed') would be a variable in ds.flux). This means that ds.flux.poloidal.perturbed and ds['flux']['poloidal']['perturbed'] should automatically work.
  • ds['flux', 'poloidal', 'perturbed'] = data_array would assign the variable ('flux', 'poloidal', 'perturbed'), and implicitly create the 'flux' group (which in turn contains the 'poloidal' group). Note that it's not possible to make assignments like ds['flux']['poloidal']['perturbed'] = data_array work, so we should discourage this syntax.
  • ds['flux'] = poloidal_ds would become valid, and work by assigning all variables in poloidal_ds into ds by prefixing their names with 'flux'.
  • Similarly, nested arguments could also be supported in the Dataset constructor, e.g., xarray.Dataset({'flux': {'poloidal': {'perturbed': data_array}}}) becomes syntactic sugar for xarray.Dataset({('flux', 'poloidal', 'perturbed'): data_array}).
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  187859705
Powered by Datasette · Queries took 4.584ms · About: xarray-datasette