From 7aa679026e982945f7429cb864d0b0f153c6d51a Mon Sep 17 00:00:00 2001
From: markus holzer <markus.holzer@fau.de>
Date: Sat, 8 Aug 2020 15:08:12 +0200
Subject: [PATCH] Added test case for DotDict

---
 pystencils/utils.py            |  4 ++--
 pystencils_tests/test_utils.py | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/pystencils/utils.py b/pystencils/utils.py
index 6cbe324e9..bdeab9536 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 0cc2895ba..231b165a9 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
-- 
GitLab