Exemplo n.º 1
0
 def format(x):
     """List of vertices. Then convex or not. Then integer for sizes."""
     # flatten vertices, then reshape into points
     temp = [np.reshape(clip(flatten(x[0]), float), (-1, 2))] + \
         clip(x[1:3], int, 0, [1, 500])
     if len(temp[0]) < 3:
         return []
     return temp
Exemplo n.º 2
0
 def format(x):
     """List of vertices. Then convex or not. Then integer for sizes."""
     # flatten vertices, then reshape into points
     temp = [np.reshape(clip(flatten(x[0]), float), (-1, 2))] + \
         clip(x[1:3], int, 0, [1, 500])
     if len(temp[0]) < 3:
         return []
     return temp
Exemplo n.º 3
0
 def apply(self, coords):
     """Compute polar/spherical coordinate arrays and apply function."""
     formula, ind = self.update(self.params)
     dim = len(coords[0])
     cylindrical = ind < 0
     skip = range(dim)
     if dim == 3:
         # north pole direction for spherical/cylindrical coordinates
         north = clip(abs(ind), int, 1, 3)-1
         del skip[north]
     # r and theta dimensions as complex
     rtheta = coords[:, skip[0]] + coords[:, skip[1]] * 1j
     theta = np.angle(rtheta)
     r = np.absolute(rtheta)
     eta = 0
     if dim == 3:
         h = coords[:, north]
         eta = np.arctan2(r, h)
         if cylindrical:
             eta = h
         else:
             r = np.sqrt(r**2+h**2)
     if cylindrical:
         coords[:, skip] = np.nan_to_num(np.transpose(
             np.transpose(coords[:, skip]) * formula(r, theta, eta)))
     else:
         coords = np.nan_to_num(np.transpose(np.transpose(coords) *
                                             formula(r, theta, eta)))
     return coords
Exemplo n.º 4
0
 def format(x):
     """Up to 4, or 9 floats."""
     x = flatten(x)
     if len(x) < 9:
         x = x[:4]
     else:
         x = x[:9]
     return clip(x, float)
Exemplo n.º 5
0
 def format(x):
     """Function, then an integer. """
     print x
     radius = "lambda theta: {}".format(x[0])
     try:
         evaluate(radius)[0](0)
         evaluate(radius)[0](np.pi)
     except:
         return []
     return [radius] + clip(np.fabs(x[1:2]), int, 1, 1000)
Exemplo n.º 6
0
 def format(x):
     """Function, then an integer. """
     print x
     radius = "lambda theta: {}".format(x[0])
     try:
         evaluate(radius)[0](0)
         evaluate(radius)[0](np.pi)
     except:
         return []
     return [radius] + clip(np.fabs(x[1:2]), int, 1, 1000)
Exemplo n.º 7
0
 def format(x):
     """Two floats. Then at least one function. Finally an integer. """
     x = flatten(x)
     if len(x) < 3:
         return []
     domain = sorted(clip(x[:2], float))
     import re
     var = 'x' if re.search(r'\bx\b', ''.join(x[2:4])) else 'y'
     top = "lambda {}: {}".format(var, x[2])
     if len(x) == 3:
         bottom = "lambda {}: -({})".format(var, x[2])
     else:
         bottom = "lambda {}: {}".format(var, x[3])
     try:
         evaluate(top)[0](domain[0])
         evaluate(bottom)[0](domain[0])
     except:
         return []
     return domain + [top, bottom, var] + clip(np.fabs(x[4:5]),
                                               int, 1, 1000)
Exemplo n.º 8
0
 def format(x):
     """Two floats. Then at least one function. Finally an integer. """
     x = flatten(x)
     if len(x) < 3:
         return []
     domain = sorted(clip(x[:2], float))
     import re
     var = 'x' if re.search(r'\bx\b', ''.join(x[2:4])) else 'y'
     top = "lambda {}: {}".format(var, x[2])
     if len(x) == 3:
         bottom = "lambda {}: -({})".format(var, x[2])
     else:
         bottom = "lambda {}: {}".format(var, x[3])
     try:
         evaluate(top)[0](domain[0])
         evaluate(bottom)[0](domain[0])
     except:
         return []
     return domain + [top, bottom, var] + clip(np.fabs(x[4:5]), int, 1,
                                               1000)
Exemplo n.º 9
0
 def format(x):
     """One integer with a lower bound. Then a positive float up to 0.99. """
     return clip(np.fabs(x[:1]), int, 3) + \
         clip(np.fabs(x[1:2]), float, 0.001, 0.999)
Exemplo n.º 10
0
 def format(x):
     """Two nonnegative integers. Then integer between 0 and 2."""
     return clip(x[:2], int, 1) + clip(x[2:3], int, 0, 2)
Exemplo n.º 11
0
 def format(x):
     """Based on kites."""
     return [1] + clip(abs(tan(x[0] / 2)), float, 0.001)
Exemplo n.º 12
0
 def format(x):
     """Based on the general triangle."""
     return [1] + clip(abs(tan(x[0])), float, 0.001, 1)
Exemplo n.º 13
0
 def format(x):
     """Two positive floats, then three ints."""
     return clip(np.fabs(x[:2]), float, 0.0001) + clip(x[2:4], int, 1) + \
         clip(x[4:5], int, 0, 2)
