dimod.serialization.fileview.FileView¶
-
class
FileView
(bqm, version=(1, 0), ignore_labels=False)[source]¶ A seekable, readable view into a binary quadratic model.
- Parameters
bqm (
BQM
) – The binary quadratic model.version (int/tuple, default=1) – The serialization version to use. Either as an integer defining the major version, or as a tuple, (major, minor).
ignore_labels (bool, default=False) – Treat the BQM as unlabelled. This is useful for large BQMs to save on space. ignore_labels=True is only supported in version 2.0+, trying to set it with version 1.x will raise a ValueError.
Note
Currently the BQM is not locked while the file view is open, in the future this will change.
-
__init__
(bqm, version=(1, 0), ignore_labels=False)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(bqm[, version, ignore_labels])Initialize self.
close
()Close the file view.
fileno
()Returns underlying file descriptor if one exists.
flush
()Flush write buffers, if applicable.
isatty
()Return whether this is an ‘interactive’ stream.
read
([size])readable
()Return whether object was opened for reading.
readall
()Read until EOF, using multiple read() call.
readinto
(buff)Read bytes into a pre-allocated, writable bytes-like object.
readinto1
(buff)Read bytes into a pre-allocated, writable bytes-like object.
readline
([size])Read and return a line from the stream.
readlines
([hint])Return a list of lines from the stream.
seek
(offset[, whence])Change the stream position to the given offset.
seekable
()Return whether object supports random access.
tell
()Return current stream position.
truncate
Truncate file to size bytes.
writable
()Return whether object was opened for writing.
write
writelines
(lines, /)Write a list of lines to stream.
Attributes
SEEK_LINEAR
SEEK_OFFSET
SEEK_QUADRATIC
closed
end
header
The header associated with the BQM.
header_end
The location (in bytes) that the header ends.
linear_end
The location (in bytes) that the linear data end.
linear_start
The location (in bytes) that the linear data starts.
neighborhood_starts
The indices of the neighborhood starts.
offset_end
offset_start
The location (in bytes) that the offset starts.
quadratic_end
The location (in bytes) that the quadratic data end.
quadratic_start
The location (in bytes) that the quadratic data starts.
variables_end
variables_section
The variables section as bytes.
variables_start