classmethod AdjDictBQM.from_coo(obj, vartype=None)[source]

Deserialize a binary quadratic model from a COOrdinate format encoding.

COOrdinate is a sparse encoding for binary quadratic models.

  • obj – (str/file): Either a string or a .read()-supporting file object that represents linear and quadratic biases for a binary quadratic model. This data is stored as a list of 3-tuples, (i, j, bias), where \(i=j\) for linear biases.

  • vartype (Vartype/str/set, optional) –

    Variable type for the binary quadratic model. Accepted input values:

    • Vartype.SPIN, 'SPIN', {-1, 1}

    • Vartype.BINARY, 'BINARY', {0, 1}

    If not provided, the vartype must be specified with a header in the file.


Variables must use index labels (numeric lables). Binary quadratic models created from COOrdinate format encoding have offsets set to zero.


This method will be deprecated in the future. The preferred pattern is to use load() or loads() directly.