Skip to content
Snippets Groups Projects

Update signal_flow_graph.SFG.find_by_type_name. Now it actually checks the...

Open Petter Källström requested to merge petka86-find_by_type_name into master
1 unresolved thread

Update signal_flow_graph.SFG.find_by_type_name. Now it actually checks the type name, and not the _graph_id. Safer (if user changed the graph_id), and no need for regex.

Merge request reports

Code Quality is loading
Ready to merge by members who can write to the target branch.

Merge details

  • The source branch is 67 commits behind the target branch.
  • 4 commits and 1 merge commit will be added to .
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Oscar Gustafsson approved this merge request

    approved this merge request

  • Please fix the test (looks like there is an additional "IN2" here). Not sure if it should be like that and the test be updated or if the code should return something else.

  • Mmm. Working on it. Does not understand how the test works. Where does the argument "sfg_two_inputs_two_outputs" come from?

  • That is a fixture from test/fixtures/signal_flow_graph.py.

    My guess is that somehow self._components_dfs_order contains two copies of IN2. Which seems to be a bug. But will also dig a bit.

  • Btw, does the current implementation cause problems? I can see that it is inefficient and not intuitive, but wrong?

  • Yep, the second input is duplicated in self._components_dfs_order. Leave this as is and then we can try to solve that problem first.

  • I don't know how to test it. Probably it works, since it uses _components_by_id, which is somehow grouped by ID (i.e. it should have one group of two 'IN2'). Okay. I leave it for the moment. I had to use this myself to get lab3 working, since I've changed IDs to 'p4' etc.

  • Gaah. I don't manage to run conftest. It just try to load submodules from /opt/conda/.../test/... instead of from B-ASIC/test/... Tried using both Python3.8 and 3.11 (with different paths within the /opt/...)

  • OK! Changing ids is not really the recommended way of doing things...

    But it clearly found another bug and your approach still makes more sense (despite the reason).

  • Ah. Original code also contains another bug: If I do find_by_type_name('sym'), it will return all components with type name "sym", but also all components with type name "sym2p". Until solved, we better not implement any "sym" component.

  • This line should solve everything:

    com for com in self._components_by_id.values() if com.type_name() == type_name

    For the moment, I do nothing but write it down here as a comment.

549 549 type_name : TypeName
550 550 The TypeName of the desired components.
551 551 """
552 reg = f"{type_name}[0-9]+"
553 p = re.compile(reg)
554 552 components = [
555 val for key, val in self._components_by_id.items() if p.match(key)
553 com for com in self._components_dfs_order if com.type_name() == type_name
556 554 ]
557 555 return components
  • I now added a method find_by_type that takes the type. This still makes sense to provide though. I had to rely on the hacky way to get rid of multiple components and also opened an issue about it #332 as it is not clear that there should be multiple instances in the dfs-list.

  • Please register or sign in to reply
    Loading