Beispiel #1
0
    def test_hstack_empty(self):
        s1 = SampleSet.empty()
        s2 = SampleSet.empty()
        exp = SampleSet.empty()

        res = hstack_samplesets(s1, s2)
        self.assertEqual(res, exp)
Beispiel #2
0
    def test_hstack_one(self):
        ss = dimod.SampleSet.from_samples({'a': 1}, vartype='BINARY', energy=0)
        emp = SampleSet.empty()

        self.assertEqual(hstack_samplesets(ss), ss)
        self.assertEqual(hstack_samplesets(ss, emp), ss)
        self.assertEqual(hstack_samplesets(emp, ss), ss)
        self.assertEqual(hstack_samplesets(ss, ss), ss)
    def test_empty(self):
        "At least one input sample is required."

        bqm = dimod.BQM.from_ising({}, {'ab': 1})

        inp = State(problem=bqm, samples=None)
        with self.assertRaises(ValueError):
            ExplodeSamples().run(inp).result()

        inp = State(problem=bqm, samples=SampleSet.empty())
        with self.assertRaises(ValueError):
            ExplodeSamples().run(inp).result()
Beispiel #4
0
    def test_empty(self):
        empty = SampleSet.empty()
        self.assertEqual(len(empty), 0)

        impliedempty = SampleSet()
        self.assertEqual(impliedempty, empty)