Skip to content

BUG: yet another bug with saving data... #54

@eigenfoo

Description

@eigenfoo

It looks like #53 introduced yet another bug. I can't really figure out what's causing it though...

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-18-34b484f29cfd> in <module>()
      1 # Save the resulting trace object as a netcdf file.
----> 2 trace.save('contest_authors.nc')

~/bayesalpha/bayesalpha/base.py in save(self, filename, group, **args)
     13     def save(self, filename, group=None, **args):
     14         """Save the results to a netcdf file."""
---> 15         self._trace.to_netcdf(filename, group=group, **args)
     16 
     17     @classmethod

/opt/conda/lib/python3.6/site-packages/xarray/core/dataset.py in to_netcdf(self, path, mode, format, group, engine, encoding, unlimited_dims, compute)
   1148                          engine=engine, encoding=encoding,
   1149                          unlimited_dims=unlimited_dims,
-> 1150                          compute=compute)
   1151 
   1152     def to_zarr(self, store=None, mode='w-', synchronizer=None, group=None,

/opt/conda/lib/python3.6/site-packages/xarray/backends/api.py in to_netcdf(dataset, path_or_file, mode, format, group, engine, writer, encoding, unlimited_dims, compute)
    722     try:
    723         dataset.dump_to_store(store, sync=sync, encoding=encoding,
--> 724                               unlimited_dims=unlimited_dims, compute=compute)
    725         if path_or_file is None:
    726             return target.getvalue()

/opt/conda/lib/python3.6/site-packages/xarray/core/dataset.py in dump_to_store(self, store, encoder, sync, encoding, unlimited_dims, compute)
   1073 
   1074         store.store(variables, attrs, check_encoding,
-> 1075                     unlimited_dims=unlimited_dims)
   1076         if sync:
   1077             store.sync(compute=compute)

/opt/conda/lib/python3.6/site-packages/xarray/backends/common.py in store(self, variables, attributes, check_encoding_set, unlimited_dims)
    372         self.set_dimensions(variables, unlimited_dims=unlimited_dims)
    373         self.set_variables(variables, check_encoding_set,
--> 374                            unlimited_dims=unlimited_dims)
    375 
    376     def set_attributes(self, attributes):

/opt/conda/lib/python3.6/site-packages/xarray/backends/netCDF4_.py in set_variables(self, *args, **kwargs)
    405     def set_variables(self, *args, **kwargs):
    406         with self.ensure_open(autoclose=False):
--> 407             super(NetCDF4DataStore, self).set_variables(*args, **kwargs)
    408 
    409     def encode_variable(self, variable):

/opt/conda/lib/python3.6/site-packages/xarray/backends/common.py in set_variables(self, variables, check_encoding_set, unlimited_dims)
    411                 name, v, check, unlimited_dims=unlimited_dims)
    412 
--> 413             self.writer.add(source, target)
    414 
    415     def set_dimensions(self, variables, unlimited_dims=None):

/opt/conda/lib/python3.6/site-packages/xarray/backends/common.py in add(self, source, target)
    270             self.targets.append(target)
    271         else:
--> 272             target[...] = source
    273 
    274     def sync(self, compute=True):

/opt/conda/lib/python3.6/site-packages/xarray/backends/netCDF4_.py in __setitem__(self, key, value)
     46         with self.datastore.ensure_open(autoclose=True):
     47             data = self.get_array()
---> 48             data[key] = value
     49 
     50     def get_array(self):

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable.__setitem__()

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable._put()

TypeError: expected bytes, float found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions