issues: 51046413
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
51046413 | MDU6SXNzdWU1MTA0NjQxMw== | 284 | to_netcdf ValueError with 0d string variable | 2002703 | closed | 0 | 1 | 2014-12-04T23:59:07Z | 2014-12-05T03:57:16Z | 2014-12-05T03:57:16Z | CONTRIBUTOR |
results in ``` ----> 1 xray.Dataset( {'password': ([], 'abcd')} ).to_netcdf('/tmp/bar.nc') /export/data/envs/popcorn/lib/python2.7/site-packages/xray/core/dataset.pyc in to_netcdf(self, filepath, kwdargs) 801 """ 802 with backends.NetCDF4DataStore(filepath, mode='w', kwdargs) as store: --> 803 self.dump_to_store(store) 804 805 dump = to_netcdf /export/data/envs/popcorn/lib/python2.7/site-packages/xray/core/dataset.pyc in dump_to_store(self, store, encoder) 793 if encoder: 794 variables, attributes = encoder(variables, attributes) --> 795 store.store(variables, attributes) 796 store.sync() 797 /export/data/envs/popcorn/lib/python2.7/site-packages/xray/backends/netCDF4_.pyc in store(self, variables, attributes) 100 # to write times, for example, would fail. 101 cf_variables, cf_attrs = cf_encoder(variables, attributes) --> 102 AbstractWritableDataStore.store(self, cf_variables, cf_attrs) 103 104 def open_store_variable(self, var): /export/data/envs/popcorn/lib/python2.7/site-packages/xray/backends/common.pyc in store(self, variables, attributes) 153 variables = dict((k, v) for k, v in iteritems(variables) 154 if not (k in neccesary_dims and is_trivial_index(v))) --> 155 self.set_variables(variables) 156 157 def set_dimensions(self, dimensions): /export/data/envs/popcorn/lib/python2.7/site-packages/xray/backends/common.pyc in set_variables(self, variables) 165 def set_variables(self, variables): 166 for vn, v in iteritems(variables): --> 167 self.set_variable(_encode_variable_name(vn), v) 168 self.set_necessary_dimensions(v) 169 /export/data/envs/popcorn/lib/python2.7/site-packages/xray/backends/netCDF4_.pyc in set_variable(self, name, variable) 151 attrs = variable.attrs.copy() 152 if self.format == 'NETCDF4': --> 153 variable, datatype = _nc4_values_and_dtype(variable) 154 else: 155 variable = encode_nc3_variable(variable) /export/data/envs/popcorn/lib/python2.7/site-packages/xray/backends/netCDF4_.pyc in _nc4_values_and_dtype(var) 47 # use character arrays instead of unicode, because unicode suppot in 48 # netCDF4 is still rather buggy ---> 49 data, dims = maybe_convert_to_char_array(var.values, var.dims) 50 var = Variable(dims, data, var.attrs, var.encoding) 51 dtype = var.dtype /export/data/envs/popcorn/lib/python2.7/site-packages/xray/backends/netcdf3.pyc in maybe_convert_to_char_array(data, dims) 55 def maybe_convert_to_char_array(data, dims): 56 if data.dtype.kind == 'S' and data.dtype.itemsize > 1: ---> 57 data = conventions.string_to_char(data) 58 dims = dims + ('string%s' % data.shape[-1],) 59 return data, dims /export/data/envs/popcorn/lib/python2.7/site-packages/xray/conventions.pyc in string_to_char(arr) 344 if kind not in ['U', 'S']: 345 raise ValueError('argument must be a string') --> 346 return arr.view(kind + '1').reshape(*[arr.shape + (-1,)]) 347 348 ValueError: new type not compatible with array. ``` Note this does not fail when the 0d value is a number. This succeeds:
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/284/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |