Closed omardipbigdata closed 6 months ago
Try again but remove the resolver keyword argument to the context. You don't want to use the attribute resolver in this case.
that will raise datatype mismatch import rule_engine context = rule_engine.Context(default_value=None) b=set(['Luke', 'Darth']) rr=['first_name <= b'] rule = rule_engine.Rule(rr[0], context) a=set(['ocean']) res1=rule.matches({'first_name': a}) print(res1) print(a<=b)
Traceback (most recent call last):
File "/Users/omarchowdhury/omarAddPlatform/git/apdp-cli/rule_engine_first_program_3.py", line 7, in
That sounds right. I don't think you can use the less than operator to find the intersection of sets. For that you need to use the bitwise and operator (&
).
Give that a shot now.
thanks for the clarification. if you can share few example that would be really helpful
The syntax is a & b
. The resulting set will have the members that are in both a
and b
.
Hi,
I would like to extent my gratitude for such a nice library. Found it recently. In my use case i am trying to compare whether a set "a" is a subset of "b" or not. when i am using below, it always returns true where else the regular python works fine with those operators.
program: import rule_engine context = rule_engine.Context(default_value=None,resolver=rule_engine.resolve_attribute) b=set(['Luke', 'Darth']) rr=['first_name <= b'] rule = rule_engine.Rule(rr[0], context) a=set(['ocean']) res1=rule.matches({'first_name': a}) print(res1) print(a<=b)
result: True False
Process finished with exit code 0