code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
if not isinstance(layer, list): layer = [layer] if not isinstance(objects, list): objects = [objects] if not isinstance(position, list): pos = [position] else: pos = sorted(position) result = [[] for _ in range(len(pos) + 1)] polygons = [] for obj in objects: if isinstance(obj, PolygonSet): polygons.extend(obj.polygons) elif isinstance(obj, CellReference) or isinstance(obj, CellArray): polygons.extend(obj.get_polygons()) else: polygons.append(obj) scaling = 1 / precision for pol in polygons: for r, p in zip(result, clipper._chop(pol, pos, axis, scaling)): r.extend(p) for i in range(len(result)): result[i] = PolygonSet(result[i], layer[i % len(layer)], datatype) return result
def slice(objects, position, axis, precision=1e-3, layer=0, datatype=0)
Slice polygons and polygon sets at given positions along an axis. Parameters ---------- objects : ``PolygonSet``, or list Operand of the slice operation. If this is a list, each element must be a ``PolygonSet``, ``CellReference``, ``CellArray``, or an array-like[N][2] of vertices of a polygon. position : number or list of numbers Positions to perform the slicing operation along the specified axis. axis : 0 or 1 Axis along which the polygon will be sliced. precision : float Desired precision for rounding vertice coordinates. layer : integer, list The GDSII layer numbers for the elements between each division. If the number of layers in the list is less than the number of divided regions, the list is repeated. datatype : integer The GDSII datatype for the resulting element (between 0 and 255). Returns ------- out : list[N] of PolygonSet Result of the slicing operation, with N = len(positions) + 1. Each PolygonSet comprises all polygons between 2 adjacent slicing positions, in crescent order. Examples -------- >>> ring = gdspy.Round((0, 0), 10, inner_radius = 5) >>> result = gdspy.slice(ring, [-7, 7], 0) >>> cell.add(result[1])
2.650412
2.510668
1.05566
poly = [] if isinstance(polygons, PolygonSet): poly.extend(polygons.polygons) elif isinstance(polygons, CellReference) or isinstance( polygons, CellArray): poly.extend(polygons.get_polygons()) else: for obj in polygons: if isinstance(obj, PolygonSet): poly.extend(obj.polygons) elif isinstance(obj, CellReference) or isinstance(obj, CellArray): poly.extend(obj.get_polygons()) else: poly.append(obj) result = clipper.offset(poly, distance, join, tolerance, 1 / precision, 1 if join_first else 0) return None if len(result) == 0 else PolygonSet( result, layer, datatype, verbose=False).fracture( max_points, precision)
def offset(polygons, distance, join='miter', tolerance=2, precision=0.001, join_first=False, max_points=199, layer=0, datatype=0)
Shrink or expand a polygon or polygon set. Parameters ---------- polygons : polygon or array-like Polygons to be offset. Must be a ``PolygonSet``, ``CellReference``, ``CellArray``, or an array. The array may contain any of the previous objects or an array-like[N][2] of vertices of a polygon. distance : number Offset distance. Positive to expand, negative to shrink. join : {'miter', 'bevel', 'round'} Type of join used to create the offset polygon. tolerance : number For miter joints, this number must be at least 2 and it represents the maximun distance in multiples of offset betwen new vertices and their original position before beveling to avoid spikes at acute joints. For round joints, it indicates the curvature resolution in number of points per full circle. precision : float Desired precision for rounding vertice coordinates. join_first : bool Join all paths before offseting to avoid unecessary joins in adjacent polygon sides. max_points : integer If greater than 4, fracture the resulting polygons to ensure they have at most ``max_points`` vertices. This is not a tessellating function, so this number should be as high as possible. For example, it should be set to 199 for polygons being drawn in GDSII files. layer : integer The GDSII layer number for the resulting element. datatype : integer The GDSII datatype for the resulting element (between 0 and 255). Returns ------- out : ``PolygonSet`` or ``None`` Return the offset shape as a set of polygons.
2.768087
2.472954
1.119344
polyA = [] polyB = [] for poly, obj in zip((polyA, polyB), (operandA, operandB)): if isinstance(obj, PolygonSet): poly.extend(obj.polygons) elif isinstance(obj, CellReference) or isinstance(obj, CellArray): poly.extend(obj.get_polygons()) elif obj is not None: for inobj in obj: if isinstance(inobj, PolygonSet): poly.extend(inobj.polygons) elif isinstance(inobj, CellReference) or isinstance( inobj, CellArray): poly.extend(inobj.get_polygons()) else: poly.append(inobj) if len(polyB) == 0: polyB.append(polyA.pop()) result = clipper.clip(polyA, polyB, operation, 1 / precision) return None if len(result) == 0 else PolygonSet( result, layer, datatype, verbose=False).fracture( max_points, precision)
def fast_boolean(operandA, operandB, operation, precision=0.001, max_points=199, layer=0, datatype=0)
Execute any boolean operation between 2 polygons or polygon sets. Parameters ---------- operandA : polygon or array-like First operand. Must be a ``PolygonSet``, ``CellReference``, ``CellArray``, or an array. The array may contain any of the previous objects or an array-like[N][2] of vertices of a polygon. operandB : polygon, array-like or ``None`` Second operand. Must be ``None``, a ``PolygonSet``, ``CellReference``, ``CellArray``, or an array. The array may contain any of the previous objects or an array-like[N][2] of vertices of a polygon. operation : {'or', 'and', 'xor', 'not'} Boolean operation to be executed. The 'not' operation returns the difference ``operandA - operandB``. precision : float Desired precision for rounding vertice coordinates. max_points : integer If greater than 4, fracture the resulting polygons to ensure they have at most ``max_points`` vertices. This is not a tessellating function, so this number should be as high as possible. For example, it should be set to 199 for polygons being drawn in GDSII files. layer : integer The GDSII layer number for the resulting element. datatype : integer The GDSII datatype for the resulting element (between 0 and 255). Returns ------- out : PolygonSet or ``None`` Result of the boolean operation.
2.68029
2.408598
1.112801
poly = [] if isinstance(polygons, PolygonSet): poly.extend(polygons.polygons) elif isinstance(polygons, CellReference) or isinstance( polygons, CellArray): poly.extend(polygons.get_polygons()) else: for obj in polygons: if isinstance(obj, PolygonSet): poly.extend(obj.polygons) elif isinstance(obj, CellReference) or isinstance(obj, CellArray): poly.extend(obj.get_polygons()) else: poly.append(obj) if hasattr(points[0][0], '__iter__'): pts = points sc = 1 if short_circuit == 'any' else -1 else: pts = (points, ) sc = 0 return clipper.inside(pts, poly, sc, 1 / precision)
def inside(points, polygons, short_circuit='any', precision=0.001)
Test whether each of the points is within the given set of polygons. Parameters ---------- points : array-like[N][2] or list of array-like[N][2] Coordinates of the points to be tested or groups of points to be tested together. polygons : polygon or array-like Polygons to be tested against. Must be a ``PolygonSet``, ``CellReference``, ``CellArray``, or an array. The array may contain any of the previous objects or an array-like[N][2] of vertices of a polygon. short_circuit : {'any', 'all'} If `points` is a list of point groups, testing within each group will be short-circuited if any of the points in the group is inside ('any') or outside ('all') the polygons. If `points` is simply a list of points, this parameter has no effect. precision : float Desired precision for rounding vertice coordinates. Returns ------- out : tuple Tuple of booleans indicating if each of the points or point groups is inside the set of polygons.
2.679137
2.371101
1.129913
newObj = libCopy.deepcopy(obj) newObj.translate(dx, dy) return newObj
def copy(obj, dx, dy)
Creates a copy of ``obj`` and translates the new object to a new location. Parameters ---------- obj : ``obj`` any translatable geometery object. dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``obj`` Translated copy of original ``obj`` Examples -------- >>> rectangle = gdspy.Rectangle((0, 0), (10, 20)) >>> rectangle2 = gdspy.copy(rectangle, 2,0) >>> myCell.add(rectangle) >>> myCell.add(rectangle2)
9.089337
12.761703
0.712235
current_library.name = name current_library.unit = unit current_library.precision = precision current_library.write_gds(outfile, cells)
def write_gds(outfile, cells=None, name='library', unit=1.0e-6, precision=1.0e-9)
Write the current GDSII library to a file. The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio ``unit/precision``. For example, if a circle with radius 1.5 is created and we set ``unit=1.0e-6`` (1 um) and ``precision=1.0e-9`` (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. Parameters ---------- outfile : file or string The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. cells : array-like The list of cells or cell names to be included in the library. If ``None``, all cells are used. name : string Name of the GDSII library. unit : number Unit size for the objects in the library (in *meters*). precision : number Precision for the dimensions of the objects in the library (in *meters*).
2.913767
3.874811
0.751977
with open(filename, 'rb') as fin: data = fin.read() contents = [] start = pos = 0 while pos < len(data): size, rec = struct.unpack('>HH', data[pos:pos + 4]) if rec == 0x0502: start = pos + 28 elif rec == 0x0700: contents.append(data[start:pos]) pos += size h = hashlib.sha1() if engine is None else engine for x in sorted(contents): h.update(x) return h.hexdigest()
def gdsii_hash(filename, engine=None)
Calculate the a hash value for a GDSII file. The hash is generated based only on the contents of the cells in the GDSII library, ignoring any timestamp records present in the file structure. Parameters ---------- filename : string Full path to the GDSII file. engine : hashlib-like engine The engine that executes the hashing algorithm. It must provide the methods ``update`` and ``hexdigest`` as defined in the hashlib module. If ``None``, the dafault ``hashlib.sha1()`` is used. Returns ------- out : string The hash correponding to the library contents in hex format.
2.786099
2.744145
1.015289
if len(self.polygons) == 0: return None return numpy.array(((min(pts[:, 0].min() for pts in self.polygons), min(pts[:, 1].min() for pts in self.polygons)), (max(pts[:, 0].max() for pts in self.polygons), max(pts[:, 1].max() for pts in self.polygons))))
def get_bounding_box(self)
Returns the bounding box of the polygons. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or ``None`` if the polygon is empty.
2.059823
2.005734
1.026967
ca = numpy.cos(angle) sa = numpy.sin(angle) sa = numpy.array((-sa, sa)) c0 = numpy.array(center) self.polygons = [(points - c0) * ca + (points - c0)[:, ::-1] * sa + c0 for points in self.polygons] return self
def rotate(self, angle, center=(0, 0))
Rotate this object. Parameters ---------- angle : number The angle of rotation (in *radians*). center : array-like[2] Center point for the rotation. Returns ------- out : ``PolygonSet`` This object.
2.950272
3.175405
0.929101
c0 = numpy.array(center) s = scalex if scaley is None else numpy.array((scalex, scaley)) self.polygons = [(points - c0) * s + c0 for points in self.polygons] return self
def scale(self, scalex, scaley=None, center=(0, 0))
Scale this object. Parameters ---------- scalex : number Scaling factor along the first axis. scaley : number or ``None`` Scaling factor along the second axis. If ``None``, same as ``scalex``. center : array-like[2] Center point for the scaling operation. Returns ------- out : ``PolygonSet`` This object.
3.585752
3.992226
0.898184
data = [] for ii in range(len(self.polygons)): if len(self.polygons[ii]) > 4094: raise ValueError("[GDSPY] Polygons with more than 4094 are " "not supported by the GDSII format.") data.append( struct.pack('>10h', 4, 0x0800, 6, 0x0D02, self.layers[ii], 6, 0x0E02, self.datatypes[ii], 12 + 8 * len(self.polygons[ii]), 0x1003)) data.extend( struct.pack('>2l', int(round(point[0] * multiplier)), int(round(point[1] * multiplier))) for point in self.polygons[ii]) data.append( struct.pack('>2l2h', int(round(self.polygons[ii][0][0] * multiplier)), int(round(self.polygons[ii][0][1] * multiplier)), 4, 0x1100)) return b''.join(data)
def to_gds(self, multiplier)
Convert this object to a series of GDSII elements. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII elements. Returns ------- out : string The GDSII binary string that represents this object.
2.901808
2.938976
0.987353
if by_spec: path_area = {} for poly, key in zip(self.polygons, zip(self.layers, self.datatypes)): poly_area = 0 for ii in range(1, len(poly) - 1): poly_area += (poly[0][0] - poly[ii + 1][0]) * ( poly[ii][1] - poly[0][1]) - ( poly[0][1] - poly[ii + 1][1]) * ( poly[ii][0] - poly[0][0]) if key in path_area: path_area[key] += 0.5 * abs(poly_area) else: path_area[key] = 0.5 * abs(poly_area) else: path_area = 0 for points in self.polygons: poly_area = 0 for ii in range(1, len(points) - 1): poly_area += (points[0][0] - points[ii + 1][0]) * ( points[ii][1] - points[0][1]) - ( points[0][1] - points[ii + 1][1]) * ( points[ii][0] - points[0][0]) path_area += 0.5 * abs(poly_area) return path_area
def area(self, by_spec=False)
Calculate the total area of the path(s). Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with ``{(layer, datatype): area}``. Returns ------- out : number, dictionary Area of this object.
1.735041
1.708189
1.01572
if max_points > 4: ii = 0 while ii < len(self.polygons): if len(self.polygons[ii]) > max_points: pts0 = sorted(self.polygons[ii][:, 0]) pts1 = sorted(self.polygons[ii][:, 1]) ncuts = len(pts0) // max_points if pts0[-1] - pts0[0] > pts1[-1] - pts1[0]: # Vertical cuts cuts = [ pts0[int(i * len(pts0) / (ncuts + 1.0) + 0.5)] for i in range(1, ncuts + 1) ] chopped = clipper._chop(self.polygons[ii], cuts, 0, 1 / precision) else: # Horizontal cuts cuts = [ pts1[int(i * len(pts1) / (ncuts + 1.0) + 0.5)] for i in range(1, ncuts + 1) ] chopped = clipper._chop(self.polygons[ii], cuts, 1, 1 / precision) self.polygons.pop(ii) layer = self.layers.pop(ii) datatype = self.datatypes.pop(ii) self.polygons.extend( numpy.array(x) for x in itertools.chain.from_iterable(chopped)) npols = sum(len(c) for c in chopped) self.layers.extend(layer for _ in range(npols)) self.datatypes.extend(datatype for _ in range(npols)) else: ii += 1 return self
def fracture(self, max_points=199, precision=1e-3)
Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most ``max_points``. This operation occurs in place. Parameters ---------- max_points : integer Maximal number of points in each resulting polygon (must be greater than 4). precision : float Desired precision for rounding vertice coordinates. Returns ------- out : ``PolygonSet`` This object.
2.161483
2.091387
1.033517
vec = numpy.array((dx, dy)) self.polygons = [points + vec for points in self.polygons] return self
def translate(self, dx, dy)
Move the polygons from one place to another Parameters ---------- dx : number distance to move in the x-direction dy : number distance to move in the y-direction Returns ------- out : ``PolygonSet`` This object.
5.917953
6.582039
0.899106
ca = numpy.cos(angle) sa = numpy.sin(angle) sa = numpy.array((-sa, sa)) c0 = numpy.array(center) if isinstance(self.direction, basestring): self.direction = _directions_dict[self.direction] * numpy.pi self.direction += angle cur = numpy.array((self.x, self.y)) - c0 self.x, self.y = cur * ca + cur[::-1] * sa + c0 self.polygons = [(points - c0) * ca + (points - c0)[:, ::-1] * sa + c0 for points in self.polygons] return self
def rotate(self, angle, center=(0, 0))
Rotate this object. Parameters ---------- angle : number The angle of rotation (in *radians*). center : array-like[2] Center point for the rotation. Returns ------- out : ``Path`` This object.
3.006598
3.19686
0.940485
if direction is None: direction = self.direction else: self.direction = direction if direction == '+x': ca = 1 sa = 0 elif direction == '-x': ca = -1 sa = 0 elif direction == '+y': ca = 0 sa = 1 elif direction == '-y': ca = 0 sa = -1 else: ca = numpy.cos(direction) sa = numpy.sin(direction) old_x = self.x old_y = self.y self.x += length * ca + axis_offset * sa self.y += length * sa - axis_offset * ca old_w = self.w old_distance = self.distance if final_width is not None: self.w = final_width * 0.5 if final_distance is not None: self.distance = final_distance if (self.w != 0) or (old_w != 0): for ii in range(self.n): d0 = ii * self.distance - (self.n - 1) * self.distance * 0.5 old_d0 = ii * old_distance - (self.n - 1) * old_distance * 0.5 self.polygons.append( numpy.array([(old_x + (old_d0 - old_w) * sa, old_y - (old_d0 - old_w) * ca), (old_x + (old_d0 + old_w) * sa, old_y - (old_d0 + old_w) * ca), (self.x + (d0 + self.w) * sa, self.y - (d0 + self.w) * ca), (self.x + (d0 - self.w) * sa, self.y - (d0 - self.w) * ca)])) if self.w == 0: self.polygons[-1] = self.polygons[-1][:-1, :] if old_w == 0: self.polygons[-1] = self.polygons[-1][1:, :] self.length += numpy.sqrt(length**2 + axis_offset**2) if isinstance(layer, list): self.layers.extend( (layer * (self.n // len(layer) + 1))[:self.n]) else: self.layers.extend(layer for _ in range(self.n)) if isinstance(datatype, list): self.datatypes.extend( (datatype * (self.n // len(datatype) + 1))[:self.n]) else: self.datatypes.extend(datatype for _ in range(self.n)) return self
def segment(self, length, direction=None, final_width=None, final_distance=None, axis_offset=0, layer=0, datatype=0)
Add a straight section to the path. Parameters ---------- length : number Length of the section to add. direction : {'+x', '-x', '+y', '-y'} or number Direction or angle (in *radians*) of rotation of the segment. final_width : number If set, the paths of this segment will have their widths linearly changed from their current value to this one. final_distance : number If set, the distance between paths is linearly change from its current value to this one along this segment. axis_offset : number If set, the paths will be offset from their direction by this amount. layer : integer, list The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. datatype : integer, list The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. Returns ------- out : ``Path`` This object.
1.791722
1.769774
1.012402
exact = True if angle == 'r': delta_i = _halfpi delta_f = 0 elif angle == 'rr': delta_i = _halfpi delta_f = -delta_i elif angle == 'l': delta_i = -_halfpi delta_f = 0 elif angle == 'll': delta_i = -_halfpi delta_f = -delta_i elif angle < 0: exact = False delta_i = _halfpi delta_f = delta_i + angle else: exact = False delta_i = -_halfpi delta_f = delta_i + angle if self.direction == '+x': self.direction = 0 elif self.direction == '-x': self.direction = numpy.pi elif self.direction == '+y': self.direction = _halfpi elif self.direction == '-y': self.direction = -_halfpi elif exact: exact = False self.arc(radius, self.direction + delta_i, self.direction + delta_f, number_of_points, max_points, final_width, final_distance, layer, datatype) if exact: self.direction = _directions_list[int( round(self.direction / _halfpi)) % 4] return self
def turn(self, radius, angle, number_of_points=0.01, max_points=199, final_width=None, final_distance=None, layer=0, datatype=0)
Add a curved section to the path. Parameters ---------- radius : number Central radius of the section. angle : {'r', 'l', 'rr', 'll'} or number Angle (in *radians*) of rotation of the path. The values 'r' and 'l' represent 90-degree turns cw and ccw, respectively; the values 'rr' and 'll' represent analogous 180-degree turns. number_of_points : integer or float If integer: number of vertices that form the object (polygonal approximation). If float: approximate curvature resolution. The actual number of points is automatically calculated. max_points : integer if ``number_of_points > max_points``, the element will be fractured in smaller polygons with at most ``max_points`` each. final_width : number If set, the paths of this segment will have their widths linearly changed from their current value to this one. final_distance : number If set, the distance between paths is linearly change from its current value to this one along this segment. layer : integer, list The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. datatype : integer, list The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. Returns ------- out : ``Path`` This object. Notes ----- The GDSII specification supports only a maximum of 199 vertices per polygon.
2.214818
2.297279
0.964105
text = self.text if len(text) % 2 != 0: text = text + '\0' data = struct.pack('>11h', 4, 0x0C00, 6, 0x0D02, self.layer, 6, 0x1602, self.texttype, 6, 0x1701, self.anchor) if (self.rotation is not None) or (self.magnification is not None) or self.x_reflection: word = 0 values = b'' if self.x_reflection: word += 0x8000 if not (self.magnification is None): # This flag indicates that the magnification is absolute, not # relative (not supported). #word += 0x0004 values += struct.pack('>2h', 12, 0x1B05) + _eight_byte_real( self.magnification) if not (self.rotation is None): # This flag indicates that the rotation is absolute, not # relative (not supported). #word += 0x0002 values += struct.pack('>2h', 12, 0x1C05) + _eight_byte_real( self.rotation) data += struct.pack('>2hH', 6, 0x1A01, word) + values return data + struct.pack( '>2h2l2h', 12, 0x1003, int(round(self.position[0] * multiplier)), int(round(self.position[1] * multiplier)), 4 + len(text), 0x1906) + text.encode('ascii') + struct.pack('>2h', 4, 0x1100)
def to_gds(self, multiplier)
Convert this label to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. Returns ------- out : string The GDSII binary string that represents this label.
3.006955
3.015368
0.99721
self.position = numpy.array((dx + self.position[0], dy + self.position[1])) return self
def translate(self, dx, dy)
Move the text from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``Label`` This object. Examples -------- >>> text = gdspy.Label((0, 0), (10, 20)) >>> text = text.translate(2, 0) >>> myCell.add(text)
4.790329
12.186238
0.393093
now = datetime.datetime.today() if timestamp is None else timestamp name = self.name if len(name) % 2 != 0: name = name + '\0' return struct.pack( '>16h', 28, 0x0502, now.year, now.month, now.day, now.hour, now.minute, now.second, now.year, now.month, now.day, now.hour, now.minute, now.second, 4 + len(name), 0x0606) + name.encode('ascii') + b''.join( element.to_gds(multiplier) for element in self.elements) + b''.join( label.to_gds(multiplier) for label in self.labels) + struct.pack('>2h', 4, 0x0700)
def to_gds(self, multiplier, timestamp=None)
Convert this cell to a GDSII structure. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII structure. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Returns ------- out : string The GDSII binary string that represents this cell.
2.784238
2.739083
1.016485
new_cell = Cell(name, exclude_from_current) if deep_copy: new_cell.elements = libCopy.deepcopy(self.elements) new_cell.labels = libCopy.deepcopy(self.labels) for ref in new_cell.get_dependencies(True): if ref._bb_valid: ref._bb_valid = False else: new_cell.elements = list(self.elements) new_cell.labels = list(self.labels) return new_cell
def copy(self, name, exclude_from_current=False, deep_copy=False)
Creates a copy of this cell. Parameters ---------- name : string The name of the cell. exclude_from_current : bool If ``True``, the cell will not be included in the global list of cells maintained by ``gdspy``. deep_copy : bool If ``False``, the new cell will contain only references to the existing elements. If ``True``, copies of all elements are also created. Returns ------- out : ``Cell`` The new copy of this cell.
3.415513
3.408389
1.00209
if isinstance(element, list): for e in element: if isinstance(e, Label): self.labels.append(e) else: self.elements.append(e) else: if isinstance(element, Label): self.labels.append(element) else: self.elements.append(element) self._bb_valid = False return self
def add(self, element)
Add a new element or list of elements to this cell. Parameters ---------- element : object, list The element or list of elements to be inserted in this cell. Returns ------- out : ``Cell`` This cell.
2.223176
2.283901
0.973412
empty = [] for element in self.elements: if isinstance(element, PolygonSet): ii = 0 while ii < len(element.polygons): if test(element.polygons[ii], element.layers[ii], element.datatypes[ii]): element.polygons.pop(ii) element.layers.pop(ii) element.datatypes.pop(ii) else: ii += 1 if len(element.polygons) == 0: empty.append(element) for element in empty: self.elements.remove(element) return self
def remove_polygons(self, test)
Remove polygons from this cell. The function or callable ``test`` is called for each polygon in the cell. If its return value evaluates to ``True``, the corresponding polygon is removed from the cell. Parameters ---------- test : callable Test function to query whether a polygon should be removed. The function is called with arguments: ``(points, layer, datatype)`` Returns ------- out : ``Cell`` This cell. Examples -------- Remove polygons in layer 1: >>> cell.remove_polygons(lambda pts, layer, datatype: ... layer == 1) Remove polygons with negative x coordinates: >>> cell.remove_polygons(lambda pts, layer, datatype: ... any(pts[:, 0] < 0))
2.095701
2.448436
0.855935
ii = 0 while ii < len(self.labels): if test(self.labels[ii]): self.labels.pop(ii) else: ii += 1 return self
def remove_labels(self, test)
Remove labels from this cell. The function or callable ``test`` is called for each label in the cell. If its return value evaluates to ``True``, the corresponding label is removed from the cell. Parameters ---------- test : callable Test function to query whether a label should be removed. The function is called with the label as the only argument. Returns ------- out : ``Cell`` This cell. Examples -------- Remove labels in layer 1: >>> cell.remove_labels(lambda lbl: lbl.layer == 1)
2.628447
4.403806
0.596858
if by_spec: cell_area = {} for element in self.elements: element_area = element.area(True) for ll in element_area.keys(): if ll in cell_area: cell_area[ll] += element_area[ll] else: cell_area[ll] = element_area[ll] else: cell_area = 0 for element in self.elements: cell_area += element.area() return cell_area
def area(self, by_spec=False)
Calculate the total area of the elements on this cell, including cell references and arrays. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell.
1.945082
1.99944
0.972813
layers = set() for element in self.elements: if isinstance(element, PolygonSet): layers.update(element.layers) elif isinstance(element, CellReference) or isinstance( element, CellArray): layers.update(element.ref_cell.get_layers()) for label in self.labels: layers.add(label.layer) return layers
def get_layers(self)
Returns a set of layers in this cell. Returns ------- out : set Set of the layers used in this cell.
3.680501
3.864414
0.952409
datatypes = set() for element in self.elements: if isinstance(element, PolygonSet): datatypes.update(element.datatypes) elif isinstance(element, CellReference) or isinstance( element, CellArray): datatypes.update(element.ref_cell.get_datatypes()) return datatypes
def get_datatypes(self)
Returns a set of datatypes in this cell. Returns ------- out : set Set of the datatypes used in this cell.
3.751724
3.550308
1.056732
if len(self.elements) == 0: return None if not (self._bb_valid and all(ref._bb_valid for ref in self.get_dependencies(True))): bb = numpy.array(((1e300, 1e300), (-1e300, -1e300))) all_polygons = [] for element in self.elements: if isinstance(element, PolygonSet): all_polygons.extend(element.polygons) elif isinstance(element, CellReference) or isinstance( element, CellArray): element_bb = element.get_bounding_box() if element_bb is not None: bb[0, 0] = min(bb[0, 0], element_bb[0, 0]) bb[0, 1] = min(bb[0, 1], element_bb[0, 1]) bb[1, 0] = max(bb[1, 0], element_bb[1, 0]) bb[1, 1] = max(bb[1, 1], element_bb[1, 1]) if len(all_polygons) > 0: all_points = numpy.concatenate(all_polygons).transpose() bb[0, 0] = min(bb[0, 0], all_points[0].min()) bb[0, 1] = min(bb[0, 1], all_points[1].min()) bb[1, 0] = max(bb[1, 0], all_points[0].max()) bb[1, 1] = max(bb[1, 1], all_points[1].max()) self._bb_valid = True _bounding_boxes[self] = bb return _bounding_boxes[self]
def get_bounding_box(self)
Returns the bounding box for this cell. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty.
1.789817
1.773151
1.009399
if depth is not None and depth < 0: bb = self.get_bounding_box() if bb is None: return {} if by_spec else [] pts = [ numpy.array([(bb[0, 0], bb[0, 1]), (bb[0, 0], bb[1, 1]), (bb[1, 0], bb[1, 1]), (bb[1, 0], bb[0, 1])]) ] polygons = {self.name: pts} if by_spec else pts else: if by_spec: polygons = {} for element in self.elements: if isinstance(element, PolygonSet): for ii in range(len(element.polygons)): key = (element.layers[ii], element.datatypes[ii]) if key in polygons: polygons[key].append( numpy.array(element.polygons[ii])) else: polygons[key] = [ numpy.array(element.polygons[ii]) ] else: cell_polygons = element.get_polygons( True, None if depth is None else depth - 1) for kk in cell_polygons.keys(): if kk in polygons: polygons[kk].extend(cell_polygons[kk]) else: polygons[kk] = cell_polygons[kk] else: polygons = [] for element in self.elements: if isinstance(element, PolygonSet): for points in element.polygons: polygons.append(numpy.array(points)) else: polygons.extend( element.get_polygons( depth=None if depth is None else depth - 1)) return polygons
def get_polygons(self, by_spec=False, depth=None)
Returns a list of polygons in this cell. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If ``by_spec`` is ``True`` the key will be the name of this cell. Returns ------- out : list of array-like[N][2] or dictionary List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if ``by_spec`` is ``True``).
1.897627
1.803741
1.052051
labels = libCopy.deepcopy(self.labels) if depth is None or depth > 0: for element in self.elements: if isinstance(element, CellReference): labels.extend( element.get_labels(None if depth is None else depth - 1)) elif isinstance(element, CellArray): labels.extend( element.get_labels(None if depth is None else depth - 1)) return labels
def get_labels(self, depth=None)
Returns a list with a copy of the labels in this cell. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------- out : list of ``Label`` List containing the labels in this cell and its references.
3.337895
3.173874
1.051678
dependencies = set() for element in self.elements: if isinstance(element, CellReference) or isinstance( element, CellArray): if recursive: dependencies.update( element.ref_cell.get_dependencies(True)) dependencies.add(element.ref_cell) return dependencies
def get_dependencies(self, recursive=False)
Returns a list of the cells included in this cell as references. Parameters ---------- recursive : bool If True returns cascading dependencies. Returns ------- out : set of ``Cell`` List of the cells referenced by this cell.
3.721639
4.007351
0.928703
self.labels = self.get_labels() if single_layer is not None: for lbl in self.labels: lbl.layer = single_layer if single_texttype is not None: for lbl in self.labels: lbl.texttype = single_texttype if single_layer is None or single_datatype is None: poly_dic = self.get_polygons(True) self.elements = [] if single_layer is None and single_datatype is None: for ld in poly_dic.keys(): self.add(PolygonSet(poly_dic[ld], *ld, verbose=False)) elif single_layer is None: for ld in poly_dic.keys(): self.add( PolygonSet( poly_dic[ld], ld[0], single_datatype, verbose=False)) else: for ld in poly_dic.keys(): self.add( PolygonSet( poly_dic[ld], single_layer, ld[1], verbose=False)) else: polygons = self.get_polygons() self.elements = [] self.add( PolygonSet( polygons, single_layer, single_datatype, verbose=False)) return self
def flatten(self, single_layer=None, single_datatype=None, single_texttype=None)
Flatten all ``CellReference`` and ``CellArray`` elements in this cell into real polygons and labels, instead of references. Parameters ---------- single_layer : integer or None If not ``None``, all polygons will be transfered to the layer indicated by this number. single_datatype : integer or None If not ``None``, all polygons will be transfered to the datatype indicated by this number. single_datatype : integer or None If not ``None``, all labels will be transfered to the texttype indicated by this number. Returns ------- out : ``Cell`` This cell.
2.254062
2.121075
1.062698
name = self.ref_cell.name if len(name) % 2 != 0: name = name + '\0' data = struct.pack('>4h', 4, 0x0A00, 4 + len(name), 0x1206) + name.encode('ascii') if (self.rotation is not None) or (self.magnification is not None) or self.x_reflection: word = 0 values = b'' if self.x_reflection: word += 0x8000 if not (self.magnification is None): # This flag indicates that the magnification is absolute, not # relative (not supported). #word += 0x0004 values += struct.pack('>2h', 12, 0x1B05) + _eight_byte_real( self.magnification) if not (self.rotation is None): # This flag indicates that the rotation is absolute, not # relative (not supported). #word += 0x0002 values += struct.pack('>2h', 12, 0x1C05) + _eight_byte_real( self.rotation) data += struct.pack('>2hH', 6, 0x1A01, word) + values return data + struct.pack( '>2h2l2h', 12, 0x1003, int(round(self.origin[0] * multiplier)), int(round(self.origin[1] * multiplier)), 4, 0x1100)
def to_gds(self, multiplier)
Convert this object to a GDSII element. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII element. Returns ------- out : string The GDSII binary string that represents this object.
3.062366
3.078048
0.994905
if not isinstance(self.ref_cell, Cell): return dict() if by_spec else 0 if self.magnification is None: return self.ref_cell.area(by_spec) else: if by_spec: factor = self.magnification**2 cell_area = self.ref_cell.area(True) for kk in cell_area.keys(): cell_area[kk] *= factor return cell_area else: return self.ref_cell.area() * self.magnification**2
def area(self, by_spec=False)
Calculate the total area of the referenced cell with the magnification factor included. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the areas of each individual pair (layer, datatype). Returns ------- out : number, dictionary Area of this cell.
2.842038
2.68081
1.060141
if not isinstance(self.ref_cell, Cell): return dict() if by_spec else [] if self.rotation is not None: ct = numpy.cos(self.rotation * numpy.pi / 180.0) st = numpy.sin(self.rotation * numpy.pi / 180.0) st = numpy.array([-st, st]) if self.x_reflection: xrefl = numpy.array([1, -1], dtype='int') if self.magnification is not None: mag = numpy.array([self.magnification, self.magnification]) if self.origin is not None: orgn = numpy.array(self.origin) if by_spec: polygons = self.ref_cell.get_polygons(True, depth) for kk in polygons.keys(): for ii in range(len(polygons[kk])): if self.x_reflection: polygons[kk][ii] = polygons[kk][ii] * xrefl if self.magnification is not None: polygons[kk][ii] = polygons[kk][ii] * mag if self.rotation is not None: polygons[kk][ii] = (polygons[kk][ii] * ct + polygons[kk][ii][:, ::-1] * st) if self.origin is not None: polygons[kk][ii] = polygons[kk][ii] + orgn else: polygons = self.ref_cell.get_polygons(depth=depth) for ii in range(len(polygons)): if self.x_reflection: polygons[ii] = polygons[ii] * xrefl if self.magnification is not None: polygons[ii] = polygons[ii] * mag if self.rotation is not None: polygons[ii] = ( polygons[ii] * ct + polygons[ii][:, ::-1] * st) if self.origin is not None: polygons[ii] = polygons[ii] + orgn return polygons
def get_polygons(self, by_spec=False, depth=None)
Returns a list of polygons created by this reference. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If ``by_spec`` is ``True`` the key will be the name of the referenced cell. Returns ------- out : list of array-like[N][2] or dictionary List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if ``by_spec`` is ``True``).
1.753369
1.746512
1.003926
if not isinstance(self.ref_cell, Cell): return [] if self.rotation is not None: ct = numpy.cos(self.rotation * numpy.pi / 180.0) st = numpy.sin(self.rotation * numpy.pi / 180.0) st = numpy.array([-st, st]) if self.x_reflection: xrefl = numpy.array([1, -1], dtype='int') if self.magnification is not None: mag = numpy.array([self.magnification, self.magnification]) if self.origin is not None: orgn = numpy.array(self.origin) labels = self.ref_cell.get_labels(depth=depth) for lbl in labels: if self.x_reflection: lbl.position = lbl.position * xrefl if self.magnification is not None: lbl.position = lbl.position * mag if self.rotation is not None: lbl.position = lbl.position * ct + lbl.position[::-1] * st if self.origin is not None: lbl.position = lbl.position + orgn return labels
def get_labels(self, depth=None)
Returns a list of labels created by this reference. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------- out : list of ``Label`` List containing the labels in this cell and its references.
2.2648
2.240101
1.011026
if not isinstance(self.ref_cell, Cell): return None if (self.rotation is None and self.magnification is None and self.x_reflection is None): key = self else: key = (self.ref_cell, self.rotation, self.magnification, self.x_reflection) deps = self.ref_cell.get_dependencies(True) if not (self.ref_cell._bb_valid and all(ref._bb_valid for ref in deps) and key in _bounding_boxes): for ref in deps: ref.get_bounding_box() self.ref_cell.get_bounding_box() tmp = self.origin self.origin = None polygons = self.get_polygons() self.origin = tmp if len(polygons) == 0: bb = None else: all_points = numpy.concatenate(polygons).transpose() bb = numpy.array(((all_points[0].min(), all_points[1].min()), (all_points[0].max(), all_points[1].max()))) _bounding_boxes[key] = bb else: bb = _bounding_boxes[key] if self.origin is None or bb is None: return bb else: return bb + numpy.array(((self.origin[0], self.origin[1]), (self.origin[0], self.origin[1])))
def get_bounding_box(self)
Returns the bounding box for this reference. Returns ------- out : Numpy array[2,2] or ``None`` Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or ``None`` if the cell is empty.
2.643542
2.642849
1.000262
self.origin = (self.origin[0] + dx, self.origin[1] + dy) return self
def translate(self, dx, dy)
Move the reference from one place to another Parameters ---------- dx : float distance to move in the x-direction dy : float distance to move in the y-direction Returns ------- out : ``CellReference`` This object.
2.69892
3.738563
0.721914
name = self.ref_cell.name if len(name) % 2 != 0: name = name + '\0' data = struct.pack('>4h', 4, 0x0B00, 4 + len(name), 0x1206) + name.encode('ascii') x2 = self.origin[0] + self.columns * self.spacing[0] y2 = self.origin[1] x3 = self.origin[0] y3 = self.origin[1] + self.rows * self.spacing[1] if (self.rotation is not None) or (self.magnification is not None) or self.x_reflection: word = 0 values = b'' if self.x_reflection: word += 0x8000 y3 = 2 * self.origin[1] - y3 if not (self.magnification is None): # This flag indicates that the magnification is absolute, not # relative (not supported). #word += 0x0004 values += struct.pack('>2h', 12, 0x1B05) + _eight_byte_real( self.magnification) if not (self.rotation is None): # This flag indicates that the rotation is absolute, not # relative (not supported). #word += 0x0002 sa = numpy.sin(self.rotation * numpy.pi / 180.0) ca = numpy.cos(self.rotation * numpy.pi / 180.0) tmp = (x2 - self.origin[0]) * ca - ( y2 - self.origin[1]) * sa + self.origin[0] y2 = (x2 - self.origin[0]) * sa + ( y2 - self.origin[1]) * ca + self.origin[1] x2 = tmp tmp = (x3 - self.origin[0]) * ca - ( y3 - self.origin[1]) * sa + self.origin[0] y3 = (x3 - self.origin[0]) * sa + ( y3 - self.origin[1]) * ca + self.origin[1] x3 = tmp values += struct.pack('>2h', 12, 0x1C05) + _eight_byte_real( self.rotation) data += struct.pack('>2hH', 6, 0x1A01, word) + values return data + struct.pack( '>6h6l2h', 8, 0x1302, self.columns, self.rows, 28, 0x1003, int(round(self.origin[0] * multiplier)), int(round(self.origin[1] * multiplier)), int( round(x2 * multiplier)), int(round(y2 * multiplier)), int(round(x3 * multiplier)), int(round( y3 * multiplier)), 4, 0x1100)
def to_gds(self, multiplier)
Convert this object to a GDSII element. Parameters ---------- multiplier : number A number that multiplies all dimensions written in the GDSII element. Returns ------- out : string The GDSII binary string that represents this object.
2.28275
2.288093
0.997665
if not isinstance(self.ref_cell, Cell): return dict() if by_spec else [] if self.rotation is not None: ct = numpy.cos(self.rotation * numpy.pi / 180.0) st = numpy.sin(self.rotation * numpy.pi / 180.0) st = numpy.array([-st, st]) if self.magnification is not None: mag = numpy.array([self.magnification, self.magnification]) if self.origin is not None: orgn = numpy.array(self.origin) if self.x_reflection: xrefl = numpy.array([1, -1], dtype='int') if by_spec: cell_polygons = self.ref_cell.get_polygons(True, depth) polygons = {} for kk in cell_polygons.keys(): polygons[kk] = [] for ii in range(self.columns): for jj in range(self.rows): spc = numpy.array( [self.spacing[0] * ii, self.spacing[1] * jj]) for points in cell_polygons[kk]: if self.magnification: polygons[kk].append(points * mag + spc) else: polygons[kk].append(points + spc) if self.x_reflection: polygons[kk][-1] = polygons[kk][-1] * xrefl if self.rotation is not None: polygons[kk][-1] = ( polygons[kk][-1] * ct + polygons[kk][-1][:, ::-1] * st) if self.origin is not None: polygons[kk][-1] = polygons[kk][-1] + orgn else: cell_polygons = self.ref_cell.get_polygons(depth=depth) polygons = [] for ii in range(self.columns): for jj in range(self.rows): spc = numpy.array( [self.spacing[0] * ii, self.spacing[1] * jj]) for points in cell_polygons: if self.magnification: polygons.append(points * mag + spc) else: polygons.append(points + spc) if self.x_reflection: polygons[-1] = polygons[-1] * xrefl if self.rotation is not None: polygons[-1] = ( polygons[-1] * ct + polygons[-1][:, ::-1] * st) if self.origin is not None: polygons[-1] = polygons[-1] + orgn return polygons
def get_polygons(self, by_spec=False, depth=None)
Returns a list of polygons created by this reference. Parameters ---------- by_spec : bool If ``True``, the return value is a dictionary with the polygons of each individual pair (layer, datatype). depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If ``by_spec`` is ``True`` the key will be name of the referenced cell. Returns ------- out : list of array-like[N][2] or dictionary List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if ``by_spec`` is ``True``).
1.733101
1.735755
0.998471
if not isinstance(self.ref_cell, Cell): return [] if self.rotation is not None: ct = numpy.cos(self.rotation * numpy.pi / 180.0) st = numpy.sin(self.rotation * numpy.pi / 180.0) st = numpy.array([-st, st]) if self.magnification is not None: mag = numpy.array([self.magnification, self.magnification]) if self.origin is not None: orgn = numpy.array(self.origin) if self.x_reflection: xrefl = numpy.array([1, -1], dtype='int') cell_labels = self.ref_cell.get_labels(depth=depth) labels = [] for ii in range(self.columns): for jj in range(self.rows): spc = numpy.array([self.spacing[0] * ii, self.spacing[1] * jj]) for clbl in cell_labels: lbl = libCopy.deepcopy(clbl) if self.magnification: lbl.position = lbl.position * mag + spc else: lbl.position = lbl.position + spc if self.x_reflection: lbl.position = lbl.position * xrefl if self.rotation is not None: lbl.position = lbl.position * ct + lbl.position[::-1] * st if self.origin is not None: lbl.position = lbl.position + orgn labels.append(lbl) return labels
def get_labels(self, depth=None)
Returns a list of labels created by this reference. Parameters ---------- depth : integer or ``None`` If not ``None``, defines from how many reference levels to retrieve labels from. Returns ------- out : list of ``Label`` List containing the labels in this cell and its references.
2.339037
2.365124
0.98897
if isinstance(cell, Cell): if (not overwrite_duplicate and cell.name in self.cell_dict and self.cell_dict[cell.name] is not cell): raise ValueError("[GDSPY] cell named {0} already present in " "library.".format(cell.name)) self.cell_dict[cell.name] = cell else: for c in cell: if (not overwrite_duplicate and c.name in self.cell_dict and self.cell_dict[c.name] is not c): raise ValueError("[GDSPY] cell named {0} already present " "in library.".format(c.name)) self.cell_dict[c.name] = c return self
def add(self, cell, overwrite_duplicate=False)
Add one or more cells to the library. Parameters ---------- cell : ``Cell`` of list of ``Cell`` Cells to be included in the library. overwrite_duplicate : bool If True an existing cell with the same name in the library will be overwritten. Returns ------- out : ``GdsLibrary`` This object.
1.991436
1.877108
1.060907
if isinstance(outfile, basestring): outfile = open(outfile, 'wb') close = True else: close = False now = datetime.datetime.today() if timestamp is None else timestamp name = self.name if len(self.name) % 2 == 0 else (self.name + '\0') outfile.write( struct.pack('>19h', 6, 0x0002, 0x0258, 28, 0x0102, now.year, now.month, now.day, now.hour, now.minute, now.second, now.year, now.month, now.day, now.hour, now.minute, now.second, 4 + len(name), 0x0206) + name.encode('ascii') + struct.pack('>2h', 20, 0x0305) + _eight_byte_real(self.precision / self.unit) + _eight_byte_real(self.precision)) if cells is None: cells = self.cell_dict.values() else: cells = [self.cell_dict.get(c, c) for c in cells] for cell in cells: outfile.write(cell.to_gds(self.unit / self.precision)) outfile.write(struct.pack('>2h', 4, 0x0400)) if close: outfile.close()
def write_gds(self, outfile, cells=None, timestamp=None)
Write the GDSII library to a file. The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio ``unit/precision``. For example, if a circle with radius 1.5 is created and we set ``unit=1.0e-6`` (1 um) and ``precision=1.0e-9`` (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. Parameters ---------- outfile : file or string The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. cells : array-like The list of cells or cell names to be included in the library. If ``None``, all cells are used. timestamp : datetime object Sets the GDSII timestamp. If ``None``, the current time is used. Notes ----- Only the specified cells are written. The user is responsible for ensuring all cell dependencies are satisfied.
2.616868
2.514512
1.040706
header = stream.read(4) if len(header) < 4: return None size, rec_type = struct.unpack('>HH', header) data_type = (rec_type & 0x00ff) rec_type = rec_type // 256 data = None if size > 4: if data_type == 0x01: data = numpy.array( struct.unpack('>{0}H'.format((size - 4) // 2), stream.read(size - 4)), dtype='uint') elif data_type == 0x02: data = numpy.array( struct.unpack('>{0}h'.format((size - 4) // 2), stream.read(size - 4)), dtype='int') elif data_type == 0x03: data = numpy.array( struct.unpack('>{0}l'.format((size - 4) // 4), stream.read(size - 4)), dtype='int') elif data_type == 0x05: data = numpy.array([ _eight_byte_real_to_float(stream.read(8)) for _ in range((size - 4) // 8) ]) else: data = stream.read(size - 4) if str is not bytes: if data[-1] == 0: data = data[:-1].decode('ascii') else: data = data.decode('ascii') elif data[-1] == '\0': data = data[:-1] return [rec_type, data]
def _read_record(self, stream)
Read a complete record from a GDSII stream file. Parameters ---------- stream : file GDSII stream file to be imported. Returns ------- out : 2-tuple Record type and data (as a numpy.array)
2.005196
2.037029
0.984373
cell = self.cell_dict.get(cell, cell) current_library.add(cell) current_library.add(cell.get_dependencies(True)) return cell
def extract(self, cell)
Extract a cell from the this GDSII file and include it in the current global library, including referenced dependencies. Parameters ---------- cell : ``Cell`` or string Cell or name of the cell to be extracted from the imported file. Referenced cells will be automatically extracted as well. Returns ------- out : ``Cell`` The extracted cell.
7.071701
5.962502
1.186029
top = list(self.cell_dict.values()) for cell in self.cell_dict.values(): for dependency in cell.get_dependencies(): if dependency in top: top.remove(dependency) return top
def top_level(self)
Output the top level cells from the GDSII data. Top level cells are those that are not referenced by any other cells. Returns ------- out : list List of top level cells.
3.810875
4.056481
0.939453
self._outfile.write(cell.to_gds(self._res)) return self
def write_cell(self, cell)
Write the specified cell to the file. Parameters ---------- cell : ``Cell`` Cell to be written. Notes ----- Only the specified cell is written. Dependencies must be manually included. Returns ------- out : ``GdsWriter`` This object.
13.316674
12.860225
1.035493
self._outfile.write(struct.pack('>2h', 4, 0x0400)) if self._close: self._outfile.close()
def close(self)
Finalize the GDSII stream library.
7.110527
5.823746
1.220954
''' Easy waveguide creation tool with absolute positioning. path : starting `gdspy.Path` points : coordinates along which the waveguide will travel finish : end point of the waveguide bend_radius : radius of the turns in the waveguide number_of_points : same as in `path.turn` direction : starting direction layer : GDSII layer number datatype : GDSII datatype number Return `path`. ''' if direction is not None: path.direction = direction axis = 0 if path.direction[1] == 'x' else 1 points.append(finish[(axis + len(points)) % 2]) n = len(points) if points[0] > (path.x, path.y)[axis]: path.direction = ['+x', '+y'][axis] else: path.direction = ['-x', '-y'][axis] for i in range(n): path.segment( abs(points[i] - (path.x, path.y)[axis]) - bend_radius, layer=layer, datatype=datatype) axis = 1 - axis if i < n - 1: goto = points[i + 1] else: goto = finish[axis] if (goto > (path.x, path.y)[axis]) ^ ((path.direction[0] == '+') ^ (path.direction[1] == 'x')): bend = 'l' else: bend = 'r' path.turn( bend_radius, bend, number_of_points=number_of_points, layer=layer, datatype=datatype) return path.segment( abs(finish[axis] - (path.x, path.y)[axis]), layer=layer, datatype=datatype)
def waveguide(path, points, finish, bend_radius, number_of_points=0.01, direction=None, layer=0, datatype=0)
Easy waveguide creation tool with absolute positioning. path : starting `gdspy.Path` points : coordinates along which the waveguide will travel finish : end point of the waveguide bend_radius : radius of the turns in the waveguide number_of_points : same as in `path.turn` direction : starting direction layer : GDSII layer number datatype : GDSII datatype number Return `path`.
3.092371
2.171903
1.423807
''' Linear tapers for the lazy. path : `gdspy.Path` to append the taper length : total length final_width : final width of th taper direction : taper direction layer : GDSII layer number (int or list) datatype : GDSII datatype number (int or list) Parameters `layer` and `datatype` must be of the same type. If they are lists, they must have the same length. Their length indicate the number of pieces that compose the taper. Return `path`. ''' if layer.__class__ == datatype.__class__ == [].__class__: assert len(layer) == len(datatype) elif isinstance(layer, int) and isinstance(datatype, int): layer = [layer] datatype = [datatype] else: raise ValueError('Parameters layer and datatype must have the same ' 'type (either int or list) and length.') n = len(layer) w = numpy.linspace(2 * path.w, final_width, n + 1)[1:] d = numpy.linspace(path.distance, final_distance, n + 1)[1:] l = float(length) / n for i in range(n): path.segment( l, direction, w[i], d[i], layer=layer[i], datatype=datatype[i]) return path
def taper(path, length, final_width, final_distance, direction=None, layer=0, datatype=0)
Linear tapers for the lazy. path : `gdspy.Path` to append the taper length : total length final_width : final width of th taper direction : taper direction layer : GDSII layer number (int or list) datatype : GDSII datatype number (int or list) Parameters `layer` and `datatype` must be of the same type. If they are lists, they must have the same length. Their length indicate the number of pieces that compose the taper. Return `path`.
3.834984
2.027309
1.891663
''' Straight or focusing grating. period : grating period number_of_teeth : number of teeth in the grating fill_frac : filling fraction of the teeth (w.r.t. the period) width : width of the grating position : grating position (feed point) direction : one of {'+x', '-x', '+y', '-y'} lda : free-space wavelength sin_theta : sine of incidence angle focus_distance : focus distance (negative for straight grating) focus_width : if non-negative, the focusing area is included in the result (usually for negative resists) and this is the width of the waveguide connecting to the grating evaluations : number of evaluations of `path.parametric` layer : GDSII layer number datatype : GDSII datatype number Return `PolygonSet` ''' if focus_distance < 0: path = gdspy.L1Path( (position[0] - 0.5 * width, position[1] + 0.5 * (number_of_teeth - 1 + fill_frac) * period), '+x', period * fill_frac, [width], [], number_of_teeth, period, layer=layer, datatype=datatype) else: neff = lda / float(period) + sin_theta qmin = int(focus_distance / float(period) + 0.5) path = gdspy.Path(period * fill_frac, position) max_points = 199 if focus_width < 0 else 2 * evaluations c3 = neff**2 - sin_theta**2 w = 0.5 * width for q in range(qmin, qmin + number_of_teeth): c1 = q * lda * sin_theta c2 = (q * lda)**2 path.parametric( lambda t: (width * t - w, (c1 + neff * numpy.sqrt(c2 - c3 * ( width * t - w)**2)) / c3), number_of_evaluations=evaluations, max_points=max_points, layer=layer, datatype=datatype) path.x = position[0] path.y = position[1] if focus_width >= 0: path.polygons[0] = numpy.vstack( (path.polygons[0][:evaluations, :], ([position] if focus_width == 0 else [(position[0] + 0.5 * focus_width, position[1]), (position[0] - 0.5 * focus_width, position[1])]))) path.fracture() if direction == '-x': return path.rotate(0.5 * numpy.pi, position) elif direction == '+x': return path.rotate(-0.5 * numpy.pi, position) elif direction == '-y': return path.rotate(numpy.pi, position) else: return path
def grating(period, number_of_teeth, fill_frac, width, position, direction, lda=1, sin_theta=0, focus_distance=-1, focus_width=-1, evaluations=99, layer=0, datatype=0)
Straight or focusing grating. period : grating period number_of_teeth : number of teeth in the grating fill_frac : filling fraction of the teeth (w.r.t. the period) width : width of the grating position : grating position (feed point) direction : one of {'+x', '-x', '+y', '-y'} lda : free-space wavelength sin_theta : sine of incidence angle focus_distance : focus distance (negative for straight grating) focus_width : if non-negative, the focusing area is included in the result (usually for negative resists) and this is the width of the waveguide connecting to the grating evaluations : number of evaluations of `path.parametric` layer : GDSII layer number datatype : GDSII datatype number Return `PolygonSet`
3.582761
2.359563
1.5184
def parse_netloc(netloc): parsed = urlparse.urlsplit('http://' + netloc) return parsed.hostname, parsed.port app = current_app._get_current_object() root_path = request.script_root server_name = app.config.get('SERVER_NAME') if server_name: hostname, port = parse_netloc(server_name) def accept(url): return url.hostname is not None and ( url.hostname == hostname or url.hostname.endswith('.' + hostname)) else: scheme = request.scheme hostname, port = parse_netloc(request.host) if (scheme, port) in DEFAULT_PORTS: port = None def accept(url): return (url.scheme, url.hostname) == (scheme, hostname) def dispatch(url_string): if isinstance(url_string, bytes): url_string = url_string.decode('utf8') url = urlparse.urlsplit(url_string) url_port = url.port if (url.scheme, url_port) in DEFAULT_PORTS: url_port = None if accept(url) and url_port == port and url.path.startswith(root_path): netloc = url.netloc if url.port and not url_port: netloc = netloc.rsplit(':', 1)[0] # remove default port base_url = '%s://%s%s' % (url.scheme, netloc, root_path) path = url.path[len(root_path):] if url.query: path += '?' + url.query # Ignore url.fragment return app, base_url, path return dispatch
def make_flask_url_dispatcher()
Return an URL dispatcher based on the current :ref:`request context <flask:request-context>`. You generally don’t need to call this directly. The context is used when the dispatcher is first created but not afterwards. It is not required after this function has returned. Dispatch to the context’s app URLs below the context’s root URL. If the app has a ``SERVER_NAME`` :ref:`config <flask:config>`, also accept URLs that have that domain name or a subdomain thereof.
2.596215
2.633494
0.985844
if dispatcher is None: dispatcher = make_flask_url_dispatcher() def flask_url_fetcher(url): redirect_chain = set() while 1: result = dispatcher(url) if result is None: return next_fetcher(url) app, base_url, path = result client = Client(app, response_wrapper=Response) if isinstance(path, unicode): # TODO: double-check this. Apparently Werzeug %-unquotes bytes # but not Unicode URLs. (IRI vs. URI or something.) path = path.encode('utf8') response = client.get(path, base_url=base_url) if response.status_code == 200: return dict( string=response.data, mime_type=response.mimetype, encoding=response.charset, redirected_url=url) # The test client can follow redirects, but do it ourselves # to get access to the redirected URL. elif response.status_code in (301, 302, 303, 305, 307): redirect_chain.add(url) url = response.location if url in redirect_chain: raise ClientRedirectError('loop detected') else: raise ValueError('Flask-WeasyPrint got HTTP status %s for %s%s' % (response.status, base_url, path)) return flask_url_fetcher
def make_url_fetcher(dispatcher=None, next_fetcher=weasyprint.default_url_fetcher)
Return an function suitable as a ``url_fetcher`` in WeasyPrint. You generally don’t need to call this directly. If ``dispatcher`` is not provided, :func:`make_flask_url_dispatcher` is called to get one. This requires a request context. Otherwise, it must be a callable that take an URL and return either ``None`` or a ``(wsgi_callable, base_url, path)`` tuple. For None ``next_fetcher`` is used. (By default, fetch normally over the network.) For a tuple the request is made at the WSGI level. ``wsgi_callable`` must be a Flask application or another WSGI callable. ``base_url`` is the root URL for the application while ``path`` is the path within the application. Typically ``base_url + path`` is equal or equivalent to the passed URL.
4.385655
3.928499
1.116369
if not hasattr(html, 'write_pdf'): html = HTML(html) pdf = html.write_pdf(stylesheets=stylesheets) response = current_app.response_class(pdf, mimetype='application/pdf') if download_filename: if automatic_download: value = 'attachment' else: value = 'inline' response.headers.add('Content-Disposition', value, filename=download_filename) return response
def render_pdf(html, stylesheets=None, download_filename=None, automatic_download=True)
Render a PDF to a response with the correct ``Content-Type`` header. :param html: Either a :class:`weasyprint.HTML` object or an URL to be passed to :func:`flask_weasyprint.HTML`. The latter case requires a request context. :param stylesheets: A list of user stylesheets, passed to :meth:`~weasyprint.HTML.write_pdf` :param download_filename: If provided, the ``Content-Disposition`` header is set so that most web browser will show the "Save as…" dialog with the value as the default filename. :param automatic_download: If True, the browser will automatic download file. :returns: a :class:`flask.Response` object.
2.616008
2.326335
1.124519
d = SIG_RE.match(sig) if not d: raise ValueError('Invalid method signature %s' % sig) d = d.groupdict() ret = [(n, Any) for n in arg_names] if 'args_sig' in d and type( d['args_sig']) is str and d['args_sig'].strip(): for i, arg in enumerate(d['args_sig'].strip().split(',')): _type_checking_available(sig, validate) if '=' in arg: if not type(ret) is OrderedDict: ret = OrderedDict(ret) dk = KWARG_RE.match(arg) if not dk: raise ValueError('Could not parse arg type %s in %s' % (arg, sig)) dk = dk.groupdict() if not sum( [(k in dk and type(dk[k]) is str and bool(dk[k].strip())) for k in ('arg_name', 'arg_type')]): raise ValueError('Invalid kwarg value %s in %s' % (arg, sig)) ret[dk['arg_name']] = _eval_arg_type(dk['arg_type'], None, arg, sig) else: if type(ret) is OrderedDict: raise ValueError('Positional arguments must occur ' 'before keyword arguments in %s' % sig) if len(ret) < i + 1: ret.append((str(i), _eval_arg_type(arg, None, arg, sig))) else: ret[i] = (ret[i][0], _eval_arg_type(arg, None, arg, sig)) if not type(ret) is OrderedDict: ret = OrderedDict(ret) return (d['method_name'], ret, (_eval_arg_type(d['return_sig'], Any, 'return', sig) if d['return_sig'] else Any))
def _parse_sig(sig, arg_names, validate=False)
Parses signatures into a ``OrderedDict`` of paramName => type. Numerically-indexed arguments that do not correspond to an argument name in python (ie: it takes a variable number of arguments) will be keyed as the stringified version of it's index. sig the signature to be parsed arg_names a list of argument names extracted from python source Returns a tuple of (method name, types dict, return type)
2.913667
2.860336
1.018645
if '(' in sig: parts = sig.split('(') sig = '%s(%s%s%s' % ( parts[0], ', '.join(types), (', ' if parts[1].index(')') > 0 else ''), parts[1]) else: sig = '%s(%s)' % (sig, ', '.join(types)) return sig
def _inject_args(sig, types)
A function to inject arguments manually into a method signature before it's been parsed. If using keyword arguments use 'kw=type' instead in the types array. sig the string signature types a list of types to be inserted Returns the altered signature.
2.640775
2.824263
0.935031
data = dumps({ 'jsonrpc': self.version, 'method': self.service_name, 'params': params, 'id': str(uuid.uuid1()) }).encode('utf-8') headers = { 'Content-Type': 'application/json-rpc', 'Accept': 'application/json-rpc', 'Content-Length': len(data) } try: req = urllib_request.Request(self.service_url, data, headers) resp = urllib_request.urlopen(req) except IOError as e: if isinstance(e, urllib_error.HTTPError): if e.code not in ( 401, 403 ) and e.headers['Content-Type'] == 'application/json-rpc': return e.read().decode('utf-8') # we got a jsonrpc-formatted respnose raise ServiceProxyException(e.code, e.headers, req) else: raise e return resp.read().decode('utf-8')
def send_payload(self, params)
Performs the actual sending action and returns the result
2.59323
2.581329
1.004611
error = { 'name': smart_text(self.__class__.__name__), 'code': self.code, 'message': "%s: %s" % (smart_text(self.__class__.__name__), smart_text(self.message)), 'data': self.data } from django.conf import settings if settings.DEBUG: import sys, traceback error['stack'] = traceback.format_exc() error['executable'] = sys.executable return error
def json_rpc_format(self)
return the Exception data in a format for JSON-RPC
3.210183
2.8374
1.131382
if isinstance(query, dict): query = str(query).replace("'", '"') return self.__call_api_get('directory', query=query, kwargs=kwargs)
def directory(self, query, **kwargs)
Search by users or channels on all server.
5.280697
5.167825
1.021841
return self.__call_api_get('spotlight', query=query, kwargs=kwargs)
def spotlight(self, query, **kwargs)
Searches for users or rooms that are visible to the user.
6.82644
5.832478
1.170419
return self.__call_api_post('users.setPreferences', userId=user_id, data=data, kwargs=kwargs)
def users_set_preferences(self, user_id, data, **kwargs)
Set user’s preferences.
5.058423
5.126865
0.98665
if user_id: return self.__call_api_get('users.info', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_get('users.info', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
def users_info(self, user_id=None, username=None, **kwargs)
Gets a user’s information, limited to the caller’s permissions.
3.013287
2.793692
1.078604
if user_id: return self.__call_api_get('users.getPresence', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_get('users.getPresence', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
def users_get_presence(self, user_id=None, username=None, **kwargs)
Gets the online presence of the a user.
2.674192
2.578561
1.037087
return self.__call_api_post('users.create', email=email, name=name, password=password, username=username, kwargs=kwargs)
def users_create(self, email, name, password, username, **kwargs)
Creates a user
3.970587
4.174914
0.951059
return self.__call_api_post('users.register', email=email, name=name, password=password, username=username, kwargs=kwargs)
def users_register(self, email, name, password, username, **kwargs)
Register a new user.
4.031107
3.855078
1.045662
if user_id: return self.__call_api_get('users.getAvatar', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_get('users.getAvatar', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
def users_get_avatar(self, user_id=None, username=None, **kwargs)
Gets the URL for a user’s avatar.
2.763134
2.619885
1.054678
if avatar_url.startswith('http://') or avatar_url.startswith('https://'): return self.__call_api_post('users.setAvatar', avatarUrl=avatar_url, kwargs=kwargs) else: avatar_file = {"image": open(avatar_url, "rb")} return self.__call_api_post('users.setAvatar', files=avatar_file, kwargs=kwargs)
def users_set_avatar(self, avatar_url, **kwargs)
Set a user’s avatar
2.483395
2.495208
0.995266
if user_id: return self.__call_api_post('users.resetAvatar', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_post('users.resetAvatar', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
def users_reset_avatar(self, user_id=None, username=None, **kwargs)
Reset a user’s avatar
2.841751
2.774863
1.024105
if user_id: return self.__call_api_post('users.createToken', userId=user_id, kwargs=kwargs) elif username: return self.__call_api_post('users.createToken', username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
def users_create_token(self, user_id=None, username=None, **kwargs)
Create a user authentication token.
3.112601
2.921489
1.065416
return self.__call_api_post('users.update', userId=user_id, data=kwargs)
def users_update(self, user_id, **kwargs)
Update an existing user.
7.079895
7.00955
1.010036
return self.__call_api_post('users.forgotPassword', email=email, data=kwargs)
def users_forgot_password(self, email, **kwargs)
Send email to reset your password.
6.565738
6.740716
0.974042
if room_id: return self.__call_api_post('chat.postMessage', roomId=room_id, text=text, kwargs=kwargs) elif channel: return self.__call_api_post('chat.postMessage', channel=channel, text=text, kwargs=kwargs) else: raise RocketMissingParamException('roomId or channel required')
def chat_post_message(self, text, room_id=None, channel=None, **kwargs)
Posts a new chat message.
2.432347
2.396661
1.01489
return self.__call_api_post('chat.delete', roomId=room_id, msgId=msg_id, kwargs=kwargs)
def chat_delete(self, room_id, msg_id, **kwargs)
Deletes a chat message.
3.835103
3.987698
0.961733
return self.__call_api_post('chat.update', roomId=room_id, msgId=msg_id, text=text, kwargs=kwargs)
def chat_update(self, room_id, msg_id, text, **kwargs)
Updates the text of the chat message.
3.417549
3.390477
1.007985
return self.__call_api_post('chat.react', messageId=msg_id, emoji=emoji, kwargs=kwargs)
def chat_react(self, msg_id, emoji='smile', **kwargs)
Updates the text of the chat message.
5.790012
5.575945
1.038391
return self.__call_api_get('chat.search', roomId=room_id, searchText=search_text, kwargs=kwargs)
def chat_search(self, room_id, search_text, **kwargs)
Search for messages in a channel by id and text message.
4.067597
3.940053
1.032371
return self.__call_api_get('chat.getMessageReadReceipts', messageId=message_id, kwargs=kwargs)
def chat_get_message_read_receipts(self, message_id, **kwargs)
Get Message Read Receipts
6.164961
5.974567
1.031867
if room_id: return self.__call_api_get('channels.info', roomId=room_id, kwargs=kwargs) elif channel: return self.__call_api_get('channels.info', roomName=channel, kwargs=kwargs) else: raise RocketMissingParamException('roomId or channel required')
def channels_info(self, room_id=None, channel=None, **kwargs)
Gets a channel’s information.
2.787444
2.647937
1.052685
return self.__call_api_get('channels.history', roomId=room_id, kwargs=kwargs)
def channels_history(self, room_id, **kwargs)
Retrieves the messages from a channel.
5.804613
5.44633
1.065784
return self.__call_api_post('channels.addAll', roomId=room_id, kwargs=kwargs)
def channels_add_all(self, room_id, **kwargs)
Adds all of the users of the Rocket.Chat server to the channel.
6.501237
5.165029
1.258703
return self.__call_api_post('channels.addModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
def channels_add_moderator(self, room_id, user_id, **kwargs)
Gives the role of moderator for a user in the current channel.
3.616
3.233603
1.118257
return self.__call_api_post('channels.removeModerator', roomId=room_id, userId=user_id, kwargs=kwargs)
def channels_remove_moderator(self, room_id, user_id, **kwargs)
Removes the role of moderator from a user in the current channel.
3.623726
3.301107
1.097731
if user_id: return self.__call_api_post('channels.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs) elif username: return self.__call_api_post('channels.addOwner', roomId=room_id, username=username, kwargs=kwargs) else: raise RocketMissingParamException('userID or username required')
def channels_add_owner(self, room_id, user_id=None, username=None, **kwargs)
Gives the role of owner for a user in the current channel.
2.290188
2.12011
1.080221
return self.__call_api_post('channels.removeOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
def channels_remove_owner(self, room_id, user_id, **kwargs)
Removes the role of owner from a user in the current channel.
3.885767
3.397933
1.143568
return self.__call_api_post('channels.archive', roomId=room_id, kwargs=kwargs)
def channels_archive(self, room_id, **kwargs)
Archives a channel.
5.812701
5.354295
1.085615
return self.__call_api_post('channels.unarchive', roomId=room_id, kwargs=kwargs)
def channels_unarchive(self, room_id, **kwargs)
Unarchives a channel.
5.289406
5.284271
1.000972
return self.__call_api_post('channels.close', roomId=room_id, kwargs=kwargs)
def channels_close(self, room_id, **kwargs)
Removes the channel from the user’s list of channels.
5.714673
5.358068
1.066555
return self.__call_api_post('channels.open', roomId=room_id, kwargs=kwargs)
def channels_open(self, room_id, **kwargs)
Adds the channel back to the user’s list of channels.
5.722006
5.215789
1.097055
return self.__call_api_post('channels.create', name=name, kwargs=kwargs)
def channels_create(self, name, **kwargs)
Creates a new public channel, optionally including users.
5.903851
5.12885
1.151106
return self.__call_api_get('channels.getIntegrations', roomId=room_id, kwargs=kwargs)
def channels_get_integrations(self, room_id, **kwargs)
Retrieves the integrations which the channel has
5.293927
5.595787
0.946056
return self.__call_api_post('channels.invite', roomId=room_id, userId=user_id, kwargs=kwargs)
def channels_invite(self, room_id, user_id, **kwargs)
Adds a user to the channel.
4.138257
3.933092
1.052164
return self.__call_api_post('channels.kick', roomId=room_id, userId=user_id, kwargs=kwargs)
def channels_kick(self, room_id, user_id, **kwargs)
Removes a user from the channel.
4.122736
3.92229
1.051104
return self.__call_api_post('channels.leave', roomId=room_id, kwargs=kwargs)
def channels_leave(self, room_id, **kwargs)
Causes the callee to be removed from the channel.
5.592596
4.840305
1.155422
return self.__call_api_post('channels.rename', roomId=room_id, name=name, kwargs=kwargs)
def channels_rename(self, room_id, name, **kwargs)
Changes the name of the channel.
4.701494
4.71413
0.99732
return self.__call_api_post('channels.setDescription', roomId=room_id, description=description, kwargs=kwargs)
def channels_set_description(self, room_id, description, **kwargs)
Sets the description for the channel.
4.594405
4.611057
0.996389
return self.__call_api_post('channels.setJoinCode', roomId=room_id, joinCode=join_code, kwargs=kwargs)
def channels_set_join_code(self, room_id, join_code, **kwargs)
Sets the code required to join the channel.
3.522203
3.358308
1.048803
return self.__call_api_post('channels.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
def channels_set_topic(self, room_id, topic, **kwargs)
Sets the topic for the channel.
4.139113
4.16807
0.993053
return self.__call_api_post('channels.setType', roomId=room_id, type=a_type, kwargs=kwargs)
def channels_set_type(self, room_id, a_type, **kwargs)
Sets the type of room this channel should be. The type of room this channel should be, either c or p.
4.31431
4.411331
0.978006
return self.__call_api_post('channels.setAnnouncement', roomId=room_id, announcement=announce, kwargs=kwargs)
def channels_set_announcement(self, room_id, announce, **kwargs)
Sets the announcement for the channel.
4.026601
4.015851
1.002677
return self.__call_api_post('channels.setCustomFields', roomId=rid, customFields=custom_fields)
def channels_set_custom_fields(self, rid, custom_fields)
Sets the custom fields for the channel.
4.938858
5.029584
0.981961