diff --git a/pystencils/utils.py b/pystencils/utils.py index 6cbe324e94469010880497672369a01f2106a88e..bdeab95363c651e4a7b31348521726d82e82c646 100644 --- a/pystencils/utils.py +++ b/pystencils/utils.py @@ -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): diff --git a/pystencils_tests/test_utils.py b/pystencils_tests/test_utils.py index 0cc2895babf8ef6694b9000530c50d1b2a2e9ba3..231b165a92134c1ab4d1c2904bb71f066ced196f 100644 --- a/pystencils_tests/test_utils.py +++ b/pystencils_tests/test_utils.py @@ -1,5 +1,6 @@ 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