dimod.binary.BinaryQuadraticModel.to_numpy_vectors#
- BinaryQuadraticModel.to_numpy_vectors(variable_order: Sequence[Hashable] | None = None, *, dtype: dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any] = None, index_dtype: dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any] = None, sort_indices: bool = False, sort_labels: bool = True, return_labels: bool = False) BQMVectors | LabelledBQMVectors [source]#
Convert binary quadratic model to 1-dimensional NumPy arrays.
- Parameters:
variable_order – Variable order for the vector output. By default uses the order of the binary quadratic model.
sort_indices – Sort the indices of the interactions such that row is always less than column and then lexicographical.
sort_labels – Equivalent to setting
variable_order=sorted(bqm.variables)
. Ignored ifvariable_order
is provided.return_labels – If True, returns a list of variable labels in the order used.
- Returns:
A named tuple with fields
linear_biases
,quadratic
, andoffset
. Ifreturn_labels == True
, it also includes alabels
field.linear_biases
is a lengthBinaryQuadraticModel.num_variables
array containing the linear biases.quadratic
is a named tuple with fieldsrow_indices
,col_indices
, andbiases
.row_indices
andcol_indices
are lengthBinaryQuadraticModel.num_interactions`
arrays containing the interaction indices.biases
contains the biases.offset
is the offset.labels
are the variable labels used.
Deprecated since version 0.10.0: The
dtype
andindex_dtype
keyword arguments will be removed in 0.12.0. They currently do nothing.