Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
bcf36af7
Commit
bcf36af7
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Rename replace_component to replace_operation
parent
fbd90a6e
Branches
Branches containing commit
No related tags found
1 merge request
!261
Replaceop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/signal_flow_graph.py
+6
-5
6 additions, 5 deletions
b_asic/signal_flow_graph.py
test/test_sfg.py
+6
-6
6 additions, 6 deletions
test/test_sfg.py
with
12 additions
and
11 deletions
b_asic/signal_flow_graph.py
+
6
−
5
View file @
bcf36af7
...
...
@@ -594,17 +594,18 @@ class SFG(AbstractOperation):
keys
.
append
(
comp
.
key
(
output_index
,
comp
.
graph_id
))
return
keys
def
replace_
component
(
self
,
component
:
Operation
,
graph_id
:
GraphID
)
->
"
SFG
"
:
def
replace_
operation
(
self
,
component
:
Operation
,
graph_id
:
GraphID
)
->
"
SFG
"
:
"""
Find and replace all components matching either on GraphID, Type or both.
Then return a new deepcopy of the sfg with the replaced component.
Find and replace an operation based on GraphID.
Then return a new deepcopy of the SFG with the replaced operation.
Parameters
----------
component : Operation
The new
component
(s), e.g. Multiplication
The new
operation
(s), e.g. Multiplication
graph_id : GraphID
The GraphID to match the
component
to replace.
The GraphID to match the
operation
to replace.
"""
sfg_copy
=
self
()
# Copy to not mess with this SFG.
...
...
This diff is collapsed.
Click to expand it.
test/test_sfg.py
+
6
−
6
View file @
bcf36af7
...
...
@@ -296,12 +296,12 @@ class TestComponents:
}
class
TestReplace
Components
:
class
TestReplace
Operation
:
def
test_replace_addition_by_id
(
self
,
operation_tree
):
sfg
=
SFG
(
outputs
=
[
Output
(
operation_tree
)])
component_id
=
"
add1
"
sfg
=
sfg
.
replace_
component
(
Multiplication
(
name
=
"
Multi
"
),
graph_id
=
component_id
)
sfg
=
sfg
.
replace_
operation
(
Multiplication
(
name
=
"
Multi
"
),
graph_id
=
component_id
)
assert
component_id
not
in
sfg
.
_components_by_id
.
keys
()
assert
"
Multi
"
in
sfg
.
_components_by_name
.
keys
()
...
...
@@ -309,7 +309,7 @@ class TestReplaceComponents:
sfg
=
SFG
(
outputs
=
[
Output
(
large_operation_tree
)])
component_id
=
"
add3
"
sfg
=
sfg
.
replace_
component
(
Multiplication
(
name
=
"
Multi
"
),
graph_id
=
component_id
)
sfg
=
sfg
.
replace_
operation
(
Multiplication
(
name
=
"
Multi
"
),
graph_id
=
component_id
)
assert
"
Multi
"
in
sfg
.
_components_by_name
.
keys
()
assert
component_id
not
in
sfg
.
_components_by_id
.
keys
()
...
...
@@ -318,7 +318,7 @@ class TestReplaceComponents:
component_id
=
"
c1
"
const_
=
sfg
.
find_by_id
(
component_id
)
sfg
=
sfg
.
replace_
component
(
Constant
(
1
),
graph_id
=
component_id
)
sfg
=
sfg
.
replace_
operation
(
Constant
(
1
),
graph_id
=
component_id
)
assert
const_
is
not
sfg
.
find_by_id
(
component_id
)
def
test_no_match_on_replace
(
self
,
large_operation_tree
):
...
...
@@ -328,7 +328,7 @@ class TestReplaceComponents:
with
pytest
.
raises
(
ValueError
,
match
=
"
No operation matching the criteria found
"
):
sfg
=
sfg
.
replace_
component
(
sfg
=
sfg
.
replace_
operation
(
Multiplication
(
name
=
"
Multi
"
),
graph_id
=
component_id
)
...
...
@@ -340,7 +340,7 @@ class TestReplaceComponents:
TypeError
,
match
=
"
The input count may not differ between the operations
"
,
):
sfg
=
sfg
.
replace_
component
(
sfg
=
sfg
.
replace_
operation
(
Multiplication
(
name
=
"
Multi
"
),
graph_id
=
component_id
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment