common_id
stringlengths
1
5
image
stringlengths
15
19
code
stringlengths
26
239
3378
Train/png/3378.png
def pesach_dow(self): jdn = conv.hdate_to_jdn(HebrewDate(self.hdate.year, Months.Nisan, 15)) return (jdn + 1) % 7 + 1
7439
Train/png/7439.png
def copy(self): return Quaternion(self.w, self.x, self.y, self.z, False)
4377
Train/png/4377.png
def get_child(self, streamId, childId, options={}): return self.get('stream/' + streamId + '/children/' + childId, options)
2252
Train/png/2252.png
def I(self): "'1' if Daylight Savings Time, '0' otherwise." if self.timezone and self.timezone.dst(self.data): return u'1' else: return u'0'
990
Train/png/990.png
def strip_z(pts): pts = np.asarray(pts) if pts.shape[-1] > 2: pts = np.asarray((pts.T[0], pts.T[1])).T return pts
112
Train/png/112.png
def min_order_amount(self) -> Money: return self._fetch('minimum order amount', self.market.code)(self._min_order_amount)()
9825
Train/png/9825.png
def sv_variant(institute_id, case_name, variant_id): data = controllers.sv_variant(store, institute_id, case_name, variant_id) return data
625
Train/png/625.png
def image(self): r = requests.get(self.image_url, stream=True) r.raise_for_status() return r.raw.read()
3219
Train/png/3219.png
def write_id3(self, filename): if not os.path.exists(filename): raise ValueError("File doesn't exists.") self.mapper.write(filename)
19
Train/png/19.png
def read_filepath(filepath, encoding='utf-8'): with codecs.open(filepath, 'r', encoding=encoding) as fo: return fo.read()
9574
Train/png/9574.png
def is_async_call(func): while isinstance(func, partial): func = func.func return inspect.iscoroutinefunction(func)
2051
Train/png/2051.png
def find_users(session, *usernames): user_string = ','.join(usernames) return _make_request(session, FIND_USERS_URL, user_string)
3886
Train/png/3886.png
def get(self, url): self._query() return Enclosure(self._resp.get(url), url)
4790
Train/png/4790.png
def cli(yamlfile, format, output, collections): print(ShExGenerator(yamlfile, format).serialize( output=output, collections=collections))
7249
Train/png/7249.png
def addbr(name): fcntl.ioctl(ifconfig.sockfd, SIOCBRADDBR, name) return Bridge(name)
4206
Train/png/4206.png
def show_firewall(self, firewall, **_params): return self.get(self.firewall_path % (firewall), params=_params)
9435
Train/png/9435.png
def tags(cls, filename, namespace=None): return cls._raster_opener(filename).tags(ns=namespace)
305
Train/png/305.png
def mod(self): return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
3321
Train/png/3321.png
def _set_ip(self): self._ip = socket.gethostbyname(self._fqdn) log.debug('IP: %s' % self._ip)
5434
Train/png/5434.png
def deallocate(self, batch): self._incomplete.remove(batch) self._free.deallocate(batch.buffer())
1795
Train/png/1795.png
def construct(cls, name, *args, **kwargs): return cls.REGISTRY[name](*args, **kwargs)
9676
Train/png/9676.png
def set_value(self, value): self.validate_value(value) self.value.set(value)
6438
Train/png/6438.png
def get_enum_doc(elt, full_name: str) -> str: "Formatted enum documentation." vals = ', '.join(elt.__members__.keys()) return f'{code_esc(full_name)}', f'<code>Enum</code> = [{vals}]'
1098
Train/png/1098.png
def divisors(n): for i in range(1, int(math.sqrt(n) + 1)): if n % i == 0: yield i if i*i != n: yield n / i
8347
Train/png/8347.png
def get_random_theme(dark=True): themes = [theme.path for theme in list_themes(dark)] random.shuffle(themes) return themes[0]
8477
Train/png/8477.png
def getstr_data(self, name, vals): fld2val = self.get_fld2val(name, vals) return self.fmt.format(**fld2val)
2390
Train/png/2390.png
def iregex(value, iregex): return re.match(iregex, value, flags=re.I)
2807
Train/png/2807.png
def delete(self): return self.bucket.delete_key(self.name, version_id=self.version_id)
9280
Train/png/9280.png
def log(cls, message): if cls.verbose > 0: msg = '[INFO] %s' % message cls.echo(msg)
2351
Train/png/2351.png
def BeginOfEventAction(self, event): self.log.info("Simulating event %s", event.GetEventID()) self.sd.setEventNumber(event.GetEventID())
6284
Train/png/6284.png
def _inner(self, x1, x2): return self.tspace._inner(x1.tensor, x2.tensor)
3179
Train/png/3179.png
def html_escape(s, encoding='utf-8', encoding_errors='strict'): return escape(make_unicode(s, encoding, encoding_errors), quote=True)
9832
Train/png/9832.png
def round_to_next(x, base): # Based on: http://stackoverflow.com/a/2272174 return int(base * math.ceil(float(x)/base))
3194
Train/png/3194.png
def do_account_info(self): s, metadata = self.n.getRegisterUserInfo() pprint.PrettyPrinter(indent=2).pprint(metadata)
8199
Train/png/8199.png
def is_same_filename(filename1, filename2): return os.path.realpath(filename1) == os.path.realpath(filename2)
6440
Train/png/6440.png
def mean_absolute_error(pred: Tensor, targ: Tensor) -> Rank0Tensor: "Mean absolute error between `pred` and `targ`." pred, targ = flatten_check(pred, targ) return torch.abs(targ - pred).mean()
1725
Train/png/1725.png
def chunks(data, chunk_size): for i in xrange(0, len(data), chunk_size): yield data[i:i+chunk_size]
6615
Train/png/6615.png
def freeze_bn(self): for layer in self.modules(): if isinstance(layer, nn.BatchNorm2d): layer.eval()
6481
Train/png/6481.png
def strip_ids(ids, ids_to_strip): ids = list(ids) while ids and ids[-1] in ids_to_strip: ids.pop() return ids
5480
Train/png/5480.png
def __permutate(self, table, block): return list(map(lambda x: block[x], table))
1115
Train/png/1115.png
def disconnect(self): self._data = await self._handler.disconnect( system_id=self.node.system_id, id=self.id)
4759
Train/png/4759.png
def ends(self, layer): ends = [] for data in self[layer]: ends.append(data[END]) return ends
319
Train/png/319.png
def col_iter(self): for k in utils.range_(self.side): yield self.col(k)
2074
Train/png/2074.png
def done_tasks(self): tasks = [task for task in self.all_tasks if task._state != NewTask._PENDING] return tasks
1229
Train/png/1229.png
def gen_key(self, *values): key = md5() KeyGen._recursive_convert(values, key) return key.hexdigest()
4072
Train/png/4072.png
def _perform_merge(self, other): if len(other.value) > len(self.value): self.value = other.value[:] return True
4639
Train/png/4639.png
def ListingBox(listing, *args, **kwargs): " Delegate the boxing to the target's Box class. " obj = listing.publishable return obj.box_class(obj, *args, **kwargs)
42
Train/png/42.png
def remove(self, **kwargs): self.helper.remove(self.inner(), **kwargs) self._inner = None
4445
Train/png/4445.png
def get_class_methods(cls): return [ node for node in cls.body if isinstance(node, ast.FunctionDef) ]
1490
Train/png/1490.png
def fix(h, i): down(h, i, h.size()) up(h, i)
4564
Train/png/4564.png
def SegmentMean(a, ids): def func(idxs): return np.mean(a[idxs], axis=0) return seg_map(func, a, ids),
5088
Train/png/5088.png
def callback(self): if self._callback_func and callable(self._callback_func): self._callback_func(self)
4234
Train/png/4234.png
def data_context_name(fn): return os.path.join(os.path.dirname(__file__), "template_data", fn)
7737
Train/png/7737.png
def read_config(): with open(PYDOCMD_CONFIG) as fp: config = yaml.load(fp) return default_config(config)
7551
Train/png/7551.png
def tohexstring(self): val = self.tostring() st = "{0:0x}".format(int(val, 2)) return st.zfill(len(self.bitmap)*2)
8856
Train/png/8856.png
def set_wheel_mode(self, ids): self.set_control_mode(dict(zip(ids, itertools.repeat('wheel'))))
4556
Train/png/4556.png
def Max(a, axis, keep_dims): return np.amax(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis), keepdims=keep_dims),
759
Train/png/759.png
def close(self): if self._subprocess is not None: os.killpg(self._subprocess.pid, signal.SIGTERM) self._subprocess = None
658
Train/png/658.png
def error(self, cmd, desc=''): return self._label_desc(cmd, desc, self.error_color)
8828
Train/png/8828.png
def save(self, filename): with open(filename, 'w') as fp: fp.write(str(self))
8589
Train/png/8589.png
def get_output(self, style=OutputStyle.file): return self.manager.get_output(style=style)
3430
Train/png/3430.png
def set(self, uri, content): key, value = self._prepare_node(uri, content) self._set(key, value)
8050
Train/png/8050.png
def get_selected_tag(self): cols, _ = self.taglist.get_focus() tagwidget = cols.original_widget.get_focus() return tagwidget.tag
1029
Train/png/1029.png
def encrypt(key, pt, Nk=4): assert Nk in {4, 6, 8} rkey = key_expand(key, Nk) ct = cipher(rkey, pt, Nk) return ct
4930
Train/png/4930.png
def to_identifier(s): if s.startswith('GPS'): s = 'Gps' + s[3:] return ''.join([i.capitalize() for i in s.split('_')]) if '_' in s else s
5516
Train/png/5516.png
def ListJobs(self, token=None): del token return [job.cron_job_id for job in data_store.REL_DB.ReadCronJobs()]
2469
Train/png/2469.png
def get_default_credentials(scopes): credentials, _ = google.auth.default(scopes=scopes) return credentials
4014
Train/png/4014.png
def floatize(self): self.x = float(self.x) self.y = float(self.y)
9365
Train/png/9365.png
def removeFilter(self, filter_index): f = self._filter[filter_index] self._filter.remove(f)
8587
Train/png/8587.png
def _sort(self): self.__dict__['_z_ordered_sprites'] = sorted( self.sprites, key=lambda sprite: sprite.z_order)
22
Train/png/22.png
def mkIntDate(s): n = s.__len__() d = int(s[-(n - 1):n]) return d
2797
Train/png/2797.png
def pop(self, index=-1): value = self._list.pop(index) del self._dict[value] return value
7314
Train/png/7314.png
def ascolumn(x, dtype=None): x = asarray(x, dtype) return x if len(x.shape) >= 2 else x.reshape(len(x), 1)
9181
Train/png/9181.png
def setup_signals(): signal.signal(signal.SIGINT, shutit_util.ctrl_c_signal_handler) signal.signal(signal.SIGQUIT, shutit_util.ctrl_quit_signal_handler)
8864
Train/png/8864.png
def switch_led_on(self, ids): self._set_LED(dict(zip(ids, itertools.repeat(True))))
5170
Train/png/5170.png
def _disconnect(self, exc_info=False): if self._stream: self._stream.close(exc_info=exc_info)
8964
Train/png/8964.png
def _remove_none_values(dictionary): return list(map(dictionary.pop, [i for i in dictionary if dictionary[i] is None]))
9942
Train/png/9942.png
def time_to_repeats(self, bins, integration_time): return math.ceil((self.device.sample_rate * integration_time) / bins)
6321
Train/png/6321.png
def name2rgb(hue): r, g, b = colorsys.hsv_to_rgb(hue / 360.0, .8, .7) return tuple(int(x * 256) for x in [r, g, b])
4834
Train/png/4834.png
def roll(rest, nick): "Roll a die, default = 100." if rest: rest = rest.strip() die = int(rest) else: die = 100 myroll = random.randint(1, die) return "%s rolls %s" % (nick, myroll)
1515
Train/png/1515.png
def _print(self, *args): string = u" ".join(args) + '\n' self.fobj.write(string)
2586
Train/png/2586.png
def load(path, cache=None, precache=False): parser = Stylesheet(cache) return parser.load(path, precache=precache)
5075
Train/png/5075.png
def expire(self, key, max_age, **opts): self.expire_at(key, time() + max_age, **opts)
4502
Train/png/4502.png
def get_pubmed_record(pmid): handle = Entrez.esummary(db="pubmed", id=pmid) record = Entrez.read(handle) return record
6748
Train/png/6748.png
def dragEnterEvent(self, event): if mimedata2url(event.mimeData()): event.accept() else: event.ignore()
7970
Train/png/7970.png
def channels_rename(self, room_id, name, **kwargs): return self.__call_api_post('channels.rename', roomId=room_id, name=name, kwargs=kwargs)
116
Train/png/116.png
def weekday(cls, year, month, day): return NepDate.from_bs_date(year, month, day).weekday()
2731
Train/png/2731.png
def parent_dir(path): return os.path.abspath(os.path.join(path, os.pardir, os.pardir, '_build'))
6463
Train/png/6463.png
def _get_shell_pid(): proc = Process(os.getpid()) try: return proc.parent().pid except TypeError: return proc.parent.pid
25
Train/png/25.png
def prefix_iter(self, ns_uri): ni = self.__lookup_uri(ns_uri) return iter(ni.prefixes)
7482
Train/png/7482.png
def json_dumps(self, obj): return json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': '))
3072
Train/png/3072.png
def requires(self): for url in NEWSPAPERS: yield IndexPage(url=url, date=self.date)
8282
Train/png/8282.png
def get_thresholds(points=100, power=3) -> list: return [(i / (points + 1)) ** power for i in range(1, points + 1)]
3076
Train/png/3076.png
def remove_experiment_choice(experiment, choice): redis = oz.redis.create_connection() oz.bandit.Experiment(redis, experiment).remove_choice(choice)
7356
Train/png/7356.png
def read_character_string(self): length = ord(self.data[self.offset]) self.offset += 1 return self.read_string(length)
6461
Train/png/6461.png
def kill(self): if self.process: self.process.kill() self.process.wait()
9155
Train/png/9155.png
def relative_path(path): return os.path.join(os.path.dirname(__file__), path)
5232
Train/png/5232.png
def delete_webhook(self, webhook): return self.manager.delete_webhook(self.scaling_group, self, webhook)
8303
Train/png/8303.png
def _edits2(word: str) -> Set[str]: return set(e2 for e1 in _edits1(word) for e2 in _edits1(e1))
5236
Train/png/5236.png
def get_new_client(self, public=True): return self._get_client(public=public, cached=False)