Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Sean Leavey
Zero
Commits
d17e6cb1
Commit
d17e6cb1
authored
May 07, 2019
by
Sean Leavey
Browse files
Add solution order test (failing)
parent
3be6b16e
Pipeline
#60912
failed with stage
in 20 minutes and 22 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/integration/liso/test_solution_order.py
0 → 100644
View file @
d17e6cb1
"""Solution ordering tests"""
import
unittest
from
zero.liso
import
LisoInputParser
class
LisoSolutionOrderTestCase
(
unittest
.
TestCase
):
"""Base test case class for solution order tests"""
def
setUp
(
self
):
self
.
reset
()
def
reset
(
self
):
"""Reset input parser"""
self
.
parser
=
LisoInputParser
()
def
parse_and_get
(
self
,
circuit
,
*
args
,
**
kwargs
):
"""Parse specified circuit and return solution"""
self
.
parser
.
parse
(
circuit
)
return
self
.
parser
.
solution
(
*
args
,
**
kwargs
)
def
parse_and_get_default_function_labels
(
self
,
circuit
,
*
args
,
**
kwargs
):
"""Parse specified circuit and return default solution function names"""
solution
=
self
.
parse_and_get
(
circuit
,
*
args
,
**
kwargs
)
labels
=
[]
for
functions
in
solution
.
default_functions
.
values
():
labels
.
extend
([
function
.
label
()
for
function
in
functions
])
return
labels
def
check_default_function_order
(
self
,
circuit
,
pattern
,
items
,
*
args
,
**
kwargs
):
"""Parse specified circuit and check its default function order matches the specified
\
pattern substituted with the specified items."""
labels
=
self
.
parse_and_get_default_function_labels
(
circuit
,
*
args
,
**
kwargs
)
with
self
.
subTest
():
print
(
labels
)
self
.
assertEqual
(
labels
,
[
pattern
%
item
for
item
in
items
])
class
SolutionOrderTestCase
(
LisoSolutionOrderTestCase
):
"""Test that default solution functions are ordered in the same way as the input file"""
def
test_solution_order_all_tfs
(
self
):
"""Test solution order with all node transfer functions"""
circuit
=
"""
c c1 270n nm2 no
c c2 7u no3 np1
c ca 1.5u nm2 ni
op n1a OP27 np1 gnd no1
op n2a OP27 gnd nm2 no
op n3a OP27 gnd nm3 no3
r ri2 3k nm3 no1
r ri1 1k no3 nm3
r r1 40k no1 nm2
r r2 2k np1 no
r ra 116k nm2 ni
r rb 2k np1 ni
r rq 23k nm2 no
r load 1k no gnd
r rin 50 nii ni
freq log 1 100 100
uinput nii
uoutput no all
"""
self
.
check_default_function_order
(
circuit
,
"nii to %s (V/V)"
,
[
"nm2"
,
"no"
,
"no3"
,
"np1"
,
"ni"
,
"no1"
,
"nm3"
,
"nii"
])
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment