Skip to content

Commit 9cbce7d

Browse files
committed
Update docs with @JoelPasvolsky review suggestions
1 parent 75ab426 commit 9cbce7d

3 files changed

Lines changed: 29 additions & 21 deletions

File tree

dimod/core/composite.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@
5454

5555

5656
class Composite(Scoped):
57-
"""Abstract base class for dimod composites over scoped resources.
57+
"""Abstract base class for dimod composites.
5858
5959
Provides the :attr:`Composite.child` mixin property and defines the :attr:`Composite.children`
6060
abstract property to be implemented. These define the supported samplers for the composed sampler.
6161
62-
It also implements default :meth:`.close` operation that closes all child samplers.
62+
:class:`.Composite` implements the :class:`~dimod.core.scoped.Scoped` interface, and
63+
provides :meth:`.close` method that closes all child samplers or composites.
6364
6465
.. versionchanged:: 0.12.19
65-
:class:`.Composite` now implements the :class:`~dimod.core.scoped.Scoped`
66-
interface, meaning all composites support context manager protocol and
67-
release scope-based resources of sub-samplers/composites by default.
66+
Implemented the :class:`~dimod.core.scoped.Scoped` interface. Now all
67+
composites support context manager protocol and release scope-based
68+
resources of sub-samplers/composites by default.
6869
"""
6970

7071
@abc.abstractproperty
@@ -83,17 +84,16 @@ def child(self):
8384
raise RuntimeError("A Composite must have at least one child Sampler")
8485

8586
def close(self):
86-
"""Release resources of child samplers/composites, in case they allocated
87-
any scope-bound resources.
87+
"""Release any scope-bound resources of child samplers or composites.
8888
8989
.. note::
9090
If a :class:`.Composite` subclass doesn't allocate resources that have
91-
to be explicitly released, there's not need to override the default
91+
to be explicitly released, there's no need to override the default
9292
:meth:`~.Composite.close` implementation.
9393
94-
However, if you do implement it on a subclass, make sure to either
95-
call ``super().close()``, or to explicitly close all child
96-
samplers/composites.
94+
However, if you do implement :meth:`~.Composite.close` on a subclass,
95+
make sure to either call ``super().close()``, or to explicitly close
96+
all child samplers/composites.
9797
9898
.. versionadded:: 0.12.19
9999
:class:`.Composite` now implements the :class:`~dimod.core.scoped.Scoped`

dimod/core/sampler.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ class Sampler(Scoped, metaclass=SamplerABCMeta):
174174
Also includes utility method :meth:`~.Sampler.remove_unknown_kwargs`,
175175
which may be used in sample methods to handle unknown kwargs.
176176
177-
Default implementation of :meth:`~.Sampler.close` does nothing, so it should
178-
be overridden to release scope-based sampler resources, it any.
177+
:class:`.Sampler` implements the :class:`~dimod.core.scoped.Scoped` interface,
178+
but the default implementation of :meth:`~.Sampler.close` does nothing. It
179+
should be overridden to release any scope-based sampler resources.
179180
180181
.. versionchanged:: 0.12.19
181182
:class:`.Sampler` now implements the :class:`~dimod.core.scoped.Scoped`

docs/reference/sampler_composites/api.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,51 @@ ABCs.
2222
- Abstract Properties
2323
- Abstract Methods
2424
- Mixin Methods
25-
* - :class:`.Sampler`
25+
* - :class:`.Scoped`
26+
-
2627
-
28+
- :meth:`~.Scoped.close`
29+
- :meth:`~.Scoped.__enter__`, :meth:`~.Scoped.__exit__`
30+
* - :class:`.Sampler`
31+
- :class:`.Scoped`
2732
- :attr:`~.Sampler.parameters`, :attr:`~.Sampler.properties`
2833
- at least one of
2934
:meth:`~.Sampler.sample`, :meth:`~.Sampler.sample_ising`, :meth:`~.Sampler.sample_qubo`
30-
- :meth:`~.Sampler.sample`, :meth:`~.Sampler.sample_ising`, :meth:`~.Sampler.sample_qubo`
35+
- :meth:`~.Sampler.sample`, :meth:`~.Sampler.sample_ising`, :meth:`~.Sampler.sample_qubo`,
36+
:meth:`~.Sampler.close`
3137
* - :class:`.Structured`
3238
-
3339
- :attr:`~.Structured.nodelist`, :attr:`~.Structured.edgelist`
3440
-
3541
- :attr:`~.Structured.structure`, :attr:`~.Structured.adjacency`, :meth:`~.Structured.to_networkx_graph`
3642
* - :class:`.Composite`
37-
-
43+
- :class:`.Scoped`
3844
- :attr:`~.Composite.children`
3945
-
40-
- :attr:`~.Composite.child`
46+
- :attr:`~.Composite.child`, :meth:`~.Composite.close`
4147
* - :class:`.ComposedSampler`
4248
- :class:`.Sampler`, :class:`.Composite`
4349
- :attr:`~.Sampler.parameters`, :attr:`~.Sampler.properties`, :attr:`~.Composite.children`
4450
- at least one of
4551
:meth:`~.Sampler.sample`, :meth:`~.Sampler.sample_ising`, :meth:`~.Sampler.sample_qubo`
4652
- :meth:`~.Sampler.sample`, :meth:`~.Sampler.sample_ising`, :meth:`~.Sampler.sample_qubo`,
47-
:attr:`~.Composite.child`
53+
:attr:`~.Composite.child`, :meth:`~.Composite.close`
4854
* - :class:`.Initialized`
4955
-
5056
-
5157
-
5258
- :attr:`~.Initialized.parse_initial_states`
5359
* - :class:`.PolySampler`
54-
-
60+
- :class:`.Scoped`
5561
- :attr:`~.PolySampler.parameters`, :attr:`~.PolySampler.properties`
5662
- :meth:`~.PolySampler.sample_poly`
57-
- :meth:`~.PolySampler.sample_hising`, :meth:`~.PolySampler.sample_hubo`
63+
- :meth:`~.PolySampler.sample_hising`, :meth:`~.PolySampler.sample_hubo`, :meth:`~.PolySampler.close`
5864
* - :class:`.ComposedPolySampler`
5965
- :class:`.PolySampler`, :class:`.Composite`
6066
- :attr:`~.PolySampler.parameters`, :attr:`~.PolySampler.properties`, :attr:`~.Composite.children`
6167
- :meth:`~.Sampler.sample_poly`
62-
- :meth:`~.Sampler.sample_hising`, :meth:`~.Sampler.sample_hubo`, :attr:`~.Composite.child`
68+
- :meth:`~.Sampler.sample_hising`, :meth:`~.Sampler.sample_hubo`, :attr:`~.Composite.child`,
69+
:meth:`~.PolySampler.close`
6370

6471
The table shows, for example, that the :class:`.Sampler` class requires that you implement
6572
the :attr:`~.Sampler.parameters` and :attr:`~.Sampler.properties` properties and at least

0 commit comments

Comments
 (0)