def test_all_linear_coefficients_are_loaded(self):
        bqm_dict = {
            "linear": [(0, 2.0), (2, 0.5), (1, -1.0)],
            "quadratic": [(0, 1, 1.2), (1, 2, 4.0)],
            "offset": 0.5,
            "vartype": "SPIN",
        }

        bqm = bqm_from_serializable(bqm_dict)
        assert bqm.linear == {0: 2.0, 2: 0.5, 1: -1.0}
    def test_vartype_is_set_correctly(self, vartype, expected_bqm_vartype):
        bqm_dict = {
            "linear": [(0, 1.0), (2, 2.0), (1, 0.5)],
            "quadratic": [(0, 1, 1), (1, 2, 4.0), (1, 3, 1e-2)],
            "offset": 0.5,
            "vartype": vartype,
        }

        bqm = bqm_from_serializable(bqm_dict)

        assert bqm.vartype == expected_bqm_vartype
    def test_offset_is_loaded(self, offset):
        bqm_dict = {
            "linear": [(0, 1.0), (1, 2.0), (2, 0.5)],
            "quadratic": [(0, 1, 2.1), (1, 2, 4.0), (1, 3, -1.0)],
            "offset": offset,
            "vartype": "BINARY",
        }

        bqm = bqm_from_serializable(bqm_dict)

        assert bqm.offset == offset
    def test_all_quadratic_coefficients_are_loaded(self):
        bqm_dict = {
            "linear": [(0, 1.0), (1, 2.0), (2, 0.5)],
            "quadratic": [(0, 1, 2.1), (1, 2, 4.0), (1, 3, -1.0)],
            "offset": 0.1,
            "vartype": "BINARY",
        }

        bqm = bqm_from_serializable(bqm_dict)

        assert bqm.quadratic == {(0, 1): 2.1, (1, 2): 4.0, (1, 3): -1.0}