code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
<|reserved_special_token_0|>
def easy():
print('Ok, seems like you are not good at math.')
print('What about this.')
print('Say you have 10 apples, your Mom gave you another 2.')
print('How many apples you have now?')
choice = input('> ')
if choice == '12':
print('You did a good job!')... | flexible | {
"blob_id": "5d05351cd6cd6c0d216e8bc09308532605bfd26e",
"index": 3007,
"step-1": "<mask token>\n\n\ndef easy():\n print('Ok, seems like you are not good at math.')\n print('What about this.')\n print('Say you have 10 apples, your Mom gave you another 2.')\n print('How many apples you have now?')\n ... | [
2,
3,
4,
5,
6
] |
import numpy as np
import tensorflow as tf
from arg_parser import args
from model_object import UnetModel
def main(args):
np.random.seed(args.random_seed)
tf.random.set_seed(args.random_seed)
unet_model = UnetModel(args)
unet_model.prepare_data(args)
unet_model.create_model(args)
une... | normal | {
"blob_id": "588f6f78908e47e0b3f1bc42fffabad34766eede",
"index": 9815,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(args):\n np.random.seed(args.random_seed)\n tf.random.set_seed(args.random_seed)\n unet_model = UnetModel(args)\n unet_model.prepare_data(args)\n unet_model.cr... | [
0,
1,
2,
3,
4
] |
"""A lightweight Python wrapper of SoX's effects."""
import shlex
from io import BufferedReader, BufferedWriter
from subprocess import PIPE, Popen
import numpy as np
from .sndfiles import (
FileBufferInput,
FileBufferOutput,
FilePathInput,
FilePathOutput,
NumpyArrayInput,
NumpyArrayOutput,
... | normal | {
"blob_id": "f98f2ef0d94839711b473ad1ca32b85645d4014e",
"index": 8764,
"step-1": "<mask token>\n\n\nclass AudioEffectsChain:\n\n def __init__(self):\n self.command = []\n\n def equalizer(self, frequency, q=1.0, db=-3.0):\n \"\"\"equalizer takes three parameters: filter center frequency in Hz,... | [
22,
27,
29,
31,
42
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def test(d_iter):
from cqlengine import columns
from cqlengine.models import Model
from cqlengine.query import ModelQuerySet
from cqlengine import connection
from cqlengine.management import sync_table
from urllib2 import urlopen, Requ... | flexible | {
"blob_id": "11f29508d52e856f4751a5dc8911a1f1c9832374",
"index": 944,
"step-1": "<mask token>\n",
"step-2": "def test(d_iter):\n from cqlengine import columns\n from cqlengine.models import Model\n from cqlengine.query import ModelQuerySet\n from cqlengine import connection\n from cqlengine.mana... | [
0,
1,
2,
3,
4
] |
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='cea',llcrnrlat=-90,urcr... | normal | {
"blob_id": "f5f9a1c7dcb7345e24f50db54649a1970fc37185",
"index": 1262,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nm.drawcoastlines()\nm.fillcontinents(color='coral', lake_color='aqua')\nm.drawparallels(np.arange(-90.0, 91.0, 30.0))\nm.drawmeridians(np.arange(-180.0, 181.0, 60.0))\nm.drawmapboundary(f... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class FileStorage:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def all(self):
"""
Return:
the dictionary __objects
"""
return self.__objects
<|reserved_special_token_0|>
def save(s... | flexible | {
"blob_id": "5461d50d3c06bc4276044cc77bd804f6e7c16b3b",
"index": 1278,
"step-1": "<mask token>\n\n\nclass FileStorage:\n <mask token>\n <mask token>\n <mask token>\n\n def all(self):\n \"\"\"\n Return:\n the dictionary __objects\n \"\"\"\n return self.__objects\n ... | [
3,
5,
7,
8,
9
] |
import os
from xml.dom import minidom
import numpy as np
def get_branches_dir(root_dir):
branches_dir = []
folds = os.listdir(root_dir)
while folds:
branch_dir = root_dir + '/' + folds.pop()
branches_dir.append(branch_dir)
return branches_dir
def tolist(xml, detname):
try:
... | normal | {
"blob_id": "2b7bb02a25504e7481d3bc637ea09bcf9addb990",
"index": 7699,
"step-1": "<mask token>\n\n\ndef get_branches_dir(root_dir):\n branches_dir = []\n folds = os.listdir(root_dir)\n while folds:\n branch_dir = root_dir + '/' + folds.pop()\n branches_dir.append(branch_dir)\n return br... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
screen = pg.display.set_mode((640, 380))
<|reserved_special_token_1|>
import pygame as pg
screen = pg.display.set_mode((640, 380))
| flexible | {
"blob_id": "c1374a048187807deac5d28dda4fbc7beeccf8f5",
"index": 5221,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nscreen = pg.display.set_mode((640, 380))\n",
"step-3": "import pygame as pg\nscreen = pg.display.set_mode((640, 380))\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
... | [
0,
1,
2
] |
import requests
import sqlite3
url = 'http://dummy.restapiexample.com/api/v1/employees'
r = requests.get(url)
packages_json = r.json()
# Create the employee database if it does not exist
db = sqlite3.connect('employee.sqlite')
#create the table
db.execute("CREATE TABLE IF NOT EXISTS employee (id INTEGER P... | normal | {
"blob_id": "497203be99643e2bb0087977f292f4ed890f9ead",
"index": 7111,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndb.execute(\n 'CREATE TABLE IF NOT EXISTS employee (id INTEGER PRIMAR KEY, employee_name TEXT, employee_salary INTEGER, employee_age INTEGER, profile_image BLOB)'\n )\nfor employee ... | [
0,
1,
2,
3,
4
] |
"""
ConstantsCommands.py
"""
TEST_HEAD = "\n >>>>>> " \
"\n >>>>>> Test in progress: {0}" \
"\n >>>>>>"
TEST_TAIL = ">>>>>> Test execution done, tearDown\n\r"
| normal | {
"blob_id": "45f0a7a78184195a593061d863ff2114abe01a46",
"index": 6321,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nTEST_HEAD = \"\"\"\n >>>>>> \n >>>>>> Test in progress: {0}\n >>>>>>\"\"\"\nTEST_TAIL = '>>>>>> Test execution done, tearDown\\n\\r'\n",
"step-3": "\"\"\"\nConstantsCommands.py\n\"\"\"\... | [
0,
1,
2
] |
# read in file of customs declaration responses
declarations_file = open('day6_declarations.txt', 'r')
lines = declarations_file.readlines()
# initialise variables
group_responses = [] # temporary container for all responses of each group member
count_any_member_has_response = 0 # count for part... | normal | {
"blob_id": "cb6ed6422a5591f1de0a947f75ad080f250e8443",
"index": 7718,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in lines:\n if line == '\\n' or line == lines[-1]:\n if line == lines[-1]:\n line = line.strip()\n group_responses.append(line)\n group_res... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class ValidateWindowCtr(object):
def __init__(self, fig, im_trans, im_truth, im_segmen, vol_trans,
vol_truth, vol_segmen, ax_trans, ax_truth, ax_segmen, index_trans,
index_truth, index_segmen):
self.fig = fig
self.im_trans, self.im_truth, self.im_segme... | flexible | {
"blob_id": "e0b28fdcbc3160bcccbb032949317a91a32eeb1b",
"index": 5394,
"step-1": "<mask token>\n\n\nclass ValidateWindowCtr(object):\n\n def __init__(self, fig, im_trans, im_truth, im_segmen, vol_trans,\n vol_truth, vol_segmen, ax_trans, ax_truth, ax_segmen, index_trans,\n index_truth, index_seg... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('credentials_as.json', encoding='utf-8') as F:
credentials = json.loads(F.read())
<|reserved_special_token_0|>
print(df)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('credentials_as.json', e... | flexible | {
"blob_id": "f15a0956c4aa27da861f9bccbeff7a6b6a909b73",
"index": 1113,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('credentials_as.json', encoding='utf-8') as F:\n credentials = json.loads(F.read())\n<mask token>\nprint(df)\n",
"step-3": "<mask token>\nwith open('credentials_as.json', e... | [
0,
1,
2,
3
] |
{'ivy': {'svm': ({'kernel': 'rbf', 'C': 10.0}, 0.034482758620689662, 0.035087719298245612), 'tuned_ensemble': ({'svm__C': 100000.0, 'rf__n_estimators': 101, 'cart__min_samples_leaf': 7, 'knn__n_neighbors': 2, 'rf__random_state': 1542, 'cart__max_depth': 33, 'cart__max_features': 0.35714285714285721, 'svm__kernel': 'sig... | normal | {
"blob_id": "fa02fb701b59728671a7e87147adaeb33422dcdb",
"index": 1600,
"step-1": "<mask token>\n",
"step-2": "{'ivy': {'svm': ({'kernel': 'rbf', 'C': 10.0}, 0.03448275862068966, \n 0.03508771929824561), 'tuned_ensemble': ({'svm__C': 100000.0,\n 'rf__n_estimators': 101, 'cart__min_samples_leaf': 7,\n '... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
print('-' * 100)
print('BIENVENIDOS A TIENDA ELEGANCIA')
print('-' * 100)
<|reserved_special_token_0|>
print(prendaseleccionada1)
<|reserved_special_token_0|>
print('La prenda: ', tipoPrenda1, 'participa de del plan SuperPuntos? s/n')
<|reserved_special_token... | flexible | {
"blob_id": "333d237dd4a203fcfde3668901d725f16fbc402e",
"index": 1684,
"step-1": "<mask token>\n",
"step-2": "print('-' * 100)\nprint('BIENVENIDOS A TIENDA ELEGANCIA')\nprint('-' * 100)\n<mask token>\nprint(prendaseleccionada1)\n<mask token>\nprint('La prenda: ', tipoPrenda1, 'participa de del plan SuperPuntos... | [
0,
1,
2,
3
] |
from yapsy.IPlugin import IPlugin
import wolframalpha
import yaml
keys_file = open("friday/plugins/KEYS")
keys = yaml.load(keys_file)
keys_file.close()
class Wolfram(IPlugin):
def can_perform(self, friday, request):
return 'result' in request and 'resolvedQuery' in request['result']\
and ... | normal | {
"blob_id": "57564c2e94a65187bf5e033ee06926fb593e11a7",
"index": 7733,
"step-1": "<mask token>\n\n\nclass Wolfram(IPlugin):\n\n def can_perform(self, friday, request):\n return 'result' in request and 'resolvedQuery' in request['result'\n ] and 'action' in request['result'] and request['resu... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(0, number_files - N - 1, N):
img1 = cv2.imread('./frames/frame%d.jpg' % i, 0)
img2 = cv2.imread('./frames/frame%d.jpg' % (i + N), 0)
kp1, des1 = sift.detectAndCompute(img1, None)
kp2, des2 = sift.det... | flexible | {
"blob_id": "397d9b1030a1ec08d04d2101f65a83547495b861",
"index": 7165,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(0, number_files - N - 1, N):\n img1 = cv2.imread('./frames/frame%d.jpg' % i, 0)\n img2 = cv2.imread('./frames/frame%d.jpg' % (i + N), 0)\n kp1, des1 = sift.detectA... | [
0,
1,
2,
3,
4
] |
import doseresponse as dr
import numpy as np
import scipy.stats as st
import numpy.random as npr
import argparse
import itertools as it
# get rid of for real version
import pandas as pd
import os
seed = 1
npr.seed(seed)
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--samples", type=int, help="number... | normal | {
"blob_id": "2f6baf4de40224f5a3d00ded35e751184ab59d0d",
"index": 9201,
"step-1": "import doseresponse as dr\nimport numpy as np\nimport scipy.stats as st\n\nimport numpy.random as npr\nimport argparse\nimport itertools as it\n\n# get rid of for real version\nimport pandas as pd\nimport os\n\nseed = 1\nnpr.seed(s... | [
0
] |
# -*- coding:Utf-8 -*-
from .game_action_manager import GameActionManager
from .menu_action_manager import OptionsActionManager, CharacterSelectionActionManager, MainMenuActionManager
| normal | {
"blob_id": "48294209d51fbe4dfb2a5130311a10c8a1dd027c",
"index": 9237,
"step-1": "<mask token>\n",
"step-2": "from .game_action_manager import GameActionManager\nfrom .menu_action_manager import OptionsActionManager, CharacterSelectionActionManager, MainMenuActionManager\n",
"step-3": "# -*- coding:Utf-8 -*-... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class Rocket:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def update(self, x, y, angle, leftPower, rightPower):
self.x = x * config.game['scale'] + config.game['width'] / 2
self.y = config.game['height'] - config.game['floorHeight'
] ... | flexible | {
"blob_id": "7a1a9d2e773fb783d8522f1ea51e753d5d3782e9",
"index": 7517,
"step-1": "<mask token>\n\n\nclass Rocket:\n <mask token>\n <mask token>\n\n def update(self, x, y, angle, leftPower, rightPower):\n self.x = x * config.game['scale'] + config.game['width'] / 2\n self.y = config.game['h... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class GraphPickleWriter(GraphWriter):
<|reserved_special_token_0|>
def write(self, *, tp_nodes, tp_edges: Mapping[str, Edge],
tp_namespaces, tn_nodes, tn_edges, tn_namespaces):
"""Write the graph as pickles."""
with open(os.path.join(self.graph_dir_path, '... | flexible | {
"blob_id": "58d069f6700149793c3446bdd4677f08eaf301ee",
"index": 670,
"step-1": "<mask token>\n\n\nclass GraphPickleWriter(GraphWriter):\n <mask token>\n\n def write(self, *, tp_nodes, tp_edges: Mapping[str, Edge],\n tp_namespaces, tn_nodes, tn_edges, tn_namespaces):\n \"\"\"Write the graph a... | [
2,
3,
4,
5,
6
] |
def sort_descending(numbers):
numbers.sort(reverse=True)
| normal | {
"blob_id": "46dc9917d9b3a7caf8d7ba5024b17d3b755fc5db",
"index": 7278,
"step-1": "<mask token>\n",
"step-2": "def sort_descending(numbers):\n numbers.sort(reverse=True)\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
def fully_connected(prev_layer, num_units, batch_norm, is_training=False):
layer = tf.layers.dense(prev_layer, num_units, use_bias=False,
activation=None)
if batch_norm:
layer = tf.layers.batch_normalization(layer, training=is_training)
layer = tf.nn.relu(layer... | flexible | {
"blob_id": "17b3f51779bda5a48c4d77c35d6bbdd2aadb13cd",
"index": 1432,
"step-1": "<mask token>\n\n\ndef fully_connected(prev_layer, num_units, batch_norm, is_training=False):\n layer = tf.layers.dense(prev_layer, num_units, use_bias=False,\n activation=None)\n if batch_norm:\n layer = tf.laye... | [
1,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class Cigarette(models.Model):
<|reserved_special_token_0|>
user = models.ForeignKey(user, blank=False, null=False, related_name=
'user_cigarettes')
cigarette_date = models.DateField(_('cigarette date'), auto_now_add=True)
cigarette_time = models.TimeField(_('cigar... | flexible | {
"blob_id": "68ea462f56ba029a7c977d9c8b94e6f913336fb7",
"index": 4680,
"step-1": "<mask token>\n\n\nclass Cigarette(models.Model):\n <mask token>\n user = models.ForeignKey(user, blank=False, null=False, related_name=\n 'user_cigarettes')\n cigarette_date = models.DateField(_('cigarette date'), a... | [
6,
12,
16,
17,
19
] |
<|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": "9d6516ea099e035fb97e5165071103698a7ec140",
"index": 5812,
"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 = [('fieldsapp',... | [
0,
1,
2,
3,
4
] |
"""
PROYECTO : Portal EDCA-HN
NOMBRE : ZipTools
Descripcion : Clase utilitaria para descomprimir archivos ZIP.
MM/DD/YYYY Colaboradores Descripcion
05/07/2019 Alla Duenas Creacion.
"""
import zipfile
from edca_mensajes import EdcaErrores as err, EdcaMensajes as msg
from edca_logs.EdcaLogger... | normal | {
"blob_id": "1190e802fde6c2c6f48bd2720688bd9231b622e0",
"index": 6564,
"step-1": "<mask token>\n\n\nclass ZipTools:\n <mask token>\n\n @staticmethod\n def descomprimir(archivo, dir_extraer):\n try:\n zip_ref = zipfile.ZipFile(archivo, 'r')\n zip_list = zip_ref.infolist()\n ... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class MainWindow(QWidget):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def initUI(self):
self.setGeometry(300, 300, 500, 600)
self.setWindowTitle('... | flexible | {
"blob_id": "33464f19c42d1a192792a73297f4d926df78ab71",
"index": 2906,
"step-1": "<mask token>\n\n\nclass MainWindow(QWidget):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def initUI(self):\n self.setGeometry(300, 300, 500, 600)\n self.setWindowTi... | [
4,
6,
9,
10,
11
] |
# Copyright (C) 2020 Claudio Marques - All Rights Reserved
dataset_path = "data/output/dataset{toReplace}.csv"
dataset_path_final = "data/output/final/datasetFinal.csv"
log_path = "data/logs/output_append.log"
numberOfThreads = 45
inputFileMalign = "data/input/malign/all.log"
outputFileMalign = "data/output/fil... | normal | {
"blob_id": "305133d4840741bd5c318a99a96660d8988dd61a",
"index": 7772,
"step-1": "<mask token>\n",
"step-2": "dataset_path = 'data/output/dataset{toReplace}.csv'\ndataset_path_final = 'data/output/final/datasetFinal.csv'\nlog_path = 'data/logs/output_append.log'\nnumberOfThreads = 45\ninputFileMalign = 'data/i... | [
0,
1,
2
] |
def generator(factor, modulus=-1, maxx=2147483647):
def next(prev):
nxt = (prev*factor) % maxx
if modulus > 0:
while nxt % modulus != 0:
nxt = (nxt * factor) % maxx
return nxt
return next
def main(a, b, a_mod=-1, b_mod=-1, N=40000000, a_fact=16807, b_fact=48... | normal | {
"blob_id": "6162911befc8ad37591f7c19b14b349c655ccac0",
"index": 3856,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(a, b, a_mod=-1, b_mod=-1, N=40000000, a_fact=16807, b_fact=48271):\n genA = generator(a_fact, a_mod)\n genB = generator(b_fact, b_mod)\n match = 0\n mask = (255 <... | [
0,
1,
2,
3,
4
] |
import csv
import us
from flask import abort, Flask, request, render_template
app = Flask(__name__) # pylint: disable=invalid-name
@app.route('/')
def root():
return render_template('index.html')
@app.route('/api')
def index():
return render_template('index.html')
@app.route('/api/total/counties')
def ... | normal | {
"blob_id": "af00c6f443426b1f61e1816d7d14ebc7e6871a82",
"index": 5562,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef root():\n return render_template('index.html')\n\n\n@app.route('/api')\ndef index():\n return render_template('index.html')\n\n\n@app.route('/api/total/counties')\ndef total_counties():\... | [
34,
39,
40,
41,
42
] |
# Create two integer variables and print their sum. What is the type of the
# result?
# Now, create a float variable and print its sum with an integer variable. What
# is the type of the result.
# Divide your smallest integer value by your largest integer value. Is the
# result what you expected? Now, do the same wit... | normal | {
"blob_id": "fcbbffe0682da9f2131fdddbef606dcae3303ce9",
"index": 1979,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(float(my_int))\n<mask token>\n",
"step-3": "greeting = 'My name is '\nyour_name = ''\nbest_string = 'I am '\nyour_age = 6\nmy_int = 5\nprint(float(my_int))\npi = 3.1415\n",
"ste... | [
0,
1,
2,
3
] |
from time import sleep
import RPi.GPIO as gpio
#GPIO.setmode(GPIO.BCM)
gpio.setwarnings(False)
def init():
gpio.setmode(gpio.BCM)
gpio.setup(26, gpio.OUT)
gpio.setup(19, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(6, gpio.OUT)
def turn_left(tf):
gpio.output(26, False)
gpio.output(19, Tru... | normal | {
"blob_id": "a7cbd595b86908fb399bf11e1522588e0b0475c3",
"index": 9226,
"step-1": "<mask token>\n\n\ndef init():\n gpio.setmode(gpio.BCM)\n gpio.setup(26, gpio.OUT)\n gpio.setup(19, gpio.OUT)\n gpio.setup(13, gpio.OUT)\n gpio.setup(6, gpio.OUT)\n\n\ndef turn_left(tf):\n gpio.output(26, False)\n ... | [
4,
6,
7,
8,
10
] |
<|reserved_special_token_0|>
class Methodos(object):
def __init__(self, driver):
self.driver = driver
self.wait = WebDriverWait(self.driver, 15)
<|reserved_special_token_0|>
def Click(self, id):
e = self.wait.until(EC.element_to_be_clickable((By.ID, id)))
e.click()
<|... | flexible | {
"blob_id": "0a23b16329d8b599a4ee533604d316bdfe4b579a",
"index": 4832,
"step-1": "<mask token>\n\n\nclass Methodos(object):\n\n def __init__(self, driver):\n self.driver = driver\n self.wait = WebDriverWait(self.driver, 15)\n <mask token>\n\n def Click(self, id):\n e = self.wait.unt... | [
3,
4,
5,
6,
7
] |
# -*- coding: utf-8 -*-
import sys
import setuptools
from distutils.core import setup
with open("README.md", "r") as fh:
long_description = fh.read()
def get_info():
init_file = 'PIKACHU/__init__.py'
with open(init_file, 'r') as f:
for line in f.readlines():
if "=" in line:
... | normal | {
"blob_id": "f14ff29a1a76c2916cb211c476a56aaa5061bf71",
"index": 8837,
"step-1": "<mask token>\n\n\ndef get_info():\n init_file = 'PIKACHU/__init__.py'\n with open(init_file, 'r') as f:\n for line in f.readlines():\n if '=' in line:\n exec(compile(line, '', 'exec'))\n re... | [
1,
2,
3,
4,
5
] |
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
from home import views
from order import views as OV
urlpatterns = [
path('user', include('user.urls')),
path('order', include('order.urls')),
path('shopcart/',... | normal | {
"blob_id": "97cc29e0d54e5d5e05dff16c92ecc4046363185f",
"index": 344,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif settings.DEBUG:\n urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT\n )\n",
"step-3": "<mask token>\nurlpatterns = [path('user', include('user.urls... | [
0,
1,
2,
3,
4
] |
class Figure:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Figure:
<|reserved_special_token_0|>
def __new__(cls, *args):
if cls is Figure:
return None
return object.__new__(cls)
<|reserve... | flexible | {
"blob_id": "ceab21e41adf171e99e6c3c8541c418d82db6168",
"index": 3272,
"step-1": "class Figure:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class Figure:\n <mask token>\n\n def __new__(cls, *args):\n if cls is Figure:\n return None\n return object.__new__... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def index(request):
data = {}
return render(request, 'polls/index.html', data)
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def index(request):
data = {}
return render(request, 'polls/index.html', data)
<|reserved_special_... | flexible | {
"blob_id": "866ff68744a16158b7917ca6defc35440208ae71",
"index": 8575,
"step-1": "<mask token>\n\n\ndef index(request):\n data = {}\n return render(request, 'polls/index.html', data)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef index(request):\n data = {}\n return render(request, 'polls/i... | [
1,
2,
3,
4,
5
] |
# Import
import sys
from .step import Step
from .repeat import Repeat
# Workout
class Workout(object):
def __init__(self):
self.workout = []
self.steps = []
self.postfixEnabled = True
# TODO: check that len(name) <= 6
def addStep(self, name, duration):
self.workout.append(... | normal | {
"blob_id": "3f80c4c212259a8f3ff96bcc745fd28a85dac3ba",
"index": 8807,
"step-1": "<mask token>\n\n\nclass Workout(object):\n <mask token>\n <mask token>\n\n def addRepeat(self, names, durations, count):\n self.workout.append(Repeat(names, durations, count))\n\n def generateCode(self, filename=... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
__all__ = ['GSClient', 'GSPath']
<|reserved_special_token_1|>
from .gsclient import GSClient
from .gspath import GSPath
__all__ = ['GSClient', 'GSPath']
<|reserved_special_token_1|>
from .gsclient import GSClient
from .gspat... | flexible | {
"blob_id": "7b726dd8ebbd5c49f9ce5bddb4779fcfbaaeb479",
"index": 5651,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['GSClient', 'GSPath']\n",
"step-3": "from .gsclient import GSClient\nfrom .gspath import GSPath\n__all__ = ['GSClient', 'GSPath']\n",
"step-4": "from .gsclient import GSCli... | [
0,
1,
2,
3
] |
from time import sleep
import RPi.GPIO as gpio
buzzer_pin = 18
gpio.setmode(gpio.BCM)
gpio.setup(buzzer_pin, gpio.OUT)
def buzz(pitch, duration):
peroid = 1.0 / pitch
delay = peroid / 2.0
cycles = int(duration * pitch)
for i in range(cycles):
gpio.output(buzzer_pin, True)
sleep(delay)
... | normal | {
"blob_id": "149ac778a552fac4499d7146db8600c91c68c60e",
"index": 4479,
"step-1": "<mask token>\n\n\ndef buzz(pitch, duration):\n peroid = 1.0 / pitch\n delay = peroid / 2.0\n cycles = int(duration * pitch)\n for i in range(cycles):\n gpio.output(buzzer_pin, True)\n sleep(delay)\n ... | [
1,
2,
3,
4
] |
from datetime import datetime
from unittest import TestCase
from vpnmupd import versions
class TestClass01(TestCase):
"""Software dependency versions compared"""
def setUp(self) -> None:
super().setUp()
self.any_string = "Some string containing v1.1.1"
def test_case01(self):
"""... | normal | {
"blob_id": "21d2de5719fafd94605f31bc07231644f4be18c5",
"index": 8749,
"step-1": "<mask token>\n\n\nclass TestClass01(TestCase):\n <mask token>\n <mask token>\n\n def test_case01(self):\n \"\"\"Version extraction\"\"\"\n version = versions.extract_version(self.any_string)\n self.ass... | [
4,
5,
8,
9,
10
] |
<|reserved_special_token_0|>
class StorageFormatArgumentsHelperTest(cli_test_lib.CLIToolTestCase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def testAddArguments(self):
"""Tests the AddArguments function."""
argument_parser = argparse.ArgumentParser(prog='cli_helper.py',
... | flexible | {
"blob_id": "2075e7e05882524c295c8542ca7aefae2cf3e0fc",
"index": 5951,
"step-1": "<mask token>\n\n\nclass StorageFormatArgumentsHelperTest(cli_test_lib.CLIToolTestCase):\n <mask token>\n <mask token>\n\n def testAddArguments(self):\n \"\"\"Tests the AddArguments function.\"\"\"\n argument_... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def euro(number):
return f'{number:.2f} €'.replace('.', ',')
<|reserved_special_token_0|>
class Data:
def __init__(self, data=None, columns=[]):
self.data = {}
self.columns = columns
self.shape = 0, 0
if data:
if columns:
... | flexible | {
"blob_id": "8db952ba5bf42443da89f4064caf012036471541",
"index": 2307,
"step-1": "<mask token>\n\n\ndef euro(number):\n return f'{number:.2f} €'.replace('.', ',')\n\n\n<mask token>\n\n\nclass Data:\n\n def __init__(self, data=None, columns=[]):\n self.data = {}\n self.columns = columns\n ... | [
8,
10,
11,
12,
13
] |
from fractions import Fraction as f
print f(49,98) * f(19, 95) * f(16, 64) * f(26, 65)
| normal | {
"blob_id": "51b32972c97df50a45eb2b9ca58cdec0394e63ee",
"index": 3193,
"step-1": "from fractions import Fraction as f\n\nprint f(49,98) * f(19, 95) * f(16, 64) * f(26, 65)\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
import numpy as np
import time
import os
import csv
import matplotlib.pyplot as plt
from GELu import GELu
from My_Dataset import MyDataset
from pytorchtools import EarlyStopping
from LSTM import LSTM
'''
Wr... | normal | {
"blob_id": "80531ac3cc247d48ee36bff581925b8f29f9e235",
"index": 8590,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef train_model(model, DEVICE, patience, n_epochs, csv_record=False):\n train_losses = []\n valid_losses = []\n avg_train_losses = []\n avg_valid_losses = []\n early_st... | [
0,
1,
2,
3,
4
] |
from compas.geometry import Frame
| normal | {
"blob_id": "d4e3751b2d4796c72be497007fe4c7d8ca67e18e",
"index": 6874,
"step-1": "<mask token>\n",
"step-2": "from compas.geometry import Frame\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: NVLGPSStatus.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _... | normal | {
"blob_id": "98d2196439a8dc3d511d176e61897aa67663a0b5",
"index": 4922,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n_sym_db.RegisterFileDescriptor(DESCRIPTOR)\n<mask token>\n_sym_db.RegisterMessage(NVLGPSStatus)\n",
"step-3": "<mask token>\n_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x:... | [
0,
1,
2,
3,
4
] |
from __future__ import absolute_import, print_function
from django.db import models
from django.utils import timezone
from sentry.db.models import (
Model,
BaseManager,
UUIDField,
sane_repr,
)
class MonitorLocation(Model):
__core__ = True
guid = UUIDField(unique=True, auto_add=True)
nam... | normal | {
"blob_id": "1a4132358fa9bd4cd74970286ec8bb212b1857cd",
"index": 5247,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass MonitorLocation(Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n app_label = 'sentry'\n db_... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class CommentForm(forms.Form):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class CommentForm(forms.Form):
... | flexible | {
"blob_id": "c2ff3c5e44fa361671a3fdb38060517bcc4bc82c",
"index": 2778,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass CommentForm(forms.Form):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass CommentForm(forms.Form):\n name = forms.CharField(labe... | [
0,
1,
2,
3
] |
import json
import paho.mqtt.client as mqtt
from datetime import datetime
import ssl
from collections import OrderedDict
import time
from tkinter import *
import numpy as np
MQTT_IP = 'emq'
MQTT_PORT = 8883
username = "spread_ICAM"
password = "spread_ICAM"
deviceType = "spread_ICAM"
version = "v1"
def on_connect(cli... | normal | {
"blob_id": "f3664f5f69207c3f2dcec96c90cd220003da0904",
"index": 4142,
"step-1": "<mask token>\n\n\ndef on_connect(client, userdata, flags, rc):\n \"\"\"0: Connection successful\n 1: Connection refused - incorrect protocol version\n 2: Connection refused - invalid client identifier\n 3: Connection re... | [
2,
3,
5,
6,
7
] |
"""
Primos <generadores> 30 pts
Realice una generador que devuelva de todos lo numeros primos
existentes de 0 hasta n-1 que cumpla con el siguiente prototipo:
def gprimo(N):
pass
a = gprimo(10)
z = [e for e in a]
print(z)
# [2, 3 ,5 ,7 ]
"""
def gprimo(nmax):
for x in range(1,nmax):
for i in ra... | normal | {
"blob_id": "732886306d949c4059b08e1bc46de3ad95ba56cb",
"index": 1685,
"step-1": "<mask token>\n\n\ndef gprimo(nmax):\n for x in range(1, nmax):\n for i in range(2, x):\n if x % i != 0:\n continue\n else:\n break\n else:\n yield x\n\... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class Model(object):
def __init__(self, batch_size=128, learning_rate=0.01, num_labels=10,
keep_prob=0.5, scope='model'):
self._batch_size = batch_size
self._learning_rate = learning_rate
self._num_labels = num_labels
self._scope = scope
... | flexible | {
"blob_id": "e9a1fd8464f6c1e65aa2c1af60becbfcbf050814",
"index": 7390,
"step-1": "<mask token>\n\n\nclass Model(object):\n\n def __init__(self, batch_size=128, learning_rate=0.01, num_labels=10,\n keep_prob=0.5, scope='model'):\n self._batch_size = batch_size\n self._learning_rate = learn... | [
2,
3,
4,
5,
6
] |
T = int(input())
for i in range(T):
start, end = map(int, input().split())
between = end - start
flag = 0
num = 1
while between > 0:
if flag % 2 == 1:
between -= num
num += 1
flag += 1
else:
between -= num
flag += 1
prin... | normal | {
"blob_id": "a96761fc483c0883b058c2b045b038522c23d426",
"index": 3441,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(T):\n start, end = map(int, input().split())\n between = end - start\n flag = 0\n num = 1\n while between > 0:\n if flag % 2 == 1:\n betwee... | [
0,
1,
2
] |
import math
import random
from PILL import Image, ImageDraw
for i in range(1,1025):
pass
for j in range(1,1025):
pass
epipedo[i][j]
for i in range(1,21):
pass
im = Image.new("RGB", (512, 512), "white")
x=random.choice(1,1025)
y=random.choice(1,1025)
r=random.choi... | normal | {
"blob_id": "a2d2ffe5ed6a844341f7ad731357bb837cee4787",
"index": 6193,
"step-1": "import math\r\nimport random\r\nfrom PILL import Image, ImageDraw\r\nfor i in range(1,1025):\r\n pass\r\n for j in range(1,1025):\r\n pass\r\n epipedo[i][j]\r\nfor i in range(1,21):\r\n pass\r\n im = Image... | [
0
] |
class Sala:
def __init__(self, sala):
self.Turmas = []
self.numero = sala
def add_turma(self, turma):
# do things
self.Turmas.append(turma)
def __str__(self):
return str(self.numero)
| normal | {
"blob_id": "e41df44db92e2ef7f9c20a0f3052e1c8c28b76c7",
"index": 6174,
"step-1": "class Sala:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class Sala:\n <mask token>\n <mask token>\n\n def __str__(self):\n return str(self.numero)\n",
"step-3": "class Sala:\n <mask t... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class FitnerappConfig(AppConfig):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class FitnerappConfig(AppConfig):
name = 'fitnerapp'
<|reserved_special_token_1|>
from djan... | flexible | {
"blob_id": "6546d04d3755d62d1a8756bdec1a10f6f018dcea",
"index": 5638,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass FitnerappConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass FitnerappConfig(AppConfig):\n name = 'fitnerapp'\n",
"step-4": "from django.apps impo... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def mutual_info(parent, child):
parent = [int(x) for x in parent]
child = [int(x) for x in child]
return mutual_info_score(parent, child)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def mimic_binar... | flexible | {
"blob_id": "360e661d8538a8f40b7546a54e9a9582fa64bd67",
"index": 700,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef mutual_info(parent, child):\n parent = [int(x) for x in parent]\n child = [int(x) for x in child]\n return mutual_info_score(parent, child)\n",
"step-3": "<mask token>\n... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class DataSet:
def __init__(self, training_folder):
self.training_folder = training_folder
print('load Data')
<|reserved_special_token_0|>
def readFiles(self, queue, file_list, start, end):
print('start-read-file')
print('start ', start)
... | flexible | {
"blob_id": "ba09dbe3fbca51ece8a7d482324a2dec32e7dc8a",
"index": 5016,
"step-1": "<mask token>\n\n\nclass DataSet:\n\n def __init__(self, training_folder):\n self.training_folder = training_folder\n print('load Data')\n <mask token>\n\n def readFiles(self, queue, file_list, start, end):\n ... | [
3,
4,
5,
6,
7
] |
txt = './KF_neko.txt.mecab'
mapData = {}
listData = []
with open('./KF31.txt', 'w') as writeFile:
with open(txt, 'r') as readFile:
for text in readFile:
# print(text)
# \tで区切って先頭だけ見る
listData = text.split('\t')
# 表層形
surface = listData[0]
... | normal | {
"blob_id": "778ee9a0ea7f57535b4de88a38cd741f2d46e092",
"index": 6966,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('./KF31.txt', 'w') as writeFile:\n with open(txt, 'r') as readFile:\n for text in readFile:\n listData = text.split('\\t')\n surface = listData[0... | [
0,
1,
2,
3
] |
'''
Unit test for `redi.create_summary_report()`
'''
import unittest
import os
import sys
from lxml import etree
from StringIO import StringIO
import time
import redi
file_dir = os.path.dirname(os.path.realpath(__file__))
goal_dir = os.path.join(file_dir, "../")
proj_root = os.path.abspath(goal_dir)+'/'
DEFAULT_DATA_... | normal | {
"blob_id": "f9dd21aac7915b9bbf91eeffb5fd58ffdb43c6c3",
"index": 5857,
"step-1": "<mask token>\n\n\nclass TestCreateSummaryReport(unittest.TestCase):\n\n def setUp(self):\n redi.configure_logging(DEFAULT_DATA_DIRECTORY)\n self.test_report_params = {'project': 'hcvtarget-uf',\n 'report... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class MainWindow(QMainWindow):
playSong = QtCore.pyqtSignal(str)
def __init__(self, music_dir):
super(MainWindow, self).__init__()
self.__music_dir = music_dir
self.resize(400, 70)
self.move(0, 0)
self.setWindowTitle('Drink')
self.s... | flexible | {
"blob_id": "4e86dd74374297c3b0ce8fea93910003dac7d5d7",
"index": 8742,
"step-1": "<mask token>\n\n\nclass MainWindow(QMainWindow):\n playSong = QtCore.pyqtSignal(str)\n\n def __init__(self, music_dir):\n super(MainWindow, self).__init__()\n self.__music_dir = music_dir\n self.resize(40... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def det_cell_king(field):
global cell_king
cell_king = {sign(fig): (x, y) for x, row in enumerate(field) for y,
fig in enumerate(row) if abs(fig) == 6}
return cell_king
<|reserved_special_token_0|>
def rook(field, color, old, new, d):
global castling_control
... | flexible | {
"blob_id": "90c9456bf22745d99fa76dbc752beae1a3835682",
"index": 7672,
"step-1": "<mask token>\n\n\ndef det_cell_king(field):\n global cell_king\n cell_king = {sign(fig): (x, y) for x, row in enumerate(field) for y,\n fig in enumerate(row) if abs(fig) == 6}\n return cell_king\n\n\n<mask token>\n\... | [
4,
8,
9,
10,
11
] |
"""
openAI gym 'cart pole-v0'
"""
import numpy as np
import tensorflow as tf
from collections import deque
import random
import dqn
import gym
import matplotlib.pyplot as plt
# define environment
env = gym.make('CartPole-v0')
# define parameters
INPUT_SIZE = env.observation_space.shape[0]
OUTPUT_SIZE = env.action_sp... | normal | {
"blob_id": "9a40861239268aa62075b77b3ed452f31bb14fac",
"index": 2458,
"step-1": "<mask token>\n\n\ndef get_copy_var_ops(src_scope_name: str, dest_scope_name: str) ->list:\n holder = []\n src_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope=\n src_scope_name)\n dest_vars = tf.get_... | [
4,
5,
6,
7,
8
] |
from binance.client import Client
from binance.websockets import BinanceSocketManager
from binance.enums import *
import time
import threading
import winsound
# Replace your_api_key, your_api_secret with your api_key, api_secret
client = Client(your_api_key, your_api_secret)
# Calculate list of symbols
def calculate... | normal | {
"blob_id": "dcc85b143f2394b7839f2fb9c2079a7dd9fa8e88",
"index": 4733,
"step-1": "<mask token>\n\n\ndef calculate_data_list():\n counter = 0\n btc = 'BTC'\n symbols = []\n all_positions = []\n positions_final = []\n volume = []\n c = []\n price_change = []\n data = client.get_ticker()\... | [
5,
8,
9,
11,
12
] |
api_key = "your_key"
| normal | {
"blob_id": "f024b0736f5fcdebede8d5b0985cf9d7170db8fc",
"index": 7401,
"step-1": "<mask token>\n",
"step-2": "api_key = 'your_key'\n",
"step-3": "api_key = \"your_key\"\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
<|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": "34f79fa3de68b53f19220697815e5bae5270d056",
"index": 9274,
"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 = [('devisa', '0... | [
0,
1,
2,
3,
4
] |
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
def find_packages():
return ['sqlpython']
classifiers = """Development Status :: 4 - Beta
Intended Audience :: Information Technology
License :: OSI Approved :: MIT License
Programming Language... | normal | {
"blob_id": "f960c95afe1f7a161e0144bb523bfaca117ae61e",
"index": 2260,
"step-1": "<mask token>\n",
"step-2": "try:\n from setuptools import setup, find_packages\nexcept ImportError:\n from distutils.core import setup\n\n def find_packages():\n return ['sqlpython']\n<mask token>\nsetup(name='sql... | [
0,
1,
2,
3
] |
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound
from django.shortcuts import render_to_response
from django.template import RequestContext
from whydjango.casestudies.forms import SubmitCaseStudyForm
def case_study_submission(request, tem... | normal | {
"blob_id": "fe3e104cf213b21c33a4b5c6e1a61315c4770eda",
"index": 6821,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef case_study_submission(request, template_name='casestudies/submit.html'):\n form = SubmitCaseStudyForm(request.POST or None)\n if form.is_valid():\n form.save()\n ... | [
0,
1,
2,
3
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This program is run at regular intervals to check the battery charge status of the uninterruptible power supply.
In our case, it is a LiPo battery with a nominal voltage of 3.7 volts. By setting the voltage for the
Raspberry PI shutdown procedure at 3.7 V,we ensure th... | normal | {
"blob_id": "67b967b688aeac1270eee836e0f6e6b3555b933e",
"index": 5,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif u_avg < u_bat_min:\n print('proper shut down of the machine due to low battery')\nelse:\n print('tout va bien dormez braves gens')\n",
"step-3": "<mask token>\npidcmes = Pidcmes()... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class StateConverters:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class DGUSScreen(Entity):
def __init__(self, hass, screen):
self._state = None
self._hass = hass
self._name = screen['name']
sel... | flexible | {
"blob_id": "6f1b08a5ae1a07a30d89f3997461f4f97658f364",
"index": 4920,
"step-1": "<mask token>\n\n\nclass StateConverters:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass DGUSScreen(Entity):\n\n def __init__(self, hass, screen):\n self._state = None\n self._hass = hass\n ... | [
7,
10,
11,
13,
14
] |
from django.shortcuts import render, redirect
# Create your views here.
from item.models import Item, Unit
def str_to_bool(s):
return True if s.lower() == 'true' else False
def item(request):
if not request.session.get('is_login', None):
return redirect('/item/item')
else:
item_list = ... | normal | {
"blob_id": "22b2ebdbb48caa593bece030d238089a0aa27053",
"index": 1983,
"step-1": "<mask token>\n\n\ndef item(request):\n if not request.session.get('is_login', None):\n return redirect('/item/item')\n else:\n item_list = Item.objects.all()\n return render(request, 'item/item.html', loc... | [
4,
5,
6,
8,
11
] |
from enum import Enum
class CellState(Enum):
EMPTY = 1
DEAD = 2
ALIVE = 3
WAS_ALIVE = 4
def __str__(self):
default_str = super(CellState, self).__str__()
if default_str == "CellState.EMPTY":
return "E"
elif default_str == "CellState.DEAD":
return "D"
elif default_str... | normal | {
"blob_id": "29bee4ef11281380aa05d22ef54cb76502ecd685",
"index": 466,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass CellState(Enum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n default_str = super(CellState, self).__str__()\n ... | [
0,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def mean_std(loader):
mean = 0
std = 0
for images, _ in loader:
batch_samples = images.size(0)
images = images.view(batch_samples, images.size(1), -1)
mean += images.mean(2).sum(0)
std += images.std(2).sum(0)
mean /= len(loader.dataset)
... | flexible | {
"blob_id": "4156b003210a41d6ec8f30e2d20adfb1f4b3deb0",
"index": 6024,
"step-1": "<mask token>\n\n\ndef mean_std(loader):\n mean = 0\n std = 0\n for images, _ in loader:\n batch_samples = images.size(0)\n images = images.view(batch_samples, images.size(1), -1)\n mean += images.mean(... | [
1,
2,
3,
4,
5
] |
import unittest
from domain.Activity import Activity
from domain.NABException import NABException
from domain.Person import Person
from domain.ActivityValidator import ActivityValidator
from repository.PersonRepository import PersonRepository
from repository.PersonFileRepository import PersonFileRepository
from reposit... | normal | {
"blob_id": "130581ddb0394dcceabc316468385d4e21959b63",
"index": 8682,
"step-1": "<mask token>\n\n\nclass StatsControllerTestCase(unittest.TestCase):\n\n def setUp(self):\n pR = PersonRepository()\n aR = ActivityRepository()\n self.L = StatsController(pR, aR)\n self.p = Person(1, '... | [
4,
5,
6,
7,
9
] |
<|reserved_special_token_0|>
class WorkerOutcome:
"""Possible outcomes for a worker.
"""
NORMAL = 'normal'
EXCEPTION = 'exception'
NO_TEST = 'no-test'
TIMEOUT = 'timeout'
SKIPPED = 'skipped'
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class... | flexible | {
"blob_id": "73a778c6e4216c23ac8d82eef96ce7b73b18f661",
"index": 9100,
"step-1": "<mask token>\n\n\nclass WorkerOutcome:\n \"\"\"Possible outcomes for a worker.\n \"\"\"\n NORMAL = 'normal'\n EXCEPTION = 'exception'\n NO_TEST = 'no-test'\n TIMEOUT = 'timeout'\n SKIPPED = 'skipped'\n\n\n<mask... | [
3,
5,
6,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def is_leap_year(date):
if date % 400 == 0:
return True
elif date % 100 == 0:
return False
elif date % 4 == 0:
return True
else:
return False
<|reserved_special_token_1|>
#returns true if given date is a leap... | flexible | {
"blob_id": "496d52a984bb8c0e72948ab0c8db5e6035427a68",
"index": 5209,
"step-1": "<mask token>\n",
"step-2": "def is_leap_year(date):\n if date % 400 == 0:\n return True\n elif date % 100 == 0:\n return False\n elif date % 4 == 0:\n return True\n else:\n return False\n",... | [
0,
1,
2
] |
import os
import sqlite3
import operator
from collections import OrderedDict
import matplotlib.pyplot as plt
def parse(url):
try:
parsed_url_components = url.split('//')
sublevel_split = parsed_url_components[1].split('/', 1)
domain = sublevel_split[0].replace("www.", "")
return domain
except IndexError:
p... | normal | {
"blob_id": "c74fc99bf8582fd83c312f27dfffbe894a2c8c1b",
"index": 3431,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef parse(url):\n try:\n parsed_url_components = url.split('//')\n sublevel_split = parsed_url_components[1].split('/', 1)\n domain = sublevel_split[0].replace... | [
0,
1,
2,
3,
4
] |
def ddm_dd_convert(coord, direction):
"""Converts GPS reading from DDM to DD
str coord - the ddm coordinate from $GPGGA
str direction - the direction of the coord (N,S,W,E)
returns - string representation of dd coordinate
"""
value = ''
if (direction == 'S' or direction =... | normal | {
"blob_id": "dc5630e17bb6ed85157b06108250427be41416d1",
"index": 7766,
"step-1": "<mask token>\n\n\ndef gprmc_convert(line):\n \"\"\"Translates $GPRMC line into documented array\n str line - the GPRMC line\n returns - the data documented into array\n \"\"\"\n gps = line.strip().split(',')\n ... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 23 20:33:08 2018
@author: ashima.garg
"""
import tensorflow as tf
class Layer():
def __init__(self, shape, mean, stddev):
self.weights = tf.Variable(tf.random_normal(shape=shape, mean=mean, stddev=stddev))
self.biases = tf.Variable(tf.zeros(shape=[s... | normal | {
"blob_id": "ed246f2887f19ccf922a4d386918f0f0771fb443",
"index": 5106,
"step-1": "<mask token>\n\n\nclass Convolution_Layer(Layer):\n\n def __init__(self, shape, mean, stddev):\n super(Convolution_Layer, self).__init__(shape, mean, stddev)\n\n def feed_forward(self, input_data, stride):\n con... | [
6,
7,
8,
9,
11
] |
<|reserved_special_token_0|>
class Tela:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def setEstagio(self, temp):
if temp in self.telas:
self.estagio = temp
else:
print('Tela não existe, erro de digitação no código')
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "d1f0baa1ff87ece50aaded5e60908269e81b6734",
"index": 1952,
"step-1": "<mask token>\n\n\nclass Tela:\n <mask token>\n <mask token>\n\n def setEstagio(self, temp):\n if temp in self.telas:\n self.estagio = temp\n else:\n print('Tela não existe, erro de digit... | [
3,
5,
6,
7,
8
] |
<|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": "09660cfcff7d5da0339da201cb18b6f63bec2df9",
"index": 1394,
"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 = [('shop', '003... | [
0,
1,
2,
3,
4
] |
# Given two binary strings, return their sum (also a binary string).
#
# For example,
# a = "11"
# b = "1"
# Return "100".
#
# Show Company Tags
# Show Tags
# Show Similar Problems
class Solution(object):
def addBinary(self, a, b):
"""
:type a: str
:type b: str
:rtype: str
... | normal | {
"blob_id": "9655cba5b459ae8b6812bcebc31cc46e19e52386",
"index": 2741,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n",
"step-3": "class Solution(object):\n\n def addBinary(self, a, b):\n \"\"\"\n :type a: str\n :type b: str\n :rtype: str\n ... | [
0,
1,
2,
3
] |
# [백준] https://www.acmicpc.net/problem/11053 가장 긴 증가하는 부분 수열
# 일단 재귀식으로 풀어보기
# 이분탐색 어떻게 할 지 모르겠다
import sys
N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().split()))
def recur():
if A[i] < A[i-1]:
| normal | {
"blob_id": "afccf460bcf04f38b8c66177c86debd39a1b165f",
"index": 5159,
"step-1": "# [백준] https://www.acmicpc.net/problem/11053 가장 긴 증가하는 부분 수열\n# 일단 재귀식으로 풀어보기\n# 이분탐색 어떻게 할 지 모르겠다\n\nimport sys\n\nN = int(sys.stdin.readline().strip())\nA = list(map(int, sys.stdin.readline().split()))\n\ndef recur():\n\n if A... | [
0
] |
import base64
import json
from werkzeug.exceptions import Unauthorized
from ab import app
from ab.utils import logger
from ab.plugins.spring import eureka
def _login(username, password):
"""
only for test
:return the access token
"""
try:
logger.info('login as user {username}'.format(us... | normal | {
"blob_id": "342063b37038c804c2afa78091b1f1c2facbc560",
"index": 3102,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_current_user(s: str=None, required=True):\n \"\"\"\n get current user by request auth header\n :param s:\n :return:\n {'code': 'SUCCESS', 'nickName': 'gs1',... | [
0,
1,
2,
3,
4
] |
from django.views.generic import (ListView, DetailView, CreateView,
DeleteView, UpdateView, TemplateView)
from django.views.generic.edit import ModelFormMixin
from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators i... | normal | {
"blob_id": "a63e5186c0eb8b5ae8510b473168db3461166513",
"index": 7784,
"step-1": "<mask token>\n\n\nclass BaseModelApi(TemplateView, ModelFormMixin):\n\n def get_template_names(self):\n prefix = self.request.method\n if prefix in ['PUT', 'PATCH', 'POST']:\n prefix = 'form'\n na... | [
14,
15,
21,
25,
26
] |
<|reserved_special_token_0|>
class Env:
<|reserved_special_token_0|>
def __init__(self, objective):
"""
Objective is wp/adp/logadp. It indicates whether considers
bomb in reward calculation. Here, we use dummy agents.
This is because, in the orignial game, the players
... | flexible | {
"blob_id": "4015078ee9640c4558a4f29ebbb89f9098a31014",
"index": 5720,
"step-1": "<mask token>\n\n\nclass Env:\n <mask token>\n\n def __init__(self, objective):\n \"\"\"\n Objective is wp/adp/logadp. It indicates whether considers\n bomb in reward calculation. Here, we use dummy agents... | [
13,
24,
32,
36,
37
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
def minimumTotal(self, triangle):
"""
:type triangle: List[List[int]]
:rtype: int
"""
t = triangle
... | flexible | {
"blob_id": "84515ef6879b54b333f9afd48c6c4b7c43ff6957",
"index": 1068,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n",
"step-3": "class Solution(object):\n\n def minimumTotal(self, triangle):\n \"\"\"\n :type triangle: List[List[int]]\n :rtype: int... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
pass
<|reserved_special_token_1|>
#coding: utf-8
"""
1) Encontre em um texto os nomes próprios e os retorne em uma lista. Utilize o Regex (‘import re’) e a função findall(). Na versão básica, ret... | flexible | {
"blob_id": "d95d899c6eae5a90c90d3d920ee40b38bf304805",
"index": 532,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n pass\n",
"step-3": "#coding: utf-8\n\"\"\" \n1) Encontre em um texto os nomes próprios e os retorne em uma lista. Utilize o Regex (‘import re’) e a função... | [
0,
1,
2
] |
from fastapi import APIRouter
from .endpoints import submissions
def get_api_router():
api_router = APIRouter()
api_router.include_router(submissions.router,
prefix="/submissions",
tags=["submissions"])
# api_router.include_router(users.router, ... | normal | {
"blob_id": "844c9af4f0d4ca33e7c69b72f9886f58ceebefdb",
"index": 2719,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_api_router():\n api_router = APIRouter()\n api_router.include_router(submissions.router, prefix='/submissions',\n tags=['submissions'])\n return api_router\n",... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
list.clear()
for i in range(0, n):
list.append('')
tmp = input().split()
list[i] = tmp[0] + list[int(tmp[1]) - 1]
for i in range(0, k):
start = input()
print(len([word for word in list if word.startswith(start)... | flexible | {
"blob_id": "1808be09c2730af5829bb0c7c0c7cfe9f80fe84c",
"index": 7546,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlist.clear()\nfor i in range(0, n):\n list.append('')\n tmp = input().split()\n list[i] = tmp[0] + list[int(tmp[1]) - 1]\nfor i in range(0, k):\n start = input()\n print(le... | [
0,
1,
2,
3
] |
import math
import numpy
import theano
from theano import tensor as T
from utils import shared_dataset
from layer import HiddenLayer, LogisticRegressionLayer
import pickle as pkl
from mlp import MLP, Costs, NeuralActivations
DEBUGGING = False
class PostMLP(MLP):
"""Post training:- Second phase MLP.
A mul... | normal | {
"blob_id": "f9ea29f882c6491a2ac0007e4d9435c732d0967a",
"index": 8582,
"step-1": "import math\n\nimport numpy\nimport theano\n\nfrom theano import tensor as T\n\nfrom utils import shared_dataset\n\nfrom layer import HiddenLayer, LogisticRegressionLayer\nimport pickle as pkl\n\nfrom mlp import MLP, Costs, NeuralA... | [
0
] |
<|reserved_special_token_0|>
def page_html(requested_url):
try:
headers = {'User-Agent':
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'
, 'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0... | flexible | {
"blob_id": "5bfb7fc60ddf4f6ad6d89771eb0a8903b04da3d9",
"index": 6187,
"step-1": "<mask token>\n\n\ndef page_html(requested_url):\n try:\n headers = {'User-Agent':\n 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'\n , 'Acc... | [
3,
4,
5,
6,
7
] |
import sys
import random
#import matplotlib.pyplot as plt
import numpy as np
import time
class Waterfilling:
"""
initializes x and r with optimal flow allocations
and link fair share rates for traffic matrix routes and link
capacities c, and level with number of levels
after running the waterfillin... | normal | {
"blob_id": "93e534e8d425510b59310dcbfc5bca9cc32f245e",
"index": 9798,
"step-1": "import sys\nimport random\n#import matplotlib.pyplot as plt\nimport numpy as np\nimport time\n\nclass Waterfilling:\n \"\"\"\n initializes x and r with optimal flow allocations\n and link fair share rates for traffic matri... | [
0
] |
class Node:
<|reserved_special_token_0|>
def __init__(self, k: int=None, loc: tuple=None, **kwargs):
"""
Each node contain dew fields:
key: node_id.
location: node's position represent as 3DPoint.
ni_out: a dictionary that holds all the "edges" that connected from this n... | flexible | {
"blob_id": "9c3f6c368c764918da5cce44da574b7c041fa414",
"index": 1364,
"step-1": "class Node:\n <mask token>\n\n def __init__(self, k: int=None, loc: tuple=None, **kwargs):\n \"\"\"\n Each node contain dew fields:\n key: node_id.\n location: node's position represent as 3DPoint.... | [
12,
13,
14,
15,
16
] |
from __future__ import print_function
from __future__ import absolute_import
from builtins import str
from builtins import range
from builtins import object
import hashlib
from xml.sax.saxutils import escape
from struct import unpack, pack
import textwrap
import json
from .anconf import warning, error, CONF, enable_c... | normal | {
"blob_id": "2e6f04c3ff3e47a2c3e9f6a7d93e7ce2955a2756",
"index": 8354,
"step-1": "<mask token>\n\n\nclass SVs(object):\n\n def __init__(self, size, ntuple, buff):\n self.__size = size\n self.__value = ntuple._make(unpack(self.__size, buff))\n\n def _get(self):\n l = []\n for i i... | [
35,
62,
63,
65,
71
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
pos_training_path = 'dataset-1/trainset/faces'
neg_training_path = 'dataset-1/trainset/non-faces'
pos_testing_path = 'dataset-1/testset/faces'
neg_testing_path = 'dataset-1/testset/non-fa... | flexible | {
"blob_id": "3f4f60ff315c8e7e4637a84629894012ed13280e",
"index": 3163,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n pos_training_path = 'dataset-1/trainset/faces'\n neg_training_path = 'dataset-1/trainset/non-faces'\n pos_testing_path = 'dataset-1/testset/faces'\n ... | [
0,
1,
2,
3
] |
import torch
import numpy as np
import torch.utils.data as data
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import time
class CNN(nn.Module):
def __init__(self, fragment_length, conv_layers_num, conv_kernel_size,
pool_kernel_size, fc_size, conv_dilation=1, pool_dilat... | normal | {
"blob_id": "415a6cf1c3f633a863851a4a407d416355398b39",
"index": 7732,
"step-1": "<mask token>\n\n\nclass CNN(nn.Module):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass CNN(nn.Module):\n\n def __init__(self, fragment_length, conv_layers_num, conv_kernel_size,\n pool_kernel... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def boxes_to_obj(self, bound):
return {'x1': bound.vertices[0].x, 'x2': bound.vertices[1].x, 'y1':
bound.vertices[0].y, 'y2': bound.vertices[2].y}
def generateTempFolder(self, prifx, src):
"""Creating temp directory.."""
print('Creating temp directory.. with src and ... | flexible | {
"blob_id": "be69a9981fe6b53c3b9c4d2893913e4f9f7efb26",
"index": 6697,
"step-1": "<mask token>\n\n\ndef boxes_to_obj(self, bound):\n return {'x1': bound.vertices[0].x, 'x2': bound.vertices[1].x, 'y1':\n bound.vertices[0].y, 'y2': bound.vertices[2].y}\n\n\ndef generateTempFolder(self, prifx, src):\n ... | [
3,
5,
6,
7,
8
] |
from flask import Flask, request, render_template
from random import choice, sample
app = Flask(__name__)
horoscopes = [
'your day will be awesome',
'your day will be terrific',
'your day will be fantastic',
'neato, you have a fantabulous day ahead',
'your day will be oh-so-not-meh',
'this day... | normal | {
"blob_id": "09d32b48ae88b1066dd0aa435a351c4fb1fc04ec",
"index": 9759,
"step-1": "from flask import Flask, request, render_template\nfrom random import choice, sample\n\napp = Flask(__name__)\n\nhoroscopes = [\n 'your day will be awesome',\n 'your day will be terrific',\n 'your day will be fantastic',\n... | [
0
] |
from final import getMood
import pickle
def get_mood(username_t,username_i):
mapping={'sadness':'0,0,255','angry':'255,0,0','happy':'0,255,0','surprise':'139,69,19','neutral':'189,183,107','fear':'255,165,0'}
#Sad: Blue, Angry: Red, Happy: Green, Surprise: Brown, Neutral:Yellow,Fear:Orange
... | normal | {
"blob_id": "aa4fd27382119e3b10d2b57c9b87deff32b5c1ab",
"index": 586,
"step-1": "from final import getMood\nimport pickle\ndef get_mood(username_t,username_i):\n mapping={'sadness':'0,0,255','angry':'255,0,0','happy':'0,255,0','surprise':'139,69,19','neutral':'189,183,107','fear':'255,165,0'}\n #Sa... | [
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.