def intervalSetMask(set0, set1): set0 = set0 if isinstance (set0, intervalset.IntervalSet) \ else intervalset.IntervalSet (set0) set1 = set1 if isinstance (set1, intervalset.IntervalSet) \ else intervalset.IntervalSet (set1) if set0.finite(): if set1.finite(): return FiniteISetMask(set0, set1) else: return FiniteSourcesISetMask(set0, set1) else: if set1.finite(): return FiniteTargetsISetMask(set0, set1) else: return IntervalSetMask(set0, set1)
def random2d(N, xScale=1.0, yScale=1.0): coords = [(xScale * _random.random(), yScale * _random.random()) for i in xrange(0, N)] g = lambda i: coords[i] g.type = 'ramdom' g.N = N g.xScale = xScale g.yScale = yScale # We should use a KD-tree here g.inverse = lambda x, y, domain=_iset.IntervalSet ((0, N - 1)): \ _numpy.array ([euclidDistance2d ((x, y), g(i)) \ for i in domain]).argmin () \ + domain.min () return g
def __call__(self, N0, N1=None): if N1 == None: N1 = N0 return cs.FiniteISetMask (iset.IntervalSet ((0, N0 - 1)), \ iset.IntervalSet ((0, N1 - 1)))
def ival(beg, end): return _iset.IntervalSet((beg, end))