def test_functional_file_empty_BINARY(self): bqm = dimod.BinaryQuadraticModel.empty(dimod.BINARY) tmpdir = tempfile.mkdtemp() filename = os.path.join(tmpdir, 'test.qubo') with open(filename, 'w') as file: coo.dump(bqm, fp=file) with open(filename, 'r') as file: new_bqm = coo.load(file, dimod.BinaryQuadraticModel, dimod.BINARY) shutil.rmtree(tmpdir) self.assertEqual(bqm, new_bqm)
def test_functional_file_SPIN(self): bqm = dimod.BinaryQuadraticModel({0: 1.}, { (0, 1): 2, (2, 3): .4 }, 0.0, dimod.SPIN) tmpdir = tempfile.mkdtemp() filename = os.path.join(tmpdir, 'test.qubo') with open(filename, 'w') as file: coo.dump(bqm, fp=file) with open(filename, 'r') as file: new_bqm = coo.load(file, dimod.BinaryQuadraticModel, dimod.SPIN) shutil.rmtree(tmpdir) self.assertEqual(bqm, new_bqm)