russellmcdonell / pyDMNrules

An implementation of DMN (Decision Model Notation) in Python
Other
40 stars 9 forks source link

Tests with booleans failing #1

Closed 0dB closed 3 years ago

0dB commented 4 years ago

Hi Russell, I like what I am seeing so far, have a small case working already.

I tripped over something: When an output variable is TRUE or FALSE in the Excel file and a test refers to it the test will fail and will report something like expected ‘True’ but got ‘True’ (sic). To move forward I replaced TRUE and FALSE with YES and NO and then it works.

See the screenshots, one where the decision uses TRUE and FALSE but which didn’t work, and one with YES / NO after I changed it in both sheets which then works.

73FBFA57-A0F2-43A3-8339-91E85400287C 1DF82B55-BCBD-4BD9-899D-B8EE2C14CB45

russellmcdonell commented 4 years ago

Yes, I tripped over this and replaced the Excel contents of TRUE and False with the S-FEEL values ( 'true and 'false ) - just start with a quote and type true or false).

I could implement that mapping internally - would that be the right thing to do?

Russell McDonell

On Wed, 4 Mar 2020 at 05:08, Norman Baatz notifications@github.com wrote:

Hi Russell, I like what I am seeing so far, have a small case working already.

I tripped over something: When an output variable is TRUE or FALSE in the Excel file and a test refers to it the test will fail and will report something like expected ‘True’ but got ‘True’ (sic). To move forward I replaced TRUE and FALSE with YES and NO and then it works.

See the screenshots, one where the decision uses TRUE and FALSE but which didn’t work, and one with YES / NO after I changed it in both sheets which then works.

[image: 73FBFA57-A0F2-43A3-8339-91E85400287C] https://user-images.githubusercontent.com/661662/75805558-59168080-5d82-11ea-8780-732e4ca47665.jpeg [image: 1DF82B55-BCBD-4BD9-899D-B8EE2C14CB45] https://user-images.githubusercontent.com/661662/75805563-5b78da80-5d82-11ea-9bef-5a086cd23c67.jpeg

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/russellmcdonell/pyDMNrules/issues/1?email_source=notifications&email_token=AECWZEWX2JHM7EJ6VYR73VDRFVBSVA5CNFSM4LAQCGRKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ISDPH5Q, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECWZEQ7HSJYWRXYNU3BBDDRFVBSVANCNFSM4LAQCGRA .

0dB commented 4 years ago

Hm, wouldn’t we then lose the ability to use, say, negation? As in tables 46 and 67 in the OMG document? There it also says

S-FEEL supports … FEEL Boolean: […] FEEL boolean has the same literal and values spaces as the Java Boolean and XML Schema Boolean datatypes.

Norman

russellmcdonell commented 4 years ago

pySFeel - the S-FEEL interpreter used by pyDMNrules equates the string constants "true" and "false" to the Python booleans True and False (which are not the same things as the Excel constant TRUE and FALSE) [10.3.1.2 Grammer rules - rule 36] Note: these are both lower case words. Table 46 is implemented in pySFeel - if your Excel cell is 'not(true) then the cell will evaluate to the Python value of False. [Not sure about 'not(otherwise) - would need to go back and check my pySFeel code] Table 67 is implemented - well the not() function is implemented, as in not(7<9) will evaluate to the Python value of False.

I cannot comment on the Java Boolean and XML Schema Boolean datatypes - but datatypes is different to data representation. S-FEEL has a representation of true/false, being "true" and "false" Python has a representation of true/false, being True and False Excel has a representation of true/false, being TRUE and FALSE - pyDMNrules currently doesn't map the Excel representation to the S-FEEL representation

Russell McDonell

On Wed, 4 Mar 2020 at 19:54, Norman Baatz notifications@github.com wrote:

Hm, wouldn’t we then lose the ability to use, say, negation? As in tables 46 and 67 in the OMG document? There it also says

S-FEEL supports … FEEL Boolean: […] FEEL boolean has the same literal and values spaces as the Java Boolean and XML Schema Boolean datatypes.

Norman

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/russellmcdonell/pyDMNrules/issues/1?email_source=notifications&email_token=AECWZEWYERORLNMFRT23UBTRFYJL3A5CNFSM4LAQCGRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENW5A2Y#issuecomment-594399339, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECWZETPWVRAWIBFSN3QBF3RFYJL3ANCNFSM4LAQCGRA .

0dB commented 4 years ago

Ok, I see what you mean. Now the mapping from "Excel" to "S-FEEL" sounds like a good idea, but let me think about it.

russellmcdonell commented 4 years ago

Technically Excel is just a vessel for carrying S-FEEL to a DMN engine. So every cell can be text, but that would be annoying. And the DMN engine is written in Python, so I have to convert "10.7" to float. But it just makes sense to allow users to put floats and dates in Excel cells. What I don't want to have to do is deal with Excel functions in cells. Have to see what NOT(TRUE) looks like in openpyxl. Both 'not(true) and 'not true work, so I'm reluctant to do too much work if openpyxl doesn't return simple booleans for NOT(TRUE). TO implement TRUE, but to barf on NOT(TRUE) would seem to be a bad thing. By the way, everything that barf is 'null' - I don't do 'error messages' - well I don't do them particularly well.

Russell McDonell

On Thu, 5 Mar 2020 at 03:50, Norman Baatz notifications@github.com wrote:

Ok, I see what you mean. Now the mapping from "Excel" to "S-FEEL" sounds like a good idea, but let me think about it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/russellmcdonell/pyDMNrules/issues/1?email_source=notifications&email_token=AECWZEU6MNT2XA7UVY3XOYDRF2BFLA5CNFSM4LAQCGRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENY3VTI#issuecomment-594655949, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECWZERLVL6FWGMYW6EPZMLRF2BFLANCNFSM4LAQCGRA .

russellmcdonell commented 3 years ago

Support for the Excel constants TRUE and FALSE, where they are the only value in a cell, will be implemented in the next release.

russellmcdonell commented 3 years ago

I have released version 1.2.0 of pySFeel and version 1.2.0 of pyDMNrules. Both have bug fixes. pyDMNrules now support the Excel boolean values TRUE and FALSE, but only if they are the only value in a cell. I have also uploaded a complex example (AN-SNAP rules (DMN).xlsx' to github. That project highlighted a number of issues that are now fixed.