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
a3aad905
Commit
a3aad905
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add more tests for errors when creating an SFG
parent
c7d96a37
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!149
Add more tests for errors when creating an SFG
Pipeline
#88704
passed
2 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_sfg.py
+97
-0
97 additions, 0 deletions
test/test_sfg.py
with
97 additions
and
0 deletions
test/test_sfg.py
+
97
−
0
View file @
a3aad905
...
...
@@ -20,6 +20,7 @@ from b_asic.core_operations import (
Multiplication
,
SquareRoot
,
Subtraction
,
SymmetricTwoportAdaptor
,
)
from
b_asic.save_load_structure
import
python_to_sfg
,
sfg_to_python
...
...
@@ -1413,3 +1414,99 @@ class TestSFGGraph:
def
test_show_sfg_invalid_engine
(
self
,
sfg_simple_filter
):
with
pytest
.
raises
(
ValueError
):
sfg_simple_filter
.
show_sfg
(
engine
=
"
ppddff
"
)
class
TestSFGErrors
:
def
test_dangling_output
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
in2
)
out1
=
Output
(
adaptor
.
output
(
0
))
# No error, maybe should be?
_
=
SFG
([
in1
,
in2
],
[
out1
])
def
test_unconnected_input_port
(
self
):
in1
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
)
out1
=
Output
(
adaptor
.
output
(
0
))
with
pytest
.
raises
(
ValueError
,
match
=
"
Unconnected input port in SFG
"
):
SFG
([
in1
],
[
out1
])
def
test_unconnected_output
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
in2
)
out1
=
Output
(
adaptor
.
output
(
0
))
out2
=
Output
()
# No error, should be
SFG
([
in1
,
in2
],
[
out1
,
out2
])
def
test_unconnected_input
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
)
out1
=
Output
(
adaptor
.
output
(
0
))
out2
=
Output
(
adaptor
.
output
(
1
))
# Correct error?
with
pytest
.
raises
(
ValueError
,
match
=
"
Unconnected input port in SFG
"
):
SFG
([
in1
,
in2
],
[
out1
,
out2
])
def
test_duplicate_input
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
in2
)
out1
=
Output
(
adaptor
.
output
(
0
))
out2
=
Output
(
adaptor
.
output
(
1
))
with
pytest
.
raises
(
ValueError
,
match
=
"
Duplicate input operation
"
):
SFG
([
in1
,
in1
],
[
out1
,
out2
])
def
test_duplicate_output
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
in2
)
out1
=
Output
(
adaptor
.
output
(
0
))
out2
=
Output
(
adaptor
.
output
(
1
))
with
pytest
.
raises
(
ValueError
,
match
=
"
Duplicate output operation
"
):
SFG
([
in1
,
in2
],
[
out1
,
out1
])
def
test_unconnected_input_signal
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
in2
)
out1
=
Output
(
adaptor
.
output
(
0
))
out2
=
Output
(
adaptor
.
output
(
1
))
signal
=
Signal
()
with
pytest
.
raises
(
ValueError
,
match
=
"
Input signal #0 is missing destination in SFG
"
):
SFG
([
in1
,
in2
],
[
out1
,
out2
],
[
signal
])
def
test_unconnected_output_signal
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
in2
)
out1
=
Output
(
adaptor
.
output
(
0
))
out2
=
Output
(
adaptor
.
output
(
1
))
signal
=
Signal
()
with
pytest
.
raises
(
ValueError
,
match
=
"
Output signal #0 is missing source in SFG
"
):
SFG
([
in1
,
in2
],
[
out1
,
out2
],
output_signals
=
[
signal
])
def
test_duplicate_input_signal
(
self
):
in1
=
Input
()
signal
=
Signal
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
signal
)
out1
=
Output
(
adaptor
.
output
(
0
))
out2
=
Output
(
adaptor
.
output
(
1
))
with
pytest
.
raises
(
ValueError
,
match
=
"
Duplicate input signal
"
):
SFG
([
in1
],
[
out1
,
out2
],
[
signal
,
signal
])
def
test_duplicate_output_signal
(
self
):
in1
=
Input
()
in2
=
Input
()
adaptor
=
SymmetricTwoportAdaptor
(
0.5
,
in1
,
in2
)
out1
=
Output
(
adaptor
.
output
(
0
))
signal
=
Signal
(
adaptor
.
output
(
1
))
# Should raise?
SFG
([
in1
,
in2
],
[
out1
],
output_signals
=
[
signal
,
signal
])
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