Skip to content

Commit c7b86f6

Browse files
committed
REFACT/BREAK(conf, plot): better name for contextman
1 parent 85a8ee2 commit c7b86f6

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

docs/source/arch.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ Architecture
368368
configuration` - this term implies also any :ref:`plot-customizations`
369369
done on the installed plotter (such as `plot styles`).
370370

371-
Installation happens by calling one of :func:`.installed_plotter` or
371+
Installation happens by calling one of :func:`.installed_plotter_plugged()` or
372372
:func:`.set_installed_plotter` functions.
373373

374374
The **default** *installed plotter* is the plotter instance that this project

graphtik/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
abort_run,
1717
debug,
1818
evictions_skipped,
19-
execution_pool,
19+
execution_pool_plugged,
2020
get_execution_pool,
2121
is_abort,
2222
is_debug,
@@ -39,7 +39,7 @@
3939
tasks_marshalled,
4040
)
4141

42-
## SEE ALSO: `.plot.installed_plotter()`, `.plot.set_installed_plotter()` &
42+
## SEE ALSO: `.plot.installed_plotter_plugged()`, `.plot.set_installed_plotter()` &
4343
# `.plot.get_installed_plotter()` configs, not imported, unless plot is needed..
4444

4545
from .modifiers import * # noqa, on purpose to include any new modifiers

graphtik/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def is_abort():
9999

100100

101101
@contextmanager
102-
def execution_pool(pool: "Optional[Pool]"):
102+
def execution_pool_plugged(pool: "Optional[Pool]"):
103103
"""Like :func:`set_execution_pool()` as a context-manager to reset old value. """
104104
resetter = _execution_pool.set(pool)
105105
try:

graphtik/plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ def supported_plot_formats() -> List[str]:
10491049

10501050

10511051
@contextmanager
1052-
def installed_plotter(plotter: Plotter) -> None:
1052+
def installed_plotter_plugged(plotter: Plotter) -> None:
10531053
"""Like :func:`set_installed_plotter()` as a context-manager to reset old value. """
10541054
if not isinstance(plotter, Plotter):
10551055
raise ValueError(f"Cannot install invalid plotter: {plotter}")

test/test_graphtik.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
abort_run,
2626
compose,
2727
evictions_skipped,
28-
execution_pool,
28+
execution_pool_plugged,
2929
get_execution_pool,
3030
is_marshal_tasks,
3131
network,
@@ -85,7 +85,7 @@ def exemethod(request):
8585
else:
8686
pool = mp_dummy.Pool(nsharks)
8787

88-
with execution_pool(pool), pool:
88+
with execution_pool_plugged(pool), pool:
8989
yield parallel
9090
else:
9191
yield parallel
@@ -1253,7 +1253,7 @@ def test_multithreading_plan_execution():
12531253
)(partial(abspow, p=3)),
12541254
)
12551255

1256-
with mp_dummy.Pool(int(2 * cpu_count())) as pool, execution_pool(pool):
1256+
with mp_dummy.Pool(int(2 * cpu_count())) as pool, execution_pool_plugged(pool):
12571257
pool.map(
12581258
# lambda i: graph.withset(name='graph').compute(
12591259
lambda i: graph.compute(

test/test_plot.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
from graphtik import base, compose, network, operation, plot
1414
from graphtik.modifiers import optional
1515
from graphtik.netop import NetworkOperation
16-
from graphtik.plot import Plotter, Style, get_installed_plotter, installed_plotter
16+
from graphtik.plot import (
17+
Plotter,
18+
Style,
19+
get_installed_plotter,
20+
installed_plotter_plugged,
21+
)
1722

1823

1924
@pytest.fixture
@@ -346,7 +351,7 @@ def test_plotter_customizations(pipeline, monkeypatch):
346351

347352
## New installed_plotter
348353
#
349-
with installed_plotter(Plotter(style=Style(kw_legend={"URL": None}))):
354+
with installed_plotter_plugged(Plotter(style=Style(kw_legend={"URL": None}))):
350355
dot = str(pipeline.plot())
351356
assert url not in dot
352357

@@ -360,7 +365,7 @@ def test_plotter_customizations(pipeline, monkeypatch):
360365
assert url in dot
361366

362367
url2 = "http://example.2.org"
363-
with installed_plotter(Plotter(style=Style(kw_legend={"URL": url2}))):
368+
with installed_plotter_plugged(Plotter(style=Style(kw_legend={"URL": url2}))):
364369
dot = str(pipeline.plot())
365370
assert url2 in dot
366371
assert url not in dot

0 commit comments

Comments
 (0)