Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephan Seitz
pystencils
Commits
7aa67902
Commit
7aa67902
authored
Aug 08, 2020
by
Markus Holzer
Browse files
Added test case for DotDict
parent
6bff474a
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/utils.py
View file @
7aa67902
...
...
@@ -206,7 +206,6 @@ class LinearEquationSystem:
non_zero_rows
=
self
.
next_zero_row
num_unknowns
=
len
(
self
.
unknowns
)
if
non_zero_rows
==
0
:
print
(
"test"
)
return
'multiple'
*
row_begin
,
left
,
right
=
self
.
_matrix
.
row
(
non_zero_rows
-
1
)
...
...
@@ -224,7 +223,8 @@ class LinearEquationSystem:
return
'multiple'
def
solution
(
self
):
"""Solves the system if it has a single solution. Returns a dictionary mapping symbol to solution value."""
"""Solves the system. Under- and overdetermined systems are supported.
Returns a dictionary mapping symbol to solution value."""
return
sp
.
solve_linear_system
(
self
.
_matrix
,
*
self
.
unknowns
)
def
_resize_if_necessary
(
self
,
new_rows
=
1
):
...
...
pystencils_tests/test_utils.py
View file @
7aa67902
import
sympy
as
sp
from
pystencils.utils
import
LinearEquationSystem
from
pystencils.utils
import
DotDict
def
test_LinearEquationSystem
():
...
...
@@ -34,3 +35,18 @@ def test_LinearEquationSystem():
les
.
add_equation
(
x
+
y
+
5
)
assert
les
.
solution_structure
()
==
'none'
def
test_DotDict
():
d
=
{
'a'
:
{
'c'
:
7
},
'b'
:
6
}
t
=
DotDict
(
d
)
assert
t
.
a
.
c
==
7
assert
t
.
b
==
6
assert
len
(
t
)
==
2
delattr
(
t
,
'b'
)
assert
len
(
t
)
==
1
t
.
b
=
6
assert
len
(
t
)
==
2
assert
t
.
b
==
6
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