Exemplo n.º 14
0
 def format(x):
     """Two integers with lower bounds."""
     return clip(x[:2], int, [3, 2])
Exemplo n.º 15
0
 def format(x):
     """Two positive floats, then three ints."""
     return clip(np.fabs(x[:2]), float, 0.0001) + clip(x[2:4], int, 1) + \
         clip(x[4:5], int, 0, 2)
Exemplo n.º 16
0
 def format(x):
     """Three positive integers."""
     return clip(x[:3], int, 1)
Exemplo n.º 17
0
 def format(x):
     """Based on the general triangle."""
     return [1] + clip(abs(tan(x[0])), float, 0.001, 1)
Exemplo n.º 18
0
 def format(x):
     """One integer with a lower bound. Then a positive float up to 0.99. """
     return clip(np.fabs(x[:1]), int, 3) + \
         clip(np.fabs(x[1:2]), float, 0.001, 0.999)
Exemplo n.º 19
0
 def format(x):
     """Which pair. Then which one of the two. The two floats for angles."""
     return clip(x[:2], int, [-1, 0], [4, 1]) + clip(x[2:4], float, 2.001)
Exemplo n.º 20
0
 def format(x):
     """One float. Then positive float."""
     return clip(x[:1], float) + clip(np.fabs(x[1:2]), float, 0.0001)
Exemplo n.º 21
0
 def format(x):
     """Two lists of floats."""
     return [clip(x[0], float), clip(x[1], float)]
Exemplo n.º 22
0
 def format(x):
     """Three positive floats. Then three positive integers."""
     return clip(x[:3], float, 0.0001) + clip(x[3:6], int, 1)
Exemplo n.º 23
0
 def format(x):
     """Free function input. Then an integer."""
     return [x[0]] + clip(x[1:2], int, 1, 3)
Exemplo n.º 24
0
 def format(x):
     """One positive float."""
     return clip(x[:1], int, 1, 30)
Exemplo n.º 25
0
 def format(x):
     """One integer with a lower bound."""
     return clip(x[:1], int, 3)
Exemplo n.º 26
0
 def format(x):
     """Positive integer. The positive float. Then two floats."""
     return clip(x[:1], int, 1) + clip(np.fabs(x[1:2]), float, 0.0001) + \
         clip(x[2:4], float)
Exemplo n.º 27
0
 def format(x):
     """Two nonnegative integers. Then integer between 0 and 2."""
     return clip(x[:2], int, 1) + clip(x[2:3], int, 0, 2)
Exemplo n.º 28
0
 def format(x):
     """Five floats. Second and fifth positive."""
     return clip(x[:1], float) + clip(np.fabs(x[1:2]), float, 0.0001) + \
         clip(x[2:4], float) + clip(np.fabs(x[4:5]), float, 0.0001)
Exemplo n.º 29
0
 def format(x):
     """One positive float."""
     return clip(np.fabs(x[:1]), float, 0.003)
Exemplo n.º 30
0
 def format(x):
     """One positive float."""
     return clip(np.fabs(x[:1]), float, 0.003)
Exemplo n.º 31
0
 def format(x):
     """One float. Then positive float."""
     return clip(x[:1], float) + clip(np.fabs(x[1:2]), float, 0.0001)
Exemplo n.º 32
0
 def format(x):
     """Three positive floats. Then three positive integers."""
     return clip(x[:3], float, 0.0001) + clip(x[3:6], int, 1)
Exemplo n.º 33
0
 def format(x):
     """Two lists of floats."""
     return [clip(x[0], float), clip(x[1], float)]
Exemplo n.º 34
0
 def format(x):
     """Positive integer. The positive float. Then two floats."""
     return clip(x[:1], int, 1) + clip(np.fabs(x[1:2]), float, 0.0001) + \
         clip(x[2:4], float)
Exemplo n.º 35
0
 def format(x):
     """Which pair. Then which one of the two. The two floats for angles."""
     return clip(x[:2], int, [-1, 0], [4, 1]) + clip(x[2:4], float, 2.001)
Exemplo n.º 36
0
 def format(x):
     """Two integers with lower bounds."""
     return clip(x[:2], int, [3, 2])
Exemplo n.º 37
0
 def format(x):
     """Three floats."""
     return clip(x[:3], float)
Exemplo n.º 38
0
 def format(x):
     """Based on kites."""
     return [1] + clip(abs(tan(x[0] / 2)), float, 0.001)
Exemplo n.º 39
0
 def format(x):
     """Three positive integers."""
     return clip(x[:3], int, 1)
Exemplo n.º 40
0
 def format(x):
     """Two positive floats. Then integer from 1,2,3."""
     return clip(np.fabs(x[:2]), float, 0.01) + clip(x[2:3], int, 1, 3)
Exemplo n.º 41
0
 def format(x):
     """One positive float."""
     return clip(x[:1], int, 1, 30)
Exemplo n.º 42
0
 def format(x):
     """Four floats."""
     return clip(x[:4], float)
Exemplo n.º 43
0
 def format(x):
     """Five floats. Second and fifth positive."""
     return clip(x[:1], float) + clip(np.fabs(x[1:2]), float, 0.0001) + \
         clip(x[2:4], float) + clip(np.fabs(x[4:5]), float, 0.0001)
Exemplo n.º 44
0
 def format(x):
     """One integer with a lower bound."""
     return clip(x[:1], int, 3)