dimod.SampleSet.to_serializable¶
-
SampleSet.to_serializable(use_bytes=False, bytes_type=<type 'str'>)[source]¶ Convert a
SampleSetto a serializable object.Note that the contents of the
SampleSet.infofield are assumed to be serializable.Parameters: - use_bytes (bool, optional, default=False) – If True, a compact representation of the biases as bytes is used.
- bytes_type (class, optional, default=bytes) – If use_bytes is True, this class is used to wrap the bytes objects in the serialization. Useful for Python 2 using BSON encoding, which does not accept the raw bytes type; bson.Binary can be used instead.
Returns: Object that can be serialized.
Return type: Examples
This example encodes using JSON.
>>> import dimod >>> import json ... >>> samples = dimod.SampleSet.from_samples([-1, 1, -1], dimod.SPIN, energy=-.5) >>> s = json.dumps(samples.to_serializable())
See also