You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@systemml.apache.org by GitBox <gi...@apache.org> on 2020/03/25 01:12:28 UTC

[GitHub] [systemml] raymondtay opened a new pull request #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions

raymondtay opened a new pull request #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions
URL: https://github.com/apache/systemml/pull/868
 
 
   The original issue i noticed was when the conditional predicate in the if-expression didn't seem what i was used to as in the C-programming language (where negative values were interpreted as _false_ while the converse values were interpreted as _true_) and that caused some discomfort.
   
   Below is an example of the issue
   ```
   // This is a session i ran from running SystemML
   scala> import org.apache.sysml.api.mlcontext._
   scala> import org.apache.sysml.api.mlcontext.ScriptFactory._
   scala> val ml = new MLContext(spark)
   scala> val s = dml(""" if(-42) print("Yes!") else print("No!") """)
   scala> ml.execute(s)
   Yes!
   ```
   In the Scala programming language, this would be a type-error
   ```
   scala> if (-31) println("yes") else println("no")
              ^
          error: type mismatch;
           found   : Int(-31)
           required: Boolean
   ```
   
   So i started mucking around _Antlr4_ and start poking around and discovered a potential fix for it. Running this fix after a build on my local machine, here's the desired result:
   ```
   Using Scala version 2.11.12 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_202)
   Type in expressions to have them evaluated.
   Type :help for more information.
   
   scala> import org.apache.sysml.api.mlcontext._
   import org.apache.sysml.api.mlcontext._
   
   scala> import org.apache.sysml.api.mlcontext.ScriptFactory._
   import org.apache.sysml.api.mlcontext.ScriptFactory._
   
   scala> val ml = new MLContext(spark)
   
   Welcome to Apache SystemML!
   Version 1.3.0-SNAPSHOT
   ml: org.apache.sysml.api.mlcontext.MLContext = org.apache.sysml.api.mlcontext.MLContext@380cd266
   
   scala> val s = dml(""" if(-42) print("Yes!") else print("No!") """)
   s: org.apache.sysml.api.mlcontext.Script =
   Inputs:
   None
   
   Outputs:
   None
   
   scala> ml.execute(s)
   ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.7ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7ANTLR Runtime version 4.5.3 used for parser compilation does not match the current runtime version 4.720/03/25 09:10:54 WARN DMLTranslator: WARNING: [line 1:4] -> -42 -- Numerical value '-42' (!= 0/1) is converted to boolean FALSE by DML
   No!
   SystemML Statistics:
   Total execution time:		0.010 sec.
   Number of executed Spark inst:	0.
   
   res0: org.apache.sysml.api.mlcontext.MLResults =
   None
   
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [systemml] raymondtay closed pull request #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions

Posted by GitBox <gi...@apache.org>.
raymondtay closed pull request #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions
URL: https://github.com/apache/systemml/pull/868
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [systemml] raymondtay commented on issue #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions

Posted by GitBox <gi...@apache.org>.
raymondtay commented on issue #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions
URL: https://github.com/apache/systemml/pull/868#issuecomment-604192818
 
 
   > thanks for creating the issue, but I'm afraid that DML follows R semantics here where both if conditions and ifelse functions interpret negative values as TRUE. Do you think adding this to the docu would help.
   > 
   > Btw, in the next days we'll merge SystemDS back into Apache SystemML with many new features and a packed roadmap.
   
   I think adding the documentation to SystemML would definitely clarify the issue. Thank you for enlightening me on this fact w.r.t **R programing language**.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [systemml] mboehm7 commented on issue #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions

Posted by GitBox <gi...@apache.org>.
mboehm7 commented on issue #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions
URL: https://github.com/apache/systemml/pull/868#issuecomment-604042157
 
 
   thanks for creating the issue, but I'm afraid that DML follows R semantics here where both if conditions and ifelse functions interpret negative values as FALSE. Do you think adding this to the docu would help.
   
   Btw, in the next days we'll merge SystemDS back into Apache SystemML with many new features and a packed roadmap.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [systemml] mboehm7 edited a comment on issue #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions

Posted by GitBox <gi...@apache.org>.
mboehm7 edited a comment on issue #868: [SYSTEMML-2537] Improve the consistency of predicates in "if-then-else" expressions
URL: https://github.com/apache/systemml/pull/868#issuecomment-604042157
 
 
   thanks for creating the issue, but I'm afraid that DML follows R semantics here where both if conditions and ifelse functions interpret negative values as TRUE. Do you think adding this to the docu would help.
   
   Btw, in the next days we'll merge SystemDS back into Apache SystemML with many new features and a packed roadmap.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services