code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
<|reserved_special_token_0|>
class FocalLoss(nn.Module):
"""https://www.kaggle.com/c/human-protein-atlas-image-classification/discussion/78109"""
def __init__(self, gamma=2):
super().__init__()
self.gamma = gamma
def forward(self, logit, target):
target = target.float()
m... | flexible | {
"blob_id": "9e9303d58c7e091bf7432060fad292c16ecf85ee",
"index": 9280,
"step-1": "<mask token>\n\n\nclass FocalLoss(nn.Module):\n \"\"\"https://www.kaggle.com/c/human-protein-atlas-image-classification/discussion/78109\"\"\"\n\n def __init__(self, gamma=2):\n super().__init__()\n self.gamma =... | [
4,
6,
7,
8,
9
] |
from pygraphblas.matrix import Matrix
from pygraphblas.types import BOOL
from pyformlang.regular_expression import Regex
class Graph:
def __init__(self):
self.n_vertices = 0
self.label_matrices = dict()
self.start_vertices = set()
self.final_vertices = set()
def from_trans(se... | normal | {
"blob_id": "2ccc3bb63445572610f6dbdfe5b1cbeef506c9a9",
"index": 8613,
"step-1": "<mask token>\n\n\nclass Graph:\n <mask token>\n <mask token>\n <mask token>\n\n def transitive_closure_1(self):\n adj_matrix = Matrix.sparse(BOOL, self.n_vertices, self.n_vertices)\n for label_matrix in se... | [
3,
5,
8,
9
] |
<|reserved_special_token_0|>
def load_path():
path = os.path.join(os.path.dirname(__file__))
if path == '':
path = '.'
return path
def create_folder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print('Issue: Creatin... | flexible | {
"blob_id": "cab233976653b8135276ff849955f32766833354",
"index": 7555,
"step-1": "<mask token>\n\n\ndef load_path():\n path = os.path.join(os.path.dirname(__file__))\n if path == '':\n path = '.'\n return path\n\n\ndef create_folder(directory):\n try:\n if not os.path.exists(directory):... | [
3,
4,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(1, n + 1):
print(i)
<|reserved_special_token_1|>
n = int(input('nhap gia tri'))
for i in range(1, n + 1):
print(i)
<|reserved_special_token_1|>
n =int(input("nhap gia tri"))
for i in range(1,n+1):
... | flexible | {
"blob_id": "21b295e28a7e4443ea116df1b22ff5074dca955a",
"index": 246,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, n + 1):\n print(i)\n",
"step-3": "n = int(input('nhap gia tri'))\nfor i in range(1, n + 1):\n print(i)\n",
"step-4": "n =int(input(\"nhap gia tri\"))\nfor i in... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(response.status_code)
print(response.apparent_encoding)
<|reserved_special_token_0|>
for music in list_music:
print(music['name'])
print('所属专辑:' + music['album']['name'])
print('歌曲时长:' + str(music['interval']) + ... | flexible | {
"blob_id": "9833af7f5f740e18cbd4d16f59474b4bacaf070c",
"index": 2026,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(response.status_code)\nprint(response.apparent_encoding)\n<mask token>\nfor music in list_music:\n print(music['name'])\n print('所属专辑:' + music['album']['name'])\n print('歌... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
modulus_size = 2048
n, e = 0, 0
k = modulus_size // 8
queries = 0
print_queries_every = 1
number_of_time_to_confirm_conforming = 10
encrypt_openssl = True
t_start = 0
cwd = ''
host = '10.0.0.1'
port = 4430
sock = 0
max_message_size = 2048
<|reserved_special... | flexible | {
"blob_id": "415d58e502e8a33f7a37c4fb2da34e838246ea9c",
"index": 2057,
"step-1": "<mask token>\n",
"step-2": "modulus_size = 2048\nn, e = 0, 0\nk = modulus_size // 8\nqueries = 0\nprint_queries_every = 1\nnumber_of_time_to_confirm_conforming = 10\nencrypt_openssl = True\nt_start = 0\ncwd = ''\nhost = '10.0.0.1... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
sys.path.append(os.pardir)
<|reserved_special_token_0|>
for i in range(iters_num):
print(i)
batch_mask = np.random.choice(train_size, batch_size)
x_batch = x_train[batch_mask]
t_batch = t_train[batch_mask]
grad... | flexible | {
"blob_id": "dbe3aa107de8e62822803d1740773a4b22f41edf",
"index": 971,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.append(os.pardir)\n<mask token>\nfor i in range(iters_num):\n print(i)\n batch_mask = np.random.choice(train_size, batch_size)\n x_batch = x_train[batch_mask]\n t_batc... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python3
import os, re
import csv, unittest
from langtag import langtag
from sldr.iana import Iana
langtagjson = os.path.join(os.path.dirname(__file__), '..', 'pub', 'langtags.json')
bannedchars = list(range(33, 45)) + [47] + list(range(58, 63)) + [94, 96]
def nonascii(s):
cs = [ord(x) for x in s]
i... | normal | {
"blob_id": "e4f194c3dbc3e1d62866343642e41fa1ecdeab93",
"index": 7380,
"step-1": "<mask token>\n\n\nclass Basic(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def _region_test(self, x):\n if x in self.iana.region:\n return True\n elif x in ('XX', 'XK'):\... | [
11,
13,
17,
18,
19
] |
from tkinter import *
root = Tk()
photo = PhotoImage(file='flag.png')
panel = Label(root, image=photo)
panel.pack()
root.mainloop()
| normal | {
"blob_id": "2d192963bfe046bce1a0c82e0179380693f5c541",
"index": 9518,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npanel.pack()\nroot.mainloop()\n",
"step-3": "<mask token>\nroot = Tk()\nphoto = PhotoImage(file='flag.png')\npanel = Label(root, image=photo)\npanel.pack()\nroot.mainloop()\n",
"step-... | [
0,
1,
2,
3
] |
import sys
import time
import pymorphy2
import pyglet
import pyttsx3
import threading
import warnings
import pytils
warnings.filterwarnings("ignore")
""" Количество раундов, вдохов в раунде, задержка дыхания на вдохе"""
rounds, breaths, hold = 4, 30, 13
def play_wav(src):
wav = pyglet.media.load(sys.path[0] + '... | normal | {
"blob_id": "a98be930058269a6adbc9a28d1c0ad5d9abba136",
"index": 35,
"step-1": "<mask token>\n\n\ndef nums(phrase, morph=pymorphy2.MorphAnalyzer()):\n \"\"\" согласование существительных с числительными, стоящими перед ними \"\"\"\n phrase = phrase.replace(' ', ' ').replace(',', ' ,')\n numeral = ''\n ... | [
10,
11,
13,
17,
18
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
while a != 0:
t = a % 10
s = s + t
a = a // 10
print(s)
<|reserved_special_token_1|>
a = int(input())
s = 0
t = 0
while a != 0:
t = a % 10
s = s + t
a = a // 10
print(s)
<|reserved_special_token_1|>
a... | flexible | {
"blob_id": "6050e83e73faaf40cbd5455efd3ad01e4e131188",
"index": 2587,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile a != 0:\n t = a % 10\n s = s + t\n a = a // 10\nprint(s)\n",
"step-3": "a = int(input())\ns = 0\nt = 0\nwhile a != 0:\n t = a % 10\n s = s + t\n a = a // 10\npri... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
try:
stack_id = cfn.describe_stacks(StackName='MinecraftInstance')['Stacks'][0][
'StackId']
cfn.delete_stack(StackName=stack_id)
print(f'Deleting Stack: {stack_id}')
except Exception as e:
print('Something ... | flexible | {
"blob_id": "b3fb210bcdec2ed552c37c6221c1f0f0419d7469",
"index": 8478,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n stack_id = cfn.describe_stacks(StackName='MinecraftInstance')['Stacks'][0][\n 'StackId']\n cfn.delete_stack(StackName=stack_id)\n print(f'Deleting Stack: {stack_id}... | [
0,
1,
2,
3,
4
] |
class boxCar:
def __init__(self, *args, **kwargs):
print('print the keyword arguments dictionary {0} by {1}'.format(
kwargs, 'WANGH'))
self.name = kwargs['name']
self.domains = ['BODY', 'PWT', 'INFO', 'ADAS', 'INF']
self.configuration = {}
def addEcu(self, ecu, doma... | flexible | {
"blob_id": "c3fae13b488a717419adb8292597746a383b332c",
"index": 7547,
"step-1": "class boxCar:\n\n def __init__(self, *args, **kwargs):\n print('print the keyword arguments dictionary {0} by {1}'.format(\n kwargs, 'WANGH'))\n self.name = kwargs['name']\n self.domains = ['BODY'... | [
4,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
class data_generator(DataGenerator):
<|reserved_special_token_0|>
def __init__(self, pattern='', is_pre=True, *args, **kwargs):
super(data_generator, self).__init__(*args, **kwargs)
self.pattern = pattern
self.is_pre = is_pre
def __iter__(self, random... | flexible | {
"blob_id": "5cb390b06026bc0899c0b10dc93f3ec1f2ffefa6",
"index": 9727,
"step-1": "<mask token>\n\n\nclass data_generator(DataGenerator):\n <mask token>\n\n def __init__(self, pattern='', is_pre=True, *args, **kwargs):\n super(data_generator, self).__init__(*args, **kwargs)\n self.pattern = pa... | [
3,
4,
6,
7,
8
] |
<|reserved_special_token_0|>
def prune_weights(weight):
for i in range(weight.shape[-1]):
tmp = deepcopy(weight[..., i])
tmp = np.abs(tmp)
tmp = np.sort(np.array(tmp))
threshold = tmp[int(tmp.shape[0] * COMPRESSION_RATE)]
weight[..., i][np.abs(weight[..., i]) < threshold] =... | flexible | {
"blob_id": "086aefaad7a4b743e5a05b3a44db971dbdbf16b6",
"index": 8299,
"step-1": "<mask token>\n\n\ndef prune_weights(weight):\n for i in range(weight.shape[-1]):\n tmp = deepcopy(weight[..., i])\n tmp = np.abs(tmp)\n tmp = np.sort(np.array(tmp))\n threshold = tmp[int(tmp.shape[0] ... | [
2,
4,
5,
6,
10
] |
<|reserved_special_token_0|>
class Settings:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Settings:
<|reserved_special_token_0|>
def __init__(self):
self.colour = 230, 230, 230
self.screen_width = 1200
... | flexible | {
"blob_id": "2402188380bc0189b88e3cfcbaabf64a9919b3d5",
"index": 8810,
"step-1": "<mask token>\n\n\nclass Settings:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Settings:\n <mask token>\n\n def __init__(self):\n self.colour = 230, 230, 230\n self.screen_width =... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
while message != 'quit':
message = input(prompt)
if message != 'quit':
print(message)
<|reserved_special_token_0|>
while active:
message = input(prompt)
if message == 'quit':
active = False
else... | flexible | {
"blob_id": "1a6f84835ec2f5fbbb064aef2cd872c24eb3839d",
"index": 8717,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile message != 'quit':\n message = input(prompt)\n if message != 'quit':\n print(message)\n<mask token>\nwhile active:\n message = input(prompt)\n if message == 'quit... | [
0,
1,
2,
3
] |
import matplotlib.pyplot as plt
import numpy as np
steps = 10
num_tests = 100
res = []
with open('txt.txt', 'r') as f:
data = f.readlines()
line = 0
for i in range(10, 110, 10):
agg = 0
for j in range(num_tests):
agg += int(data[line])
line += 1
res.append(... | normal | {
"blob_id": "176ffac7ad47f5c43a24acc664631f8353ec5100",
"index": 967,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('txt.txt', 'r') as f:\n data = f.readlines()\n line = 0\n for i in range(10, 110, 10):\n agg = 0\n for j in range(num_tests):\n agg += int(data[... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class Bunker(Sprite):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def blitme(self):
"""Draw the ship at its current location"""
self.screen.blit(self.image, self.rect)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Bunker(Sp... | flexible | {
"blob_id": "d088aadc4d88267b908c4f6de2928c812ef36739",
"index": 1603,
"step-1": "<mask token>\n\n\nclass Bunker(Sprite):\n <mask token>\n <mask token>\n\n def blitme(self):\n \"\"\"Draw the ship at its current location\"\"\"\n self.screen.blit(self.image, self.rect)\n",
"step-2": "<mask... | [
2,
3,
4,
5,
6
] |
def formula(a,b):
if(b == 0):
print "You can not divide by zero"
else:
return (a+b)/b
print formula(4,4)
print formula(2,0)
| normal | {
"blob_id": "dffd575b9d5b763abdbce6f88586c183b71086c4",
"index": 7701,
"step-1": "def formula(a,b):\n if(b == 0):\n print \"You can not divide by zero\"\n else:\n return (a+b)/b \n\n\nprint formula(4,4)\nprint formula(2,0)\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": ... | [
0
] |
import redis
r = redis.StrictRedis()
r.set("counter", 40)
print(r.get("counter"))
print(r.incr("counter"))
print(r.incr("counter"))
print(r.get("counter"))
| normal | {
"blob_id": "b38c9357030b2eac8298743cfb4d6c4d58c99ed4",
"index": 7463,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nr.set('counter', 40)\nprint(r.get('counter'))\nprint(r.incr('counter'))\nprint(r.incr('counter'))\nprint(r.get('counter'))\n",
"step-3": "<mask token>\nr = redis.StrictRedis()\nr.set('c... | [
0,
1,
2,
3,
4
] |
def readint(): return int(raw_input())
T = readint()
for t in xrange(T):
N = int(raw_input())
res = 0
sum = 0
min = 1000000
for i in raw_input().split():
r = int(i)
res ^= r
sum += r
if min > r: min = r
if res == 0:
sum -= min
print "Case #%d: %s" % (t + 1, sum)
else:
print "Case ... | normal | {
"blob_id": "81a1fbd13b06e4470bfbaa0d1716d5301e1a4b36",
"index": 1035,
"step-1": "def readint(): return int(raw_input())\r\n\r\nT = readint()\r\nfor t in xrange(T):\r\n\tN = int(raw_input())\r\n\tres = 0\r\n\tsum = 0\r\n\tmin = 1000000\r\n\tfor i in raw_input().split():\r\n\t\tr = int(i)\r\n\t\tres ^= r\r\n\t\ts... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for d in tests:
d['code'] = d['prompt'] == 'code'
d['correct'] = d['accuracy'] * d['trials']
p = d['accuracy']
d['err'] = 0.842 * math.sqrt(p * (1 - p) / d['trials'])
<|reserved_special_token_0|>
plt.style.use('dar... | flexible | {
"blob_id": "6b6397fd18848ffa2ae9c0ec1443d20f2cbeb8b0",
"index": 3637,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor d in tests:\n d['code'] = d['prompt'] == 'code'\n d['correct'] = d['accuracy'] * d['trials']\n p = d['accuracy']\n d['err'] = 0.842 * math.sqrt(p * (1 - p) / d['trials'])\... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class PasswordGenerator:
<|reserved_special_token_0|>
def __init__(self, length, *, uppercase=True, lowercase=True, digits=
True, special=True):
self.length = length
self.uppercase = uppercase
self.lowercase = lowercase
self.digits = digits... | flexible | {
"blob_id": "eafe89de10c4187057b0cc1e0e9772f03a576b0d",
"index": 9771,
"step-1": "<mask token>\n\n\nclass PasswordGenerator:\n <mask token>\n\n def __init__(self, length, *, uppercase=True, lowercase=True, digits=\n True, special=True):\n self.length = length\n self.uppercase = upperca... | [
4,
6,
10,
12,
13
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
DEFAULT_LL_URL = 'https://ll.thespacedevs.com'
DEFAULT_VERSION = '2.0.0'
DEFAULT_API_URL = '/'.join([DEFAULT_LL_URL, DEFAULT_VERSION])
<|reserved_special_token_1|>
DEFAULT_LL_URL = "https://ll.thespacedevs.com"
DEFAULT_VERSION = "2.0.0"
DEFAULT_API_URL = "... | flexible | {
"blob_id": "1a72da7f436e6c5e73e396b771f8ce1a3affba1a",
"index": 3010,
"step-1": "<mask token>\n",
"step-2": "DEFAULT_LL_URL = 'https://ll.thespacedevs.com'\nDEFAULT_VERSION = '2.0.0'\nDEFAULT_API_URL = '/'.join([DEFAULT_LL_URL, DEFAULT_VERSION])\n",
"step-3": "DEFAULT_LL_URL = \"https://ll.thespacedevs.com\... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class WSMessage:
def __init__(self, command: str, data: any=None) ->None:
self.command = command
self.data = data
<|reserved_special_token_0|>
def dictData(self) ->dict:
return self.data
<|reserved_special_token_1|>
<|reserved_special_token_0|>
c... | flexible | {
"blob_id": "d4621ef378b89490278c09e569f781aef1fcef3f",
"index": 7013,
"step-1": "<mask token>\n\n\nclass WSMessage:\n\n def __init__(self, command: str, data: any=None) ->None:\n self.command = command\n self.data = data\n <mask token>\n\n def dictData(self) ->dict:\n return self.d... | [
3,
4,
5,
6
] |
class cal4:
def setdata(self, n1):
self.n1 = n1
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class cal4:
def setdata(self, n1):
self.n1 = n1
def display(self):
return n1 * n1
<|reserved_special_token_0|>
<|reserved_special_tok... | flexible | {
"blob_id": "65b90fccd0ee74b369475aa9fe33f159881c8b82",
"index": 6645,
"step-1": "class cal4:\n\n def setdata(self, n1):\n self.n1 = n1\n <mask token>\n\n\n<mask token>\n",
"step-2": "class cal4:\n\n def setdata(self, n1):\n self.n1 = n1\n\n def display(self):\n return n1 * n1\... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
@norecursion
def configuration(localization, *varargs, **kwargs):
global module_type_store
str_32070 = get_builtin_python_type_instance(stypy.reporting.
localization.Localization(__file__, 9, 33), 'str', '')
None_32071 = module_type_store.get_type_of(stypy.reporting.lo... | flexible | {
"blob_id": "4453b8176cda60a3a8f4800860b87bddfdb6cafa",
"index": 7963,
"step-1": "<mask token>\n\n\n@norecursion\ndef configuration(localization, *varargs, **kwargs):\n global module_type_store\n str_32070 = get_builtin_python_type_instance(stypy.reporting.\n localization.Localization(__file__, 9, 3... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
@app.route('/healthz')
def healthz():
return 'ok'
@app.route('/alive')
def alive():
return 'ok'
@app.route('/hello')
def hello():
myhost = os.uname()[1]
body = 'V1 - Hello World! - %s' % myhost
return body
<|reserved_special_token_0|>
<|reserved_special_token_1... | flexible | {
"blob_id": "0259fddbe3ce030030a508ce7118a6a03930aa51",
"index": 7375,
"step-1": "<mask token>\n\n\n@app.route('/healthz')\ndef healthz():\n return 'ok'\n\n\n@app.route('/alive')\ndef alive():\n return 'ok'\n\n\n@app.route('/hello')\ndef hello():\n myhost = os.uname()[1]\n body = 'V1 - Hello World! -... | [
3,
4,
5,
6,
7
] |
# -*- coding:utf-8 -*-
from spider.driver.spider.base.spider import *
class LvmamaHotelSpider(Spider):
def get_comment_info2(self,shop_data):
params_list_comment1 = self.params_dict.get(ParamType.COMMENT_INFO_1)
comment_len = shop_data.get(FieldName.SHOP_COMMENT_NUM)
while(True):
... | normal | {
"blob_id": "931e73ffce6d24dbfb92501670245e20fc403a7a",
"index": 7969,
"step-1": "<mask token>\n\n\nclass LvmamaHotelSpider(Spider):\n\n def get_comment_info2(self, shop_data):\n params_list_comment1 = self.params_dict.get(ParamType.COMMENT_INFO_1)\n comment_len = shop_data.get(FieldName.SHOP_CO... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class Event(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Event(object):
<|reserved_special_token_0|>
def to_dict(self):
d = {}
for item in self.__dict__:
... | flexible | {
"blob_id": "7554b00f8c4d40f1d3ee2341f118048ca7ad10ea",
"index": 709,
"step-1": "<mask token>\n\n\nclass Event(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Event(object):\n <mask token>\n\n def to_dict(self):\n d = {}\n for item in self.__dict__:\n ... | [
1,
2,
3,
4
] |
from __future__ import print_function
import os
from twisted.internet.task import react
from twisted.internet.defer import Deferred, inlineCallbacks
from twisted.internet.protocol import Factory
from twisted.internet.protocol import Protocol
from twisted.internet.endpoints import TCP4ClientEndpoint, connectProtocol
f... | normal | {
"blob_id": "532bcf8ae0ee40dc3eb4bd7170acfcb5d21cc4b9",
"index": 1984,
"step-1": "<mask token>\n\n\nclass StdIOFactory(Factory):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass StandardInput(LineReceiver, StandardIO):\n \"\"\"\n Reads stdin and writes every line received as a message to th... | [
7,
12,
13,
14,
16
] |
<|reserved_special_token_0|>
def checkuser(username, password, cursor, user_db):
cursor.execute('select * from %s WHERE username = %d AND password = %d' %
(user_db, int(username), int(password)))
return cursor.fetchall()
def tcplink(sock, addr):
conn = pymysql.connect()
cursor = conn.cursor(... | flexible | {
"blob_id": "758e5b9a65132c4bdee4600e79c27f9c0f272312",
"index": 8308,
"step-1": "<mask token>\n\n\ndef checkuser(username, password, cursor, user_db):\n cursor.execute('select * from %s WHERE username = %d AND password = %d' %\n (user_db, int(username), int(password)))\n return cursor.fetchall()\n\... | [
2,
3,
4,
5,
6
] |
import requests
import re
from bs4 import BeautifulSoup
r = requests.get("https://terraria.fandom.com/wiki/Banners_(enemy)")
soup = BeautifulSoup(r.text, 'html.parser')
list_of_banners = soup.find_all('span', {'id': re.compile(r'_Banner')})
x_count = 1
y_count = 1
for banner_span in list_of_banners:
print(f"{banner... | normal | {
"blob_id": "e60d57e8884cba8ce50a571e3bd0affcd4dcaf68",
"index": 4056,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor banner_span in list_of_banners:\n print(f\"{banner_span['id']}, {x_count}, {y_count}\")\n x_count += 1\n if x_count == 51:\n x_count = 1\n y_count += 1\n ... | [
0,
1,
2,
3,
4
] |
def guguPrint(n):
print('*' * 30)
for i in range(1, 10):
print('{} X {} = {}'.format(n, i, n * i))
if __name__ =="__main__":
print('Main으로 실행되었음') | normal | {
"blob_id": "aa2e24d80789f2a6ebd63ec42a17499f1e79ca49",
"index": 5237,
"step-1": "<mask token>\n",
"step-2": "def guguPrint(n):\n print('*' * 30)\n for i in range(1, 10):\n print('{} X {} = {}'.format(n, i, n * i))\n\n\n<mask token>\n",
"step-3": "def guguPrint(n):\n print('*' * 30)\n for ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Sender:
def __init__(self, reverseMap, info):
self.reverseMap = reverseMap
self.info = info
def sendMessage(self, message):
data = {'timestamp': message.timestamp, 'message': message.message}
body = json.dumps(data).encode('utf-8')
h... | flexible | {
"blob_id": "67446f50d1c062eddcad282d3bf508967c5192fc",
"index": 4905,
"step-1": "<mask token>\n\n\nclass Sender:\n\n def __init__(self, reverseMap, info):\n self.reverseMap = reverseMap\n self.info = info\n\n def sendMessage(self, message):\n data = {'timestamp': message.timestamp, 'm... | [
9,
12,
13,
15,
16
] |
class Solution:
def minRemoveToMakeValid(self, s: str) -> str:
bracketsToRemove = set()
stack = []
for i, c in enumerate(s):
if c not in '()':
continue
if c == '(':
stack.append(i)
elif not stack:
... | normal | {
"blob_id": "1bab6b039462bb5762aa588d5ba7c3e74362d0a7",
"index": 823,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n",
"step-3": "class Solution:\n\n def minRemoveToMakeValid(self, s: str) ->str:\n bracketsToRemove = set()\n stack = []\n f... | [
0,
1,
2,
3,
4
] |
import inspect
import json
import socket
import sys
import execnet
import logging
from remoto.process import check
class BaseConnection(object):
"""
Base class for Connection objects. Provides a generic interface to execnet
for setting up the connection
"""
executable = ''
remote_import_system... | normal | {
"blob_id": "ae38995d153deed2e6049b7b65fb5f28dfcef470",
"index": 1442,
"step-1": "<mask token>\n\n\nclass BaseConnection(object):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, hostname, logger=None, sudo=False, threads=1, eager=\n True, detect_sudo=False, use_ssh=False, i... | [
19,
23,
27,
30,
31
] |
<|reserved_special_token_0|>
class CifarResNeXt(nn.Module):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class ResNeXtBottleneck(nn.Modul... | flexible | {
"blob_id": "50ed1512b0e6ff8e01f5d4aa034406fa78850176",
"index": 2293,
"step-1": "<mask token>\n\n\nclass CifarResNeXt(nn.Module):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass ResNeXtBottleneck(nn.Module):\n <mask token>\n\n... | [
1,
8,
10,
11,
13
] |
<|reserved_special_token_0|>
class GameBoard:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def draw(self):
self.playerSprites.draw()
self.groundSprites.draw()
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def moveGamePiece(self, gamePiece: gp.GamePiec... | flexible | {
"blob_id": "2d7431996bc8d1099c08fddc815b4706deb4f023",
"index": 4393,
"step-1": "<mask token>\n\n\nclass GameBoard:\n <mask token>\n <mask token>\n\n def draw(self):\n self.playerSprites.draw()\n self.groundSprites.draw()\n <mask token>\n <mask token>\n\n def moveGamePiece(self, ... | [
7,
12,
13,
17,
18
] |
from application.routes import pad_num, tracking_gen
from flask import url_for
from flask_testing import TestCase
from application import app, db
from application.models import Users, Orders
from os import getenv
class TestCase(TestCase):
def create_app(self):
app.config.update(
SQLALCHEMY_DA... | normal | {
"blob_id": "eeece3bf423f85f05ef11db47909215578e64aec",
"index": 4912,
"step-1": "<mask token>\n\n\nclass TestViews(TestCase):\n <mask token>\n\n def test_add_order_get(self):\n response = self.client.get(url_for('add_order'))\n self.assertEqual(response.status_code, 200)\n\n def test_view... | [
20,
27,
32,
33,
34
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
m.choropleth(geo_data=json, name='choropleth', data=data, columns=['State',
'Unemployment'], Key_on='feature.id', fill_color='YlGn', fill_opacity=
0.7, line_opacity=0.2, legend_name='Unemployment Rate (%)')
folium.LayerCon... | flexible | {
"blob_id": "382cb55a6b849f0240276d8f45746e995b16d714",
"index": 4455,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nm.choropleth(geo_data=json, name='choropleth', data=data, columns=['State',\n 'Unemployment'], Key_on='feature.id', fill_color='YlGn', fill_opacity=\n 0.7, line_opacity=0.2, legend_... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
chromedriver = os.path.abspath(os.path.dirname(__file__)
) + '\\chromedriver\\' + getchromdriver_version()
download_path = os.path.abspath(os.path.dirname(__file__)) + '\\'
Suffix_name = ['.bin', '.rar', '.zip', '.7z']
<|res... | flexible | {
"blob_id": "5b4a196de60a3a30bc571c559fe5f211563b8999",
"index": 5449,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nchromedriver = os.path.abspath(os.path.dirname(__file__)\n ) + '\\\\chromedriver\\\\' + getchromdriver_version()\ndownload_path = os.path.abspath(os.path.dirname(__file__)) + '\\\\'\nS... | [
0,
1,
2,
3
] |
from tkinter import *
class Menuutje:
def __init__(self, master):
menu = Menu(master)
master.config(menu=menu)
subMenu = Menu(menu)
menu.add_cascade(label="File", menu=subMenu)
subMenu.add_command(label="New Game...", command=self.doNothing)
subMenu.add_command(la... | normal | {
"blob_id": "8fbfa53be826b45b53b530a1766f6a68c61f5be9",
"index": 9377,
"step-1": "from tkinter import *\n\n\nclass Menuutje:\n\n def __init__(self, master):\n menu = Menu(master)\n master.config(menu=menu)\n\n subMenu = Menu(menu)\n menu.add_cascade(label=\"File\", menu=subMenu)\n ... | [
0
] |
<|reserved_special_token_0|>
def get_labelled_data_from_directories(data_dir, maxlen=None):
texts = []
labels_index = {}
labels = []
for name in sorted(os.listdir(data_dir)):
path = os.path.join(data_dir, name)
if os.path.isdir(path):
label_id = len(labels_index)
... | flexible | {
"blob_id": "365e2059d5ed3d7f8d9dbb4e44f563b79d68b087",
"index": 1856,
"step-1": "<mask token>\n\n\ndef get_labelled_data_from_directories(data_dir, maxlen=None):\n texts = []\n labels_index = {}\n labels = []\n for name in sorted(os.listdir(data_dir)):\n path = os.path.join(data_dir, name)\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
INITIAL_B = 0.15062677711161448
B_FACTOR = 5.0
INITIAL_GE = 0.22581915788215678
GE_BOUNDS = [1.0 / 10.0, 1.0 / 4.0]
FIXED_P = 0.9401234488501574
INITIAL_GU = 0.2145066414796447
GU_BOUNDS = [1.0 / 15.0, 1.0 / 2.0]
INITIAL_GI = 0.19235137989123863
GI_BOUNDS = [... | flexible | {
"blob_id": "47cf3045f2fa0f69759e09b1599e4afe953c06d8",
"index": 5138,
"step-1": "<mask token>\n",
"step-2": "INITIAL_B = 0.15062677711161448\nB_FACTOR = 5.0\nINITIAL_GE = 0.22581915788215678\nGE_BOUNDS = [1.0 / 10.0, 1.0 / 4.0]\nFIXED_P = 0.9401234488501574\nINITIAL_GU = 0.2145066414796447\nGU_BOUNDS = [1.0 /... | [
0,
1,
2
] |
<|reserved_special_token_0|>
def nl():
print('\n')
def main():
print('Start')
msg = 'ana i mujica'
msg2 = msg.replace('a', '$')
print(msg)
print(msg2)
ivana = 'ivana'
print(ivana * 2)
fruit = ['banana', 'apple', 'legit']
for i in range(len(fruit)):
print(fruit[i], end... | flexible | {
"blob_id": "b0cdf75ff00d72ada75990dd850546414bc11125",
"index": 1799,
"step-1": "<mask token>\n\n\ndef nl():\n print('\\n')\n\n\ndef main():\n print('Start')\n msg = 'ana i mujica'\n msg2 = msg.replace('a', '$')\n print(msg)\n print(msg2)\n ivana = 'ivana'\n print(ivana * 2)\n fruit =... | [
2,
3,
4,
5,
6
] |
from py.test import raises
from ..lazymap import LazyMap
def test_lazymap():
data = list(range(10))
lm = LazyMap(data, lambda x: 2 * x)
assert len(lm) == 10
assert lm[1] == 2
assert isinstance(lm[1:4], LazyMap)
assert lm.append == data.append
assert repr(lm) == '<LazyMap [0, 1, 2, 3, 4, 5,... | normal | {
"blob_id": "3e7d80fdd1adb570934e4b252bc25d5746b4c68e",
"index": 3912,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_lazymap():\n data = list(range(10))\n lm = LazyMap(data, lambda x: 2 * x)\n assert len(lm) == 10\n assert lm[1] == 2\n assert isinstance(lm[1:4], LazyMap)\n ... | [
0,
1,
2,
3
] |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import xlrd
from enum import Enum
from sklearn import linear_model
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
import statsmodels.formula.api as smf
import statsmodels.api as sm
import statsmodels.formula.a... | normal | {
"blob_id": "a903f9c5cae1c2eb2f40dc8ba29f0625a3d34224",
"index": 9690,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef forward_selected(data, response):\n \"\"\"Linear model designed by forward selection.\n\n Parameters:\n -----------\n data : pandas DataFrame with all possible predict... | [
0,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class RepresentationPane(BasePane):
def __init__(self, setting_dict):
BasePane.__init__(self)
repLayout = QVBoxLayout()
genLayout = QFormLayout()
self.winLenEdit = QLineEdit()
genLayout.addRow(QLabel('Window length (s):'), self.winLenEdit)
... | flexible | {
"blob_id": "88a3c3fad9717675ed13bcbc778d635f6552c4b1",
"index": 8215,
"step-1": "<mask token>\n\n\nclass RepresentationPane(BasePane):\n\n def __init__(self, setting_dict):\n BasePane.__init__(self)\n repLayout = QVBoxLayout()\n genLayout = QFormLayout()\n self.winLenEdit = QLineE... | [
20,
23,
28,
30,
31
] |
import sys
def dir_slash():
slash = '/'
if 'win' in sys.platform:
slash = '\\'
return slash
| normal | {
"blob_id": "b12c8d0cb1cd1e48df6246fe3f16467b2db296e0",
"index": 745,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef dir_slash():\n slash = '/'\n if 'win' in sys.platform:\n slash = '\\\\'\n return slash\n",
"step-3": "import sys\n\n\ndef dir_slash():\n slash = '/'\n if 'w... | [
0,
1,
2
] |
from cell import Cell
from tkinter import messagebox
import time
import fileTools
class Playground:
"""
The playground for the program. All cells are stored here. This object also import/export cells to the playground
:param screen: The screen object.
:param mouse: The mouse object.
... | normal | {
"blob_id": "80d5cc9871ec753fb9239df7680ac62809baa496",
"index": 8177,
"step-1": "<mask token>\n\n\nclass Playground:\n <mask token>\n\n def __init__(self, root, screen, mouse, keyboard):\n self.root = root\n self.screen = screen\n self.mouse = mouse\n self.keyboard = keyboard\n... | [
12,
16,
17,
18,
19
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@pytest.mark.slow
@pytest.mark.skipif('flair' not in sys.modules, reason=
'requires the Flair library')
def test_flair_simple(small_dataset):
flair_model = FlairModel(model_path='ner', entities_to_keep=['PERSON'])
ev... | flexible | {
"blob_id": "813d27e8f9c1a416dab2f891dd71e4791bb92dbb",
"index": 1040,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.mark.slow\n@pytest.mark.skipif('flair' not in sys.modules, reason=\n 'requires the Flair library')\ndef test_flair_simple(small_dataset):\n flair_model = FlairModel(mode... | [
0,
1,
2,
3
] |
import requests
import os
from slugify import slugify as PipSlugify
import shutil
# will install any valid .deb package
def install_debian_package_binary(package_path):
os.system("sudo dpkg -i {package_path}".format(
package_path=package_path
))
os.system("sudo apt-get install -f")
def download_inst... | normal | {
"blob_id": "f546eb40ee8a7308ded62532731561029e5ec335",
"index": 7870,
"step-1": "<mask token>\n\n\ndef download_install_deb(package_path, package_url):\n download_file(package_path, package_url)\n install_debian_package_binary(package_path)\n remove_file(package_path)\n\n\n<mask token>\n\n\ndef write_f... | [
4,
6,
7,
8,
10
] |
"""
Listing 1.36
Python extends the basic grouping syntax to add named groups. Using
names to refer to groups makes it easier to modify the pattern over
time, without having to also modify the code using the match results.
To set the name of a group, use the syntax (?P<name>pattern)
Use groupdict() to retrieve the d... | normal | {
"blob_id": "be6a2e45f735fe578392b03c3030890b6cd5b4bc",
"index": 2865,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n text = 'This is some text -- with punctuation.'\n print(text)\n print()\n patterns = ['^(?P<first_word>\\\\w+)', '(?P<last_word>\\\\w+)\\\\S*$',\n '(?... | [
0,
1,
2,
3,
4
] |
"""
You are given pre-order traversal with a slight modification.
It includes null pointers when a particular node has nil left/right child.
Reconstruct the binary tree with this information.
Ex. [H, B, F, None, None, E, A, None, None, None, C, None, D, None, G, I, None, None, None]
H
/ \
B C
/ \ ... | normal | {
"blob_id": "3aee336956ac6f962c34f51a27dc4abebf2cc7c8",
"index": 8474,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef contruct_tree(pre_order, index=0):\n index += 1\n if index >= len(pre_order):\n raise IndexError('wtf is wrong with you?')\n root = pre_order[index]\n if root i... | [
0,
1,
2,
3
] |
# -*- coding:utf-8 -*-
from common import *
import itertools
def iteration_spider():
max_errors = 5
num_errors = 0
for page in itertools.count(1):
url = 'http://example.webscraping.com/view/-{}'.format(page)
html = download(url)
if html is None:
num_errors += 1
if num_errors == max_errors:
break
... | normal | {
"blob_id": "0eaba8f570772de864f52168a597b47a4150d015",
"index": 5924,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef iteration_spider():\n max_errors = 5\n num_errors = 0\n for page in itertools.count(1):\n url = 'http://example.webscraping.com/view/-{}'.format(page)\n htm... | [
0,
1,
2,
3,
4
] |
#!/usr/local/autopkg/python
"""
JamfScriptUploader processor for uploading items to Jamf Pro using AutoPkg
by G Pugh
"""
import os.path
import sys
from time import sleep
from autopkglib import ProcessorError # pylint: disable=import-error
# to use a base module in AutoPkg we need to add this path to the sys.pa... | normal | {
"blob_id": "35d99713df754052a006f76bb6f3cfe9cf875c0b",
"index": 3993,
"step-1": "<mask token>\n\n\nclass JamfScriptUploader(JamfUploaderBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass JamfScriptUploader(J... | [
1,
4,
5,
7,
8
] |
<|reserved_special_token_0|>
class MorningGreeting(MappedAsDataclass, Model):
<|reserved_special_token_0|>
id: Mapped[int] = mapped_column(init=False, primary_key=True)
platform: Mapped[str]
bot_id: Mapped[str]
group_id: Mapped[str] = mapped_column(default='')
guild_id: Mapped[str] = mapped_co... | flexible | {
"blob_id": "28e5667db4a620ec627cd94154a024b4c8dbc5f7",
"index": 6171,
"step-1": "<mask token>\n\n\nclass MorningGreeting(MappedAsDataclass, Model):\n <mask token>\n id: Mapped[int] = mapped_column(init=False, primary_key=True)\n platform: Mapped[str]\n bot_id: Mapped[str]\n group_id: Mapped[str] ... | [
1,
2,
3,
4,
5
] |
'''
Created on Dec 2, 2013
A reference entity implementation for Power devices
that can be controlled via RF communication.
@author: rycus
'''
from entities import Entity, EntityType
from entities import STATE_UNKNOWN, STATE_OFF, STATE_ON
from entities import COMMAND_ON, COMMAND_OFF
class GenericPower(Entity):
... | normal | {
"blob_id": "18e76df1693d4fc27620a0cf491c33197caa5d15",
"index": 4055,
"step-1": "<mask token>\n\n\nclass GenericPower(Entity):\n <mask token>\n\n def __init__(self, unique_id, entity_type=EntityType.find(100), name=\n 'Unnamed entity', state=STATE_UNKNOWN, state_value=None, last_checkin=0\n ... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
class Group(Actor):
"""Represents a formal or informal collective of Actors."""
pass
class Organization(Actor):
"""Represents an organization."""
pass
class Person(Actor):
"""Represents an individual person."""
pass
class Service(Actor):
"""Represents a s... | flexible | {
"blob_id": "b92f24cddae7b392af2417b39bb4f58e3f661cc6",
"index": 2785,
"step-1": "<mask token>\n\n\nclass Group(Actor):\n \"\"\"Represents a formal or informal collective of Actors.\"\"\"\n pass\n\n\nclass Organization(Actor):\n \"\"\"Represents an organization.\"\"\"\n pass\n\n\nclass Person(Actor):... | [
8,
10,
11,
12,
13
] |
'''
Calculations used by algorithms
All calculations for training shall have a standard API that takes in `batch` from algorithm.sample() method and return np array for calculation.
`batch` is a dict containing keys to any data type you wish, e.g. {rewards: np.array([...])}
'''
from slm_lab.lib import logger, util
impo... | normal | {
"blob_id": "07095bc815f5342b66ef4ca74b769321f3ef2ec5",
"index": 7240,
"step-1": "<mask token>\n\n\ndef calc_returns(batch, gamma):\n \"\"\"\n Calculate the simple returns (full rollout) for advantage\n i.e. sum discounted rewards up till termination\n \"\"\"\n rewards = batch['rewards']\n asse... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class Player:
<|reserved_special_token_0|>
def hit(self):
self.cards += random.randint(1, 11)
def deal(self):
self.cards = random.randint(1, 11) + random.randint(1, 11)
self.dealer = random.randint(1, 11)
<|reserved_special_token_0|>
def rese... | flexible | {
"blob_id": "db159cfb198311b0369f65eb9e10947c4d28c695",
"index": 2919,
"step-1": "<mask token>\n\n\nclass Player:\n <mask token>\n\n def hit(self):\n self.cards += random.randint(1, 11)\n\n def deal(self):\n self.cards = random.randint(1, 11) + random.randint(1, 11)\n self.dealer = ... | [
4,
5,
8,
9,
10
] |
<|reserved_special_token_0|>
class Ball(Turtle):
def __init__(self, x, y, dx, dy, r):
Turtle.__init__(self)
self.pu()
self.goto(x, y)
self.dx = dx
self.dy = dy
self.r = r
self.shape('circle')
self.shapesize(r / 10)
r = random.randint(0, 255)... | flexible | {
"blob_id": "17cd6746e58a7f33bc239c1420d51c6810ed02d8",
"index": 3575,
"step-1": "<mask token>\n\n\nclass Ball(Turtle):\n\n def __init__(self, x, y, dx, dy, r):\n Turtle.__init__(self)\n self.pu()\n self.goto(x, y)\n self.dx = dx\n self.dy = dy\n self.r = r\n s... | [
4,
5,
6,
7,
8
] |
print raw_input().count(raw_input()) | normal | {
"blob_id": "2d4b0e7b430ffb5d236300079ded4b848e6c6485",
"index": 3602,
"step-1": "print raw_input().count(raw_input())",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
from .FactorWarData import Get_FactorWar_Data
| flexible | {
"blob_id": "5aa55a96e414ad6b3ceebbcbd71c23a1fd69f0d1",
"index": 6400,
"step-1": "<mask token>\n",
"step-2": "from .FactorWarData import Get_FactorWar_Data\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
from zipfile import ZipFile
import reference_new_stdds
import reader
import os
def runall(path):
print("==========================")
"""get the current path """
abs_file_path = os.path.abspath(__file__)
parent_dir = os.path.dirname(abs_file_path)
parent_dir = os.path.dirname(parent_dir)
""" ... | normal | {
"blob_id": "1158ab95ac67d62459284267a8cc9f587daf89b1",
"index": 9329,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef runall(path):\n print('==========================')\n \"\"\"get the current path \"\"\"\n abs_file_path = os.path.abspath(__file__)\n parent_dir = os.path.dirname(abs_... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
"""
Expression Parser Tree for fully parenthesized input expression
"""
from bintree import BinaryTree
from stackModule import Stack
def buildParseTree(expression):
expList = expression.split()
empTree = BinaryTree('')
parentStack = Stack()
parentStack.push(empTree)
currentNode ... | normal | {
"blob_id": "e18ebf961c2daa7dd127d08f85edb6ea519e3470",
"index": 8359,
"step-1": "#!/usr/bin/python\n\n\"\"\"\nExpression Parser Tree for fully parenthesized input expression\n\"\"\"\n\nfrom bintree import BinaryTree\nfrom stackModule import Stack\n\ndef buildParseTree(expression):\n expList = expression.spli... | [
0
] |
<|reserved_special_token_0|>
def setStep(w1, w2, w3, w4):
GPIO.output(A1Pin, w1)
GPIO.output(A2Pin, w2)
GPIO.output(B1Pin, w3)
GPIO.output(B2Pin, w4)
def wheel(pos):
if pos < 0 or pos > 255:
r = g = b = 0
elif pos < 85:
r = int(pos * 3)
g = int(255 - pos * 3)
... | flexible | {
"blob_id": "4a711642af753ba2c82ce3351b052a4973e17e7d",
"index": 9672,
"step-1": "<mask token>\n\n\ndef setStep(w1, w2, w3, w4):\n GPIO.output(A1Pin, w1)\n GPIO.output(A2Pin, w2)\n GPIO.output(B1Pin, w3)\n GPIO.output(B2Pin, w4)\n\n\ndef wheel(pos):\n if pos < 0 or pos > 255:\n r = g = b = ... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class TestViews(TestCase):
<|reserved_special_token_0|>
def test_add_order_get(self):
response = self.client.get(url_for('add_order'))
self.assertEqual(response.status_code, 200)
def test_view_order_get(self):
response = self.client.get(url_for('view_... | flexible | {
"blob_id": "eeece3bf423f85f05ef11db47909215578e64aec",
"index": 4912,
"step-1": "<mask token>\n\n\nclass TestViews(TestCase):\n <mask token>\n\n def test_add_order_get(self):\n response = self.client.get(url_for('add_order'))\n self.assertEqual(response.status_code, 200)\n\n def test_view... | [
20,
27,
32,
33,
34
] |
<|reserved_special_token_0|>
class Weapon(Equipment):
def __init__(self, name, power):
super(Weapon, self).__init__(name)
self.power = power
<|reserved_special_token_0|>
def __str__(self):
return '{}: Power({})'.format(self.name, self.power)
<|reserved_special_token_1|>
<|rese... | flexible | {
"blob_id": "276d7ac493ddcb327dbce279d9f4bc8a74c98245",
"index": 5749,
"step-1": "<mask token>\n\n\nclass Weapon(Equipment):\n\n def __init__(self, name, power):\n super(Weapon, self).__init__(name)\n self.power = power\n <mask token>\n\n def __str__(self):\n return '{}: Power({})'.... | [
3,
4,
5,
6,
7
] |
def solution(citations):
# 사이테이션을 정렬
citations.sort()
#
for i in range(len(citations)):
if citations[i] >= len(citations) - i:
return len(citations)-i
print(solution([3,0,6,1,5])) | normal | {
"blob_id": "0b3d6339faf9d66d4e1338599e4784fac0f63d3f",
"index": 5310,
"step-1": "<mask token>\n",
"step-2": "def solution(citations):\n citations.sort()\n for i in range(len(citations)):\n if citations[i] >= len(citations) - i:\n return len(citations) - i\n\n\n<mask token>\n",
"step-... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "913e1f5a0af436ef081ab567c44b4149299d0ec6",
"index": 3154,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('application... | [
0,
1,
2,
3,
4
] |
def usage_list(self):
print('Available modules')
print('=================')
for module in sorted(self.list()):
if ('module' not in self.mods[module]):
self.import_module(module)
if (not self.mods[module]['module'].__doc__):
continue
text = self.mods[module]['m... | normal | {
"blob_id": "d0eb6ea2e816ac59ae93684edb38ff3a49909633",
"index": 762,
"step-1": "<mask token>\n",
"step-2": "def usage_list(self):\n print('Available modules')\n print('=================')\n for module in sorted(self.list()):\n if 'module' not in self.mods[module]:\n self.import_modu... | [
0,
1,
2
] |
from abc import ABCMeta, abstractmethod, ABC
from domain.models.network_information import NetworkInformation
class AbstractTensorboardExportService(ABC):
__metaclass__ = ABCMeta
@abstractmethod
def save_tensorboard(self, network_info: NetworkInformation) ->None:
raise NotImplementedError
| normal | {
"blob_id": "08c3155a5fbf6c94f5885c12cfc7c917313ae9c7",
"index": 5929,
"step-1": "<mask token>\n\n\nclass AbstractTensorboardExportService(ABC):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass AbstractTensorboardExportService(ABC):\n <mask token>\n\n @abstractmethod\n def sa... | [
1,
2,
3,
4
] |
from Common.TreasureIsland import TIenv
from .Agent import TIagent
import torch
feature_size = (8, 8)
env = TIenv(frame_rate=0, num_marks=1, feature_size=feature_size)
agent = TIagent(feature_size=feature_size, learning_rate=0.0001)
EPISODE_COUNT = 50000
STEP_COUNT = 40
for episode in range(EPISODE_COUNT):
o... | normal | {
"blob_id": "bf133e73f0c842603dbd7cc3a103a2aa95e2236e",
"index": 4359,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor episode in range(EPISODE_COUNT):\n obs = env.reset()\n agent.reset()\n steps = 0\n if (episode + 1) % 100 == 0:\n state = {'model_state': agent.model.state_dict(), ... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('auth', '0001_initial'),
('c4c_app', '0006_c4cjob_complete'),
]
operations = [
migrations.AlterModelOptions(
... | normal | {
"blob_id": "30986eb0a6cd82f837dd14fb383529a6a41def9a",
"index": 8338,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('auth', '000... | [
0,
1,
2,
3,
4
] |
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import User
from django.shortcuts import render, redirect
from django.urls import reverse_lazy
from django.views... | normal | {
"blob_id": "dc9b5fbe082f7cf6cd0a9cb0d1b5a662cf3496f0",
"index": 4768,
"step-1": "<mask token>\n\n\nclass PayForList(LoginRequiredMixin, ListView):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass PayForDetailView(LoginRequiredMixin, DetailView):\n template_name = 'money_easy/payfor_detail.htm... | [
22,
23,
28,
29,
31
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in word:
if 'a' <= i and i <= 'z' or 'A' <= i and i <= 'Z':
letter += 1
if '0' <= i and i <= '9':
digit += 1
print("""LETTERS {0}
DIGITS {1}""".format(letter, digit))
<|reserved_special_token_1|>
... | flexible | {
"blob_id": "f2a508ae99697d6ba320b158a1000379b975d568",
"index": 2227,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in word:\n if 'a' <= i and i <= 'z' or 'A' <= i and i <= 'Z':\n letter += 1\n if '0' <= i and i <= '9':\n digit += 1\nprint(\"\"\"LETTERS {0} \n DIGITS {1}\"\"\"... | [
0,
1,
2,
3
] |
l={1,2,3,4}
try:
print(l)
s=len(l)
if s>5:
raise TypeError
print(d[2])
except TypeError:
print("Error!!!length should be less than or equals to 5")
except NameError:
print("index out of range")
else:
for i in l:
print(i)
finally:
print("execution done!!!!!!") | normal | {
"blob_id": "e59e60b0a4b7deca9c510bd6b9c58636c6d34c80",
"index": 1027,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n print(l)\n s = len(l)\n if s > 5:\n raise TypeError\n print(d[2])\nexcept TypeError:\n print('Error!!!length should be less than or equals to 5')\nexcept Name... | [
0,
1,
2,
3
] |
import tkinter as tk
from functools import partial
from numpy import random
from base import NinePalaceGame
class SingleMode(NinePalaceGame):
player1 = player = 'O'
player2 = computer = 'X'
def __init__(self):
self.create_choose_one_window()
super().__init__()
self.main_game_wind... | normal | {
"blob_id": "841743d4e9d683827962d83a77a87c6432842add",
"index": 8013,
"step-1": "<mask token>\n\n\nclass SingleMode(NinePalaceGame):\n <mask token>\n <mask token>\n <mask token>\n\n def player_play(self, i, j):\n if not self.game_is_over and not self.box[i][j]:\n self.box[i][j] = 1... | [
6,
7,
9,
11,
13
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
app_name = 'genius'
urlpatterns = [path('', home, name='home'), path('class/', Classes, name=
'class'), path('class/add-name', Add_name, name='add-name'), path(
'class/create', Class_create, name='create-class'), path(
... | flexible | {
"blob_id": "fd6a32652b845b2a6d6d8934c0dde91afdddd9f3",
"index": 9046,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp_name = 'genius'\nurlpatterns = [path('', home, name='home'), path('class/', Classes, name=\n 'class'), path('class/add-name', Add_name, name='add-name'), path(\n 'class/create',... | [
0,
1,
2,
3
] |
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
"""
Using the django shell:
$ python manage.py shell
from django.contrib.auth.models import User
from accounts.models import Profile
from papers.models import Paper, Comment, Rating, UserSavedPaper
users = User... | normal | {
"blob_id": "052574be3f4a46bceefc0a54b1fe268a7cef18a9",
"index": 3061,
"step-1": "<mask token>\n\n\nclass Comment(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.text\n\n\nclass Rating(models.Model):\n rating = models.Positi... | [
8,
9,
10,
13,
14
] |
<|reserved_special_token_0|>
class Codec:
<|reserved_special_token_0|>
def decode(self, s):
"""Decodes a single string to a list of strings.
:type s: str
:rtype: List[str]
"""
i, str = 0, []
while i < len(s):
sharp = s.find('#', i)
... | flexible | {
"blob_id": "b94392c9c6547415326d80ff0923cb8ba9251783",
"index": 5724,
"step-1": "<mask token>\n\n\nclass Codec:\n <mask token>\n\n def decode(self, s):\n \"\"\"Decodes a single string to a list of strings.\n \n :type s: str\n :rtype: List[str]\n \"\"\"\n i, str = ... | [
5,
6,
7,
8,
10
] |
#!/usr/bin/env python
###############################################################################
# Copyright 2017 The Apollo Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy ... | normal | {
"blob_id": "4b552731fcfc661c7ad2d63c7c47f79c43a8ae5e",
"index": 4839,
"step-1": "<mask token>\n\n\nclass Config(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @classmethod\n def get_pb(cls):\n \"\"\"Get a pb instance from the... | [
4,
6,
7,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def sun_prepare(xpoint, ypoint, radius, color, angle):
delta_list = []
radius_list = []
for delta in range(0, 360, angle):
delta_list.append(delta)
radius_list.append(random.randint(radius - 10, radiu... | flexible | {
"blob_id": "46babde9c26a944c9d29121b6bbf89a32f242a81",
"index": 251,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef sun_prepare(xpoint, ypoint, radius, color, angle):\n delta_list = []\n radius_list = []\n for delta in range(0, 360, angle):\n delta_list.append(delta)\n rad... | [
0,
1,
2,
3,
4
] |
from django.apps import AppConfig
class QuadraticEquationsSolverConfig(AppConfig):
name = 'quadratic_equations_solver'
| normal | {
"blob_id": "730fc527f3d2805559e8917e846b0b13f4a9f6ee",
"index": 2316,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass QuadraticEquationsSolverConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass QuadraticEquationsSolverConfig(AppConfig):\n name = 'quadratic_equations... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def top(request):
return render(request, 'new_questions.html', {'title': 'Топ вопросов',
'questions': paginate(request, models.Question.objects.get_hot()),
'tags': paginate(request, models.Tag.objects.hottest())[:10],
'users': paginate(request, models.CustomUse... | flexible | {
"blob_id": "c4b4585501319fd8a8106c91751bb1408912827a",
"index": 3180,
"step-1": "<mask token>\n\n\ndef top(request):\n return render(request, 'new_questions.html', {'title': 'Топ вопросов',\n 'questions': paginate(request, models.Question.objects.get_hot()),\n 'tags': paginate(request, models.T... | [
8,
12,
13,
18,
20
] |
<|reserved_special_token_0|>
class OrderForm(ModelForm):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class Meta:
model = Order
fields = 'stock... | flexible | {
"blob_id": "044e3479c32357e22ca3165d8601d8bd2a439fcb",
"index": 2329,
"step-1": "<mask token>\n\n\nclass OrderForm(ModelForm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n model = Order\n fields = 'stock', 'order... | [
3,
4,
5,
6,
8
] |
<|reserved_special_token_0|>
class ModelBase(unittest.TestCase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def get(self, url):
"""Process a GET request to the app"""
return self.app.get(get_url(url), follow_redirects=True)
<|reserved_special_token_0|>
def verify_o... | flexible | {
"blob_id": "a5856e12c281ed6a252f499a380f9c51082ea740",
"index": 3711,
"step-1": "<mask token>\n\n\nclass ModelBase(unittest.TestCase):\n <mask token>\n <mask token>\n\n def get(self, url):\n \"\"\"Process a GET request to the app\"\"\"\n return self.app.get(get_url(url), follow_redirects=... | [
31,
43,
44,
49,
56
] |
#!/usr/bin/env python3
import torch
import torch.nn as nn
import torch.nn.functional as F
import pytorch_lightning as pl
import torchmetrics
class BaselineModule(pl.LightningModule):
def __init__(self, input_size, num_classes=4, lr=3e-4):
super().__init__()
self.backbone = nn.Sequential( # CBR-Ti... | normal | {
"blob_id": "7d43b20ebee2f4cd509bbd896c9e6ae8b2c4b354",
"index": 7128,
"step-1": "<mask token>\n\n\nclass BaselineModule(pl.LightningModule):\n <mask token>\n\n def _get_hidden_size(self, input_size):\n self.backbone(torch.randn(1, 3, input_size, input_size))\n\n def forward(self, input_tensor):\... | [
3,
5,
6,
7,
9
] |
import os
class User(object):
def __init__(self, meta):
meta.update({
'groups': meta.get('groups', []) + [meta['username']]
})
self.meta = meta
@property
def username(self):
return self.meta['username']
@property
def groups(self):
return self.... | normal | {
"blob_id": "aa47b7c74b9b6b8a7f014de4bd58236edeba485d",
"index": 5971,
"step-1": "<mask token>\n\n\nclass User(object):\n\n def __init__(self, meta):\n meta.update({'groups': meta.get('groups', []) + [meta['username']]})\n self.meta = meta\n\n @property\n def username(self):\n retur... | [
9,
11,
12,
13,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def get_urls(search_string, start):
temp = []
url = 'http://www.google.com/search'
payload = {'q': search_string, 'start': start}
my_headers = {'User-agent': 'Mozilla/11.0'}
r = requests.get(url, params=paylo... | flexible | {
"blob_id": "68dcac07bbdb4dde983939be98ece127d963c254",
"index": 3610,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_urls(search_string, start):\n temp = []\n url = 'http://www.google.com/search'\n payload = {'q': search_string, 'start': start}\n my_headers = {'User-agent': 'Mozi... | [
0,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class Ensemble(object):
"""Ensemble base_models on train data than fit/predict
The object input is composed of 'n_splits', 'stacker' and list of
'base_models'.
The __init__ method self-assign the inputs.
The fit_predict method divides the dataset in 'n_splits' then ... | flexible | {
"blob_id": "21c581131cff8cf2f4aa407055184d56865a6335",
"index": 9783,
"step-1": "<mask token>\n\n\nclass Ensemble(object):\n \"\"\"Ensemble base_models on train data than fit/predict\n\n The object input is composed of 'n_splits', 'stacker' and list of\n 'base_models'.\n\n The __init__ method self-a... | [
4,
5,
6,
7,
8
] |
class Image:
def __init__(self, **kwargs):
self.ClientID = kwargs['ClientID']
self.DealerID = kwargs['DealerID']
self.VIN = kwargs['VIN']
self.UrlVdp = None
self.PhotoURL = kwargs['PhotoURL']
self.VdpActive = None
def __repr__(self):
return f"{se... | normal | {
"blob_id": "3dc4e10145ad42c0168fec3462da0f87c1e661a5",
"index": 8701,
"step-1": "<mask token>\n\n\nclass VehiclePhoto:\n <mask token>\n\n def __repr__(self):\n return f'{self.VehiclePhotoID} {self.VIN} {self.UrlVdp}'\n",
"step-2": "class Image:\n <mask token>\n <mask token>\n\n\nclass Vehic... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
def jump(self, nums: List[int]) ->int:
if len(nums) < 2:
return 0
jump = 1
curr_max = max_reach = nums[0]
for i i... | flexible | {
"blob_id": "7f2ffa653486d000c9eee0087fc1e6ca0c84003c",
"index": 5671,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def jump(self, nums: List[int]) ->int:\n if len(nums) < 2:\n return 0\n jump = 1\n curr_max = m... | [
0,
1,
2,
3
] |
#downloads project detail reports from the web and places them in the correct project folder created by makeFolders.py
import os, openpyxl, time, shutil
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
wb = openpyxl.load_workbook('ProjectSummary.xlsx')
sheet = wb.active
browser = webdri... | normal | {
"blob_id": "6e9fd8ee2a187888df07c9dd1c32fe59a111c869",
"index": 8823,
"step-1": "<mask token>\n\n\ndef pdfToFolder(projectName):\n os.chdir('/home/gmclaughlin/Downloads')\n if projectName.find('DEM') != -1:\n shutil.move('/home/gmclaughlin/Downloads/Detail Report - Basic.pdf',\n \n ... | [
1,
2,
3,
4,
5
] |
# 同一目录下的引用调用还是随意导入使用的
# 跨包使用就需要使用TwoUsage里面的两种方式。
import Importex
Importex.atest()
| normal | {
"blob_id": "1a66e7f59ada43deb8e28b9806dc4fb9be4ae247",
"index": 5771,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nImportex.atest()\n",
"step-3": "import Importex\nImportex.atest()\n",
"step-4": "# 同一目录下的引用调用还是随意导入使用的\n# 跨包使用就需要使用TwoUsage里面的两种方式。\n\nimport Importex\n\nImportex.atest()\n",
"step-... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Test(TestItem):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def abortRun(self):
sel... | flexible | {
"blob_id": "cac9d84f20a79b115c84ff4fe8cf4640182a42d7",
"index": 754,
"step-1": "<mask token>\n\n\nclass Test(TestItem):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def abortRun(self):\n self._runHistory.pop()\n <m... | [
33,
64,
81,
104,
122
] |
<|reserved_special_token_0|>
class UDPProtocol:
<|reserved_special_token_0|>
def connection_made(self, transport):
self.transport = transport
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def stop(self):
self.transport.close()
<|rese... | flexible | {
"blob_id": "cca543f461724c3aac8fef23ef648883962bd706",
"index": 4607,
"step-1": "<mask token>\n\n\nclass UDPProtocol:\n <mask token>\n\n def connection_made(self, transport):\n self.transport = transport\n <mask token>\n <mask token>\n <mask token>\n\n def stop(self):\n self.tran... | [
3,
5,
8,
9,
11
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.