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
f4ded614
Commit
f4ded614
authored
4 years ago
by
angloth
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for deepcopying and also some additional edge cases for constructing
parent
17ff7b41
No related branches found
No related tags found
5 merge requests
!31
Resolve "Specify internal input/output dependencies of an Operation"
,
!25
Resolve "System tests iteration 1"
,
!24
Resolve "System tests iteration 1"
,
!23
Resolve "Simulate SFG"
,
!21
Resolve "Print SFG"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_sfg.py
+65
-10
65 additions, 10 deletions
test/test_sfg.py
with
65 additions
and
10 deletions
test/test_sfg.py
+
65
−
10
View file @
f4ded614
from
b_asic
import
SFG
from
b_asic.signal
import
Signal
from
b_asic.core_operations
import
Addition
,
Constant
from
b_asic.core_operations
import
Addition
,
Constant
,
Multiplication
from
b_asic.special_operations
import
Input
,
Output
class
TestConstructor
:
def
test_direct_input_to_output_sfg_construction
(
self
):
inp
=
Input
(
"
INP1
"
)
out
=
Output
(
None
,
"
OUT1
"
)
out
.
input
(
0
).
connect
(
inp
,
"
S1
"
)
sfg
=
SFG
(
inputs
=
[
inp
],
outputs
=
[
out
])
assert
len
(
list
(
sfg
.
components
))
==
3
assert
sfg
.
input_count
==
1
assert
sfg
.
output_count
==
1
def
test_same_signal_input_and_output_sfg_construction
(
self
):
sig1
=
Signal
(
None
,
None
,
"
S1
"
)
sfg
=
SFG
(
input_signals
=
[
sig1
],
output_signals
=
[
sig1
])
assert
len
(
list
(
sfg
.
components
))
==
3
assert
sfg
.
input_count
==
1
assert
sfg
.
output_count
==
1
def
test_outputs_construction
(
self
,
operation_tree
):
outp
=
Output
(
operation_tree
)
sfg
=
SFG
(
outputs
=
[
outp
])
...
...
@@ -20,13 +41,47 @@ class TestConstructor:
assert
sfg
.
input_count
==
0
assert
sfg
.
output_count
==
1
def
test_operations_construction
(
self
,
operation_tree
):
sfg1
=
SFG
(
operations
=
[
operation_tree
])
sfg2
=
SFG
(
operations
=
[
operation_tree
.
input
(
1
).
signals
[
0
].
source
.
operation
])
assert
len
(
list
(
sfg1
.
components
))
==
5
assert
len
(
list
(
sfg2
.
components
))
==
5
assert
sfg1
.
input_count
==
0
assert
sfg2
.
input_count
==
0
assert
sfg1
.
output_count
==
0
assert
sfg2
.
output_count
==
0
class
TestDeepCopy
:
def
test_deep_copy_no_duplicates
(
self
):
inp1
=
Input
(
"
INP1
"
)
inp2
=
Input
(
"
INP2
"
)
inp3
=
Input
(
"
INP3
"
)
add1
=
Addition
(
inp1
,
inp2
,
"
ADD1
"
)
mul1
=
Multiplication
(
add1
,
inp3
,
"
MUL1
"
)
out1
=
Output
(
mul1
,
"
OUT1
"
)
mac_sfg
=
SFG
(
inputs
=
[
inp1
,
inp2
],
outputs
=
[
out1
],
name
=
"
mac_sfg
"
)
mac_sfg_deep_copy
=
mac_sfg
.
deep_copy
()
for
g_id
,
component
in
mac_sfg
.
_components_by_id
.
items
():
component_copy
=
mac_sfg_deep_copy
.
find_by_id
(
g_id
)
assert
component
.
name
==
component_copy
.
name
def
test_deep_copy
(
self
):
inp1
=
Input
(
"
INP1
"
)
inp2
=
Input
(
"
INP2
"
)
inp3
=
Input
(
"
INP3
"
)
add1
=
Addition
(
None
,
None
,
"
ADD1
"
)
add2
=
Addition
(
None
,
None
,
"
ADD2
"
)
mul1
=
Multiplication
(
None
,
None
,
"
MUL1
"
)
out1
=
Output
(
None
,
"
OUT1
"
)
add1
.
input
(
0
).
connect
(
inp1
,
"
S1
"
)
add1
.
input
(
1
).
connect
(
inp2
,
"
S2
"
)
add2
.
input
(
0
).
connect
(
add1
,
"
S4
"
)
add2
.
input
(
1
).
connect
(
inp3
,
"
S3
"
)
mul1
.
input
(
0
).
connect
(
add1
,
"
S5
"
)
mul1
.
input
(
1
).
connect
(
add2
,
"
S6
"
)
out1
.
input
(
0
).
connect
(
mul1
,
"
S7
"
)
mac_sfg
=
SFG
(
inputs
=
[
inp1
,
inp2
],
outputs
=
[
out1
],
name
=
"
mac_sfg
"
)
mac_sfg_deep_copy
=
mac_sfg
.
deep_copy
()
for
g_id
,
component
in
mac_sfg
.
_components_by_id
.
items
():
component_copy
=
mac_sfg_deep_copy
.
find_by_id
(
g_id
)
assert
component
.
name
==
component_copy
.
name
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