Skip to content

Commit b7ac800

Browse files
committed
REFACT(plot): Plotter-->Plottable
1 parent c18bb07 commit b7ac800

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ v4.1.0 (13 Dec 2019, @ankostis): ChainMap Solution for Rewrites, stable TOPOLOG
272272

273273
+ drop(net): ``_PinInstruction`` class is not needed.
274274
+ drop(netop): `overwrites_collector` parameter; now in :meth:`.Solution.overwrites()`.
275-
+ ENH(plot): ``Solution`` is also a :class:`.Plotter`; e.g. use ``sol.plot(...)```.
275+
+ ENH(plot): ``Solution`` is also a :class:`.Plottable`; e.g. use ``sol.plot(...)```.
276276

277277
+ DROP(plot): `executed` arg from plotting; now embedded in `solution`.
278278

docs/source/plotting.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ solution of the last computation, calling methods with arguments like this::
2929

3030
The legend for all graphtik diagrams, generated by :func:`.legend()`.
3131

32-
The same :meth:`.Plotter.plot()` method applies also for:
32+
The same :meth:`.Plottable.plot()` method applies also for:
3333

3434
- :class:`.NetworkOperation`
3535
- :class:`.Network`
@@ -68,7 +68,7 @@ If you want all details, plot the solution::
6868

6969
.. Tip::
7070
The `pydot.Dot <https://pypi.org/project/pydot/>`_ instances returned by
71-
:meth:`.Plotter.plot()` are rendered directly in *Jupyter/IPython* notebooks
71+
:meth:`.Plottable.plot()` are rendered directly in *Jupyter/IPython* notebooks
7272
as SVG images.
7373

