Skip to content

Commit

Permalink
Merge pull request #1316 from arcondello/feature/keyword-only-sampler…
Browse files Browse the repository at this point in the history
…-args

Make optional sampler args keyword-only
  • Loading branch information
arcondello committed Mar 13, 2023
2 parents d5a3059 + fa6e6d6 commit 5ef7897
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
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()``.

0 comments on commit 5ef7897

Please sign in to comment.