Пример #1
0
    def satisfiedBy(self, example):
        try:
            a = lookup(self.descriptionA, example).center
            b = lookup(self.descriptionB, example).center
            c = lookup(self.descriptionC, example).center
            d = lookup(self.descriptionD, example).center

        except DescriptionException:
            return False
        except AttributeError:
            return False

        t = torsion(a, b, c, d)
        #print a, b, c, d
        #print self.center -self.range, t, self.center + self.range

        satisfied = self.center - self.range < t < self.center + self.range
        if self.negated:
            satisfied = not satisfied

        if satisfied:
            example.__dict__[self.name] = t
            return satisfied # ho ho
        else:
            return False
Пример #2
0
    def measure(self, structure):
        try:
            a = lookup(self.descriptionA, structure).center
            b = lookup(self.descriptionB, structure).center
            c = lookup(self.descriptionC, structure).center
            d = lookup(self.descriptionD, structure).center

            return torsion(a, b, c, d)
        except AttributeError:
            print "TORSION MEASURE FALIURE :", self.descriptionA, self.descriptionB, self.descriptionC, self.descriptionD
            return 0.0