Open alexsomoza opened 3 years ago
Hi, thanks for asking the question. The logical operators for the rules engine are '&' and '|' (yes the bitwise operators). The reason is because in Python it is not possible to override the logical operators, so as much as I don't like it, I had to settle with such syntax. Please try the following ruleset:
from durable.lang import *
with ruleset('test1'):
@when_all((m.insulation == 'OIP') & (((m.tan_dif_hist_20 <= -25) & (m.tan_dif_hist_20 >= -44)) | ((m.tan_dif_hist_20 <= 55) & (m.tan_dif_hist_20 >=25))))
def clase_M(c):
print('M')
@when_all((m.insulation == 'OIP') & ((m.tan_dif_hist_20 <= 25) & (m.tan_dif_hist_20 >= -25)))
def clase_G(c):
print('G')
post_batch('test1',[{ 'insulation': 'OIP', 'tan_dif_hist_20':55},
{ 'insulation': 'OIP', 'tan_dif_hist_20':10},
{ 'insulation': 'OIP', 'tan_dif_hist_20':-33}])
I have this:
from durable.lang import * with ruleset('test1'): @when_all(m.insulation == 'OIP' and ((-44 <= m.tan_dif_hist_20 <= -25) or (25 <= m.tan_dif_hist_20 <= 55)) ) def clase_M(c): print('M') @when_all(m.insulation == 'OIP' and (-25 <= m.tan_dif_hist_20 <= 25)) def clase_G(c): print('G') and I run this post_batch('test1',[{ 'insulation': 'OIP', 'tan_dif_hist_20':55}, { 'insulation': 'OIP', 'tan_dif_hist_20':10}, { 'insulation': 'OIP', 'tan_dif_hist_20':-33}])
and get this error:
MessageNotHandledException Traceback (most recent call last)