I'm using yamlize to serialize some floats. It works great with normal floats but when I get the floats from numpy.linspace, it crashes with the following traceback:
File "C:\Python27\lib\site-packages\yamlize\attributes.py",line 170, in to_yaml
val_node = self.type.to_yaml(dumper, data, round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\objects.py (file:///C:/Python27/lib/site-packages/yamlize/objects.py)",line 261, in to_yaml
node = self.__to_yaml(dumper)
File "C:\Python27\lib\site-packages\yamlize\objects.py (file:///C:/Python27/lib/site-packages/yamlize/objects.py)",line 319, in __to_yaml
attribute.to_yaml(self, dumper, node_items, self.__round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\attributes.py (file:///C:/Python27/lib/site-packages/yamlize/attributes.py)",line 275, in to_yaml
dumper, value, self.key_attr[0], round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\objects.py (file:///C:/Python27/lib/site-packages/yamlize/objects.py)",line 277, in to_yaml_key_val
node = self.__to_yaml(dumper, key_attribute)
File "C:\Python27\lib\site-packages\yamlize\objects.py (file:///C:/Python27/lib/site-packages/yamlize/objects.py)",line 319, in __to_yaml
attribute.to_yaml(self, dumper, node_items, self.__round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\attributes.py (file:///C:/Python27/lib/site-packages/yamlize/attributes.py)",line 170, in to_yaml
val_node = self.type.to_yaml(dumper, data, round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\objects.py (file:///C:/Python27/lib/site-packages/yamlize/objects.py)",line 261, in to_yaml
node = self.__to_yaml(dumper)
File "C:\Python27\lib\site-packages\yamlize\objects.py (file:///C:/Python27/lib/site-packages/yamlize/objects.py)",line 319, in __to_yaml
attribute.to_yaml(self, dumper, node_items, self.__round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\attributes.py (file:///C:/Python27/lib/site-packages/yamlize/attributes.py)",line 238, in to_yaml
val_node = self.val_type.to_yaml(dumper, data, round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\sequences.py (file:///C:/Python27/lib/site-packages/yamlize/sequences.py)",line 147, in to_yaml
item_node = self.item_type.to_yaml(dumper, item, self.__round_trip_data)
File "C:\Python27\lib\site-packages\yamlize\yamlizable.py (file:///C:/Python27/lib/site-packages/yamlize/yamlizable.py)",line 185, in to_yaml
node = dumper.represent_data(data if cls.__to_yaml is None else cls.__to_yaml(data))
File "C:\Python27\lib\site-packages\ruamel\yaml\representer.py (file:///C:/Python27/lib/site-packages/ruamel/yaml/representer.py)",line 111, in represent_data
node = self.yaml_representers[None](self, data)
File "C:\Python27\lib\site-packages\ruamel\yaml\representer.py (file:///C:/Python27/lib/site-packages/ruamel/yaml/representer.py)",line 375, in represent_undefined
raise RepresenterError("cannot represent an object: %s" % data)
ruamel.yaml.representer.RepresenterError: cannot represent an object: 0.17
A workaround is to float(val) each thing going in so they're floats instead of numpy.float64s. But it might be nice to have the library be able to handle numpy float64
I'm using yamlize to serialize some floats. It works great with normal floats but when I get the floats from
numpy.linspace
, it crashes with the following traceback:A workaround is to
float(val)
each thing going in so they'refloat
s instead ofnumpy.float64
s. But it might be nice to have the library be able to handle numpyfloat64