This is an automated email from the ASF dual-hosted git repository.

baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git

commit 22a8e12d38f9134c4eb006d1ceca6f773a412416
Author: baunsgaard <[email protected]>
AuthorDate: Fri Aug 19 16:44:35 2022 +0200

    [MINOR] Add stats test for python
---
 .../python/tests/basics/test_context_creation.py   |  1 +
 ...t_context_creation.py => test_context_stats.py} | 58 +++++++++++++---------
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/src/main/python/tests/basics/test_context_creation.py 
b/src/main/python/tests/basics/test_context_creation.py
index 1a70deb4ca..6a72757255 100644
--- a/src/main/python/tests/basics/test_context_creation.py
+++ b/src/main/python/tests/basics/test_context_creation.py
@@ -49,3 +49,4 @@ class TestContextCreation(unittest.TestCase):
         b.close()
         c.close()
         d.close()
+
diff --git a/src/main/python/tests/basics/test_context_creation.py 
b/src/main/python/tests/basics/test_context_stats.py
similarity index 55%
copy from src/main/python/tests/basics/test_context_creation.py
copy to src/main/python/tests/basics/test_context_stats.py
index 1a70deb4ca..745629868c 100644
--- a/src/main/python/tests/basics/test_context_creation.py
+++ b/src/main/python/tests/basics/test_context_stats.py
@@ -21,31 +21,43 @@
 
 import unittest
 
+import numpy as np
 from systemds.context import SystemDSContext
+np.random.seed(1412)
 
 
 class TestContextCreation(unittest.TestCase):
 
-    def test_same_port(self):
-        # Same port should graciously change port
-        sds1 = SystemDSContext(port=9415)
-        sds2 = SystemDSContext(port=9415)
-        sds1.close()
-        sds2.close()
-
-    def test_create_10_contexts(self):
-        # Creating multiple contexts and closing them should be no problem.
-        for _ in range(0, 10):
-            SystemDSContext().close()
-
-    def test_create_multiple_context(self):
-        # Creating multiple contexts in sequence but open at the same time is 
okay.
-        a = SystemDSContext()
-        b = SystemDSContext()
-        c = SystemDSContext()
-        d = SystemDSContext()
-
-        a.close()
-        b.close()
-        c.close()
-        d.close()
+    sds: SystemDSContext = None
+
+
+    @classmethod
+    def setUpClass(cls):
+        cls.sds = SystemDSContext()
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.sds.close()
+
+    def getM(self):
+        m1 = np.array(np.random.randint(10, size=5*5), dtype=np.int)
+        m1.shape = (5, 5)
+        return m1
+
+    def test_stats_v1(self):
+        a = self.sds.from_numpy(self.getM())
+        a = a + 1
+        a = a * 4
+        a = a + 3
+        a = a / 23
+
+        self.sds.capture_stats()
+        a.compute()
+        self.sds.capture_stats(False)
+
+        stats = self.sds.get_stats()
+        self.sds.clear_stats()
+        instructions = "\n".join(stats.split("Heavy hitter 
instructions:")[1].split("\n")[2:])
+        assert("+" in instructions and "*" in instructions and "/" in 
instructions)
+
+

Reply via email to