common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
877
Train/png/877.png
def build(self, **kw): global MkdirBuilder if self.builder is not MkdirBuilder: SCons.Node.Node.build(self, **kw)
9058
Train/png/9058.png
def _is_suffix(self, t): return t not in NOT_SUFFIX and (t.replace('.', '') in SUFFIXES or t.replace('.', '') in SUFFIXES_LOWER)
5173
Train/png/5173.png
def get_all_names(chebi_ids): all_names = [get_names(chebi_id) for chebi_id in chebi_ids] return [x for sublist in all_names for x in sublist]
1328
Train/png/1328.png
def get_applicable_values(self): return [v for v in self._values if v.is_active and not v.is_all_results]
5405
Train/png/5405.png
def _replace_nan(a, val): mask = isnull(a) return where_method(val, mask, a), mask
6069
Train/png/6069.png
def shutdown(self): self.stop = True if self.stats: self.stats.shutDownStats() self.join()
8688
Train/png/8688.png
def angle(self, v): return acos((self * v) / (self.length() * v.length()))
9946
Train/png/9946.png
def unregister_widget(self, widget_cls): if widget_cls.__name__ in self.widgets: del self.widgets[widget_cls().get_name()]
1446
Train/png/1446.png
def subscription(self): return self.client.customer_subscriptions.with_parent_id(self.customer_id).get(self.subscription_id)
847
Train/png/847.png
def readFILTER(self): filterId = self.readUI8() filter = SWFFilterFactory.create(filterId) filter.parse(self) return filter
8255
Train/png/8255.png
def load(self): self._list = self._source.load() self._list_iter = itertools.cycle(self._list)
7941
Train/png/7941.png
def complete_db(self, text, line, begidx, endidx): return [i for i in PsiturkNetworkShell.db_commands if i.startswith(text)]
9505
Train/png/9505.png
def dmat(c, nocc): "Form the density matrix from the first nocc orbitals of c" return np.dot(c[:, :nocc], c[:, :nocc].T)
616
Train/png/616.png
def clear(self) -> None: self.click() for i in self.text: self._parent.send_keyevents(Keys.DEL)
8939
Train/png/8939.png
def resize(self, height, width, **kwargs): self.client.resize(self.container, height=height, width=width)
5116
Train/png/5116.png
def clip_to_seconds(m: Union[int, pd.Series]) -> Union[int, pd.Series]: return m // pd.Timedelta(1, unit='s').value
6118
Train/png/6118.png
def accept(self, visitor): func = getattr(visitor, "visit_" + self.__class__.__name__.lower()) return func(self)
736
Train/png/736.png
def to_esc(self): chunks = chunked(self.stream, 2) return ''.join(r'\x' + ''.join(pair) for pair in chunks)
4810
Train/png/4810.png
def dimensions(self): return ImageDimensions(self._info.file.width, self._info.file.height)
3953
Train/png/3953.png
def warn(self, message, *args, **kwargs): self._log(logging.WARNING, message, *args, **kwargs)
7440
Train/png/7440.png
def redraw(self): if self._multiscat is not None: self._multiscat._update() self.vispy_widget.canvas.update()
8742
Train/png/8742.png
def paint(self, iconic, painter, rect, mode, state, options): for opt in options: self._paint_icon(iconic, painter, rect, mode, state, opt)
351
Train/png/351.png
def chunks(l, n): # http://stackoverflow.com/a/3226719 # ...not that this is hard to understand. return [l[x:x+n] for x in range(0, len(l), n)]
8535
Train/png/8535.png
def queuedb_row_factory(cursor, row): d = {} for idx, col in enumerate(cursor.description): d[col[0]] = row[idx] return d
4321
Train/png/4321.png
def update(self): self._json = self._request( method='GET', url=self.API )._json
5795
Train/png/5795.png
def revert(self, strip=0, root=None): reverted = copy.deepcopy(self) reverted._reverse() return reverted.apply(strip, root)
8863
Train/png/8863.png
def scan(self, ids=range(254)): return [id for id in ids if self.ping(id)]
6980
Train/png/6980.png
def deserialize(self, apic_frame): return Image(data=apic_frame.data, desc=apic_frame.desc, type=apic_frame.type)
6130
Train/png/6130.png
def get_activations(self): res = (self.added, self.removed) self.added = set() self.removed = set() return res
9994
Train/png/9994.png
def x_plus(self, dx=None): if dx is None: self.x += self.dx else: self.x = self.x + dx
3093
Train/png/3093.png
def _rel_path(self, path, basepath=None): basepath = basepath or self.src_dir return path[len(basepath) + 1:]
7952
Train/png/7952.png
def metric_parts(metric): operator, met = resolve_metric_as_tuple(metric) return operator.name, met.name
4462
Train/png/4462.png
def copy(self): c = matrix() c.tt = self.tt.copy() c.n = self.n.copy() c.m = self.m.copy() return c
4576
Train/png/4576.png
def hr_avg(self): hr_data = self.hr_values() return int(sum(hr_data) / len(hr_data))
1367
Train/png/1367.png
def prox_soft(X, step, thresh=0): thresh_ = _step_gamma(step, thresh) return np.sign(X)*prox_plus(np.abs(X) - thresh_, step)
2063
Train/png/2063.png
def is_(self, state): translator = self._meta['translator'] state = translator.translate(state) return self.actual_state == state
9561
Train/png/9561.png
def fopenat_rw(base_fd, path): return os.fdopen(openat(base_fd, path, os.O_RDWR), 'rb+')
4560
Train/png/4560.png
def SegmentSum(a, ids, *args): def func(idxs): return reduce(np.add, a[idxs]) return seg_map(func, a, ids),
6001
Train/png/6001.png
def radiance_to_bt(arr, wc_, a__, b__): return a__ + b__ * (C2 * wc_ / (da.log(1 + (C1 * (wc_ ** 3) / arr))))
1630
Train/png/1630.png
def bytes_to_str(self, b): "convert bytes array to raw string" if PYTHON_MAJOR_VER == 3: return b.decode(charset_map.get(self.charset, self.charset)) return b
4669
Train/png/4669.png
def parentItem(self, value): self._parentItem = value self._recursiveSetNodePath(self._constructNodePath())
6044
Train/png/6044.png
def all_dependencies(self, target): for dep in target.closure(bfs=True, **self.target_closure_kwargs): yield dep
2191
Train/png/2191.png
def apis(self): value = self.attributes['apis'] if isinstance(value, six.string_types): value = shlex.split(value) return value
2418
Train/png/2418.png
def depth(self): return len(self.path.rstrip(os.sep).split(os.sep))
5466
Train/png/5466.png
def count_rows_with_nans(X): if X.ndim == 2: return np.where(np.isnan(X).sum(axis=1) != 0, 1, 0).sum()
6099
Train/png/6099.png
def setto(self, s): length = len(s) self.b[self.j+1:self.j+1+length] = s self.k = self.j + length
3911
Train/png/3911.png
def do(self): "run it, you can get a good stitching of the complete URL." return urlunparse((self.scheme, self.netloc, self.path, self.params, self.query, self.fragment))
7290
Train/png/7290.png
def close(self): self.consumer.close() self.publisher.close() self._closed = True
2035
Train/png/2035.png
def _tag(element): tag = element.tag if tag[0] == "{": uri, tag = tag[1:].split("}") return tag
3652
Train/png/3652.png
def __updateDataItem(self): uri = self.getUri() self.__dataItem = self.__parseResponseServer(uri)
4254
Train/png/4254.png
def readXML(self): data = self.readLongString() root = xml.fromstring(data) self.context.addObject(root) return root
7183
Train/png/7183.png
def data(self, value): self.loader.save_image(self.category, self.image, value)
2442
Train/png/2442.png
def visit_Name(self, node: AST, dfltChaining: bool = True) -> str: return node.id
9867
Train/png/9867.png
def parse_package_json(): with open(locate_package_json()) as pjson: data = json.loads(pjson.read()) return data
2443
Train/png/2443.png
def visit_Expr(self, node: AST, dfltChaining: bool = True) -> str: return self.visit(node.value)
4716
Train/png/4716.png
def state(self): ev = self._query_waiters.request(self.__do_query_state) ev.wait(1.0) return self._state
4451
Train/png/4451.png
def format_ffmpeg_filter(name, params): return "%s=%s" % (name, ":".join("%s=%s" % (k, v) for k, v in params.items()))
3956
Train/png/3956.png
def _update_handler(self, handler_class, level): handler = self._get_handler(handler_class) handler.setLevel(level)
1172
Train/png/1172.png
def from_name(cls, name): return Author(name=name, sha512=cls.hash_name(name))
8928
Train/png/8928.png
def _correlate(self): a = self.algorithm(**self.algorithm_params) self.correlation_result = a.run()
5129
Train/png/5129.png
def valid_modes(self): default_mode = (self.mode,) if self.mode is not None else None return getattr(self, '_valid_mode', default_mode)
7588
Train/png/7588.png
def popitem(self): key, value = super(LFUCache, self).popitem() return (key, value[1])
9081
Train/png/9081.png
def _empty_cache(self): self._children, self._parents = None, None self._rchildren, self._rparents = {}, {}
1867
Train/png/1867.png
def do_not_disturb(self, enabled): self._set_setting( { CONST.SETTINGS_DO_NOT_DISTURB: str(enabled).lower() })
5939
Train/png/5939.png
def fetchall(self): result = self.query.result() return [row.values() for row in result]
2805
Train/png/2805.png
def query(transport, query): with CommandLineClient(transport) as client: echo_event(client.query(query))
6244
Train/png/6244.png
def scale_to_control(x, axis_scale=350., min_v=-1.0, max_v=1.0): x = x / axis_scale x = min(max(x, min_v), max_v) return x
9934
Train/png/9934.png
def _set_node_lists(self, new): for edge in self.edges: edge._nodes = self.nodes
7102
Train/png/7102.png
def prepare(self, f): self.g = autograd.grad(f) self.h = autograd.hessian(f)
7927
Train/png/7927.png
def close(self): if self.fd: os.close(self.fd) self.fd = None
2669
Train/png/2669.png
def _read_next_line(self): prev_line = self._line self._line = self.stream.readline() return prev_line
6075
Train/png/6075.png
def parse_cookies(self, req: Request, name: str, field: Field) -> typing.Any: return core.get_value(req.cookies, name, field)
7325
Train/png/7325.png
def pull_stream(image): return (json.loads(s) for s in _get_docker().pull(image, stream=True))
9677
Train/png/9677.png
def start(self): self.status = 'pending' self.thing.action_notify(self) self.perform_action() self.finish()
6403
Train/png/6403.png
def series2cat(df: DataFrame, *col_names): "Categorifies the columns `col_names` in `df`." for c in listify(col_names): df[c] = df[c].astype('category').cat.as_ordered()
8025
Train/png/8025.png
def focus(self, cli, buffer_name): assert isinstance(buffer_name, six.text_type) self.focus_stack = [buffer_name]
1325
Train/png/1325.png
def match(pattern, data, **parse_kwargs): return [m.value for m in parse(pattern, **parse_kwargs).find(data)]
2524
Train/png/2524.png
def _cleanup(path: str) -> None: if os.path.isdir(path): shutil.rmtree(path)
5240
Train/png/5240.png
def name(self): return ffi.string( lib.EnvGetDeftemplateName(self._env, self._tpl)).decode()
3774
Train/png/3774.png
def _query_gen(self): return urlencode(self.__query__, safe=self.safe, querydelimiter=self.__querydelimiter__)
6854
Train/png/6854.png
def function_is_noop(function_node: ast.FunctionDef) -> bool: return all(node_is_noop(n) for n in function_node.body)
9870
Train/png/9870.png
def mkdummy(name, **attrs): return type( name, (), dict(__repr__=(lambda self: "<%s>" % name), **attrs) )()
3136
Train/png/3136.png
def get_many(self, ids): return [self.instance(id, **fields) for id, fields in zip(ids, self.api.mget(ids))]
6104
Train/png/6104.png
def close(self): if self.device is not None and self.device.is_open: self.device.flush() self.device.close()
6205
Train/png/6205.png
def PyobjColumns(obj): 'Return columns for each public attribute on an object.' return [ColumnAttr(k, type(getattr(obj, k))) for k in getPublicAttrs(obj)]
2672
Train/png/2672.png
def copy(self): mapping = OrderedDict(self.mapping.items()) return self.__class__(self.key, self.value, mapping)
5068
Train/png/5068.png
def format_cell(cell, datetime_fmt=None): if datetime_fmt and isinstance(cell, datetime): return cell.strftime(datetime_fmt) return cell
2518
Train/png/2518.png
def save_to_file(cn_topo, filename): jstr = cn_topo.serialize() with open(filename, 'w') as outfile: outfile.write(jstr)
2648
Train/png/2648.png
def kindex(matrix, k): ix = (np.arange(len(matrix)), matrix.argsort(axis=0)[k]) return ix
1179
Train/png/1179.png
def complete_opt_display(self, text, *_): return [t + " " for t in DISPLAYS if t.startswith(text)]
4745
Train/png/4745.png
def setwinsize(self, rows, cols): self._winsize = (rows, cols) self.pty.set_size(cols, rows)
9240
Train/png/9240.png
def on_excepthandler(self, node): # ('type', 'name', 'body') return (self.run(node.type), node.name, node.body)
4404
Train/png/4404.png
def hasannotationlayer(self, annotationtype=None, set=None): l = self.layers(annotationtype, set) return (len(l) > 0)
6768
Train/png/6768.png
def go_up(self): vsb = self.scrollarea.verticalScrollBar() vsb.setValue(int(vsb.value() - vsb.singleStep()))
3450
Train/png/3450.png
def size(self, value): self._size = value self._thumb = self._link_to_img()
4835
Train/png/4835.png
def curse(rest): "Curse the day!" if rest: cursee = rest else: cursee = 'the day' karma.Karma.store.change(cursee, -1) return "/me curses %s!" % cursee
9116
Train/png/9116.png
def _fetch_items(self): if self._items is None: self._items = list(self.engine.items(self)) return self._items
2487
Train/png/2487.png
def gid(self, value): self.bytearray[self._get_slicers(2)] = bytearray(c_int32(value or 0))
7074
Train/png/7074.png
def grow(self): "Add another worker to the pool." t = self.worker_factory(self) t.start() self._size += 1
4751
Train/png/4751.png
def get_prefix(self, el): prefix = self.get_prefix_name(el) return util.lower(prefix) if prefix is not None and not self.is_xml else prefix