Commit 7aa67902 authored by Markus Holzer's avatar Markus Holzer
Browse files

Added test case for DotDict

parent 6bff474a
......@@ -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):
......
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment