Skip to content

Commit 95345c8

Browse files
committed
REFACT(pipe): NULL_OP inherrit base Op (not FnOp) to break ...
import-time dependency pipeline.py --> op.py.
1 parent a374017 commit 95345c8

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

graphtik/network.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,10 @@ def proc_op(op, parent=None):
634634
"""clone FuncOperation with certain props changed"""
635635
from .op import FunctionalOperation
636636

637-
assert isinstance(op, FunctionalOperation), op
638-
639637
## Convey any node-props specified in the pipeline here
640638
# to all sub-operations.
641639
#
642-
if kw:
640+
if kw and isinstance(op, FunctionalOperation):
643641
if node_props:
644642
kw["node_props"] = {**op.node_props, **node_props}
645643

@@ -650,7 +648,7 @@ def parent_wrapper(ren_args: RenArgs) -> str:
650648
return renamer(ren_args._replace(parent=parent))
651649

652650
kw["renamer"] = parent_wrapper
653-
op = op = op.withset(**kw)
651+
op = op.withset(**kw)
654652

655653
return op
656654

graphtik/pipeline.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,34 @@
1616

1717
from .base import UNSET, Items, Operation, PlotArgs, Plottable, RenArgs, aslist, jetsam
1818
from .modifiers import dep_renamed
19-
from .op import FunctionalOperation, reparse_operation_data
2019

2120
log = logging.getLogger(__name__)
2221

2322

24-
class NULL_OP(FunctionalOperation):
23+
class NULL_OP(Operation):
2524
"""
2625
Eliminates same-named operations added later during term:`operation merging`.
2726
2827
:seealso: :ref:`operation-merging`
2928
"""
3029

3130
def __init__(self, name):
32-
super().__init__(name=name)
31+
self.name = name
32+
33+
def __hash__(self):
34+
return hash(self.name)
35+
36+
def __eq__(self, o):
37+
return self.name == o.name
38+
39+
def __repr__(self):
40+
return f"{type(self).__name__}({self.name})"
3341

3442
def compute(self, *args, **kw):
35-
raise AssertionError("Should have been eliminated!")
43+
raise AssertionError(f"{self} should have been eliminated!")
44+
45+
def prepare_plot_args(self, *args, **kw):
46+
raise AssertionError(f"{self} should have been eliminated!")
3647

3748

3849
def _id_bool(b):
@@ -85,6 +96,7 @@ def __init__(
8596
*Operations may only be added once, ...*
8697
"""
8798
from .network import build_network
99+
from .op import reparse_operation_data
88100

89101
## Set data asap, for debugging, although `net.withset()` will reset them.
90102
self.name = name

0 commit comments

Comments
 (0)