home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 856728083

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
856728083 MDU6SXNzdWU4NTY3MjgwODM= 5146 HTML formatting of non-string attribute names fails 367900 closed 0     3 2021-04-13T08:36:31Z 2021-11-11T18:21:31Z 2021-11-11T18:21:31Z CONTRIBUTOR      

Working in a notebook (and presumably, anywhere else that uses the HTML formatter to show an array), non-string attribute keys cause an exception. The output then falls back to the repr value.

```python console In [1]: import xarray as xr

In [2]: data = xr.DataArray([1, 2, 3], attrs={1: 3.14})

In [3]: data.attrs Out[3]: {1: 3.14}

In [4]: data python traceback


AttributeError Traceback (most recent call last) /usr/lib/python3.9/site-packages/IPython/core/formatters.py in call(self, obj) 343 method = get_real_method(obj, self.print_method) 344 if method is not None: --> 345 return method() 346 return None 347 else:

~/software/external/xarray/xarray/core/common.py in repr_html(self) 148 if OPTIONS["display_style"] == "text": 149 return f"

{escape(repr(self))}
" --> 150 return formatting_html.array_repr(self) 151 152 def _iter(self: Any) -> Iterator[Any]:

~/software/external/xarray/xarray/core/formatting_html.py in array_repr(arr) 269 sections.append(coord_section(arr.coords)) 270 --> 271 sections.append(attr_section(arr.attrs)) 272 273 return _obj_repr(arr, header_components, sections)

~/software/external/xarray/xarray/core/formatting_html.py in _mapping_section(mapping, name, details_func, max_items_collapse, enabled) 171 return collapsible_section( 172 name, --> 173 details=details_func(mapping), 174 n_items=n_items, 175 enabled=enabled,

~/software/external/xarray/xarray/core/formatting_html.py in summarize_attrs(attrs) 47 48 def summarize_attrs(attrs): ---> 49 attrs_dl = "".join( 50 f"<dt>{escape(k)} :</dt>" f"<dd>{escape(str(v))}</dd>" 51 for k, v in attrs.items()

~/software/external/xarray/xarray/core/formatting_html.py in <genexpr>(.0) 48 def summarize_attrs(attrs): 49 attrs_dl = "".join( ---> 50 f"<dt>{escape(k)} :</dt>" f"<dd>{escape(str(v))}</dd>" 51 for k, v in attrs.items() 52 )

/usr/lib/python3.9/html/init.py in escape(s, quote) 17 translated. 18 """ ---> 19 s = s.replace("&", "&") # Must be done first! 20 s = s.replace("<", "<") 21 s = s.replace(">", ">")

AttributeError: 'int' object has no attribute 'replace' python console Out[4]: <xarray.DataArray (dim_0: 3)> array([1, 2, 3]) Dimensions without coordinates: dim_0 Attributes: 1: 3.14 ```

Environment:

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: c91983d4765b23e0474231c85057d31f9b6b2f33 python: 3.9.2 (default, Feb 20 2021, 18:40:11) [GCC 10.2.0] python-bits: 64 OS: Linux OS-release: 5.11.13-arch1-1 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_NZ.UTF-8 LOCALE: en_NZ.UTF-8 libhdf5: 1.12.0 libnetcdf: 4.7.4 xarray: 0.17.0 pandas: 1.2.3 numpy: 1.20.1 scipy: 1.6.2 netCDF4: 1.5.6 pydap: None h5netcdf: 0.10.0 h5py: 3.2.1 Nio: None zarr: None cftime: 1.4.1 nc_time_axis: None PseudoNetCDF: None rasterio: 1.2.2 cfgrib: None iris: None bottleneck: 1.3.2 dask: 2021.03.0 distributed: 2021.03.0 matplotlib: 3.4.1 cartopy: 0.18.0 seaborn: None numbagg: None pint: None setuptools: 54.2.0 pip: 20.3.1 conda: None pytest: 6.2.3 IPython: 7.22.0 sphinx: 3.5.4
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/5146/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.658ms · About: xarray-datasette