def evaluateInner(self, context): center = valueInContext(self.center, context) radius = valueInContext(self.radius, context) return CircularRegion(center, radius, name=self.name, resolution=self.resolution)
def evaluateInner(self, context): regs = (valueInContext(reg, context) for reg in self.regions) orientation = valueInContext(self.orientation, context) return IntersectionRegion(*regs, orientation=orientation, sampler=self.sampler, name=self.name)
def evaluateInner(self, context): obj = valueInContext(self.object, context) arguments = tuple( valueInContext(arg, context) for arg in self.arguments) kwargs = { name: valueInContext(arg, context) for name, arg in self.kwargs.items() } return VectorMethodDistribution(self.method, obj, arguments, kwargs)
def evaluateInner(self, context): if self.optWeights is None: return type(self)(valueInContext(opt, context) for opt in self.options) else: return type(self)({ valueInContext(opt, context): wt for opt, wt in self.optWeights.items() })
def evaluateInner(self, context): function = valueInContext(self.function, context) arguments = tuple( valueInContext(arg, context) for arg in self.arguments) kwargs = { name: valueInContext(arg, context) for name, arg in self.kwargs.items() } return FunctionDistribution(function, arguments, kwargs)
def evaluateInner(self, context): if self.cumulativeWeights is not None: return Options({ valueInContext(opt, context): wt for opt, wt in self.weights.items() }) else: return Options( [valueInContext(opt, context) for opt in self.options])
def evaluateInner(self, context): regionA = valueInContext(self.regionA, context) regionB = valueInContext(self.regionB, context) orientation = valueInContext(self.orientation, context) return DifferenceRegion(regionA, regionB, orientation=orientation, sampler=self.sampler, name=self.name)
def evaluateInner(self, context): position = valueInContext(self.position, context) heading = valueInContext(self.heading, context) width = valueInContext(self.width, context) length = valueInContext(self.length, context) return RectangularRegion(position, heading, width, length, name=self.name)
def evaluateInner(self, context): center = valueInContext(self.center, context) radius = valueInContext(self.radius, context) heading = valueInContext(self.heading, context) angle = valueInContext(self.angle, context) return SectorRegion(center, radius, heading, angle, name=self.name, resolution=self.resolution)
def test_distribution_method_encapsulation_lazy(): vf = VectorField("Foo", lambda pos: 0) da = DelayedArgument(set(), lambda context: Options([1, 2])) pt = vf.followFrom(Vector(0, 0), da, steps=1) assert isinstance(pt, DelayedArgument) evpt = valueInContext(pt, {}) assert not needsLazyEvaluation(evpt) assert isinstance(evpt, VectorMethodDistribution) assert evpt.method is underlyingFunction(vf.followFrom)
def test_delayed_call(): da = DelayedArgument(('blob', ), lambda context: (lambda x, y=1: x * y + context.blob)) res = da(42, y=2) assert isinstance(res, DelayedArgument) context = LazilyEvaluable.makeContext(blob=-7) evres = valueInContext(res, context) assert not needsLazyEvaluation(evres) assert evres == 77
def test_delayed_call(): da = DelayedArgument(('blob', ), lambda context: (lambda x, y=1: x * y + context.blob)) res = da(42, y=2) assert isinstance(res, DelayedArgument) Thingy = namedtuple('Thingy', 'blob') evres = valueInContext(res, Thingy(blob=-7)) assert not needsLazyEvaluation(evres) assert evres == 77
def evaluateInner(self, context): return Vector(*(valueInContext(coord, context) for coord in self.coordinates))
def evaluateInner(self, context): self.baseColor = valueInContext(self.baseColor, context) self.hueNoise = valueInContext(self.hueNoise, context) self.satNoise = valueInContext(self.satNoise, context) self.lightNoise = valueInContext(self.lightNoise, context)
def evaluateInner(self, context): opts = tuple(valueInContext(opt, context) for opt in self.options) return UniformDistribution(opts)
def evaluateInner(self, context): mean = valueInContext(self.mean, context) stddev = valueInContext(self.stddev, context) return TruncatedNormal(mean, stddev, self.low, self.high)
def evaluateInner(self, context): mean = valueInContext(self.mean, context) stddev = valueInContext(self.stddev, context) return Normal(mean, stddev)
def evaluateInner(self, context): low = valueInContext(self.low, context) high = valueInContext(self.high, context) return Range(low, high)
def evaluateInner(self, context): return type(self)(valueInContext(self.index, context), (valueInContext(opt, context) for opt in self.options))
def evaluateInner(self, context): hdg = valueInContext(self.heading, context) return OrientedVector(*(valueInContext(coord, context) for coord in self.coordinates), hdg)
def evaluateInner(self, context): obj = valueInContext(self.object, context) operands = tuple(valueInContext(arg, context) for arg in self.operands) return VectorOperatorDistribution(self.operator, obj, operands)
def evaluateInner(self, context): center = valueInContext(self.center, context) radius = valueInContext(self.radius, context) return CircularRegion(center, radius)
def evaluateInner(self, context): position = valueInContext(self.position, context) heading = valueInContext(self.heading, context) width = valueInContext(self.width, context) height = valueInContext(self.height, context) return RectangularRegion(position, heading, width, height)
def evaluateInner(self, context): coordinates = (valueInContext(coord, context) for coord in self.coordinates) return TupleDistribution(*coordinates, builder=self.builder)
def evaluateInner(self, context): obj = valueInContext(self.object, context) return AttributeDistribution(self.attribute, obj)
def check(context): ca = valueInContext(checkA, context) cb = valueInContext(checkB, context) if underlyingType(ca) is not underlyingType(cb): raise RuntimeParseError(error) return arg.evaluateIn(context)
def evaluateInner(self, context): return StarredDistribution(valueInContext(self.value, context), self.lineno)