Beispiel #1
0
 def evaluateInner(self, context):
     center = valueInContext(self.center, context)
     radius = valueInContext(self.radius, context)
     return CircularRegion(center,
                           radius,
                           name=self.name,
                           resolution=self.resolution)
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
 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()
         })
Beispiel #5
0
 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)
Beispiel #6
0
 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])
Beispiel #7
0
 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)
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
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)
Beispiel #11
0
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
Beispiel #12
0
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
Beispiel #13
0
 def evaluateInner(self, context):
     return Vector(*(valueInContext(coord, context)
                     for coord in self.coordinates))
Beispiel #14
0
 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)
Beispiel #15
0
	def evaluateInner(self, context):
		opts = tuple(valueInContext(opt, context) for opt in self.options)
		return UniformDistribution(opts)
Beispiel #16
0
	def evaluateInner(self, context):
		mean = valueInContext(self.mean, context)
		stddev = valueInContext(self.stddev, context)
		return TruncatedNormal(mean, stddev, self.low, self.high)
Beispiel #17
0
	def evaluateInner(self, context):
		mean = valueInContext(self.mean, context)
		stddev = valueInContext(self.stddev, context)
		return Normal(mean, stddev)
Beispiel #18
0
	def evaluateInner(self, context):
		low = valueInContext(self.low, context)
		high = valueInContext(self.high, context)
		return Range(low, high)
Beispiel #19
0
	def evaluateInner(self, context):
		return type(self)(valueInContext(self.index, context),
		                  (valueInContext(opt, context) for opt in self.options))
Beispiel #20
0
	def evaluateInner(self, context):
		hdg = valueInContext(self.heading, context)
		return OrientedVector(*(valueInContext(coord, context) for coord in self.coordinates), hdg)
Beispiel #21
0
 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)
Beispiel #22
0
 def evaluateInner(self, context):
     center = valueInContext(self.center, context)
     radius = valueInContext(self.radius, context)
     return CircularRegion(center, radius)
Beispiel #23
0
 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)
Beispiel #24
0
	def evaluateInner(self, context):
		coordinates = (valueInContext(coord, context) for coord in self.coordinates)
		return TupleDistribution(*coordinates, builder=self.builder)
Beispiel #25
0
	def evaluateInner(self, context):
		obj = valueInContext(self.object, context)
		return AttributeDistribution(self.attribute, obj)
Beispiel #26
0
 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)
Beispiel #27
0
	def evaluateInner(self, context):
		return StarredDistribution(valueInContext(self.value, context), self.lineno)