Skip to content

Commit 664e1b2

Browse files
committed
refact(netop): rename netop.narrow() --> narrowed()
1 parent c39f8ba commit 664e1b2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

graphtik/netop.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def __init__(
5050
):
5151
"""
5252
:param inputs:
53-
see :meth:`narrow()`
53+
see :meth:`narrowed()`
5454
:param outputs:
55-
see :meth:`narrow()`
55+
see :meth:`narrowed()`
5656
:param predicate:
5757
a 2-argument callable(op, node-data) that should return true for nodes to include
5858
:param method:
@@ -65,7 +65,7 @@ def __init__(
6565
If missing, values are simply discarded.
6666
6767
:raises ValueError:
68-
see :meth:`narrow()`
68+
see :meth:`narrowed()`
6969
"""
7070
## Set data asap, for debugging, although `pruned()` will reset them.
7171
self.name = name
@@ -96,7 +96,7 @@ def __repr__(self):
9696
f"{clsname}({self.name!r}, needs={needs}, provides={provides}, x{nops}ops)"
9797
)
9898

99-
def narrow(
99+
def narrowed(
100100
self,
101101
inputs: Items = None,
102102
outputs: Items = None,
@@ -295,7 +295,7 @@ def compose(
295295
of multiple times (one for each time the operation appears).
296296
:param node_props:
297297
added as-is into NetworkX graph, to provide for filtering
298-
by :meth:`.NetworkOperation.narrow()`.
298+
by :meth:`.NetworkOperation.narrowed()`.
299299
:param method:
300300
either `parallel` or None (default);
301301
if ``"parallel"``, launches multi-threading.

test/test_graphtik.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,10 @@ def test_node_props_based_prune():
357357
# assert netop(**inp)["sum"] == 6
358358

359359
pred = lambda n, d: d.get("color", None) != "red"
360-
assert netop.narrow(predicate=pred)(**inp)["sum"] == 5
360+
assert netop.narrowed(predicate=pred)(**inp)["sum"] == 5
361361

362362
pred = lambda n, d: "color" not in d
363-
assert netop.narrow(predicate=pred)(**inp)["sum"] == 3
363+
assert netop.narrowed(predicate=pred)(**inp)["sum"] == 3
364364

365365

366366
def test_input_based_pruning():
@@ -412,8 +412,8 @@ def test_deps_pruning_vs_narrowing(samplenet):
412412
assert "sum3" in results
413413
assert results["sum3"] == add(c, sum2)
414414

415-
# Compare with both `narrow()`.
416-
net = samplenet.narrow(inputs=["c", "sum2"], outputs=["sum3"])
415+
# Compare with both `narrowed()`.
416+
net = samplenet.narrowed(inputs=["c", "sum2"], outputs=["sum3"])
417417
results = net(c=c, sum2=sum2)
418418

419419
# Make sure we got expected result without having to pass a, b, or d.
@@ -645,7 +645,7 @@ def test_same_outputs_operations_order():
645645

646646
inp = {"a": 3, "b": 1}
647647
assert addsub(**inp) == {"a": 3, "b": 1, "ab": 4, "AB": 4}
648-
assert addsub.narrow(outputs="AB")(**inp) == {"AB": 4}
648+
assert addsub.narrowed(outputs="AB")(**inp) == {"AB": 4}
649649
assert subadd(**inp) == {"a": 3, "b": 1, "ab": 2, "AB": 2}
650650
assert subadd.compute(inp, "AB") == {"AB": 2}
651651

@@ -678,7 +678,7 @@ def test_unsatisfied_operations():
678678
exp = {"a": 10, "b1": 2, "a+b1": 12}
679679
assert pipeline(**{"a": 10, "b1": 2}) == exp
680680
assert pipeline.compute({"a": 10, "b1": 2}, ["a+b1"]) == filtdict(exp, "a+b1")
681-
assert pipeline.narrow(outputs=["a+b1"])(**{"a": 10, "b1": 2}) == filtdict(
681+
assert pipeline.narrowed(outputs=["a+b1"])(**{"a": 10, "b1": 2}) == filtdict(
682682
exp, "a+b1"
683683
)
684684

0 commit comments

Comments
 (0)