common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
2636
Train/png/2636.png
def update(self): node = self._fritz.get_device_element(self.ain) self._update_from_node(node)
8171
Train/png/8171.png
def post_object_async(self, path, **kwds): return self.do_request_async(self.api_url + path, 'POST', **kwds)
5286
Train/png/5286.png
def get_list_from_file(file_name): with open(file_name, mode='r', encoding='utf-8') as f1: lst = f1.readlines() return lst
5467
Train/png/5467.png
def score(self, X, y, **kwargs): return self.estimator.score(X, y, **kwargs)
430
Train/png/430.png
def url_read_text(url, verbose=True): r data = url_read(url, verbose) text = data.decode('utf8') return text
652
Train/png/652.png
def time_ago(dt): now = datetime.datetime.now() return humanize.naturaltime(now - dt)
49
Train/png/49.png
def _extract_email(gh): return next( (x.email for x in gh.emails() if x.verified and x.primary), None)
357
Train/png/357.png
def to_eng(num_in): x = decimal.Decimal(str(num_in)) eng_not = x.normalize().to_eng_string() return (eng_not)
6701
Train/png/6701.png
def show_replace(self): self.show(hide_replace=False) for widget in self.replace_widgets: widget.show()
6819
Train/png/6819.png
def _get_device_grain(name, proxy=None): device = _retrieve_device_cache(proxy=proxy) return device.get(name.upper())
9643
Train/png/9643.png
def is_square_matrix(mat): mat = np.array(mat) if mat.ndim != 2: return False shape = mat.shape return shape[0] == shape[1]
9084
Train/png/9084.png
def getCenter(self): return Location(self.x+(self.w/2), self.y+(self.h/2))
9506
Train/png/9506.png
def geigh(H, S): "Solve the generalized eigensystem Hc = ESc" A = cholorth(S) E, U = np.linalg.eigh(simx(H, A)) return E, np.dot(A, U)
9707
Train/png/9707.png
def open(self): self.stats = self.linter.add_stats() self._returns = [] self._branches = defaultdict(int) self._stmts = []
709
Train/png/709.png
def get_by(self, name): return next((item for item in self if item.name == name), None)
6638
Train/png/6638.png
def ToDatetime(self): return datetime.utcfromtimestamp( self.seconds + self.nanos / float(_NANOS_PER_SECOND))
7846
Train/png/7846.png
def _get_all_scanner_ids(zap_helper): scanners = zap_helper.zap.ascan.scanners() return [s['id'] for s in scanners]
4735
Train/png/4735.png
def shell_call(self, shellcmd): return (subprocess.call(self.shellsetup + shellcmd, shell=True))
5633
Train/png/5633.png
def poll(): coordinator.master_thread.start() for i in coordinator.slave_threads: coordinator.slave_threads[i].start()
5652
Train/png/5652.png
def _leading_space_count(line): i = 0 while i < len(line) and line[i] == ' ': i += 1 return i
7110
Train/png/7110.png
def execute_javascript(self, *args, **kwargs): ret = self.__exec_js(*args, **kwargs) return ret
1782
Train/png/1782.png
def load(self, project: typing.Union[projects.Project, None]): self._project = project
8426
Train/png/8426.png
def command(self, command, raw=False, timeout_ms=None): return ''.join(self.streaming_command(command, raw, timeout_ms))
281
Train/png/281.png
def _merge_maps(m1, m2): return type(m1)(chain(m1.items(), m2.items()))
7583
Train/png/7583.png
def pop(self, key): if key in self._keys: self._keys.remove(key) super(ListDict, self).pop(key)
2654
Train/png/2654.png
def hessian(x, a): j = jac(x, a) return j.T.dot(j)
5117
Train/png/5117.png
def spread(self, m: Union[int, pd.Series]) -> Union[int, pd.Series]: return (m * 111_111) % self.TEN_DIGIT_MODULUS
4392
Train/png/4392.png
def handle_m2m_user(self, sender, instance, **kwargs): self.handle_save(instance.user.__class__, instance.user)
3083
Train/png/3083.png
def Eg(self, **kwargs): return self.unstrained.Eg(**kwargs) + self.Eg_strain_shift(**kwargs)
8937
Train/png/8937.png
def get_species(species_id): result = _get(species_id, settings.SPECIES) return Species(result.content)
6721
Train/png/6721.png
def parent_directory(self): self.chdir(os.path.join(getcwd_or_home(), os.path.pardir))
6816
Train/png/6816.png
def ret_list_minions(self): tgt = _tgt_set(self.tgt) return self._ret_minions(tgt.intersection)
8047
Train/png/8047.png
def expand(self, msgpos): MT = self._tree[msgpos] MT.expand(MT.root)
4319
Train/png/4319.png
def by_name(queryset, name=None): if name: queryset = queryset.filter(name=name) return queryset
9657
Train/png/9657.png
def c_if(self, classical, val): self.data = [gate.c_if(classical, val) for gate in self.data] return self
6515
Train/png/6515.png
def get_lr(lr, epoch, steps, factor): for s in steps: if epoch >= s: lr *= factor return lr
3425
Train/png/3425.png
def bind_to_instance(self, instance): self.binding = instance self.middleware.append(instance)
7918
Train/png/7918.png
def show(self): IPython.display.display(IPython.display.HTML(self.as_html()))
2852
Train/png/2852.png
def load_object_by_name(object_name): mod_name, attr = object_name.rsplit('.', 1) mod = import_module(mod_name) return getattr(mod, attr)
8611
Train/png/8611.png
def _fast_read(self, infile): infile.seek(0) return (int(infile.read().decode().strip()))
1656
Train/png/1656.png
def open(self, mode='rb'): fs, path = self._get_fs() return fs.open(path, mode=mode)
8317
Train/png/8317.png
def image_to_texture(image): vtex = vtk.vtkTexture() vtex.SetInputDataObject(image) vtex.Update() return vtex
918
Train/png/918.png
def net_send(out_data, conn): print('Sending {} bytes'.format(len(out_data))) conn.send(out_data)
7297
Train/png/7297.png
def crop_box(im, box=False, **kwargs): if box: im = im.crop(box) return im
6176
Train/png/6176.png
def set_val(self, direct, section, val): if val is not None: self.config.set(direct, section, val) self.update()
200
Train/png/200.png
def update_features(self, poly): for feature in self.features: feature.wavelength = poly(feature.xpos)
9762
Train/png/9762.png
def get_connection(db=DATABASE): return database.connect(host=HOST, port=PORT, user=USER, password=PASSWORD, database=db)
7242
Train/png/7242.png
def turn_right(self): self.at(ardrone.at.pcmd, True, 0, 0, 0, self.speed)
5902
Train/png/5902.png
def log_interp(x, xp, *args, **kwargs): return log_interpolate_1d(x, xp, *args, **kwargs)
1899
Train/png/1899.png
def is_dn(s): if s == '': return True rm = DN_REGEX.match(s) return rm is not None and rm.group(0) == s
5668
Train/png/5668.png
def _get_params(self): return np.hstack((self.varianceU, self.varianceY, self.lengthscaleU, self.lengthscaleY))
2251
Train/png/2251.png
def error(self, message, code=1): sys.stderr.write(message) sys.exit(code)
2408
Train/png/2408.png
def set_string(self, string): self.string = string self.length = len(string) self.reset_position()
1051
Train/png/1051.png
def configure_alias(graph, ns, mappings): convention = AliasConvention(graph) convention.configure(ns, mappings)
7905
Train/png/7905.png
def is_iterable_of_int(l): r if not is_iterable(l): return False return all(is_int(value) for value in l)
3101
Train/png/3101.png
def shift(self, x): return tuple.__new__(self.__class__, (self[0] + x, self[1] + x))
1330
Train/png/1330.png
def unpickle_stats(stats): stats = cPickle.loads(stats) stats.stream = True return stats
1681
Train/png/1681.png
def gifsicle(ext_args): args = _GIFSICLE_ARGS + [ext_args.new_filename] extern.run_ext(args) return _GIF_FORMAT
5059
Train/png/5059.png
def kvp_dict(d): return ', '.join( ["{}={}".format(k, quotable(v)) for k, v in d.items()])
8445
Train/png/8445.png
def format(self, version=0x10, wipe=None): return super(FelicaLite, self).format(version, wipe)
232
Train/png/232.png
def download(self): p = Pool() p.map(self._download, self.days)
4920
Train/png/4920.png
def plot3d_init(fignum): from mpl_toolkits.mplot3d import Axes3D fig = plt.figure(fignum) ax = fig.add_subplot(111, projection='3d') return ax
6289
Train/png/6289.png
def is_iso8601(instance: str): if not isinstance(instance, str): return True return ISO8601.match(instance) is not None
3781
Train/png/3781.png
def setdefault(obj: JsonObj, k: str, value: Union[Dict, JsonTypes]) -> JsonObjTypes: return obj._setdefault(k, value)
1463
Train/png/1463.png
def check_status_logfile(self, checker_func): self.status = checker_func(self.logfile) return self.status
224
Train/png/224.png
def _write(self, session, openFile, replaceParamFile): # Write lines openFile.write(text(self.projection))
7477
Train/png/7477.png
def to_datetime(date): return datetime.datetime.combine(date, datetime.datetime.min.time())
1073
Train/png/1073.png
def content_type(self, data): self._content_type = str(data) self.add_header('Content-Type', str(data))
8816
Train/png/8816.png
def visit_Name(self, node): if isinstance(node.ctx, ast.Store): self.result[node.id] = True
8335
Train/png/8335.png
def choplist(n, seq): r = [] for x in seq: r.append(x) if len(r) == n: yield tuple(r) r = [] return
1287
Train/png/1287.png
def serve(self, filename): if not self.exists(filename): abort(404) return self.backend.serve(filename)
3318
Train/png/3318.png
def show(config): with open(config, 'r'): main.show(yaml.load(open(config)))
7445
Train/png/7445.png
def search_name(self, name, dom=None): if dom is None: dom = self.browser return expect(dom.find_by_name, args=[name])
7912
Train/png/7912.png
def plot(self): plt.plot(self.bin_edges, self.hist, self.bin_edges, self.best_pdf)
7666
Train/png/7666.png
def close(self): if not self.closed: check(_coreaudio.ExtAudioFileDispose(self._obj)) self.closed = True
8250
Train/png/8250.png
def filtered(self, step_names): return Graph(steps=self.steps, dag=self.dag.filter(step_names))
3818
Train/png/3818.png
def read_until(data: bytes, *, return_tail: bool = True, from_=None) -> bytes: return (yield (Traps._read_until, data, return_tail, from_))
8681
Train/png/8681.png
def load_input(): file = open(_input_file, 'r') result = json.loads(file.read().strip('\0').strip()) file.close() return result
2552
Train/png/2552.png
def get_custom_fields(self): return CustomField.objects.filter( content_type=ContentType.objects.get_for_model(self))
4989
Train/png/4989.png
def _ipython_display_(self): from IPython.display import display self.build_widget() display(self.widget())
9020
Train/png/9020.png
def get_info(cls): return '\n'.join( [str(cls._instances[key]) for key in cls._instances] )
3008
Train/png/3008.png
def compose(self, name, *args): return self._compose(name, args, mkdir=False)
3509
Train/png/3509.png
def _updated_cb(self, downtotal, downdone, uptotal, updone): self.emit('updated', downtotal, downdone, uptotal, updone)
1540
Train/png/1540.png
def set_items(self, items): self.adapter.clear() self.adapter.addAll(items)
7296
Train/png/7296.png
def strip_tail(sequence, values): return list(reversed(list(strip_head(reversed(sequence), values))))
570
Train/png/570.png
def response(self, url): resp = requests.get(url).content return self.parseresponse(resp)
7229
Train/png/7229.png
def find(self, resource_id, query=None): return self.proxy.find(resource_id, query=query)
1849
Train/png/1849.png
def _writen(fd, data): while data: n = os.write(fd, data) data = data[n:]
8285
Train/png/8285.png
def bech32_hrp_expand(hrp): return [ord(x) >> 5 for x in hrp] + [0] + [ord(x) & 31 for x in hrp]
5090
Train/png/5090.png
def set_latency(self, latency): self._client['config']['latency'] = latency yield from self._server.client_latency(self.identifier, latency)
8575
Train/png/8575.png
def populate_values(self): obj = self._get_base_state() self.base_state = json.dumps(obj)
497
Train/png/497.png
def by_id(self, id): path = partial(_path, self.adapter) path = path(id) return self._get(path)
6245
Train/png/6245.png
def get_frames(self): frames = super(CalibratedPair, self).get_frames() return self.calibration.rectify(frames)
8138
Train/png/8138.png
def select_observations(self, name): return [n for n in self.get_obs_nodes() if n.obsname == name]
5884
Train/png/5884.png
def smembers(self, key, *, encoding=_NOTSET): return self.execute(b'SMEMBERS', key, encoding=encoding)
5582
Train/png/5582.png
def results(self): return dict(e0=self.e0, b0=self.b0, b1=self.b1, v0=self.v0)
8338
Train/png/8338.png
def _remap_dirname(local, remote): def do(x): return x.replace(local, remote, 1) return do
7180
Train/png/7180.png
def save_feature(self, cat, img, feature, data): filename = self.path(cat, img, feature) mkdir(filename) savemat(filename, {'output': data})
9389
Train/png/9389.png
def get_stress(self, a): s = np.zeros(6, dtype=float) for c in self.calcs: s += c.get_stress(a) return s
6210
Train/png/6210.png
def scaleX(self, x): 'returns plotter x coordinate' return round(self.plotviewBox.xmin+(x-self.visibleBox.xmin)*self.xScaler)