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 obje...
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 o...
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):...
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 ver...
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 ...
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]...
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):...
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 test...
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 ------- ...
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 ...
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]...
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 ...
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), ...
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 f...
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('...
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 t...
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] - p...
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_poi...
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 ...
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(...
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...
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 ...
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': ...
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,...
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 ...
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 ...
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, no...
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 ...
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...
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 ...
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(el...
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]): ...
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 q...
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 w...
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: ...
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 ----...
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.g...
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(elemen...
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: ...
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],...
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...
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 - ...
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 con...
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)) ...
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...
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...
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 ...
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(T...
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 ------- ...
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_...
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 ...
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: ...
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 contai...
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, s...
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] ...
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.ma...
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 ...
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...
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 contai...
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))...
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. Re...
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') ...
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`` ...
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 = ...
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 aut...
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`` ...
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 : ...
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 `...
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 ...
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 ...
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 ...
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 {'+...
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 = pa...
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...
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 ...
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 eith...
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 = '...
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 ...
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().spl...
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_name...
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',...
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...
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 req...
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 require...
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', ...
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 r...
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 r...
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('roo...
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 RocketMissingPara...
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