7474
You may increase the height of the SVG cell output with something like this::
@@ -136,7 +136,7 @@ directive from :mod:`.sphinxext` module to embed graph-plots into your generated
136136
137137
the variable name containing what to render, which it can be:
138138
139-
- an instance of :class:`.Plotter` (such as :class:`.NetworkOperation`,
139+
- an instance of :class:`.Plottable` (such as :class:`.NetworkOperation`,
140140
:class:`.Network`, :class:`.ExecutionPlan` or :class:`.Solution`);
141141
142142
- an already plotted ``pydot.Dot`` instance, ie, the result of a :meth:`.plot()` call
@@ -231,7 +231,7 @@ which you may :graphtik:`reference <addmul-anchor>` with this syntax:
231231
.. hint::
232232
In this case, the ``:graphvar:`` parameter is not really needed, since
233233
the code contains just one variable assignment receiving a subclass
234-
of :class:`.Plotter` or :class:`pydot.Dot` instance.
234+
of :class:`.Plottable` or :class:`pydot.Dot` instance.
235235

236236
Additionally, the doctest code producing the *plottable* does not have to be contained
237237
in the *graphtik* directive.

graphtik/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def jetsam(ex, locs, *salvage_vars: str, annotation="jetsam", **salvage_mappings
201201

202202

203203
## Defined here, to avoid subclasses importing `plot` module.
204-
class Plotter(abc.ABC):
204+
class Plottable(abc.ABC):
205205
"""
206206
Classes wishing to plot their graphs should inherit this and ...
207207
@@ -274,7 +274,7 @@ def plot(
274274
275275
Check :data:`.default_jupyter_render` for defaults.
276276
277-
Note that the `graph` argument is absent - Each Plotter provides
277+
Note that the `graph` argument is absent - Each Plottable provides
278278
its own graph internally; use directly :func:`.render_pydot()` to provide
279279
a different graph.
280280

graphtik/netop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import networkx as nx
1111
from boltons.setutils import IndexedSet as iset
1212

13-
from .base import UNSET, Items, Plotter, aslist, astuple, jetsam
13+
from .base import UNSET, Items, Plottable, aslist, astuple, jetsam
1414
from .config import is_debug, reset_abort
1515
from .modifiers import optional, sideffect
1616
from .network import ExecutionPlan, Network, NodePredicate, Solution, yield_ops
@@ -89,7 +89,7 @@ def proc_op(op, parent=None):
8989
return net
9090

9191

92-
class NetworkOperation(Operation, Plotter):
92+
class NetworkOperation(Operation, Plottable):
9393
"""
9494
An operation that can :term:`compute` a network-graph of operations.
9595

graphtik/network.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import networkx as nx
1616
from boltons.setutils import IndexedSet as iset
1717

18-
from .base import UNSET, Items, Plotter, aslist, astuple, jetsam
18+
from .base import UNSET, Items, Plottable, aslist, astuple, jetsam
1919
from .config import (
2020
get_execution_pool,
2121
is_abort,
@@ -126,7 +126,7 @@ def _unsatisfied_operations(dag, inputs: Collection) -> List:
126126
return unsatisfied
127127

128128

129-
class Solution(ChainMap, Plotter):
129+
class Solution(ChainMap, Plottable):
130130
"""
131131
Collects outputs from operations, preserving :term:`overwrites`.
132132
@@ -447,7 +447,7 @@ def _do_task(task):
447447

448448

449449
class ExecutionPlan(
450-
namedtuple("ExecPlan", "net needs provides dag steps asked_outs"), Plotter
450+
namedtuple("ExecPlan", "net needs provides dag steps asked_outs"), Plottable
451451
):
452452
"""
453453
A pre-compiled list of operation steps that can :term:`execute` for the given inputs/outputs.
@@ -854,7 +854,7 @@ def execute(self, named_inputs, outputs=None, *, name="") -> Solution:
854854
raise
855855

856856

857-
class Network(Plotter):
857+
class Network(Plottable):
858858
"""
859859
A graph of operations that can :term:`compile` an execution plan.
860860

graphtik/op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
UNSET,
1818
Items,
1919
MultiValueError,
20-
Plotter,
20+
Plottable,
2121
aslist,
2222
astuple,
2323
jetsam,

graphtik/plot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#: A nested dictionary controlling the rendering of graph-plots in Jupyter cells,
2020
#:
21-
#: as those returned from :meth:`.Plotter.plot()` (currently as SVGs).
21+
#: as those returned from :meth:`.Plottable.plot()` (currently as SVGs).
2222
#: Either modify it in place, or pass another one in the respective methods.
2323
#:
2424
#: The following keys are supported.
@@ -207,7 +207,7 @@ def build_pydot(
207207
"""
208208
Build a *Graphviz* out of a Network graph/steps/inputs/outputs and return it.
209209
210-
See :meth:`.Plotter.plot()` for the arguments, sample code, and
210+
See :meth:`.Plottable.plot()` for the arguments, sample code, and
211211
the legend of the plots.
212212
"""
213213
from .op import Operation
@@ -411,7 +411,7 @@ def render_pydot(dot: pydot.Dot, filename=None, show=False, jupyter_render: str
411411
:return:
412412
the matplotlib image if ``show=-1``, or the `dot`.
413413
414-
See :meth:`.Plotter.plot()` for sample code.
414+
See :meth:`.Plottable.plot()` for sample code.
415415
"""
416416
# Save plot
417417
#
@@ -454,7 +454,7 @@ def legend(
454454
arch_url="https://graphtik.readthedocs.io/en/latest/arch.html",
455455
):
456456
"""
457-
Generate a legend for all plots (see :meth:`.Plotter.plot()` for args)
457+
Generate a legend for all plots (see :meth:`.Plottable.plot()` for args)
458458
459459
:param arch_url:
460460
the url to the architecture section explaining *graphtik* glossary.

graphtik/sphinxext/_graphtikbuilder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
from sphinx.locale import _, __
1515
from sphinx.util import logging
1616

17-
from ..base import Plotter
17+
from ..base import Plottable
1818
from ..network import Solution
1919
from . import doctestglobs, dynaimage, graphtik_node
2020

21-
Plottable = Union[None, Plotter, pydot.Dot]
21+
PlottableType = Union[None, Plottable, pydot.Dot]
2222

2323
log = logging.getLogger(__name__)
2424

@@ -72,12 +72,12 @@ def _globals_updated(self, code: extdoctest.TestCode, globs: dict):
7272
)
7373

7474
def _is_plottable(self, value):
75-
return isinstance(value, (Plotter, pydot.Dot))
75+
return isinstance(value, (Plottable, pydot.Dot))
7676

7777
def _retrieve_graphvar_plottable(
7878
self, globs: dict, graphvar, location,
79-
) -> Plottable:
80-
plottable: Plottable = None
79+
) -> PlottableType:
80+
plottable: PlottableType = None
8181

8282
if graphvar is None:
8383
## Pick last plottable from globals.

0 commit comments

Comments
 (0)