Baunsgaard commented on a change in pull request #1234:
URL: https://github.com/apache/systemds/pull/1234#discussion_r617343037



##########
File path: src/main/python/tests/algorithms/test_pca.py
##########
@@ -49,10 +51,38 @@ def test_500x2(self):
         m1 = self.generate_matrices_for_pca(30, seed=1304)
         X = Matrix(self.sds, m1)
         # print(features)
-        [res, model, _, _ ] = pca(X, K=1, scale="FALSE", 
center="FALSE").compute()
+        [res, model, _, _] = pca(X, K=1, scale="FALSE", 
center="FALSE").compute()
         for (x, y) in zip(m1, res):
             self.assertTrue((x[0] > 0 and y > 0) or (x[0] < 0 and y < 0))
 
+    def test_500x2b(self):
+        """
+        This test constructs a line of values in 2d space. 
+        That if fit correctly maps perfectly to 1d space.
+        The check is simply if the input value was positive
+        then the output value should be similar.
+        """
+        m1 = self.generate_matrices_for_pca(30, seed=1304)
+        X = Matrix(self.sds, m1)
+        # print(features)
+        X._check_matrix_op()
+        params_dict = {'X': X, 'K': 1, 'scale': "FALSE", 'center': "FALSE"}
+        nodeC = OperationNode2(self.sds, 'pca', named_input_nodes=params_dict,
+                               outputs=[("res", OutputType.MATRIX), ("model", 
OutputType.MATRIX), ("scale", OutputType.MATRIX), ("center", 
OutputType.MATRIX)])
+        nodeD = OperationNode2(self.sds, 'abs', 
unnamed_input_nodes=[nodeC.output_nodes["model"]])

Review comment:
       In the end the tests should reflect what a user should write, therefore 
in this case
   The goal become these three:
   
   
   ```python
   [res, model, _, _] = pca(...)
   res = abs(res)
   ```
   
   or
   
   ```python
   m= pca(...)
   res = abs(m[0])
   ```
   
   or
   
   
   ```python
   m= pca(...)
   res = abs(m["model"])
   ```
   
   Now this is challenging since it require some change in our generated 
algorithms.
   Maybe to keep the project simple, you could make a new test file and do the 
following:
   
   ```python
   X = self.sds.rand(rows=1, cols=2, seed = 3)
   Y = self.sds.rand(rows=2, cols=1, seed=3)
   # I want the default to be unnamed input nodes if the argument is a list,
   # or if it is a dictionary named input nodes.
   M = multinode(sds, 'list', [X,Y])
   print(M[1]).compute()
   ```
   this should result in a script if you execute with  looking something like:
   ```dml
   X = rand(rows = 1, cols = 2,  seed = 3)
   Y = rand(rows = 2, cols = 1, seed = 3)
   m = list(X,Y)
   print(toString(m[1]))
   ```
   
   If it is not clear please say so :)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to