I have the following code, and the Experta engine gives unexpected output: None
. Is the P
predicate function applied correctly?
from experta import Fact, KnowledgeEngine, L, AS, Rule, P, AND
class QuoteFact(Fact):
"""Info about the traffic light."""
pass
class GoodSymbolFact(Fact):
pass
class _RuleEngine(KnowledgeEngine):
@Rule(
QuoteFact(P(lambda x: float(x.price) > 1.00))
)
def accept(self, quote_fact):
good_symbol_fact = GoodSymbolFact(symbol=quote_fact.symbol)
self.declare(good_symbol_fact)
_engine = _RuleEngine()
_engine.reset()
_engine.declare(QuoteFact(price=100.00, symbol="AAPL"))
result = _engine.run()
print(result)