text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> def clear_inputhook(self, app=None):
"""Set PyOS_InputHook to NULL and return the previous one.
Parameters
----------
app : optional, ignored
This parameter is allowed only so that clear_inputhook() can be
called with a similar interface as all the ... | code_fim | hard | {
"lang": "python",
"repo": "omazapa/ipython-zmq",
"path": "/IPython/lib/inputhook.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return hmod
def pyGetModuleBaseNameW(hproc, hmod):
GetModuleBaseNameW = psapi.GetModuleBaseNameW
GetModuleBaseNameW.argtypes = (wintypes.HANDLE,
wintypes.HMODULE,
wintypes.LPWSTR,
wintypes... | code_fim | hard | {
"lang": "python",
"repo": "SuprHackerSteve/pyinject",
"path": "/purepywin32/psapi.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SuprHackerSteve/pyinject path: /purepywin32/psapi.py
import ctypes
from ctypes import wintypes
import purepywin32.common as common
psapi = ctypes.WinDLL('psapi.dll')
def pyEnumProcesses():
EnumProcesses = psapi.EnumProcesses
EnumProcesses.argtypes = (wintypes.PDWORD,
... | code_fim | hard | {
"lang": "python",
"repo": "SuprHackerSteve/pyinject",
"path": "/purepywin32/psapi.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret = EnumProcessModules(handle,
ctypes.byref(hmod),
ctypes.sizeof(hmod),
ctypes.byref(cb_needed))
if not ret:
raise ctypes.WinError()
return hmod
def pyGetModuleBaseNameW(hproc, hmod):
GetModu... | code_fim | hard | {
"lang": "python",
"repo": "SuprHackerSteve/pyinject",
"path": "/purepywin32/psapi.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_lr(self):
if self.last_epoch == 0:
return self.base_lrs
elif self.last_epoch in self.restarts:
self.last_restart = self.last_epoch
self.T_max = self.T_period[self.restarts.index(self.last_epoch) + 1]
weight = self.restart_weights[... | code_fim | hard | {
"lang": "python",
"repo": "riverlight/egvsr",
"path": "/codes/models/optim/lr_schedules.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.last_epoch == 0:
return self.base_lrs
elif self.last_epoch in self.restarts:
self.last_restart = self.last_epoch
self.T_max = self.T_period[self.restarts.index(self.last_epoch) + 1]
weight = self.restart_weights[self.restarts.index(se... | code_fim | hard | {
"lang": "python",
"repo": "riverlight/egvsr",
"path": "/codes/models/optim/lr_schedules.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: riverlight/egvsr path: /codes/models/optim/lr_schedules.py
import math
from torch.optim.lr_scheduler import _LRScheduler
class CosineAnnealingLR_Restart(_LRScheduler):
""" Originally from BasicSR:
https://github.com/xinntao/BasicSR/blob/master/codes/models/lr_scheduler.py
"""
... | code_fim | hard | {
"lang": "python",
"repo": "riverlight/egvsr",
"path": "/codes/models/optim/lr_schedules.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
V.SetEnabled(int)
C++: void SetEnabled(int) override;
Methods for activating this widget. Note that the widget
representation must be specified or the widget will not appear.
ProcessEvents (On by default) must be On for Enabled widget to
... | code_fim | hard | {
"lang": "python",
"repo": "gen4438/vtk-python-stubs",
"path": "/typings/vtkmodules/vtkInteractionWidgets/vtkAbstractWidget.pyi",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gen4438/vtk-python-stubs path: /typings/vtkmodules/vtkInteractionWidgets/vtkAbstractWidget.pyi
"""
This type stub file was generated by pyright.
"""
import vtkmodules.vtkRenderingCore as __vtkmodules_vtkRenderingCore
class vtkAbstractWidget(__vtkmodules_vtkRenderingCore.vtkInteractorObserver):
... | code_fim | hard | {
"lang": "python",
"repo": "gen4438/vtk-python-stubs",
"path": "/typings/vtkmodules/vtkInteractionWidgets/vtkAbstractWidget.pyi",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class FeatureLog10MedianHouseValue(BaseHousingTransformingFeature):
name = "log10_median_house_value"
def transform(self, df):
return np.log10(df["median_house_value"])
class FeatureBucketizedLatitude(BaseHousingTransformingFeature):
name = "bucketized_latitude"
def transform(s... | code_fim | hard | {
"lang": "python",
"repo": "nguyen-viet-hung/tabml",
"path": "/examples/housing/feature_manager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def transform(self, df):
return self.transformer.transform(df[["households"]]).reshape(-1)
class FeatureScaledCleanMedianIncome(BaseHousingTransformingFeature):
name = "scaled_median_income"
def fit(self, df):
self.transformer = StandardScaler()
train_data = df.query... | code_fim | hard | {
"lang": "python",
"repo": "nguyen-viet-hung/tabml",
"path": "/examples/housing/feature_manager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nguyen-viet-hung/tabml path: /examples/housing/feature_manager.py
import numpy as np
import pandas as pd
from sklearn.preprocessing import LabelEncoder, StandardScaler
from tabml import data_processing, datasets
from tabml.feature_manager import BaseFeatureManager, BaseTransformingFeature
DATA_... | code_fim | hard | {
"lang": "python",
"repo": "nguyen-viet-hung/tabml",
"path": "/examples/housing/feature_manager.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
bool : Return true if number of values higher than the previous one equals patience.
"""
if self.best_model is None:
self.best_model = model
if(newLoss > self.lastLoss):
self.succeedingHigherValues += 1
else:
... | code_fim | hard | {
"lang": "python",
"repo": "guaishou/amorf-Regression-for-multi--target",
"path": "/amorf/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> torch.save({'state_dict': model.state_dict()}, 'checkpoint.pth.tar')
def printMessage(Message, verbosity):
"""Prints messages if verbosity is set
Does not do much currently but can be expanded later.
"""
if(verbosity == 1):
print(Message)<|fim_prefix|># repo: guaishou/a... | code_fim | hard | {
"lang": "python",
"repo": "guaishou/amorf-Regression-for-multi--target",
"path": "/amorf/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: guaishou/amorf-Regression-for-multi--target path: /amorf/utils.py
import torch
class EarlyStopping:
"""
Early Stopping Mechanism
Returns True if training should stop and False if it should continue.
Saves the best model.
Only works for decreasing loss values.
Args:
... | code_fim | hard | {
"lang": "python",
"repo": "guaishou/amorf-Regression-for-multi--target",
"path": "/amorf/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> delete("static/upload/")
delete("static/predict/")
def getwidth(path):
img=Image.open(path)
size = img.size # width and height
aspect = size[0]/size[1] # width/height
w = 300 * aspect
return int(w)
def gender():
if request.method=='POST':
space_free()
f= r... | code_fim | medium | {
"lang": "python",
"repo": "Shekharmaheswari85/Gender_Classification_Deployment",
"path": "/main/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Shekharmaheswari85/Gender_Classification_Deployment path: /main/views.py
from flask import render_template,request
import os
from PIL import Image
from utility import utils
UPLOAD_FOLDER='static/upload'
def error():
return render_template('error.html')
def base():
return render_templa... | code_fim | hard | {
"lang": "python",
"repo": "Shekharmaheswari85/Gender_Classification_Deployment",
"path": "/main/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cfg.use_aux:
metric_dict = {
'name': ['top1', 'top2', 'top3', 'iou'],
'op': [MultiLabelAcc(), AccTopk(cfg.griding_num, 2), AccTopk(cfg.griding_num, 3), Metric_mIoU(cfg.num_lanes+1)],
'data_src': [('cls_out', 'cls_label'), ('cls_out', 'cls_label'), ('cls_o... | code_fim | hard | {
"lang": "python",
"repo": "cfzd/Ultra-Fast-Lane-Detection",
"path": "/utils/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.iters = 0
self.base_lr = [group['lr'] for group in optimizer.param_groups]
def step(self, external_iter = None):
self.iters += 1
if external_iter is not None:
self.iters = external_iter
if self.warmup == 'linear' and self.iters < self.warmup_it... | code_fim | hard | {
"lang": "python",
"repo": "cfzd/Ultra-Fast-Lane-Detection",
"path": "/utils/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cfzd/Ultra-Fast-Lane-Detection path: /utils/factory.py
from utils.loss import SoftmaxFocalLoss, ParsingRelationLoss, ParsingRelationDis
from utils.metrics import MultiLabelAcc, AccTopk, Metric_mIoU
from utils.dist_utils import DistSummaryWriter
import torch
def get_optimizer(net,cfg):
trai... | code_fim | hard | {
"lang": "python",
"repo": "cfzd/Ultra-Fast-Lane-Detection",
"path": "/utils/factory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kadc87/dsmp-pre-work path: /Superhero-Statistics/code.py
# --------------
#Header files
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#path of the data file- path
#Code starts here
data = pd.read_csv(path)
data['Gender'].replace('-', 'Agender', inplace = Tru... | code_fim | hard | {
"lang": "python",
"repo": "kadc87/dsmp-pre-work",
"path": "/Superhero-Statistics/code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># --------------
#Code starts here
fig, (ax_1, ax_2, ax_3) = plt.subplots(3, 1)
data.boxplot('Intelligence', ax = ax_1)
data.boxplot('Speed', ax = ax_2)
data.boxplot('Power', ax = ax_3)<|fim_prefix|># repo: kadc87/dsmp-pre-work path: /Superhero-Statistics/code.py
# --------------
#Header files
impor... | code_fim | hard | {
"lang": "python",
"repo": "kadc87/dsmp-pre-work",
"path": "/Superhero-Statistics/code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lagrassa/planorparam path: /planorparam/agent/old/belief.py
import numpy as np
from scipy.stats import multivariate_normal
import shapely.geometry as sg
from sympy.geometry import *
class Belief():
def __init__(self, mu=None, cov=None, particles = [], walls = [], init_only = False, action=N... | code_fim | hard | {
"lang": "python",
"repo": "lagrassa/planorparam",
"path": "/planorparam/agent/old/belief.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #inside_wall = bool(len(intersection(seg, self.line)))
intersections = seg.intersection(self.sg_line)
inside_wall = bool(len(intersections.coords))
return int(inside_wall)
def dist_to(self, pt):
return self.sg_line.distance(sg.Point(pt))
def closest_pt(sel... | code_fim | hard | {
"lang": "python",
"repo": "lagrassa/planorparam",
"path": "/planorparam/agent/old/belief.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.pose = pose
self.contacts = [] #tuples of (robot_surface, world_surface)
def world_contact_surfaces(self):
return [x[1] for x in self.contacts]
def mala_distance(q, belief):
if isinstance(q, Belief):
distance = 0
for particle in q.particles:
... | code_fim | hard | {
"lang": "python",
"repo": "lagrassa/planorparam",
"path": "/planorparam/agent/old/belief.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: theatlantic/python-active-directory path: /lib/activedirectory/util/misc.py
#
# This file is part of Python-AD. Python-AD is free software that is made
# available under the MIT license. Consult the file "LICENSE" that is
# distributed together with this file for the exact licensing terms.
#
# Py... | code_fim | medium | {
"lang": "python",
"repo": "theatlantic/python-active-directory",
"path": "/lib/activedirectory/util/misc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return the host name.
The host name is defined as the "short" host name. If the hostname as
returned by gethostname() includes a domain, the part until the first
period ('.') is returned.
"""
hostname = socket.gethostname()
if '.' in hostname:
hostname = hostname.sp... | code_fim | medium | {
"lang": "python",
"repo": "theatlantic/python-active-directory",
"path": "/lib/activedirectory/util/misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saltstack/salt path: /tests/pytests/functional/states/file/test_pruned.py
import pytest
pytestmark = [
pytest.mark.windows_whitelisted,
pytest.mark.slow_test,
]
@pytest.fixture(scope="module")
def file(states):
return states.file
@pytest.fixture(scope="function")
def single_dir_w... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/tests/pytests/functional/states/file/test_pruned.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_pruned_success_recurse_and_deleted(file, nested_empty_dirs):
ret = file.pruned(name=nested_empty_dirs, recurse=True)
assert ret.result is True
assert len(ret.changes["deleted"]) == 27
assert ret.comment == "Recursively removed empty directories under {}".format(
nested_em... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/tests/pytests/functional/states/file/test_pruned.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hack-e-d/God_s_eye path: /snapper.py
import cv2
def snap(ptc,ptf,img):
dim=(2000,1290)
img = cv2.rectangle(img,<|fim_suffix|>mg, (ptf[1]-1, ptf[0]-1), (ptf[1]+1,ptf[0]+1), (0, 0, 255), 2)
resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)
cv2.imwrite("colision.jpg",... | code_fim | medium | {
"lang": "python",
"repo": "hack-e-d/God_s_eye",
"path": "/snapper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ze(img, dim, interpolation = cv2.INTER_AREA)
cv2.imwrite("colision.jpg",resized)<|fim_prefix|># repo: hack-e-d/God_s_eye path: /snapper.py
import cv2
def snap(ptc,ptf,img):
dim=(2000,1290)
img = cv2.rectangle(img, (ptc[1]-1, ptc[0]-1), (ptc[1]+1,ptc[0]+1), (0, 255, 0), 2)
img = cv2.rec... | code_fim | medium | {
"lang": "python",
"repo": "hack-e-d/God_s_eye",
"path": "/snapper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> results = sp.search(q='investment female', type='show', limit=50, market='GB')
playlists = []
for show in results['shows']['items']:
if 'invest' not in show['name'].lower() and 'investment' not in show['description'].lower():
continue
playli... | code_fim | hard | {
"lang": "python",
"repo": "nikiis/HerFinance",
"path": "/spotify.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if os.environ.get('SPOTIFY_DEBUG'):
print('\n'.join([p['name'] for p in playlists]))
with open('playlist.json', 'w') as f:
json.dump(playlists, f)<|fim_prefix|># repo: nikiis/HerFinance path: /spotify.py
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
import os... | code_fim | hard | {
"lang": "python",
"repo": "nikiis/HerFinance",
"path": "/spotify.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nikiis/HerFinance path: /spotify.py
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
import os
import json
class Spotify:
def __init__(self, id, secret):
self.id = id
self.secret = secret
def get_playlists(self):
sp = spotipy.Spotify(auth_manag... | code_fim | hard | {
"lang": "python",
"repo": "nikiis/HerFinance",
"path": "/spotify.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from __future__ import absolute_import
import unittest
from asposehtmlcloud.api.translation_api import TranslationApi
from asposehtmlcloud.rest import ApiException
from test.test_helper import TestHelper
class TestTranslationApi(unittest.TestCase):
def setUp(self):
self.api = TranslationApi... | code_fim | hard | {
"lang": "python",
"repo": "aspose-cloud/aspose-html-cloud-python",
"path": "/test/test_translation_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aspose-cloud/aspose-html-cloud-python path: /test/test_translation_api.py
# coding: utf-8
"""
--------------------------------------------------------------------------------------------------------------------
<copyright company="Aspose" file="test_translation_api.py">
Copyright (c) 2018 As... | code_fim | hard | {
"lang": "python",
"repo": "aspose-cloud/aspose-html-cloud-python",
"path": "/test/test_translation_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
source_url = "https://www.le.ac.uk/oerresources/bdra/html/page_02.htm"
src_lang = "en"
res_lang = "fr"
try:
# Translate url
res = self.api.translation_get_translate_document_by_url(source_url, src_lang, res_lang)
self.assertTr... | code_fim | hard | {
"lang": "python",
"repo": "aspose-cloud/aspose-html-cloud-python",
"path": "/test/test_translation_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kc97ble/icrew path: /src/events/migrations/0007_announcement_hidden.py
# Generated by Django 3.0.1 on 2020-01-05 16:01
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AddField(
model_name='announce... | code_fim | medium | {
"lang": "python",
"repo": "kc97ble/icrew",
"path": "/src/events/migrations/0007_announcement_hidden.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('events', '0006_announcement'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='hidden',
field=models.BooleanField(default=False),
),
]<|fim_prefix|># repo: kc97ble/icrew path: /src/even... | code_fim | easy | {
"lang": "python",
"repo": "kc97ble/icrew",
"path": "/src/events/migrations/0007_announcement_hidden.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('events', '0006_announcement'),
]
operations = [
migrations.AddField(
model_name='announcement',
name='hidden',
field=models.BooleanField(default=False),
),
]<|fim_prefix|># repo: kc97ble/icrew path: /src/event... | code_fim | medium | {
"lang": "python",
"repo": "kc97ble/icrew",
"path": "/src/events/migrations/0007_announcement_hidden.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HesslerY/opt_tau path: /bokeh/opt_tau_python.py
from numpy import pi, sin, cos, sqrt
from math import atan2, atan
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button
axis_color = 'lightgoldenrodyellow'
Nom_min = 3
Nom_max = 10
def opt_tau_anal(e,w,W)... | code_fim | hard | {
"lang": "python",
"repo": "HesslerY/opt_tau",
"path": "/bokeh/opt_tau_python.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Default params
Nom = 8
fmin = 1.0
fmax = 9.0
eps = 0.7
freq = np.linspace(fmin,fmax,Nom)
om = 2.0*np.pi*freq*(1.0-1j*eps)
tau = opt_tau_anal(eps,om[0].real,om[-1].real)
Jopt = J_opt(eps, min(om.real), max(om.real))
cc = list('gbcmy')
col = list('r')
j = -1
for k in range(1,Nom-1):
j=j+1... | code_fim | hard | {
"lang": "python",
"repo": "HesslerY/opt_tau",
"path": "/bokeh/opt_tau_python.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tsp-team/panda3d path: /bsp/src/leveleditor/grid/Grid.py
from panda3d.core import LineSegs, NodePath, Vec4, Point3, AntialiasAttrib
from .GridSettings import GridSettings
class Grid:
def __init__(self, viewport):
self.viewport = viewport
self.doc = viewport.doc
# S... | code_fim | hard | {
"lang": "python",
"repo": "tsp-team/panda3d",
"path": "/bsp/src/leveleditor/grid/Grid.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> zoom = self.calcZoom()
step = GridSettings.DefaultStep
low = GridSettings.Low
high = GridSettings.High
actualDist = step * zoom
if GridSettings.HideSmallerToggle:
while actualDist < GridSettings.HideSmallerThan:
step *= GridSettin... | code_fim | hard | {
"lang": "python",
"repo": "tsp-team/panda3d",
"path": "/bsp/src/leveleditor/grid/Grid.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.removeCurrentGrid()
self.lastStep = step
if step in self.gridsByStep:
self.gridNp = self.gridsByStep[step].copyTo(self.viewport.gridRoot)
return task.cont
segs = LineSegs()
i = low
while i <= high:
color = GridSett... | code_fim | hard | {
"lang": "python",
"repo": "tsp-team/panda3d",
"path": "/bsp/src/leveleditor/grid/Grid.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Blisse/RunescapeTools path: /CelticKnotSolver/__main__.py
import collections
def main():
knot1 = collections.deque(["Cs", "Ds", "F", "St", "As", "Bl", "M", "De", "So", "Bl", "Ai", "W", "St", "Lw", "Bl", "Du"])
knot2 = collections.deque(["Ms", "Bl", "M", "Co", "Lv", "Du", "Bd", "Bl", "De"... | code_fim | hard | {
"lang": "python",
"repo": "Blisse/RunescapeTools",
"path": "/CelticKnotSolver/__main__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j in range(1, len(knot2)):
knot2.rotate(1)
for k in range(1, len(knot3)):
knot3.rotate(1)
if (knot1[knot1_to_2[0]] == knot2[knot2_to_1[0]] and
knot1[knot1_to_2[1]] == knot2[knot2_to_1[1]] and
kn... | code_fim | hard | {
"lang": "python",
"repo": "Blisse/RunescapeTools",
"path": "/CelticKnotSolver/__main__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Replace -1 for negative, +1 for positive labels
signed_label = tf.where(
tf.cast(labels, tf.bool), tf.ones(input_length, tf.int32),
tf.scalar_mul(-1, tf.ones(input_length, tf.int32)))
# negative of index for negative label, positive index for positive labe... | code_fim | hard | {
"lang": "python",
"repo": "NVIDIA/DeepLearningExamples",
"path": "/TensorFlow2/Segmentation/MaskRCNN/mrcnn_tf2/object_detection/balanced_positive_negative_sampler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NVIDIA/DeepLearningExamples path: /TensorFlow2/Segmentation/MaskRCNN/mrcnn_tf2/object_detection/balanced_positive_negative_sampler.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file excep... | code_fim | hard | {
"lang": "python",
"repo": "NVIDIA/DeepLearningExamples",
"path": "/TensorFlow2/Segmentation/MaskRCNN/mrcnn_tf2/object_detection/balanced_positive_negative_sampler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
The model with the name.
"""
return getattr(open_alchemy.models, name, None)
def get_model_schema(*, name: str) -> typing.Optional[types.Schema]:
"""
Get the schema of a model by name from models.
Args:
name: The name of the model.
Returns:
... | code_fim | hard | {
"lang": "python",
"repo": "jdkandersson/OpenAlchemy",
"path": "/open_alchemy/facades/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jdkandersson/OpenAlchemy path: /open_alchemy/facades/models.py
"""Functions for interacting with the OpenAlchemy models."""
import typing
import open_alchemy
from open_alchemy import types
def get_base() -> typing.Any:
"""
Get the models.Base used as the declarative base for models.
... | code_fim | medium | {
"lang": "python",
"repo": "jdkandersson/OpenAlchemy",
"path": "/open_alchemy/facades/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_model_schema(*, name: str) -> typing.Optional[types.Schema]:
"""
Get the schema of a model by name from models.
Args:
name: The name of the model.
Returns:
The schema of the model with the name.
"""
model = get_model(name=name)
if model is None:
... | code_fim | hard | {
"lang": "python",
"repo": "jdkandersson/OpenAlchemy",
"path": "/open_alchemy/facades/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.drivers = {
'jsonium.drivers.FileDriver': FileDriver,
'jsonium.drivers.MemoryDriver': MemoryDriver
}
@property
def drivers(self):
return self._drivers
@drivers.setter
def drivers(self, drivers):
if not isinstance(drivers, dict)... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/jsonium",
"path": "/jsonium/drivers/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/jsonium path: /jsonium/drivers/factory.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from jsonium.abstract import Driver
from jsonium.drivers import (
FileDriver,
MemoryDriver,
)
<|fim_suffix|> _drivers = None
def __init__(self, *args, **kwargs):
self.driv... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/jsonium",
"path": "/jsonium/drivers/factory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, *args, **kwargs):
self.drivers = {
'jsonium.drivers.FileDriver': FileDriver,
'jsonium.drivers.MemoryDriver': MemoryDriver
}
@property
def drivers(self):
return self._drivers
@drivers.setter
def drivers(self, drivers):... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/jsonium",
"path": "/jsonium/drivers/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 18F/tock path: /tock/api/tests.py
json_no_late_timecards(self):
res = client().get(reverse('Submissions', kwargs={'num_past_reporting_periods': 1})).data
self.assertEqual(len(res), 0)
def test_submissions_json_too_many_periods(self):
res = client().get(reverse('Submis... | code_fim | hard | {
"lang": "python",
"repo": "18F/tock",
"path": "/tock/api/tests.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> response = client().get(reverse('HoursByQuarterByUser')).data
self.assertEqual(len(response), 1)
row = response[0]
self.assertEqual(row['username'], str(self.user))
self.assertEqual(row['billable'], 15)
self.assertEqual(row['nonbillable'], 5)
self.as... | code_fim | hard | {
"lang": "python",
"repo": "18F/tock",
"path": "/tock/api/tests.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 18F/tock path: /tock/api/tests.py
me='aaron.snow')[0]
token = Token.objects.get_or_create(user=request_user)[0].key
client = APIClient()
client.credentials(HTTP_AUTHORIZATION='Token ' + token)
return client
# common fixtures for all API tests
FIXTURES = [
'tock/fixtures/prod_... | code_fim | hard | {
"lang": "python",
"repo": "18F/tock",
"path": "/tock/api/tests.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SupriyoDam/DS-450-python path: /Two Pointers Problems/Find triplets with zero sum.py
class Solution:
#Function to find triplets with zero sum.
def findTriplets(self, arr, n):
return self.threeSum(arr)
def twosum(self, arr, index, target):
<|fim_suffix|> for... | code_fim | hard | {
"lang": "python",
"repo": "SupriyoDam/DS-450-python",
"path": "/Two Pointers Problems/Find triplets with zero sum.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.res = 0
arr.sort()
for i in range(len(arr)-2):
if (i==0) or (i and arr[i] != arr[i-1]):
if self.twosum(arr, i+1, -arr[i]):
return 1
return 0<|fim_prefix|># repo: SupriyoDam/DS-450-python path: /Two Pointers Proble... | code_fim | hard | {
"lang": "python",
"repo": "SupriyoDam/DS-450-python",
"path": "/Two Pointers Problems/Find triplets with zero sum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif arr[i] + arr[j] < target:
i += 1
else:
j -= 1
def threeSum(self, arr):
self.res = 0
arr.sort()
for i in range(len(arr)-2):
if (i==0) or (i and arr[i] != arr[i-1]):
if self.twosum(arr, i+1... | code_fim | hard | {
"lang": "python",
"repo": "SupriyoDam/DS-450-python",
"path": "/Two Pointers Problems/Find triplets with zero sum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # if log_s:
# log.TMAKE_LOG_SUCCESS = True
# if log_d == False:
# log.TMAKE_LOG_DEBUG = False
# if log_i == False:
# log.TMAKE_LOG_INFO = False
# if log_e == False:
# log.TMAKE_LOG_ERROR = False
de... | code_fim | hard | {
"lang": "python",
"repo": "tomken/tmake",
"path": "/core/info/tmake_info.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomken/tmake path: /core/info/tmake_info.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import os
import core
from core.cmake_gens.tmake_cmakelists import recover_cmakelists, change_cmakelists_output
from core.info.tmake_path_info import PathInfo
from .tmake_arguments import ArgumentsI... | code_fim | hard | {
"lang": "python",
"repo": "tomken/tmake",
"path": "/core/info/tmake_info.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> from core.info import tmake_builtin
tmake_builtin.TMAKE_CPU_ARCH = arch
self.arch = arch
if "projsmap" in self.param:
del self.param["projsmap"]
self.deps_mgr.clear()
self.deps_mgr.update_arch(arch)
def parse_project(self):
"""parse ... | code_fim | hard | {
"lang": "python",
"repo": "tomken/tmake",
"path": "/core/info/tmake_info.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: molonti/CursoemVideo---Python path: /Mundo01/Python/aula10-035.py
from time import sleep
a = float(input('Insira a medida do primeiro lado do triângulo: '))
b = float(input('<|fim_suffix|>ulo: '))
print('Aguarde ...')
if (a < (b+c) and b < (a+c) and c < (a+b)):
print('Estas medidas satisfazem... | code_fim | medium | {
"lang": "python",
"repo": "molonti/CursoemVideo---Python",
"path": "/Mundo01/Python/aula10-035.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>m a condição de existência de um triângulo.')
else:
print('Estas medidas não podem formar um triângulo.')<|fim_prefix|># repo: molonti/CursoemVideo---Python path: /Mundo01/Python/aula10-035.py
from time import sleep
a = float(input('Insira a medida do primeiro lado do triângulo: '))
b = float(input('... | code_fim | hard | {
"lang": "python",
"repo": "molonti/CursoemVideo---Python",
"path": "/Mundo01/Python/aula10-035.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if currency_from == currency_to:
return 1
factor_from = Currency.objects.get(code__exact=currency_from).factor
factor_to = Currency.objects.get(code__exact=currency_to).factor
return Decimal(factor_to / factor_from).quantize(Decimal('0.00001'), ROUND_UP)
def get_symbol(currency):... | code_fim | hard | {
"lang": "python",
"repo": "jmp0xf/django-currencies",
"path": "/currencies/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jmp0xf/django-currencies path: /currencies/utils.py
from decimal import Decimal, ROUND_UP
from currencies.models import Currency
def calculate_price(price, currency):
price = Decimal(price)
currency = Currency.objects.get(code__exact=currency)
default = Currency.objects.get(is_defau... | code_fim | hard | {
"lang": "python",
"repo": "jmp0xf/django-currencies",
"path": "/currencies/utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert result == '''\
<p><bukvitsa>Н</bukvitsa>о даждь изводство<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup> и крепость</p>
<div class="footnote">
<hr>
<ol>
<li id="fn:1">
<p>избытие <a class="footnote-backref" href="#fnref:1" title="Jump back to footnote 1 in the text">V... | code_fim | hard | {
"lang": "python",
"repo": "slavonic/cumd",
"path": "/cumd/test/test_cumd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: slavonic/cumd path: /cumd/test/test_cumd.py
from cumd.cumd import cumd
def test_smoke():
result = cumd('''
# Hello
~Some text with ~some red bukvas
''')
assert result == '''<h1>Hello</h1>
<p><red>S</red>ome text with <red>s</red>ome red bukvas</p>\
'''
def test_digraph():
result = ... | code_fim | hard | {
"lang": "python",
"repo": "slavonic/cumd",
"path": "/cumd/test/test_cumd.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_anchor():
result = cumd('''
+Оу҆слы́шахъ, =гдⷭ҇и=+, <<84>>смотре́нїѧ твоегѡ̀ та́инство...
''')
assert result == '''\
<p><wide>Оу҆слы́шахъ, <red>гдⷭ҇и</red></wide>, <anchor label="84" page="84"></anchor>смотре́нїѧ твоегѡ̀ та́инство...</p>\
'''
def test_verse_anchor():
result = cumd(''... | code_fim | hard | {
"lang": "python",
"repo": "slavonic/cumd",
"path": "/cumd/test/test_cumd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return len(self.dataset)
def __getitem__(self, item):
return self.dataset.get_item(item, predict_hw=self.predict_hw, rescale_hw=self.img_hw, return_img_data=True,
exist_merge=True, keep_pixelunit=True, use_special_type=True, ignore_unknow_label=Fal... | code_fim | hard | {
"lang": "python",
"repo": "One-sixth/konohana_net",
"path": "/_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: One-sixth/konohana_net path: /_test.py
from like_fcos.Detector import Detector
from konohana_det_dataset2 import KonohanaDataset
import config.a_config as cfg
from torch.utils.data.dataset import Dataset
from torch.utils.data.dataloader import DataLoader
from progressbar import progressbar
impor... | code_fim | hard | {
"lang": "python",
"repo": "One-sixth/konohana_net",
"path": "/_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Build the command with mandatory params
cmd = 'gbp %s-update ' % cfgobj_dict[cfgobj] + str(name_uuid)
# Build the cmd string for optional/non-default args/values
for arg, value in six.iteritems(attr):
if '_' in arg:
arg = string.replace(arg, '_... | code_fim | hard | {
"lang": "python",
"repo": "mr-smart/group-based-policy",
"path": "/gbpservice/tests/contrib/gbpfunctests/libs/config_libs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mr-smart/group-based-policy path: /gbpservice/tests/contrib/gbpfunctests/libs/config_libs.py
, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import command... | code_fim | hard | {
"lang": "python",
"repo": "mr-smart/group-based-policy",
"path": "/gbpservice/tests/contrib/gbpfunctests/libs/config_libs.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def gbp_del_all_anyobj(self, cfgobj):
"""
This function deletes all entries for any policy-object
"""
cfgobj_dict = {"action": "policy-action",
"classifier": "policy-classifier",
"rule": "policy-rule",
... | code_fim | hard | {
"lang": "python",
"repo": "mr-smart/group-based-policy",
"path": "/gbpservice/tests/contrib/gbpfunctests/libs/config_libs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>就爬Orz','我爪巴','你给爷爬OuO','呜呜呜别骂了 再骂BOT就傻了TAT','就不爬>_<','欺负可爱BOT 建议超级加倍TuT']
index = random.randint(0,len(str)-1)
await session.send(str[index])
# @on_command('图来',only_to_me = False)
# async def _ (session:CommandSession):
# await asyncio.sleep(0.2)
# #await session.send('[CQ:]')<|fim_prefi... | code_fim | medium | {
"lang": "python",
"repo": "chenxuan353/tweetToBot",
"path": "/plugins/zhuaba.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenxuan353/tweetToBot path: /plugins/zhuaba.py
from nonebot import on_command, CommandSession
import asyncio
import json
import random
# on_command 装饰器将函数声明为一个命令处理器
@on_command('爪巴',only_to_me =<|fim_suffix|>就爬Orz','我爪巴','你给爷爬OuO','呜呜呜别骂了 再骂BOT就傻了TAT','就不爬>_<','欺负可爱BOT 建议超级加倍TuT']
index = ra... | code_fim | medium | {
"lang": "python",
"repo": "chenxuan353/tweetToBot",
"path": "/plugins/zhuaba.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __enter__(self):
if self.level is not None:
self.old_level = self.logger.level
self.logger.setLevel(self.level)
if self.handler:
self.logger.addHandler(self.handler)
def __exit__(self, et, ev, tb):
if self.level is not None:
... | code_fim | hard | {
"lang": "python",
"repo": "rainbow-mind-machine/rainbow-mind-machine",
"path": "/tests/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rainbow-mind-machine/rainbow-mind-machine path: /tests/utils.py
import sys
from contextlib import contextmanager
from io import StringIO
import logging
@contextmanager
def captured_output():
"""
https://stackoverflow.com/a/17981937
"""
new_out, new_err = StringIO(), StringIO()
... | code_fim | hard | {
"lang": "python",
"repo": "rainbow-mind-machine/rainbow-mind-machine",
"path": "/tests/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.level is not None:
self.old_level = self.logger.level
self.logger.setLevel(self.level)
if self.handler:
self.logger.addHandler(self.handler)
def __exit__(self, et, ev, tb):
if self.level is not None:
self.logger.setLevel(... | code_fim | hard | {
"lang": "python",
"repo": "rainbow-mind-machine/rainbow-mind-machine",
"path": "/tests/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if c in countries:
res = countries[c]
else:
url = 'https://affiliation-matcher.staging.dataesr.ovh/match'
param = {'type': 'country', 'query': c, 'verbose': False}
r = requests.post(url, json=param)
res = r.json()
countries[c] = res
if 'highlight... | code_fim | medium | {
"lang": "python",
"repo": "dataesr/harvest-orcid",
"path": "/project/server/main/diaspora/country.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dataesr/harvest-orcid path: /project/server/main/diaspora/country.py
import requests
import pickle
import os
from project.server.main.logger import get_logger
logger = get_logger(__name__)
countries = {}
try:
countries = pickle.load(open('/upw_data/countries.pkl', 'rb'))
logger.debug(f'... | code_fim | hard | {
"lang": "python",
"repo": "dataesr/harvest-orcid",
"path": "/project/server/main/diaspora/country.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_country(c):
if c in countries:
res = countries[c]
else:
url = 'https://affiliation-matcher.staging.dataesr.ovh/match'
param = {'type': 'country', 'query': c, 'verbose': False}
r = requests.post(url, json=param)
res = r.json()
countries[c] = r... | code_fim | hard | {
"lang": "python",
"repo": "dataesr/harvest-orcid",
"path": "/project/server/main/diaspora/country.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#http://adventuresinmachinelearning.com/reinforcement-learning-tutorial-python-keras/
# TODO handle collisions
# TODO optimize speed
renderer.finish()<|fim_prefix|># repo: AI-Guru/RTSDRL path: /sandbox.py
import time
from rtsdrl import Environment, Entity, Harvester, Resource, PyGameRenderer
<|fim_mi... | code_fim | hard | {
"lang": "python",
"repo": "AI-Guru/RTSDRL",
"path": "/sandbox.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AI-Guru/RTSDRL path: /sandbox.py
import time
from rtsdrl import Environment, Entity, Harvester, Resource, PyGameRenderer
# Create the environment and add some entities.
environment = Environment()
environment.add_entity(Harvester(50.0, 50.0, "harvester1"))
environment.add_entity(Harvester(150.0... | code_fim | hard | {
"lang": "python",
"repo": "AI-Guru/RTSDRL",
"path": "/sandbox.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class IsAnnotator(RolePermission):
unsafe_methods_check = False
role_name = settings.ROLE_ANNOTATOR
class IsAnnotationApproverAndReadOnly(RolePermission):
role_name = settings.ROLE_ANNOTATION_APPROVER
class IsAnnotationApprover(RolePermission):
unsafe_methods_check = False
role_na... | code_fim | hard | {
"lang": "python",
"repo": "doccano/doccano",
"path": "/backend/projects/permissions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: doccano/doccano path: /backend/projects/permissions.py
from django.conf import settings
from rest_framework.permissions import SAFE_METHODS, BasePermission
from .models import Member
class RolePermission(BasePermission):
UNSAFE_METHODS = ("POST", "PATCH", "DELETE")
unsafe_methods_check... | code_fim | medium | {
"lang": "python",
"repo": "doccano/doccano",
"path": "/backend/projects/permissions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarcoMontaltoMonella/RxPY path: /rx/core/observable/onerrorresumenext.py
import rx
from rx.concurrency import current_thread_scheduler
from rx.core import Observable
from rx.disposable import CompositeDisposable, SingleAssignmentDisposable, SerialDisposable
from rx.internal.utils import is_future... | code_fim | hard | {
"lang": "python",
"repo": "MarcoMontaltoMonella/RxPY",
"path": "/rx/core/observable/onerrorresumenext.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> d = SingleAssignmentDisposable()
subscription.disposable = d
def on_resume(state=None):
scheduler.schedule(action, state)
d.disposable = current.subscribe_(observer.on_next, on_resume, on_resume, scheduler)
cancelable.disposable = ... | code_fim | hard | {
"lang": "python",
"repo": "MarcoMontaltoMonella/RxPY",
"path": "/rx/core/observable/onerrorresumenext.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HeyIamJames/CodingInterviewPractice path: /Convert_Array.py
"""
Given an array:
[a_1, a_2, ..., a_N, b_1, b_2, ..., b_N, c_1, c_2, ..., c_N ]
convert it to:
[a_1, b_1, c_1, a_2, b_2, c_2, ..., a_N, b_N, c_N]
"""
<|fim_suffix|>return zip(l[0:len(l)/3],l[len(l)/3:2*len(l)/3],l[2*len(l)/3:])<|f... | code_fim | easy | {
"lang": "python",
"repo": "HeyIamJames/CodingInterviewPractice",
"path": "/Convert_Array.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>return zip(l[0:len(l)/3],l[len(l)/3:2*len(l)/3],l[2*len(l)/3:])<|fim_prefix|># repo: HeyIamJames/CodingInterviewPractice path: /Convert_Array.py
"""
Given an array:
[a_1, a_2, ..., a_N, b_1, b_2, ..., b_N, c_1, c_2, ..., c_N ]
convert it to:
[a_1, b_1, c_1, a_2, b_2, c_2, ..., a_N, b_N, c_N]
"""
<|f... | code_fim | easy | {
"lang": "python",
"repo": "HeyIamJames/CodingInterviewPractice",
"path": "/Convert_Array.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for idx in range(1, len(metadata)):
for strain, row in metadata[ idx ][ 'data' ].items():
if strain not in combined_data:
combined_data[ strain ] = {c: EMPTY for c in combined_columns}
for column in combined_columns:
if column in row:
... | code_fim | hard | {
"lang": "python",
"repo": "abnsy/spheres-augur-build",
"path": "/scripts/combine_metadata.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # READ IN METADATA FILES
metadata = [ ]
for (origin, fname) in zip(args.origins, args.metadata):
data, columns = read_metadata(fname)
metadata.append(
{'origin': origin, "fname": fname, 'data': data, 'columns': columns, 'strains': {s for s in data.keys()}})
# S... | code_fim | hard | {
"lang": "python",
"repo": "abnsy/spheres-augur-build",
"path": "/scripts/combine_metadata.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abnsy/spheres-augur-build path: /scripts/combine_metadata.py
import argparse
from augur.utils import read_metadata
from Bio import SeqIO
import csv
import sys
EMPTY = ''
# This script was written in preparation for a future augur where commands
# may take multiple metadata files, thus making t... | code_fim | hard | {
"lang": "python",
"repo": "abnsy/spheres-augur-build",
"path": "/scripts/combine_metadata.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: omegachysis/arche-engine path: /arche/motion/actout.py
from arche.motion.action import Action
import logging
log = logging.getLogger("R.Engine.Motion")
class Disappear(Action):
<|fim_suffix|> pass
def update(self, dt):
self.sprite.alpha = 0
self.sprite.hide()
... | code_fim | medium | {
"lang": "python",
"repo": "omegachysis/arche-engine",
"path": "/arche/motion/actout.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.sprite.alpha = 0
self.sprite.hide()
self.finish()<|fim_prefix|># repo: omegachysis/arche-engine path: /arche/motion/actout.py
from arche.motion.action import Action
<|fim_middle|>import logging
log = logging.getLogger("R.Engine.Motion")
class Disappear(Action):
name =... | code_fim | hard | {
"lang": "python",
"repo": "omegachysis/arche-engine",
"path": "/arche/motion/actout.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: omegachysis/arche-engine path: /arche/motion/actout.py
from arche.motion.action import Action
<|fim_suffix|> name = "out.appear"
def __init__(self, sprite):
super(Disappear, self).__init__(sprite)
def begin(self):
pass
def update(self, dt):
self.sprite.a... | code_fim | medium | {
"lang": "python",
"repo": "omegachysis/arche-engine",
"path": "/arche/motion/actout.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: s-ilic/gdm_class_public path: /scripts/many_times.py
# coding: utf-8
# In[ ]:
# import necessary modules
# uncomment to get plots displayed in notebook
# uncomment to get plots displayed in notebook
#%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from c... | code_fim | hard | {
"lang": "python",
"repo": "s-ilic/gdm_class_public",
"path": "/scripts/many_times.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>,\, \mathrm{cross.}$',
xy=(background_ks_at_tau(tau_label_ks),tau_label_ks),
xytext=(0.07*background_aH_at_tau(tau_label_ks),0.8*tau_label_ks),
arrowprops=dict(facecolor='black', shrink=0.05, width=1, headlength=5, headwidth=5))
ax_Theta.annotate(r'$\m... | code_fim | hard | {
"lang": "python",
"repo": "s-ilic/gdm_class_public",
"path": "/scripts/many_times.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.