common_id
stringlengths 1
5
| image
stringlengths 15
19
| code
stringlengths 26
239
|
|---|---|---|
5998
|
Train/png/5998.png
|
def xyz2lonlat(x, y, z):
lon = xu.rad2deg(xu.arctan2(y, x))
lat = xu.rad2deg(xu.arctan2(z, xu.sqrt(x**2 + y**2)))
return lon, lat
|
8468
|
Train/png/8468.png
|
def _get_go2nt(self, goids):
go2nt_all = self.grprobj.go2nt
return {go: go2nt_all[go] for go in goids}
|
3023
|
Train/png/3023.png
|
def build_duration(self):
return int(self.state.build_done) - int(self.state.build)
|
1363
|
Train/png/1363.png
|
def prox_unity_plus(X, step, axis=0):
return prox_unity(prox_plus(X, step), step, axis=axis)
|
1930
|
Train/png/1930.png
|
def scanerror(self, msg):
error('scan error: ' + msg + ' on line {}'.format(self.sline))
sys.exit(-1)
|
1994
|
Train/png/1994.png
|
def should_ignore(self, filename):
_, ext = os.path.splitext(filename)
return ext in self.ignored_file_extensions
|
4090
|
Train/png/4090.png
|
def process_response(self, response):
self.response_headers = [(k, v)
for k, v in sorted(response.headers.items())]
|
3907
|
Train/png/3907.png
|
def increment(d, key, val=1):
if key in d:
d[key] += val
else:
d[key] = val
|
10081
|
Train/png/10081.png
|
def t_LSQBR(self, t):
r"\["
t.endlexpos = t.lexpos + len(t.value)
return t
|
6587
|
Train/png/6587.png
|
def normalize_bboxes(bboxes, rows, cols):
return [normalize_bbox(bbox, rows, cols) for bbox in bboxes]
|
4424
|
Train/png/4424.png
|
def lock(self, key, timeout=0, sleep=0):
return MockRedisLock(self, key, timeout, sleep)
|
2985
|
Train/png/2985.png
|
def update_schema(self):
self.commit()
self.build_source_files.schema.objects_to_record()
self.commit()
|
177
|
Train/png/177.png
|
def frommembers(cls, members=()):
return cls.fromint(sum(map(cls._map.__getitem__, set(members))))
|
8838
|
Train/png/8838.png
|
def run_tile(job_ini, sites_slice):
return run_job(job_ini, sites_slice=(sites_slice.start, sites_slice.stop))
|
5484
|
Train/png/5484.png
|
def signature(self):
self._data.sort()
str_to_sign = self._delimiter.join(self._data)
return hashlib.sha1(str_to_sign).hexdigest()
|
1468
|
Train/png/1468.png
|
def norm(x, mu, sigma=1.0):
return stats.norm(loc=mu, scale=sigma).pdf(x)
|
10067
|
Train/png/10067.png
|
def init_mq(self):
mq = self.init_connection()
self.init_consumer(mq)
return mq.connection
|
8096
|
Train/png/8096.png
|
def ustep(self):
self.U += self.rsdl_r(self.AX, self.Y)
|
3360
|
Train/png/3360.png
|
def get_base_modules():
" Get list of installed modules. "
return sorted(filter(
lambda x: op.isdir(op.join(MOD_DIR, x)),
listdir(MOD_DIR)))
|
4651
|
Train/png/4651.png
|
def read_service_ids_by_date(path: str) -> Dict[datetime.date, FrozenSet[str]]:
feed = load_raw_feed(path)
return _service_ids_by_date(feed)
|
5845
|
Train/png/5845.png
|
def debug_sleep(self, timeout):
fut = self.execute(b'DEBUG', b'SLEEP', timeout)
return wait_ok(fut)
|
3140
|
Train/png/3140.png
|
def get_hash(self, handle):
fpath = self._fpath_from_handle(handle)
return DiskStorageBroker.hasher(fpath)
|
787
|
Train/png/787.png
|
def clear(self):
self.bad = False
self.errors = {}
self._collection.clear()
|
402
|
Train/png/402.png
|
def spaced_items(list_, n, **kwargs):
indexes = spaced_indexes(len(list_), n, **kwargs)
items = list_[indexes]
return items
|
7371
|
Train/png/7371.png
|
def shape(self) -> Tuple[int, ...]:
return tuple(int(sub) for sub in self.ratios.shape)
|
3942
|
Train/png/3942.png
|
def remove_dups(seq):
seen = set()
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))]
|
5036
|
Train/png/5036.png
|
def apply(self, template, context={}):
context.update(self.context)
return self.env.from_string(template).render(context)
|
4051
|
Train/png/4051.png
|
def d(msg, *args, **kwargs):
return logging.log(DEBUG, msg, *args, **kwargs)
|
7513
|
Train/png/7513.png
|
def resolve(self, notes=None):
self.set_status(self._redmine.ISSUE_STATUS_ID_RESOLVED, notes=notes)
|
436
|
Train/png/436.png
|
def _cldf2wordlist(dataset, row='parameter_id', col='language_id'):
return lingpy.Wordlist(_cldf2wld(dataset), row=row, col=col)
|
8369
|
Train/png/8369.png
|
def rate(s=switchpoint, e=early_mean, l=late_mean):
out = empty(len(disasters_array))
out[:s] = e
out[s:] = l
return out
|
2369
|
Train/png/2369.png
|
def count(cls, *criteria, **filters):
return cls.query.filter(*criteria).filter_by(**filters).count()
|
9438
|
Train/png/9438.png
|
def shape(self):
if self._shape is None:
self._populate_from_rasterio_object(read_image=False)
return self._shape
|
4820
|
Train/png/4820.png
|
def getP2(self):
return Point(self.center[0] + self.radius,
self.center[1] + self.radius)
|
2607
|
Train/png/2607.png
|
def handle_lrr_message(sender, message):
print(sender, message.partition, message.event_type, message.event_data)
|
272
|
Train/png/272.png
|
def sizeHint(self):
w, h = self.get_width_height()
return QtCore.QSize(w, h)
|
2545
|
Train/png/2545.png
|
def files(self):
'iterate over found files'
for _f in self.searchresult.files.iterchildren():
yield ProtoFile.factory(_f, jfs=self.jfs, parentpath=unicode(_f.abspath))
|
122
|
Train/png/122.png
|
def update(self, permission):
self.needs.update(permission.needs)
self.excludes.update(permission.excludes)
|
7498
|
Train/png/7498.png
|
def evaluate(x, amplitude, mean, stddev):
return 1.0 - Gaussian1D.evaluate(x, amplitude, mean, stddev)
|
9845
|
Train/png/9845.png
|
def _height_is_big_enough(image, height):
if height > image.size[1]:
raise ImageSizeError(image.size[1], height)
|
786
|
Train/png/786.png
|
def reverseDict(d):
retD = {}
for k in d:
retD[d[k]] = k
return retD
|
2604
|
Train/png/2604.png
|
def get_best_frequencies(self):
return self.freq[self.best_local_optima], self.per[self.best_local_optima]
|
9099
|
Train/png/9099.png
|
def compare_dict(da, db):
sa = set(da.items())
sb = set(db.items())
diff = sa & sb
return dict(sa - diff), dict(sb - diff)
|
444
|
Train/png/444.png
|
def read_csv(text, sep="\t"):
import pandas as pd # no top level load to make a faster import of db
return pd.read_csv(StringIO(text), sep="\t")
|
993
|
Train/png/993.png
|
def rotset_cb(self, setting, value, chviewer, info):
return self.rotset(chviewer, info.chinfo)
|
5737
|
Train/png/5737.png
|
def turn_right():
motors.left_motor(-150) # spin CCW
motors.right_motor(-150) # spin CCW
board.sleep(0.5)
motors.brake()
board.sleep(0.1)
|
51
|
Train/png/51.png
|
def hsv_to_rgb(self, HSV):
"hsv to linear rgb"
gammaRGB = self._ABC_to_DEF_by_fn(HSV, hsv_to_rgb)
return self._ungamma_rgb(gammaRGB)
|
391
|
Train/png/391.png
|
def install(self, binder, module):
ModuleAdapter(module, self._injector).configure(binder)
|
8418
|
Train/png/8418.png
|
def _nvram_file(self):
return os.path.join(self.working_dir, "nvram_{:05d}".format(self.application_id))
|
34
|
Train/png/34.png
|
def save_rst(self, fd):
from pylon.io import ReSTWriter
ReSTWriter(self).write(fd)
|
7605
|
Train/png/7605.png
|
def remove_stopped_threads(self):
self.threads = [t for t in self.threads if t.is_alive()]
|
4884
|
Train/png/4884.png
|
def get_item_at(self, *args, **kwargs):
return self.proxy.get_item_at(coerce_point(*args, **kwargs))
|
6331
|
Train/png/6331.png
|
def previous_layout(pymux, variables):
" Select previous layout. "
pane = pymux.arrangement.get_active_window()
if pane:
pane.select_previous_layout()
|
808
|
Train/png/808.png
|
def flip_motion(self, value):
if value:
self.cam.enable_motion_detection()
else:
self.cam.disable_motion_detection()
|
2288
|
Train/png/2288.png
|
def get_chunks(Array, Chunksize):
for i in range(0, len(Array), Chunksize):
yield Array[i:i + Chunksize]
|
3470
|
Train/png/3470.png
|
def stayOpen(self):
if not self._wantToClose:
self.show()
self.setGeometry(self._geometry)
|
1759
|
Train/png/1759.png
|
def set_thumbnail(self, thumbnail):
self._thumbnail = thumbnail
return self._listitem.setThumbnailImage(thumbnail)
|
885
|
Train/png/885.png
|
def parse_report(self, current_type, report_data):
fmt = self.known_formats[current_type]
return fmt(report_data)
|
9671
|
Train/png/9671.png
|
def inverse(self):
return Snapshot(self.num_qubits, self.num_clbits, self.params[0],
self.params[1])
|
6765
|
Train/png/6765.png
|
def toggle_codecompletion(self, checked):
self.shell.set_codecompletion_auto(checked)
self.set_option('codecompletion/auto', checked)
|
1844
|
Train/png/1844.png
|
def read_byte(self, address):
LOGGER.debug("Reading byte from device %s!", hex(address))
return self.driver.read_byte(address)
|
7386
|
Train/png/7386.png
|
def body(self):
res = self._body[self.bcount]()
self.bcount += 1
return res
|
4376
|
Train/png/4376.png
|
def put(self, path, body):
return self._make_request('put',
self._format_url(API_ROOT + path), {
'json': body
})
|
7035
|
Train/png/7035.png
|
def lowstrip(term):
term = re.sub('\s+', ' ', term)
term = term.lower()
return term
|
9030
|
Train/png/9030.png
|
def request_networks(blink):
url = "{}/networks".format(blink.urls.base_url)
return http_get(blink, url)
|
2860
|
Train/png/2860.png
|
def size(self):
if not self._size:
self._size = os.path.getsize(self._path)
return self._size
|
23
|
Train/png/23.png
|
def reference(self, tkn: str):
return self.grammarelts[tkn] if tkn in self.grammarelts else UndefinedElement(tkn)
|
7266
|
Train/png/7266.png
|
def prev_window(self, widget, data=None):
self.path_window.hide()
self.parent.open_window(widget, self.data)
|
4600
|
Train/png/4600.png
|
def wait_until_exit(self):
[t.join() for t in self.threads]
self.threads = list()
|
3987
|
Train/png/3987.png
|
def has_table(table_name):
return db.engine.dialect.has_table(
db.engine.connect(),
table_name
)
|
53
|
Train/png/53.png
|
def advance(self):
elem = next(self._iterable)
for deque in self._deques:
deque.append(elem)
|
8404
|
Train/png/8404.png
|
def upcaseTokens(s, l, t):
return [tt.upper() for tt in map(_ustr, t)]
|
2159
|
Train/png/2159.png
|
def add_ones(a):
arr = N.ones((a.shape[0], a.shape[1]+1))
arr[:, :-1] = a
return arr
|
3104
|
Train/png/3104.png
|
def getquery(query):
'Performs a query and get the results.'
try:
conn = connection.cursor()
conn.execute(query)
data = conn.fetchall()
conn.close()
except:
data = list()
return data
|
2302
|
Train/png/2302.png
|
def add_state(self):
sid = len(self.states)
self.states.append(SFAState(sid))
|
9210
|
Train/png/9210.png
|
def delay_or_fail(self, *args, **kwargs):
return self.async_or_fail(args=args, kwargs=kwargs)
|
4308
|
Train/png/4308.png
|
def plotIndividual(self):
pl.plot(self.x_int, self.y_int)
pl.grid(True)
pl.show()
|
8341
|
Train/png/8341.png
|
def remap_index_fn(ref_file):
return os.path.join(os.path.dirname(os.path.dirname(ref_file)), "star")
|
7568
|
Train/png/7568.png
|
def setTimeout(self, time):
self.conversation.SetDDETimeout(round(time))
return self.conversation.GetDDETimeout()
|
7348
|
Train/png/7348.png
|
def suppress_logging(log_level=logging.CRITICAL):
logging.disable(log_level)
yield
logging.disable(logging.NOTSET)
|
1784
|
Train/png/1784.png
|
def tagged(self, tag, offset=0, count=25):
return json.loads(self.client('tag', 'get', tag, offset, count))
|
7156
|
Train/png/7156.png
|
def circstd(dts, axis=2):
R = np.abs(np.exp(1.0j * dts).mean(axis=axis))
return np.sqrt(-2.0 * np.log(R))
|
3797
|
Train/png/3797.png
|
def hdf5_not_storable(_type, *args, **kwargs):
hdf5_service.registerStorable(not_storable(_type), *args, **kwargs)
|
4397
|
Train/png/4397.png
|
def call_closers(self, client, clients_list):
for func in self.closers:
func(client, clients_list)
|
8383
|
Train/png/8383.png
|
def rt(nu, size=None):
return rnormal(0, 1, size) / np.sqrt(rchi2(nu, size) / nu)
|
4135
|
Train/png/4135.png
|
def get_composition(source, *fxns):
val = source
for fxn in fxns:
val = fxn(val)
return val
|
3773
|
Train/png/3773.png
|
def list_dir_abspath(path):
return map(lambda f: os.path.join(path, f), os.listdir(path))
|
3941
|
Train/png/3941.png
|
def map_over_glob(fn, path, pattern):
return [fn(x) for x in glob.glob(os.path.join(path, pattern))]
|
7519
|
Train/png/7519.png
|
def amod(a, b):
modded = int(a % b)
return b if modded is 0 else modded
|
4140
|
Train/png/4140.png
|
def schema_map(schema):
mapper = {}
for name in getFieldNames(schema):
mapper[name] = name
return mapper
|
9196
|
Train/png/9196.png
|
def _new_from_cdata(cls, cdata: Any) -> "Color":
return cls(cdata.r, cdata.g, cdata.b)
|
3254
|
Train/png/3254.png
|
def reader(f):
return unicodecsv.reader(f, encoding='utf-8', delimiter=b',', quotechar=b'"')
|
4273
|
Train/png/4273.png
|
def isLineComment(self, text):
m = self.lineComment(text, 0)
return m and m.start(0) == 0 and m.end(0) == len(text)
|
2595
|
Train/png/2595.png
|
def getConfig(self, key):
if hasattr(self, key):
return getattr(self, key)
else:
return False
|
9873
|
Train/png/9873.png
|
def set_default_tlw(self, tlw, designer, inspector):
"track default top level window for toolbox menu default action"
self.designer = designer
self.inspector = inspector
|
7257
|
Train/png/7257.png
|
def pop_event(self):
if len(self.event_list) > 0:
evt = self.event_list.pop(0)
return evt
return None
|
637
|
Train/png/637.png
|
def make_request(parameters):
r = requests.get(bcdata.WFS_URL, params=parameters)
return r.json()["features"]
|
2328
|
Train/png/2328.png
|
def move(self, target):
shutil.move(self.path, self._to_backend(target))
|
4245
|
Train/png/4245.png
|
def has_directory(self, name: str):
return os.path.isdir(self._path / name)
|
3156
|
Train/png/3156.png
|
def add(self, member, score):
return self.client.zadd(self.name, member, score)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.