fpom / snakes

SNAKES is the Net Algebra Kit for Editors and Simulators
https://snakes.ibisc.univ-evry.fr
Other
88 stars 29 forks source link

Inhibitor arc is throwing exception #20

Open m-h-b-tu opened 3 years ago

m-h-b-tu commented 3 years ago

Unfortunately commit 13f8c40ab184bf0d2208b70288095825edb4fccc part of d79ddb0 introduced a bug to class Inhibitor.

In case where a place is unmarked the example Inhibitor(Variable("x")).check(Substitution(x=1), MultiSet([1, 2, 3])) becomes Inhibitor(Variable("x")).check(Substitution(), MultiSet([])) and class Variable throws an exception inside its method bind because the parameter binding does not include self.name.

This might be a quick fix inspired by the modes method:

def check (self, binding, tokens) :
    """Check whether the label allows to fire with tokens

    >>> Inhibitor(Value(1)).check(Substitution(), MultiSet([1, 2, 3]))
    False
    >>> Inhibitor(Value(4)).check(Substitution(), MultiSet([1, 2, 3]))
    True
    >>> Inhibitor(Variable("x")).check(Substitution(x=1), MultiSet([1, 2, 3]))
    False
    >>> Inhibitor(Variable("x")).check(Substitution(x=4), MultiSet([1, 2, 3]))
    True
    """
    try :
        checks = self._annotation.check(binding, tokens)
    except DomainError :
        checks = False
    return (not checks
            and self._condition(binding))