dimod.binary.BinaryQuadraticModel.is_almost_equal#

BinaryQuadraticModel.is_almost_equal(other: BinaryQuadraticModel | QuadraticModel | float | floating | integer, places: int = 7) bool[source]#

Test for near equality to all biases of a given binary quadratic model.

Parameters:
  • other – Binary quadratic model with which to compare biases.

  • places – Number of decimal places to which the Python round() function calculates approximate equality.

Examples

>>> bqm1 = dimod.BinaryQuadraticModel({0: 0.1234},
...                                   {(0, 1): -1.1234},0, "BINARY")
>>> bqm2 = dimod.BinaryQuadraticModel({0: 0.1232},
...                                   {(0, 1): -1.1229},0, "BINARY")
>>> bqm1.is_almost_equal(bqm2, 4)
False
>>> bqm1.is_almost_equal(bqm2, 3)
True