Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make optional sampler args keyword-only #1316

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dimod/reference/samplers/exact_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ def __init__(self):
self.properties = {}
self.parameters = {}

def sample_cqm(self, cqm: ConstrainedQuadraticModel, rtol: float = 1e-6,
atol: float = 1e-8, **kwargs) -> SampleSet:
def sample_cqm(self, cqm: ConstrainedQuadraticModel, *,
rtol: float = 1e-6,
atol: float = 1e-8,
**kwargs) -> SampleSet:
"""Sample from a constrained quadratic model.

Args:
Expand Down
2 changes: 1 addition & 1 deletion dimod/reference/samplers/identity_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class IdentitySampler(Sampler, Initialized):

properties = {}

def sample(self, bqm: BinaryQuadraticModel,
def sample(self, bqm: BinaryQuadraticModel, *,
initial_states: typing.Optional[SamplesLike] = None,
initial_states_generator: InitialStateGenerator = 'random',
num_reads: typing.Optional[int] = None,
Expand Down
2 changes: 1 addition & 1 deletion dimod/reference/samplers/random_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self):
self.parameters = {'num_reads': []}
self.properties = {}

def sample(self, bqm, num_reads=10, seed=None, **kwargs):
def sample(self, bqm, *, num_reads=10, seed=None, **kwargs):
"""Return random samples for a binary quadratic model.

Variable assignments are chosen by coin flip.
Expand Down
2 changes: 1 addition & 1 deletion dimod/reference/samplers/simulated_annealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self):
'num_sweeps': []}
self.properties = {}

def sample(self, bqm, beta_range=None, num_reads=10, num_sweeps=1000, **kwargs):
def sample(self, bqm, *, beta_range=None, num_reads=10, num_sweeps=1000, **kwargs):
"""Sample from low-energy spin states using simulated annealing.

Args:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
upgrade:
- Make ``beta_range``, ``num_reads``, and ``num_sweeps`` keyword-only arguments for ``SimulatedAnnealingSampler.sample()``.
- Make ``num_reads`` and ``seed`` keyword-only arguments for ``RandomSampler.sample()``.
- Make ``initial_states``, ``initial_states_generator``, ``num_reads`` and ``seed`` keyword-only arguments for ``IdentitySampler.sample()``.
- Make ``rtol`` and ``atol`` keyword-only arguments for ``ExactCQMSolver.sample_cqm()``.