dimod.binary.BinaryQuadraticModel.to_numpy_vectors¶
- BinaryQuadraticModel.to_numpy_vectors(variable_order: Optional[Sequence[Hashable]] = None, *, dtype: Union[numpy.dtype, None, type, numpy.typing._dtype_like._SupportsDType[numpy.dtype], str, Tuple[Any, int], Tuple[Any, Union[typing_extensions.SupportsIndex, Sequence[typing_extensions.SupportsIndex]]], List[Any], numpy.typing._dtype_like._DTypeDict, Tuple[Any, Any]] = None, index_dtype: Union[numpy.dtype, None, type, numpy.typing._dtype_like._SupportsDType[numpy.dtype], str, Tuple[Any, int], Tuple[Any, Union[typing_extensions.SupportsIndex, Sequence[typing_extensions.SupportsIndex]]], List[Any], numpy.typing._dtype_like._DTypeDict, Tuple[Any, Any]] = None, sort_indices: bool = False, sort_labels: bool = True, return_labels: bool = False) Union[dimod.typing.BQMVectors, dimod.typing.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.