dimod.serialization.fileview.load#

load(fp, cls=None)[source]#

Load a model from a file.

Parameters:
  • fp (bytes-like/file-like) – If file-like, should be a readable, seekable file-like object. If bytes-like, it will be wrapped with io.BytesIO.

  • cls (class, optional) – Deprecated keyword argument. Does nothing.

Returns:

The loaded model.

Examples

This example saves a binary quadratic model to a TemporaryFile() and then uses load() to read that file into a quadratic model.

>>> from dimod.serialization.fileview import load
>>> bqm = dimod.BQM({0: 1.0}, {(0, 1): 2, (2, 3): 0.4}, 0.0, dimod.BINARY)
>>> bqm_file = bqm.to_file()
>>> _ = bqm_file.seek(0)
>>> qm = dimod.QuadraticModel.from_bqm(load(bqm_file))

Deprecated since version 0.10.0: The cls keyword will be removed in dimod 0.12.0. It currently does nothing.