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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7850c9f  [MINOR] change header to boolean
7850c9f is described below

commit 7850c9f56ab0d482675f5c771c3f05c1fd8b8f56
Author: baunsgaard <[email protected]>
AuthorDate: Tue Apr 27 13:29:31 2021 +0200

    [MINOR] change header to boolean
    
    The latest commit of unified matadata made it not valid to read in
    a boolean as string in the metadatafile. this ment the pythonfederated
    tests failed.
    This commit simply corrects the metadata file generated in the federated
    python tests. But in the future we might want to be able to parse the
    boolean from a string in the mdt file.
---
 src/main/python/tests/federated/runFedTest.sh          |  2 ++
 .../tests/federated/test_federated_aggregations.py     |  9 ++++-----
 .../python/tests/federated/test_federated_basic.py     | 18 ++++++------------
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/src/main/python/tests/federated/runFedTest.sh 
b/src/main/python/tests/federated/runFedTest.sh
index 6dcf311..0d6b4f4 100755
--- a/src/main/python/tests/federated/runFedTest.sh
+++ b/src/main/python/tests/federated/runFedTest.sh
@@ -29,6 +29,7 @@
 # FIELDS
 workerdir="tests/federated/worker/"
 outputdir="tests/federated/output/"
+tmpfiledir="tests/federated/tmp/"
 mkdir $workerdir
 mkdir $outputdir
 w1_Output="$workerdir/w1"
@@ -59,6 +60,7 @@ echo -e "\n------------\nTest output:\n------------"
 cat $log
 grepvals="$(tail -n 10 $log | grep OK)"
 rm -r $outputdir
+rm -r $tmpfiledir
 echo -e "------------\n"
 if [[ $grepvals == *"OK"* ]]; then
        exit 0
diff --git a/src/main/python/tests/federated/test_federated_aggregations.py 
b/src/main/python/tests/federated/test_federated_aggregations.py
index 742db1e..cab3b17 100644
--- a/src/main/python/tests/federated/test_federated_aggregations.py
+++ b/src/main/python/tests/federated/test_federated_aggregations.py
@@ -39,19 +39,19 @@ m1.shape = (dim, dim)
 m2 = np.array(np.random.randint(5, size=dim * dim) + 1, dtype=np.double)
 m2.shape = (dim, dim)
 
-tempdir = "/tmp/test_federated_aggregations/"
-mtd = {"format": "csv", "header": "false", "rows": dim, "cols": dim}
+tempdir = "./tests/federated/tmp/test_federated_aggregations/"
+mtd = {"format": "csv", "header": True, "rows": dim, "cols": dim, "data_type": 
"matrix", "value_type": "double" }
 
 # Create the testing directory if it does not exist.
 if not os.path.exists(tempdir):
     os.makedirs(tempdir)
 
 # Save data files for the Federated workers.
-np.savetxt(tempdir + "m1.csv", m1, delimiter=",")
+np.savetxt(tempdir + "m1.csv", m1, delimiter=",", header="a,b,c,d,e")
 with io.open(tempdir + "m1.csv.mtd", "w", encoding="utf-8") as f:
     f.write(json.dumps(mtd, ensure_ascii=False))
 
-np.savetxt(tempdir + "m2.csv", m2, delimiter=",")
+np.savetxt(tempdir + "m2.csv", m2, delimiter=",", header="a,b,c,d,e")
 with io.open(tempdir + "m2.csv.mtd", "w", encoding="utf-8") as f:
     f.write(json.dumps(mtd, ensure_ascii=False))
 
@@ -251,4 +251,3 @@ class TestFederatedAggFn(unittest.TestCase):
 
 if __name__ == "__main__":
     unittest.main(exit=False)
-    shutil.rmtree(tempdir)
diff --git a/src/main/python/tests/federated/test_federated_basic.py 
b/src/main/python/tests/federated/test_federated_basic.py
index b160d7b..f4baac5 100644
--- a/src/main/python/tests/federated/test_federated_basic.py
+++ b/src/main/python/tests/federated/test_federated_basic.py
@@ -39,19 +39,19 @@ m1.shape = (dim, dim)
 m2 = np.array(np.random.randint(5, size=dim * dim) + 1, dtype=np.double)
 m2.shape = (dim, dim)
 
-tempdir = "/tmp/test_federated_basic/"
-mtd = {"format": "csv", "header": "false", "rows": dim, "cols": dim}
+tempdir = "./tests/federated/tmp/test_federated_aggregations/"
+mtd = {"format": "csv", "header": True, "rows": dim, "cols": dim, "data_type": 
"matrix", "value_type": "double" }
 
 # Create the testing directory if it does not exist.
 if not os.path.exists(tempdir):
     os.makedirs(tempdir)
 
 # Save data files for the Federated workers.
-np.savetxt(tempdir + "m1.csv", m1, delimiter=",")
+np.savetxt(tempdir + "m1.csv", m1, delimiter=",", header="a,b,c,d,e")
 with io.open(tempdir + "m1.csv.mtd", "w", encoding="utf-8") as f:
     f.write(json.dumps(mtd, ensure_ascii=False))
 
-np.savetxt(tempdir + "m2.csv", m2, delimiter=",")
+np.savetxt(tempdir + "m2.csv", m2, delimiter=",", header="a,b,c,d,e")
 with io.open(tempdir + "m2.csv.mtd", "w", encoding="utf-8") as f:
     f.write(json.dumps(mtd, ensure_ascii=False))
 
@@ -73,9 +73,9 @@ class TestFederatedAggFn(unittest.TestCase):
         cls.sds.close()
 
     def test_1(self):
-        f_m1 = Federated(self.sds, [fed1], [([0, 0], [dim, dim])]).compute()
+        f_m1 = Federated(self.sds, [fed1], [([0,0], [dim, dim])]).compute()
         res = np.allclose(f_m1, m1)
-        self.assertTrue(res)
+        self.assertTrue(res, "\n" + str(f_m1) + " is not equal to \n" + 
str(m1))
 
     def test_2(self):
         f_m2 = Federated(self.sds, [fed2], [([0, 0], [dim, dim])]).compute()
@@ -115,11 +115,6 @@ class TestFederatedAggFn(unittest.TestCase):
         res = np.allclose(f_m1_m2, m1_m2)
         self.assertTrue(res)
 
-    # -----------------------------------
-    # The rest of the tests are
-    # Extended functionality not working Yet
-    # -----------------------------------
-
     def test_5(self):
         #   [[m1,m1,m1,m1,m1, 0, 0, 0, 0, 0]
         #    [m1,m1,m1,m1,m1, 0, 0, 0, 0, 0]
@@ -276,4 +271,3 @@ class TestFederatedAggFn(unittest.TestCase):
 
 if __name__ == "__main__":
     unittest.main(exit=False)
-    shutil.rmtree(tempdir)

Reply via email to