@@ -89,7 +89,7 @@ def _align_variables(variables, join='outer'):
8989 return new_variables
9090
9191
92- def _expand_variables (raw_variables , old_variables = {} , compat = 'identical' ):
92+ def _expand_variables (raw_variables , old_variables = None , compat = 'identical' ):
9393 """Expand a dictionary of variables.
9494
9595 Returns a dictionary of Variable objects suitable for inserting into a
@@ -102,6 +102,8 @@ def _expand_variables(raw_variables, old_variables={}, compat='identical'):
102102 Raises ValueError if any conflicting values are found, between any of the
103103 new or old variables.
104104 """
105+ if old_variables is None :
106+ old_variables = {}
105107 new_variables = OrderedDict ()
106108 new_coord_names = set ()
107109 variables = ChainMap (new_variables , old_variables )
@@ -329,7 +331,7 @@ def _add_missing_coords_inplace(self):
329331 coord = Coordinate (dim , data )
330332 self ._variables [dim ] = coord
331333
332- def _update_vars_and_coords (self , new_variables , new_coord_names = {} ,
334+ def _update_vars_and_coords (self , new_variables , new_coord_names = None ,
333335 needs_copy = True , check_coord_names = True ):
334336 """Add a dictionary of new variables to this dataset.
335337
@@ -340,6 +342,8 @@ def _update_vars_and_coords(self, new_variables, new_coord_names={},
340342 Set `needs_copy=False` only if this dataset is brand-new and hence
341343 can be thrown away if this method fails.
342344 """
345+ if new_coord_names is None :
346+ new_coord_names = {}
343347 # default to creating another copy of variables so can unroll if we end
344348 # up with inconsistent dimensions
345349 variables = self ._variables .copy () if needs_copy else self ._variables
@@ -804,8 +808,10 @@ def reset_coords(self, names=None, drop=False, inplace=False):
804808 del obj ._variables [name ]
805809 return obj
806810
807- def dump_to_store (self , store , encoder = None , sync = True , encoding = {} ):
811+ def dump_to_store (self , store , encoder = None , sync = True , encoding = None ):
808812 """Store dataset contents to a backends.*DataStore object."""
813+ if encoding is None :
814+ encoding = {}
809815 variables , attrs = conventions .encode_dataset_coordinates (self )
810816
811817 check_encoding = set ()
@@ -823,7 +829,7 @@ def dump_to_store(self, store, encoder=None, sync=True, encoding={}):
823829 store .sync ()
824830
825831 def to_netcdf (self , path = None , mode = 'w' , format = None , group = None ,
826- engine = None , encoding = {} ):
832+ engine = None , encoding = None ):
827833 """Write dataset contents to a netCDF file.
828834
829835 Parameters
@@ -868,6 +874,8 @@ def to_netcdf(self, path=None, mode='w', format=None, group=None,
868874 variable specific encodings as values, e.g.,
869875 ``{'my_variable': {'dtype': 'int16', 'scale_factor': 0.1, 'zlib': True}, ...}``
870876 """
877+ if encoding is None :
878+ encoding = {}
871879 from ..backends .api import to_netcdf
872880 return to_netcdf (self , path , mode , format = format , group = group ,
873881 engine = engine , encoding = encoding )
0 commit comments