issues: 101061611
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
101061611 | MDU6SXNzdWUxMDEwNjE2MTE= | 533 | DataArray.name should always be a string | 2443309 | closed | 0 | 2 | 2015-08-14T17:36:02Z | 2015-09-18T17:35:26Z | 2015-09-18T17:35:26Z | MEMBER | Consider the following example: ``` Python import numpy as np import xray da = xray.DataArray(np.random.random((4, 5))) ds = da.to_dataset(name=0) # or name=True, or name=(4) ds.to_netcdf('test.nc') ``` raises this error: ``` python /Users/jhamman/anaconda/lib/python3.4/site-packages/xray/backends/netCDF4_.py in prepare_variable(self, name, variable) 228 endian='native', 229 least_significant_digit=encoding.get('least_significant_digit'), --> 230 fill_value=fill_value) 231 nc4_var.set_auto_maskandscale(False) 232 netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.createVariable (netCDF4/_netCDF4.c:13217)() /Users/jhamman/anaconda/lib/python3.4/posixpath.py in normpath(path) 330 if path == empty: 331 return dot --> 332 initial_slashes = path.startswith(sep) 333 # POSIX allows one or two initial slashes, but treats three or more 334 # as single slash. AttributeError: 'int' object has no attribute 'startswith' ``` I think one way to solve this is to cast the name attribute to a string at the time of assignment. Another way is just to raise an error if a not string variable name is used. |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/533/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |