[Libre-soc-bugs] [Bug 1094] insndb instruction database visitor-walker is needed

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sun Jun 4 15:12:38 BST 2023


--- Comment #39 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Dmitry Selyutin from comment #36)

> Basically what I want is "only filter some specific records to be visited,
> where record name matches the CLI arguments".


i pass in a col_subset (a set - by CSV-name - of which columns)
and a row_subsetfn.

row_subsetfn receives the row and returns True/False.

however the *visitor* would simply go:

     def child_data_function(self, child_index, child_data):
          if some_filter_criteria(child_data):

ahhh i know what you've missed.  look again at the pyomo Visitor API:


the "enterNode()" function is where the Visitor API allows for "results"
to be accumulated - partially - and keeps all necessary state information.

  83        initializeWalker(expr) -> walk, result
  84        enterNode(N1) -> args, data
  85        {for N2 in args:}
  86          beforeChild(N1, N2) -> descend, child_result
  87            enterNode(N2) -> N2_args, N2_data
  88            [...]
  89            exitNode(N2, n2_data) -> child_result
  90          acceptChildResult(N1, data, child_result) -> data
  91          afterChild(N1, N2) -> None
  92        exitNode(N1, data) -> N1_result
  93        finalizeWalker(result) -> result

so the Visitor-callbacks receive all the information they need to "keep track".

one of the things they can "keep track" of is: an object with the
filter arguments.  anything else can also be passed "up the stack"
of the Visitor-callbacks.

You are receiving this mail because:
You are on the CC list for the bug.

More information about the libre-soc-bugs mailing list