home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 405371789

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/2292#issuecomment-405371789 https://api.github.com/repos/pydata/xarray/issues/2292 405371789 MDEyOklzc3VlQ29tbWVudDQwNTM3MTc4OQ== 1217238 2018-07-16T20:30:16Z 2018-07-16T20:30:16Z MEMBER

Hi @joshburkart -- thanks for raising this concern.

I agree, it would be nice to support enums (really any hashable value) as dimension names. Our current checks for strings are somewhat inconsistent, e.g., you can actually use these in an xarray.Dataset if you use the fully explicit API for constructing a dataset: python ds = xr.Dataset( data_vars={'foo': ((CoordId.LAT, CoordId.LON), np.arange(3 * 2).reshape(3, 2))}, coords={CoordId.LAT: ((CoordId.LAT,), [1, 2, 3]), CoordId.LON: ((CoordId.LON,), [7, 8])}, )

But now if you try to print the dataset, you get an error about sorting: ```python-traceback


TypeError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in call(self, obj) 697 type_pprinters=self.type_printers, 698 deferred_pprinters=self.deferred_printers) --> 699 printer.pretty(obj) 700 printer.flush() 701 return stream.getvalue()

/usr/local/lib/python3.6/dist-packages/IPython/lib/pretty.py in pretty(self, obj) 396 if callable(meth): 397 return meth(obj, self, cycle) --> 398 return _default_pprint(obj, self, cycle) 399 finally: 400 self.end_group()

/usr/local/lib/python3.6/dist-packages/IPython/lib/pretty.py in default_pprint(obj, p, cycle) 516 if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs: 517 # A user-provided repr. Find newlines and replace them with p.break() --> 518 _repr_pprint(obj, p, cycle) 519 return 520 p.begin_group(1, '<')

/usr/local/lib/python3.6/dist-packages/IPython/lib/pretty.py in repr_pprint(obj, p, cycle) 707 """A pprint that just redirects to the normal repr function.""" 708 # Find newlines and replace them with p.break() --> 709 output = repr(obj) 710 for idx,output_line in enumerate(output.splitlines()): 711 if idx:

/usr/local/lib/python3.6/dist-packages/xarray/core/formatting.py in repr(self) 62 63 def repr(self): ---> 64 return ensure_valid_repr(self.unicode()) 65 66

/usr/local/lib/python3.6/dist-packages/xarray/core/dataset.py in unicode(self) 1188 1189 def unicode(self): -> 1190 return formatting.dataset_repr(self) 1191 1192 def info(self, buf=None):

/usr/local/lib/python3.6/dist-packages/xarray/core/formatting.py in dataset_repr(ds) 415 416 dims_start = pretty_print(u'Dimensions:', col_width) --> 417 summary.append(u'%s(%s)' % (dims_start, dim_summary(ds))) 418 419 if ds.coords:

/usr/local/lib/python3.6/dist-packages/xarray/core/formatting.py in dim_summary(obj) 324 325 def dim_summary(obj): --> 326 elements = [u'%s: %s' % (k, v) for k, v in obj.sizes.items()] 327 return u', '.join(elements) 328

/usr/local/lib/python3.6/dist-packages/xarray/core/formatting.py in <listcomp>(.0) 324 325 def dim_summary(obj): --> 326 elements = [u'%s: %s' % (k, v) for k, v in obj.sizes.items()] 327 return u', '.join(elements) 328

/usr/lib/python3.6/_collections_abc.py in iter(self) 741 742 def iter(self): --> 743 for key in self._mapping: 744 yield (key, self._mapping[key]) 745

/usr/local/lib/python3.6/dist-packages/xarray/core/utils.py in iter(self) 311 312 def iter(self): --> 313 return iter(self.mapping) 314 315 def len(self):

/usr/local/lib/python3.6/dist-packages/xarray/core/utils.py in iter(self) 347 348 def iter(self): --> 349 return iter(sorted(self.mapping)) 350 351 def len(self):

TypeError: '<' not supported between instances of 'CoordId' and 'CoordId' ```

I would be open to PRs to improve the situation.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  341643235
Powered by Datasette · Queries took 0.704ms · About: xarray-datasette