dimod.testing.sampler.load_sampler_bqm_tests#

load_sampler_bqm_tests(sampler, max_num_variables=None, suppress_overload_warning=False)[source]#

Populate the decorated TestCase with sampler tests using small BQMs.

Parameters:
  • sampler (obj/callable) – A Sampler. If given as an object, the same sampler will be used for all tests, if given as a callable a new sampler will be instantiated for each test.

  • max_num_variables (int, optional) – The maximum BQM size to be tested. Defaults to unlimited.

  • suppress_overload_warning (bool, optional, default=False) – If True and the decorated class has a method matching one of the ones generated by load_sampler_bqm_tests, a warning will be emitted.

Example

For example, if one wanted to test the ExactSolver,

import unittest

import dimod.testing

@dimod.testing.load_sampler_bqm_tests(dimod.ExactSolver)
class TestExactSolver(unittest.TestCase):
    pass

unittest.main()