code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
from flask import Flask from flask import request from flask import session from flask import jsonify from flask import make_response import mariadb import datetime import json import scad_utils testing: bool = True if testing: fake_datetime = datetime.datetime(2020, 8, 7, 15, 10) app = Flask(__name__) app.confi...
normal
{ "blob_id": "ff6b7e2097d78b013f8f5989adee47156579cb9e", "index": 6226, "step-1": "<mask token>\n\n\n@app.route('/login', methods=['POST'])\ndef login() ->dict:\n db_connection = db.get_connection()\n db_cursor = db_connection.cursor(named_tuple=True)\n data: dict = request.get_json()\n query: str = (...
[ 10, 11, 12, 14, 16 ]
from django.db import models # Create your models here. from django.db import models # Create your models here. class Project(models.Model): project_id = models.IntegerField(primary_key=True) project_name = models.CharField(max_length=50) project_description = models.CharField(max_length=200, blank=True, ...
normal
{ "blob_id": "2783fc24806c323ab4ac44fbac55eef73142ab80", "index": 7710, "step-1": "<mask token>\n\n\nclass Facility(models.Model):\n facility_id = models.IntegerField(primary_key=True)\n facility_name = models.CharField(max_length=50)\n facility_description = models.CharField(max_length=100, blank=True,\...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print( """ <html> <body> <p>Generated {0}</p> </body> </html>""" .format(datetime.now())) <|reserved_special_token_1|> <|reserved_special_token_0|> from datetime import datetime pr...
flexible
{ "blob_id": "e8eac1e4433eee769d317de9ba81d5181168fdca", "index": 6293, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\n \"\"\" <html>\n <body>\n <p>Generated {0}</p>\n </body>\n </html>\"\"\"\n .format(datetime.now()))\n", "step-3": "<mask token>\nfrom da...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python ''' Generate tree search dot file ''' import copy # Colors supported by graphviz, in some pleasing order colors = { "fa": "brown", "fb": "brown1", "ea": "cadetblue", "eb": "cadetblue1", "pa": "orange", "pb": "orange4" } curId = 1 capAset = 4 capBset = 7 goal = 2 de...
normal
{ "blob_id": "599da0f045ab5c2b3f568def3d89452b56cac029", "index": 9083, "step-1": "#!/usr/bin/env python\n\n'''\n Generate tree search dot file\n'''\nimport copy\n\n# Colors supported by graphviz, in some pleasing order\ncolors = {\n \"fa\": \"brown\",\n \"fb\": \"brown1\",\n \"ea\": \"cadetblue\",\n ...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def game_manager(info_list): dictionary = {} for piece_info in info_list: piece_info = piece_info.split('||') piece_info[2] = int(piece_info[2]) if piece_info[2] not in dictionary: dictionary[piece_info[2]] = {(piec...
flexible
{ "blob_id": "a382edb861a43ac3065a781ea996a8d1dd819954", "index": 6649, "step-1": "<mask token>\n", "step-2": "def game_manager(info_list):\n dictionary = {}\n for piece_info in info_list:\n piece_info = piece_info.split('||')\n piece_info[2] = int(piece_info[2])\n if piece_info[2] no...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @listen_to('(.*)') def receive_question(message, question_string): if message._body['channel'] == SLACK_CHANNEL: try: query_ccjieba = ccjieba.cut(question_string.strip()) query_unigram = unigram.cut(question_string.strip()) results = post_mu...
flexible
{ "blob_id": "3630f83e7e6a10f42e96f8bd6fa9714232d9176b", "index": 4552, "step-1": "<mask token>\n\n\n@listen_to('(.*)')\ndef receive_question(message, question_string):\n if message._body['channel'] == SLACK_CHANNEL:\n try:\n query_ccjieba = ccjieba.cut(question_string.strip())\n q...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class TestBloomFilter(object): def test_setup(self): bf = BloomFilter(1000) assert 10 == bf._num_hashes assert 14380 == bf._num_bits assert 14380 == len(bf._bitarray) assert 0 == bf._bitarray.count() bf = BloomFilter(1000, error=0.01) ...
flexible
{ "blob_id": "24e486edc6f80e0b7d58b5df898e6d34f53111c8", "index": 4389, "step-1": "<mask token>\n\n\nclass TestBloomFilter(object):\n\n def test_setup(self):\n bf = BloomFilter(1000)\n assert 10 == bf._num_hashes\n assert 14380 == bf._num_bits\n assert 14380 == len(bf._bitarray)\n ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> class PrinterTkinter: def __init__(self): self.root = Tk() self.root.title('气球发放') self.runid_to_node = dict() self.runid_to_uid = dict() self.runid_to_pid = dict() self.have_uid_pid = set() self.unfinished_runid = [] se...
flexible
{ "blob_id": "76e1f811d06af0e6e83ae989a236a5cd22c55e01", "index": 2985, "step-1": "<mask token>\n\n\nclass PrinterTkinter:\n\n def __init__(self):\n self.root = Tk()\n self.root.title('气球发放')\n self.runid_to_node = dict()\n self.runid_to_uid = dict()\n self.runid_to_pid = dic...
[ 5, 8, 10, 12, 13 ]
<|reserved_special_token_0|> class NET(nn.Module): <|reserved_special_token_0|> def uzunluk(self, x): x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2)) x = F.max_pool2d(F.relu(self.conv2(x)), (2, 2)) x = F.max_pool2d(F.relu(self.conv3(x)), (2, 2)) if self.boyut is None: ...
flexible
{ "blob_id": "ad63beedc460b3d64a51d0b1f81f8e44cb559749", "index": 1655, "step-1": "<mask token>\n\n\nclass NET(nn.Module):\n <mask token>\n\n def uzunluk(self, x):\n x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))\n x = F.max_pool2d(F.relu(self.conv2(x)), (2, 2))\n x = F.max_pool2d(F.re...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import datetime class Migration(migrations.Migration): dependencies = [ ('products', '0007_auto_20150904_1320'), ] operations = [ migrations.AddField( model_name='custome...
normal
{ "blob_id": "fd52379d125d6215fe12b6e01aa568949511549d", "index": 6964, "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 = [('products', ...
[ 0, 1, 2, 3, 4 ]
# import visual_servoing_utils_main as utils from autolab_core import rigid_transformations as rt from yumipy import YuMiState class YumiConstants: T_gripper_gripperV = rt.RigidTransform(rotation=[[-1, 0, 0], [0, 1, 0], [0, 0, -1]], from_frame='gripper', to_frame='obj') ...
normal
{ "blob_id": "34c81b9318d978305748d413c869a86ee6709e2c", "index": 996, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass YumiConstants:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for h in range(11, 41): for i in range(model_img_array.shape[0]): for j in range(model_img_array.shape[2]): dis = np.sqrt(pow(13 - i, 2) + pow(9 - j, 2)) if dis <= 2: model_img_a...
flexible
{ "blob_id": "f84ab1530cbc6bd25c45fc607d8f1cd461b180bf", "index": 2089, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor h in range(11, 41):\n for i in range(model_img_array.shape[0]):\n for j in range(model_img_array.shape[2]):\n dis = np.sqrt(pow(13 - i, 2) + pow(9 - j, 2))\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class LogicTests(utils_testcase.TestCase): def setUp(self): super(LogicTests, self).setUp() game_logic.create_test_map() self.account_1 = self.accounts_factory.create_account() self.account_1_items = (prototypes.AccountItemsPrototype. get_b...
flexible
{ "blob_id": "89e5e82c073f7f87c00fc844c861c6c5cbe6a695", "index": 8893, "step-1": "<mask token>\n\n\nclass LogicTests(utils_testcase.TestCase):\n\n def setUp(self):\n super(LogicTests, self).setUp()\n game_logic.create_test_map()\n self.account_1 = self.accounts_factory.create_account()\n ...
[ 5, 6, 7, 8, 9 ]
class Ball: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Ball: <|reserved_special_token_0|> def draw(self): self.canvas.move(self.id, self.x, self.y) pos = self.canvas.coords(self.id) if pos[1] <= ...
flexible
{ "blob_id": "cb1e73d172314c8d3d31f6e49fa67582375c0c58", "index": 7183, "step-1": "class Ball:\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "class Ball:\n <mask token>\n\n def draw(self):\n self.canvas.move(self.id, self.x, self.y)\n pos = self.canvas.coords(self.id)\n...
[ 1, 2, 3, 4, 5 ]
import pytest from time import sleep from timeflux.helpers.background import Task class DummyWorker(): def echo(self, message='hello', delay=0, fail=False): sleep(delay) if fail: raise Exception('failed') self.message = message return(self.message) def test_default(working_path): ...
normal
{ "blob_id": "d2e46944ab05c5e8c1979101728b7b25900be342", "index": 415, "step-1": "<mask token>\n\n\nclass DummyWorker:\n\n def echo(self, message='hello', delay=0, fail=False):\n sleep(delay)\n if fail:\n raise Exception('failed')\n self.message = message\n return self.me...
[ 4, 5, 7, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': pygame.init() fuente = pygame.font.Font(None, 36) pantalla = pygame.display.set_mode([ANCHO, ALTO]) pantalla.fill(BLANCO) General = pygame.sprite.Group() Jugadores = pygame.sprite...
flexible
{ "blob_id": "85fc2fc0a404c20b1f0806412424192ea4a50a9b", "index": 7085, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n pygame.init()\n fuente = pygame.font.Font(None, 36)\n pantalla = pygame.display.set_mode([ANCHO, ALTO])\n pantalla.fill(BLANCO)\n General = pyg...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def getTeams(reign, uprising, hunters, fuel, mayhem, gladiators, charge, outlaws, spark, spitfire, excelsior, eternal, fusion, dynasty, shock, dragons, defiant, valiant, titans, justice): teamList = discord.Embed(tit...
flexible
{ "blob_id": "9a02e09cbfe2c9b6ebb9d20ba6cea639871f0838", "index": 7647, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getTeams(reign, uprising, hunters, fuel, mayhem, gladiators, charge,\n outlaws, spark, spitfire, excelsior, eternal, fusion, dynasty, shock,\n dragons, defiant, valiant, tit...
[ 0, 1, 2, 3 ]
import tornado.web import tornado.escape from torcms.core.base_handler import BaseHandler from owslib.csw import CatalogueServiceWeb from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox class DirectorySearchHandler(BaseHandler): def initialize(self): super(DirectorySearchHandler, self).initializ...
normal
{ "blob_id": "72ce7c48c9d1a7bcdbaead12648d03970663a11e", "index": 3227, "step-1": "<mask token>\n\n\nclass DirectorySearchHandler(BaseHandler):\n\n def initialize(self):\n super(DirectorySearchHandler, self).initialize()\n <mask token>\n <mask token>\n <mask token>\n\n def ajax_get(self, uui...
[ 9, 10, 11, 13, 14 ]
from typing import List import tensorflow as tf from tensorflow.keras.layers import Dense """Possible agent network structures implemented as Tensorflow Modules""" class QNetwork: """Create the neural network architecture for the DQN agent.""" def __init__( self, state_dim: int, act...
normal
{ "blob_id": "a3e655350fb5fe7999bea4a87fb62c7698fb63f1", "index": 6663, "step-1": "<mask token>\n\n\nclass QNetwork:\n <mask token>\n\n def __init__(self, state_dim: int, action_dim: int=3,\n hidden_layer_sizes: List=[128, 256, 256, 128], activation: str='relu'):\n self._state_dim = state_dim\...
[ 2, 3, 4, 5, 6 ]
from PIL import Image from flask_restplus import Namespace, Resource from werkzeug.datastructures import FileStorage from core.models.depthinthewild import DepthInTheWild from core.utils import serve_pil_image api = Namespace('nyudepth', description='Models Trained on NYUDepth') upload_parser = api.parser() upload_pars...
normal
{ "blob_id": "acf409f2e56cd16b7dc07476b49b9c18675f7775", "index": 5540, "step-1": "<mask token>\n\n\n@api.route('/depthinthewild/transform')\n@api.expect(upload_parser)\nclass DepthInTheWildDepthTransform(Resource):\n <mask token>\n\n\n@api.route('/depthinthewild/transform_raw')\n@api.expect(upload_parser)\ncl...
[ 3, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def check_triads(trio, final_str): list_occur_zero = [i for i in range(len(final_str)) if final_str. startswith(trio + '0', i)] list_occur_one = [i for i in range(len(final_str)) if final_str. startswith(...
flexible
{ "blob_id": "29304bdbf93b0b1308025db1d35a92346c6dcbe0", "index": 3799, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef check_triads(trio, final_str):\n list_occur_zero = [i for i in range(len(final_str)) if final_str.\n startswith(trio + '0', i)]\n list_occur_one = [i for i in range(l...
[ 0, 1, 2, 3, 5 ]
import cv2 as cv #! THESE ARE IMAGES THAT AREN'T DOWNSIZED #original_image_1 = cv.imread("hamburger_face.JPG") #original_image_2 = cv.imread("hammock_reading.JPG") #original_image_3 = cv.imread("sofa_face.JPG") #original_image_4 = cv.imread("frisbee_team.JPG") original_image_5 = cv.imread("mans_face.JPG") # ...
normal
{ "blob_id": "d0bd08bea65878f5fccfc4affecdf53cc36179df", "index": 6633, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor face in detected_faces:\n x, y, w, h = face\n cv.rectangle(original_image_5, (x, y), (x + w, y + h), (0, 255, 0), 2)\ncv.imshow('orig_img', original_image_5)\ncv.waitKey(0)\ncv....
[ 0, 1, 2, 3, 4 ]
import json import re from bs4 import BeautifulSoup from bs4.element import NavigableString, Tag from common import dir_path def is_element(el, tag): return isinstance(el, Tag) and el.name == tag class ElemIterator(): def __init__(self, els): self.els = els self.i = 0 def peek(self): try: ...
normal
{ "blob_id": "cb08f64d1ad7e53f1041684d4ca4ef65036c138d", "index": 44, "step-1": "<mask token>\n\n\ndef is_element(el, tag):\n return isinstance(el, Tag) and el.name == tag\n\n\nclass ElemIterator:\n\n def __init__(self, els):\n self.els = els\n self.i = 0\n\n def peek(self):\n try:\n...
[ 10, 12, 14, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('/home', views.home), url('/about', views.about)] <|reserved_special_token_1|> from django.conf.urls import url from tree import views urlpatterns = [url('/home', views.home), url('/about', views.about)] <|...
flexible
{ "blob_id": "3313f01ed98433f4b150c4d8e877ac09eb8403b4", "index": 5652, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('/home', views.home), url('/about', views.about)]\n", "step-3": "from django.conf.urls import url\nfrom tree import views\nurlpatterns = [url('/home', views.home), ur...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(12): mp = monthlyPaymentRate * rb rb = rb - mp rb = rb + rb * monthlyir print('remaining balance: ', round(rb, 2)) <|reserved_special_token_1|> balance = 42 annualInterestRate = 0.2 monthlyPaymentRate...
flexible
{ "blob_id": "1429524b0ae3b679bc3d4386dd17ed50b0fff381", "index": 146, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(12):\n mp = monthlyPaymentRate * rb\n rb = rb - mp\n rb = rb + rb * monthlyir\nprint('remaining balance: ', round(rb, 2))\n", "step-3": "balance = 42\nannualInter...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> __all__ = ['language'] <|reserved_special_token_0|> <|reserved_special_token_1|> __all__ = ['language'] from StringTemplate import *
flexible
{ "blob_id": "e70c25ce1d61437aacfe7fad0a51e096e1ce4f5d", "index": 5212, "step-1": "<mask token>\n", "step-2": "__all__ = ['language']\n<mask token>\n", "step-3": "__all__ = ['language']\nfrom StringTemplate import *\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
<|reserved_special_token_0|> def computeDice(im1, im2): im1 = np.asarray(im1).astype(np.bool) im2 = np.asarray(im2).astype(np.bool) if im1.shape != im2.shape: raise ValueError( 'Shape mismatch: im1 and im2 must have the same shape.') intersection = np.logical_and(im1, im2) dice...
flexible
{ "blob_id": "cb03fcf9c9cb61b3546865fe40cc411745e1fc94", "index": 6872, "step-1": "<mask token>\n\n\ndef computeDice(im1, im2):\n im1 = np.asarray(im1).astype(np.bool)\n im2 = np.asarray(im2).astype(np.bool)\n if im1.shape != im2.shape:\n raise ValueError(\n 'Shape mismatch: im1 and im2...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def test_mat(): model = models.load_metabolic_model('RECON2_mat') assert isinstance(model, MetabolicModel) assert len(model.reactions) == 7440 assert len(model.species) == 5063 def test_to_json(): model = models.load_metabolic_model('RECON2.2') json = model.to_JS...
flexible
{ "blob_id": "863bae04a90143ed942a478c4b71a2269e123bb5", "index": 2980, "step-1": "<mask token>\n\n\ndef test_mat():\n model = models.load_metabolic_model('RECON2_mat')\n assert isinstance(model, MetabolicModel)\n assert len(model.reactions) == 7440\n assert len(model.species) == 5063\n\n\ndef test_to...
[ 2, 3, 4, 5, 6 ]
from django.apps import AppConfig class AdminrequestsConfig(AppConfig): name = 'adminRequests'
normal
{ "blob_id": "e08b7a96c957895068e584a0564f02c52acd48ec", "index": 3753, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AdminrequestsConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AdminrequestsConfig(AppConfig):\n name = 'adminRequests'\n", "step-4": "from djan...
[ 0, 1, 2, 3 ]
import pandas as pd import numpy as np import sys def avg (x): return [sum(x[i])/row for i in range(col)] def sd (x): return [np.std(x[i]) for i in range(col)] def cov (x, md_x): cov_xy=[[0 for r in range(col)] for c in range(col)] for i in range(col): for j in range (col): for k ...
normal
{ "blob_id": "ad3c5ed3d6a9aa83e69f53d3fec845e8e2b1c9c6", "index": 883, "step-1": "<mask token>\n\n\ndef avg(x):\n return [(sum(x[i]) / row) for i in range(col)]\n\n\n<mask token>\n\n\ndef cov(x, md_x):\n cov_xy = [[(0) for r in range(col)] for c in range(col)]\n for i in range(col):\n for j in ran...
[ 3, 4, 5, 6, 7 ]
############################## Import Modules ################################## import pandas as pd import numpy as np import re from scipy import stats import matplotlib.pyplot as plt ############################## Define Functions ################################ # generate list containing data of standard curve de...
normal
{ "blob_id": "19949b07c866d66b3ef00b6a386bf89f03e06294", "index": 7984, "step-1": "<mask token>\n\n\ndef process_std(standard_input_file):\n try:\n with open(standard_input_file, 'r') as in_handle:\n lin_reg_lst = []\n for line in in_handle:\n line = line.strip('\\n'...
[ 3, 4, 5, 6, 8 ]
from arnold import config class TestMicrophone: def setup_method(self, method): self.config = config.SENSOR['microphone'] def test_config(self): required_config = [ 'card_number', 'device_index', 'sample_rate', 'phrase_time_limit', 'energy_threshold' ] ...
normal
{ "blob_id": "164167590051fac3f3fd80c5ed82621ba55c4cc4", "index": 9597, "step-1": "<mask token>\n\n\nclass TestMicrophone:\n <mask token>\n\n def test_config(self):\n required_config = ['card_number', 'device_index', 'sample_rate',\n 'phrase_time_limit', 'energy_threshold']\n for co...
[ 3, 4, 5, 6, 7 ]
def findOrder(numCourses,prerequisites): d={} for i in prerequisites: if i[0] not in d: d[i[0]]=[i[1]] if i[1] not in d: d[i[1]]=[] else: d[i[0]].append(i[1]) res=[] while d: for i in range(numCourses): if d[i] == []: res.append(d[i]) tmp=d[i] del d[i] for j in d: if tmp i...
normal
{ "blob_id": "75b13f4985fcf26fb9f7fb040554b52b13c1806d", "index": 4848, "step-1": "def findOrder(numCourses,prerequisites):\n\td={}\n\tfor i in prerequisites:\n\t\tif i[0] not in d:\n\t\t\td[i[0]]=[i[1]]\n\t\t\tif i[1] not in d:\n\t\t\t\td[i[1]]=[]\n\t\telse:\n\t\t\td[i[0]].append(i[1])\n\tres=[]\n\twhile d:\n\t\...
[ 0 ]
from colander_validators import ( email, url) def test_url(): assert url("ixmat.us") == True assert url("http://bleh.net") == True assert type(url("://ixmat.us")) == str assert type(url("ixmat")) == str def test_email(): assert email("barney@purpledino.com") == True assert email("b...
normal
{ "blob_id": "40637c7a5e45d0fe4184478a1be2e08e5040c93b", "index": 8931, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_email():\n assert email('barney@purpledino.com') == True\n assert email('barney.10.WHATDINO@purple.com') == True\n assert type(email('barney')) == str\n assert ty...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 from pexpect import pxssh import time s = pxssh.pxssh() ip = "" #replace ip address username= "" #replace username password= "" #replace password s.login (ip, username, password) print ("SSH session login successful") s.sendline ('application stop') s.prompt() # match the prompt print("S...
normal
{ "blob_id": "dd9574ea08beb9bc5f1413afd63c751fd42cba67", "index": 6406, "step-1": "<mask token>\n", "step-2": "<mask token>\ns.login(ip, username, password)\nprint('SSH session login successful')\ns.sendline('application stop')\ns.prompt()\nprint('Stopping the app')\nprint(\"\"\"\nStarting the app\"\"\")\ns.sen...
[ 0, 1, 2, 3, 4 ]
import datetime from django.db import models from django.utils import timezone class Acoount(models.Model): first_name = models.CharField("Ім\'я", max_length=50) last_name = models.CharField('Прізвище', max_length=50) username = models.CharField('Псевдонім', max_length=50) email = models.CharField('Е...
normal
{ "blob_id": "18c2fe40b51ad1489d55aa2be068a1c4f381a2a5", "index": 553, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Acoount(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name = 'А...
[ 0, 1, 2, 4, 5 ]
from django.test import TestCase from recruitmentapp.apps.core.models import Competence class CompetenceTest(TestCase): def setUp(self): self.competence = Competence.objects.create(name='mining') self.competence.set_current_language('sv') self.competence.name = 'gruvarbete' self.c...
normal
{ "blob_id": "d7b0ff6549d854d21ad1d2d0f5a9e7f75f4ac1d5", "index": 956, "step-1": "<mask token>\n\n\nclass CompetenceTest(TestCase):\n <mask token>\n\n def test_translation(self):\n competence = Competence.objects.first()\n self.assertEqual(competence.name, 'mining')\n competence.set_cur...
[ 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @login_required def post_create(request): """ This makes sure that the form accpets a POST requests (of some data) or Nothing. Without this the form would even accept empty data. """ form = PostForm(request.POST or ...
flexible
{ "blob_id": "4a2437d3d6ba549910bc30a67bf391b9bbafd25f", "index": 6210, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@login_required\ndef post_create(request):\n \"\"\"\n\t\tThis makes sure that the form accpets a POST requests (of some data) or Nothing.\n\t\tWithout this the form would even acce...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class SWFRect(object): def __init__(self, xmin, xmax, ymin, ymax): self.xmin = xmin self.xmax = xmax self.ymin = ymin self.ymax = ymax def __str__(self): return 'SWFRect(' + str(self.xmin) + ',' + str(self.xmax) + ',' + str( se...
flexible
{ "blob_id": "4556febd5fddf390f370a8e24871eacf08d34c9f", "index": 7087, "step-1": "<mask token>\n\n\nclass SWFRect(object):\n\n def __init__(self, xmin, xmax, ymin, ymax):\n self.xmin = xmin\n self.xmax = xmax\n self.ymin = ymin\n self.ymax = ymax\n\n def __str__(self):\n ...
[ 17, 18, 20, 22, 24 ]
from collections import Counter class Solution: def countStudents(self, students, sandwiches) ->int: if not students or not sandwiches: return 0 while students: top_san = sandwiches[0] if top_san == students[0]: students = students[1:] ...
normal
{ "blob_id": "235fce2615e2a5879f455aac9bcecbc2d152679b", "index": 4548, "step-1": "<mask token>\n\n\nclass Solution:\n\n def countStudents(self, students, sandwiches) ->int:\n if not students or not sandwiches:\n return 0\n while students:\n top_san = sandwiches[0]\n ...
[ 2, 3, 5, 6 ]
# -*- coding: utf-8 -*- a=float(input('Digite um número:')) b=(a-(a%1)) c=(a%1) print('O valor inteiro é %d' %b) print('O valor decimal é %.6f' %c)
normal
{ "blob_id": "1b09b18926dc95d4c4b3088f45088f12c162ccb3", "index": 5465, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('O valor inteiro é %d' % b)\nprint('O valor decimal é %.6f' % c)\n", "step-3": "a = float(input('Digite um número:'))\nb = a - a % 1\nc = a % 1\nprint('O valor inteiro é %d' % b)\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def validate_url(ch, method, properties, body): message = json.loads(body) valid = True print(f"Got new URL to check: {message['url']}.") try: urllib.request.urlopen('https://github.com/' + message['url']) except urllib.error.HTTPError as e: if e.code !...
flexible
{ "blob_id": "4a09096abf073294afcf21b1eff9350329d4db33", "index": 5252, "step-1": "<mask token>\n\n\ndef validate_url(ch, method, properties, body):\n message = json.loads(body)\n valid = True\n print(f\"Got new URL to check: {message['url']}.\")\n try:\n urllib.request.urlopen('https://github....
[ 1, 2, 3, 4, 5 ]
import os import location import teamList import pandas as pd import csv import matplotlib.pyplot as plt import numpy as np from scipy import stats ##adapted from code from this website: ## https://towardsdatascience.com/simple-little-tables-with-matplotlib-9780ef5d0bc4 year = "18-19" team = "ARI" seasonReportRaw =...
normal
{ "blob_id": "ba7db49ca7956fdc055702ffccba769485fd0046", "index": 8915, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor row in data:\n cell_text.append([f'{x:1.2f}' for x in row])\n<mask token>\nplt.figure(linewidth=2, edgecolor=fig_border, facecolor=\n fig_background_color, tight_layout={'pad': ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def intersection(set_a, set_b): res = [i for i in set_a if i in set_b] return res <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def recursiveUnioniser(set): if isinstance(set[0], int): return set res = [] for i in...
flexible
{ "blob_id": "c632c50028fee2f19fb65458f0b55ec228b8006f", "index": 2137, "step-1": "<mask token>\n\n\ndef intersection(set_a, set_b):\n res = [i for i in set_a if i in set_b]\n return res\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef recursiveUnioniser(set):\n if isinstance(set[0], int):\n ...
[ 1, 4, 5, 6, 7 ]
#!/usr/bin/python3 # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2018 foree <foree@foree-pc> # # Distributed under terms of the MIT license. """ 配置logging的基本配置 """ import logging import sys import os from common.common import get_root_path FILE_LEVEL = logging.DEBUG STREAM_LEVEL = logging.WARN LOG_DIR = ...
normal
{ "blob_id": "96910e9b6861fc9af0db3a3130d898fd1ee3daad", "index": 3356, "step-1": "<mask token>\n", "step-2": "<mask token>\nif not os.path.exists(LOG_DIR):\n os.mkdir(LOG_DIR)\nif not os.path.exists(PATH_LOG):\n f = open(PATH_LOG, 'w')\n f.write('')\n f.close()\n<mask token>\nlogger.setLevel(loggin...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.insert(0, parentdir) <|reserved_special_token_0|> s2.setTitle('二叉树——递归套路') <|reserved_special_token_0|> r2.setTitle('二叉树——递归套路') <|reserved_special_token_0|> xmind.build(content, r2) xmind.save(w, os.path.dirname(os.path....
flexible
{ "blob_id": "b713e38824db13f919484b071fb35afb29e26baa", "index": 3803, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.insert(0, parentdir)\n<mask token>\ns2.setTitle('二叉树——递归套路')\n<mask token>\nr2.setTitle('二叉树——递归套路')\n<mask token>\nxmind.build(content, r2)\nxmind.save(w, os.path.dirname(os.pat...
[ 0, 1, 2, 3, 4 ]
class Config(object): DEBUG = False TESTING = False class ProductionConfig(Config): CORS_ALLOWED_ORIGINS = "productionexample.com" class DevelopmentConfig(Config): DEBUG = True CORS_ALLOWED_ORIGINS = "developmentexample.com" class TestingConfig(Config): TESTING = True
normal
{ "blob_id": "b76c868a29b5edd07d0da60b1a13ddb4ac3e2913", "index": 6988, "step-1": "<mask token>\n\n\nclass DevelopmentConfig(Config):\n DEBUG = True\n CORS_ALLOWED_ORIGINS = 'developmentexample.com'\n\n\nclass TestingConfig(Config):\n TESTING = True\n", "step-2": "<mask token>\n\n\nclass ProductionConf...
[ 4, 5, 7, 8, 9 ]
<|reserved_special_token_0|> def augment(components, augmentors, use_o=False): """ Augmenting of images. :param components: components :return: updated components. """ img_path = components[0] height = components[1] width = components[2] center = components[3] bbox = component...
flexible
{ "blob_id": "e47223622a2718830d830dbb779800659d659ae3", "index": 8472, "step-1": "<mask token>\n\n\ndef augment(components, augmentors, use_o=False):\n \"\"\"\n Augmenting of images.\n\n :param components: components\n :return: updated components.\n \"\"\"\n img_path = components[0]\n height...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class Vintage: <|reserved_special_token_0|> def __init__(self, year, month): self.year, self.month = year, month self.csv = LocalCSV(year, month) <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_spec...
flexible
{ "blob_id": "e78c4f65d84d5b33debb415005e22f926e14d7d4", "index": 1203, "step-1": "<mask token>\n\n\nclass Vintage:\n <mask token>\n\n def __init__(self, year, month):\n self.year, self.month = year, month\n self.csv = LocalCSV(year, month)\n <mask token>\n <mask token>\n <mask token>...
[ 9, 13, 14, 15, 19 ]
from django.contrib import admin from .models import Game, Scrap admin.site.register(Game) admin.site.register(Scrap)
normal
{ "blob_id": "7e328992392a4ff2b0e23920a8907e38f63fcff0", "index": 7168, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Game)\nadmin.site.register(Scrap)\n", "step-3": "from django.contrib import admin\nfrom .models import Game, Scrap\nadmin.site.register(Game)\nadmin.site.register(Sc...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class Skeleton: <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, nml_path: str=None, parameters: Parameters=None, strict=True): """ The Skeleton constructor expects either a path to a nml file or a Parameters object as input argumen...
flexible
{ "blob_id": "365d031a31f3596df6fb71e620c293382d6ead1f", "index": 2635, "step-1": "<mask token>\n\n\nclass Skeleton:\n <mask token>\n <mask token>\n\n def __init__(self, nml_path: str=None, parameters: Parameters=None,\n strict=True):\n \"\"\" The Skeleton constructor expects either a path ...
[ 25, 43, 44, 46, 50 ]
<|reserved_special_token_0|> @login_manager.user_loader def load_user(userid): try: return models.user.get(models.User.id == userid) except models.DoesNotExist: return None def initialize(): models.DATABASE.connect() models.DATABASE.create_tables([models.User], safe=True) models....
flexible
{ "blob_id": "849c468e4890c19806c678089ec8668576538b12", "index": 2717, "step-1": "<mask token>\n\n\n@login_manager.user_loader\ndef load_user(userid):\n try:\n return models.user.get(models.User.id == userid)\n except models.DoesNotExist:\n return None\n\n\ndef initialize():\n models.DATAB...
[ 8, 9, 10, 13, 14 ]
<|reserved_special_token_0|> def calcSuccess(predictedCounter, randAssault): vidLabel.pack_forget() if predictedCounter == 'parry_R': instructionLabel.config(text='RIGHT PARRY') if randAssault == 4 or randAssault == 2: descriptionLabel.config(text="You've successfully parried!") ...
flexible
{ "blob_id": "8cf6a9243182a4f6b68199a8967e06790396dc10", "index": 5967, "step-1": "<mask token>\n\n\ndef calcSuccess(predictedCounter, randAssault):\n vidLabel.pack_forget()\n if predictedCounter == 'parry_R':\n instructionLabel.config(text='RIGHT PARRY')\n if randAssault == 4 or randAssault =...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class Folder(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class Meta: verbose_name_plural = 'Folders/Categories' class Bookmark(models.Model): name = models.CharField(max_length=200) url = models....
flexible
{ "blob_id": "ca3cdbd5d5d30be4f40925366994c3ea9d9b9614", "index": 3195, "step-1": "<mask token>\n\n\nclass Folder(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name_plural = 'Folders/Categories'\n\n\nclass Bookmark(models.Model):\n name = models.Char...
[ 4, 5, 6, 7, 8 ]
from app01 import models from rest_framework.views import APIView # from api.utils.response import BaseResponse from rest_framework.response import Response from rest_framework.pagination import PageNumberPagination from api.serializers.course import DegreeCourseSerializer # 查询所有学位课程 class DegreeCourseView(APIView):...
normal
{ "blob_id": "2b3f8b1ac4735785683c00f6e6ced85d201de53f", "index": 8567, "step-1": "<mask token>\n\n\nclass DegreeCourseDetailView(APIView):\n\n def get(self, request, pk, *args, **kwargs):\n response = {'code': 100, 'data': None, 'error': None}\n try:\n degree_course = models.DegreeCou...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> conn.request('GET', '/teams/statistics?season=2016&team=768&league=4', headers=headers) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> conn = http.client.HTTPSConnection('v3.football....
flexible
{ "blob_id": "a6617934c5e6527cf59225a5d159d1ce8a33db50", "index": 6681, "step-1": "<mask token>\n", "step-2": "<mask token>\nconn.request('GET', '/teams/statistics?season=2016&team=768&league=4',\n headers=headers)\n<mask token>\n", "step-3": "<mask token>\nconn = http.client.HTTPSConnection('v3.football.a...
[ 0, 1, 2, 3, 4 ]
n, imp = list(map(int, input().split())) villagers = {} peoples = [] susList = set() for i in range(n): peeps = set(list(map(int, input().split()))[1:]) # Initialize the set villagers[i+1] = villagers.get(i+1, set()) for p in peeps: if i+1 in peeps: susList.add(i+1) break...
normal
{ "blob_id": "3eca3066a6c6484257ca17164d35654812a87b80", "index": 6636, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n peeps = set(list(map(int, input().split()))[1:])\n villagers[i + 1] = villagers.get(i + 1, set())\n for p in peeps:\n if i + 1 in peeps:\n ...
[ 0, 1, 2, 3 ]
"""This is the body of the low-level worker tool. A worker is intended to run as a process that imports a module, mutates it in one location with one operator, runs the tests, reports the results, and dies. """ import difflib import importlib import inspect import json import logging import subprocess import sys impo...
normal
{ "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|> <|reserved_special_token_0|> for i in range(a): d = b * (a - i) + c * (a - (a - i)) + c * (a - (a - i)) + b * (a - i) print(d) <|reserved_special_token_1|> <|reserved_special_token_0|> a = int(input('numero: ')) b = '*' c = 'o' for i in range(a): ...
flexible
{ "blob_id": "155b243ad7d93bcf2b74cd5b2bd3409ab7ec7473", "index": 8488, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(a):\n d = b * (a - i) + c * (a - (a - i)) + c * (a - (a - i)) + b * (a - i)\n print(d)\n", "step-3": "<mask token>\na = int(input('numero: '))\nb = '*'\nc = 'o'\nfo...
[ 0, 1, 2, 3, 4 ]
A, B = map(int, input().split()) K = (B ** 2 - A ** 2) / (2 * A - 2 * B) print(int(abs(K))) if K.is_integer() else print('IMPOSSIBLE')
normal
{ "blob_id": "36a7d3ed28348e56e54ce4bfa937363a64ee718f", "index": 6981, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(int(abs(K))) if K.is_integer() else print('IMPOSSIBLE')\n", "step-3": "A, B = map(int, input().split())\nK = (B ** 2 - A ** 2) / (2 * A - 2 * B)\nprint(int(abs(K))) if K.is_intege...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def deps_remote(): for step in INSTALL_STEPS: run(step) <|reserved_special_token_1|> <|reserved_special_token_0|> def deps_local(): for step in INSTALL_STEPS: local(step) def deps_remote(): for step in INSTALL_STEPS: run(step) <|reserved_specia...
flexible
{ "blob_id": "d64140466e62b78506d0f200f451649023697a3b", "index": 1386, "step-1": "<mask token>\n\n\ndef deps_remote():\n for step in INSTALL_STEPS:\n run(step)\n", "step-2": "<mask token>\n\n\ndef deps_local():\n for step in INSTALL_STEPS:\n local(step)\n\n\ndef deps_remote():\n for step...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(N): x, y = map(int, input().split()) if x * x + y * y <= D2: ans += 1 print(ans) <|reserved_special_token_1|> N, D = map(int, input().split()) ans = 0 D2 = D * D for i in range(N): x, y = map(...
flexible
{ "blob_id": "947055d1d6acc50e1722d79ea30e327414cd9c41", "index": 8523, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(N):\n x, y = map(int, input().split())\n if x * x + y * y <= D2:\n ans += 1\nprint(ans)\n", "step-3": "N, D = map(int, input().split())\nans = 0\nD2 = D * D\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def calc_accumulated_indicende_per_ccaa(report, num_days=15): ccaas = data_sources.get_ccaas_in_dset(report) dframe = report['dframe'] num_cases = dframe['num_casos'] ccaa_column = data_sources.get_ccaa_column_in_index(num_cases.index) index = num_cases.index.to_frame(...
flexible
{ "blob_id": "4c5b3042a785342d6ef06fdc882e0dcf91a787c3", "index": 7816, "step-1": "<mask token>\n\n\ndef calc_accumulated_indicende_per_ccaa(report, num_days=15):\n ccaas = data_sources.get_ccaas_in_dset(report)\n dframe = report['dframe']\n num_cases = dframe['num_casos']\n ccaa_column = data_sources...
[ 4, 9, 10, 11, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Player: <|reserved_special_token_0|> def pick_up_item(self, item): if len(self.items) <= 3: self.items.append(item) print( f""" NOW YOU HAVE THE {item}! You can drop it at any time by typing 'dro...
flexible
{ "blob_id": "b355bd5a519d65ea35d4e8d5e6a384424d79130a", "index": 3620, "step-1": "<mask token>\n", "step-2": "class Player:\n <mask token>\n\n def pick_up_item(self, item):\n if len(self.items) <= 3:\n self.items.append(item)\n print(\n f\"\"\"\n\nNOW YOU HAVE ...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def send_ty(): DonorName = 'list' while DonorName == 'list': DonorName = input( '"Provide Donor Full Name, or type: "List" to display a list of all donors => ' ) if DonorName.lower().strip() == 'list': view_donors() c...
flexible
{ "blob_id": "f2292d1816699392663bdbf7a06c334de3b2022c", "index": 7118, "step-1": "<mask token>\n\n\ndef send_ty():\n DonorName = 'list'\n while DonorName == 'list':\n DonorName = input(\n '\"Provide Donor Full Name, or type: \"List\" to display a list of all donors => '\n )\n ...
[ 7, 9, 10, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TeacherForm(forms.Form): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TeacherForm(forms.Form): name = forms.CharField(label='You...
flexible
{ "blob_id": "7c5877eea78c3fa8b7928219edd52e2502c16c09", "index": 6392, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TeacherForm(forms.Form):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TeacherForm(forms.Form):\n name = forms.CharField(label='Your Name', max...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def connect(autocommit=False, attrs_before=None): return pyodbc.connect(CNXNSTR, autocommit=autocommit, attrs_before= attrs_before) <|reserved_special_token_0|> def test_nvarchar(cursor: pyodbc.Cursor): _test_vartype(cursor, 'nvarchar') def test_varbinary(cursor: pyo...
flexible
{ "blob_id": "51358ac7d4fc093f8291cfd9f098e3ac3db86cce", "index": 8282, "step-1": "<mask token>\n\n\ndef connect(autocommit=False, attrs_before=None):\n return pyodbc.connect(CNXNSTR, autocommit=autocommit, attrs_before=\n attrs_before)\n\n\n<mask token>\n\n\ndef test_nvarchar(cursor: pyodbc.Cursor):\n ...
[ 47, 56, 70, 97, 108 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: def merge(self, nums1, m, nums2, n): """ Do not return anything, modify nums1 in-place instead. """ ...
flexible
{ "blob_id": "4f13e2858d9cf469f14026808142886e5c3fcc85", "index": 28, "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 merge(self, nums1, m, nums2, n):\n \"\"\"\n Do not return anything, modify nums1 in-place ins...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def vecs2numpy(fname, new_file_name, file_type, file_len=None): if file_type == 'bvecs': vectors, dim = vecs_io.bvecs_read_mmap(fname) elif file_type == 'ivecs': vectors, dim = vecs_io.ivecs_read_mmap(fname) elif file_type == 'fvecs': vectors, dim = vec...
flexible
{ "blob_id": "5f84c8654c976bca2fa33e8f9ba5e28e3249253d", "index": 7312, "step-1": "<mask token>\n\n\ndef vecs2numpy(fname, new_file_name, file_type, file_len=None):\n if file_type == 'bvecs':\n vectors, dim = vecs_io.bvecs_read_mmap(fname)\n elif file_type == 'ivecs':\n vectors, dim = vecs_io....
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class A2C_agent(object): <|reserved_special_token_0|> def act(self, state): action_distribution = self.actor_network.forward(state) action = np.random.choice(self.num_of_actions, p= action_distribution.detach().numpy()) return action def m...
flexible
{ "blob_id": "72b086e833ab3ee4ec3102869d74513ef3657675", "index": 1926, "step-1": "<mask token>\n\n\nclass A2C_agent(object):\n <mask token>\n\n def act(self, state):\n action_distribution = self.actor_network.forward(state)\n action = np.random.choice(self.num_of_actions, p=\n acti...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from nose.tools import * from json import json def test_json_basestring(): assert_equals(json("Hello World"), '"Hello World"') def test_json_integer(): assert_equals(json(9), "9") def test_json_float(): assert_equals(json(1.234), "1.234") def test_json...
normal
{ "blob_id": "09ce2aeccfd1f3f4f130fd79001db47485cc95c2", "index": 9891, "step-1": "<mask token>\n\n\ndef test_json_float():\n assert_equals(json(1.234), '1.234')\n\n\ndef test_json_array():\n data = [1, 2, 3]\n assert_equals(json(data), '[1,2,3]')\n\n\ndef test_json_array02():\n data = ['bla', 1, 1.2]...
[ 12, 13, 19, 22, 24 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> try: from ez_setup import use_setuptools use_setuptools() except ImportError: pass <|reserved_special_token_0|> setup(name='django-defaultsite', version='1.1', packages=find_packages( 'src'), package_dir={'': 'src'...
flexible
{ "blob_id": "5580e5942370c925b759b09675306cdfbc7dd4f1", "index": 3633, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n from ez_setup import use_setuptools\n use_setuptools()\nexcept ImportError:\n pass\n<mask token>\nsetup(name='django-defaultsite', version='1.1', packages=find_packages(\n...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # coding:utf-8 # 改进小红球 class Ball: def __init__(self, canvas, paddle, color): self.canvas = canvas self.paddle = paddle self.id = canvas.create_oval(10, 10, 25, 25, fill=color) self.canvas.move(self.id, 245, 100) starts = [-3, -2, -1, 1, 2, 3] ...
normal
{ "blob_id": "cb1e73d172314c8d3d31f6e49fa67582375c0c58", "index": 7183, "step-1": "class Ball:\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "class Ball:\n <mask token>\n\n def draw(self):\n self.canvas.move(self.id, self.x, self.y)\n pos = self.canvas.coords(self.id)\n...
[ 1, 2, 3, 4, 5 ]
class Solution: def countBits(self, num: int) -> List[int]: total = [] for i in range(num + 1): counter = bin(i).count('1') # for j in bin(i): # if j == '1': # counter += 1 total.append(counter) return total...
normal
{ "blob_id": "c6554ff18c23a61d3694e73b808f44c96f9a19c4", "index": 2012, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def countBits(self, num: int) ->List[int]:\n total = []\n for i in range(num + 1):\n counter = bin(i)....
[ 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": "b36f3ffed888edaa7716f712f1549dc205799caf", "index": 6338, "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 = [('lots', '001...
[ 0, 1, 2, 3, 4 ]
y_true = [7, 3, 3, 4, 9, 9, 2, 5, 0, 0, 6, 3, 1, 6, 8, 7, 9, 7, 4, 2, 0, 1, 4, 1, 7, 7, 5, 0, 8, 0, 1, 7, 4, 2, 2, 4, 9, 3, 1, 7, 1, 2, 1, 7, 5, 9, 9, 4, 8, 5, 7, 2, 7, 5, 5, 6, 6, 1, 2, 6, 6, 5, 3, 2, 3, 8, 8, 8, 8, 5, 3, 4, 3, 2, 8, 1, 9, 0, 6, 8, 6, 1, 1, 1, 5, 4, 8, 8, 5, 5, 8, 6, 4, 4, 6, 9, 8, 1, ...
normal
{ "blob_id": "593d3221e34c0eef51228082d767d8516ec93ca2", "index": 8002, "step-1": "<mask token>\n", "step-2": "y_true = [7, 3, 3, 4, 9, 9, 2, 5, 0, 0, 6, 3, 1, 6, 8, 7, 9, 7, 4, 2, 0, 1,\n 4, 1, 7, 7, 5, 0, 8, 0, 1, 7, 4, 2, 2, 4, 9, 3, 1, 7, 1, 2, 1, 7, 5, 9,\n 9, 4, 8, 5, 7, 2, 7, 5, 5, 6, 6, 1, 2, 6, 6...
[ 0, 1 ]
# -*- coding: utf-8 -*- # @COPYRIGHT_begin # # Copyright [2015] Michał Szczygieł, M4GiK Software # # 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 of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
normal
{ "blob_id": "9f2105d188ac32a9eef31b21065e9bda13a02995", "index": 6735, "step-1": "<mask token>\n\n\n@register.inclusion_tag('tags/fieldsetForm.html')\ndef show_fieldsetform(form):\n \"\"\"\n Renders given form without marking required fields.\n @param form:\n @return:\n \"\"\"\n return {'form':...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def _get_single_variable(self, name, shape=None, dtype=dtypes.float32, initializer=None, regularizer=None, partition_info=None, reuse=None, trainable=True, collections=None, caching_device=None, validate_shape= True, use_resource=None): """Get...
flexible
{ "blob_id": "51ef1c0f6a17e12b2324a80f962b2ce47cc05bcc", "index": 1348, "step-1": "<mask token>\n", "step-2": "def _get_single_variable(self, name, shape=None, dtype=dtypes.float32,\n initializer=None, regularizer=None, partition_info=None, reuse=None,\n trainable=True, collections=None, caching_device=No...
[ 0, 1, 2 ]
from ethereum.abi import ( decode_abi, normalize_name as normalize_abi_method_name, method_id as get_abi_method_id) from ethereum.utils import encode_int, zpad, decode_hex import json import time from web3 import Web3, HTTPProvider, TestRPCProvider from solc import compile_source from web3.contract import ...
normal
{ "blob_id": "6437cb90ebaed7cf59df780062ebccf77fcef084", "index": 4123, "step-1": "<mask token>\n\n\ndef decode_contract_call(contract_abi: list, call_data: str):\n call_data_bin = decode_hex(call_data)\n method_signature = call_data_bin[:4]\n for description in contract_abi:\n if description.get(...
[ 1, 2, 3, 4, 5 ]
import cv2 #imports cv2 package import numpy as np #imports numpy package import matplotlib.pyplot as plt #imports matplotlib.pyplot package img_noblur = cv2.imread('road8.jpg') #reads the image imgnew = img_noblur.copy() #creates a copy of the image img_noblur_grey = cv2.cvtColor(img_noblu...
normal
{ "blob_id": "7b4f46f6c286a7d0ef45079b2fd238b81d5f89eb", "index": 3493, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor x in range(0, len(lines)):\n for x1, y1, x2, y2 in lines[x]:\n cv2.line(imgnew, (x1, y1), (x2, y2), (0, 255, 0), 5)\n<mask token>\nplt.subplot(131), plt.imshow(img_noblur, c...
[ 0, 1, 2, 3, 4 ]
#rules used for pattern matching # #1. x='[abc]' either a,b or c #eg: # import re # x="[abc]" # matcher=re.finditer(x,"abt cq5kz") # for match in matcher: # print(match.start()) # print(match.group()) #2. x='[^abc]' except abc #eg: # import re # x="[^abc]" # matcher=re.finditer(x,"abt cq5kz") # for match in ...
normal
{ "blob_id": "1ddc261cf174c109583fd0ead1f537673d29090a", "index": 1433, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor match in matcher:\n print(match.start())\n print(match.group())\n", "step-3": "<mask token>\nx = '[a-zA-Z]'\nmatcher = re.finditer(x, 'abtABIkz')\nfor match in matcher:\n p...
[ 0, 1, 2, 3, 4 ]
from django.shortcuts import render, redirect from django.contrib import messages from .models import * from django.views.decorators.csrf import csrf_exempt def index(request): notes = Note.objects.all().order_by('-created_at') context = { "notes" : notes } return render(request, 'notes/index.h...
normal
{ "blob_id": "e983db4b99e73929c02eb84fab1ee56138048052", "index": 8221, "step-1": "<mask token>\n\n\ndef index(request):\n notes = Note.objects.all().order_by('-created_at')\n context = {'notes': notes}\n return render(request, 'notes/index.html', context)\n\n\ndef add(request):\n if request.method ==...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class QuantModelMetricsResource(MetricsResource): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class MlModelMetricsResource(MetricsResource): """ This resource handles the HTTP requests coming to the endpoint "/ml_model/m...
flexible
{ "blob_id": "1431a0049c05a99e0b68052f56bf8e2e3c48e1aa", "index": 622, "step-1": "<mask token>\n\n\nclass QuantModelMetricsResource(MetricsResource):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass MlModelMetricsResource(MetricsResource):\n \"\"\"\n This resource handles the HTTP requests c...
[ 16, 19, 23, 25, 26 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def classFactory(iface): from .tilemapscaleplugin import TileMapScalePlugin return TileMapScalePlugin(iface) <|reserved_special_token_1|> # -*- coding: utf-8 -*- """ /**************************************************...
flexible
{ "blob_id": "f2e2ebd5b848cf3a01b7304e5e194beb3eec1c10", "index": 1214, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef classFactory(iface):\n from .tilemapscaleplugin import TileMapScalePlugin\n return TileMapScalePlugin(iface)\n", "step-3": "# -*- coding: utf-8 -*-\n\"\"\"\n/*************...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class ClusterTestCase(unittest.TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ClusterTestCase(unittest.TestCase): def test_cluster(self): n = 10 experiments, outcomes = ut...
flexible
{ "blob_id": "a7e2b016131dfdb75e537e86875e1b2f19fb3d9d", "index": 2580, "step-1": "<mask token>\n\n\nclass ClusterTestCase(unittest.TestCase):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass ClusterTestCase(unittest.TestCase):\n\n def test_cluster(self):\n n = 10\n ex...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def print_usage(): sys.stderr.write( """ Find the length of the biggest line in the file. Usage: ./biggestLine <delimiter> <field number - first element is 0> <file path> """ ) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_specia...
flexible
{ "blob_id": "c84175edb88f5b9219c22ec717ec30bb530982a2", "index": 2861, "step-1": "<mask token>\n\n\ndef print_usage():\n sys.stderr.write(\n \"\"\"\nFind the length of the biggest line in the file.\nUsage: ./biggestLine <delimiter> <field number - first element is 0> <file path>\n \"\"\"\n ...
[ 1, 2, 3, 4, 5 ]
from nose.tools import assert_equal def rec_coin(target, coins): ''' INPUT: Target change amount and list of coin values OUTPUT: Minimum coins needed to make change Note, this solution is not optimized. ''' # Default to target value min_coins = target # Check to see if we have a sin...
normal
{ "blob_id": "f8c30f8ccd1b901fd750a2c9e14cab78e1d12a14", "index": 4039, "step-1": "<mask token>\n\n\ndef rec_coin(target, coins):\n \"\"\"\n INPUT: Target change amount and list of coin values\n OUTPUT: Minimum coins needed to make change\n\n Note, this solution is not optimized.\n \"\"\"\n min_...
[ 4, 6, 7, 8, 9 ]
N = int(input("Max value N? ")) s = set() for i in range(2, N + 1): s.add(i) for num in sorted(s): k = num + num while k <= N: if k in s: s.remove(k) k += num print("Primes:", end = " ") for num in sorted(s): print(num, end = " ")
normal
{ "blob_id": "bf5422792533f85967a5573d9e6f370a7967a914", "index": 120, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(2, N + 1):\n s.add(i)\nfor num in sorted(s):\n k = num + num\n while k <= N:\n if k in s:\n s.remove(k)\n k += num\nprint('Primes:', end=' ...
[ 0, 1, 2, 3 ]
""" These are data input download and prep scripts. They download and massage the data for the UBM calculations (calc.py) """ from __future__ import absolute_import, division, print_function, unicode_literals import time import urllib try: # For Python 3.0 and later import urllib.request except ImportError: ...
normal
{ "blob_id": "afb09f9d5860994f38e8553b19e7ebc339cc2df6", "index": 8785, "step-1": "<mask token>\n\n\ndef get_file_list(save_path, wld='*.105*.hdf'):\n \"\"\"\n\n Args:\n save_path: path to folder where raw MODIS files are\n wld: common wildcard in all of the raw MODIS files\n\n Returns:\n ...
[ 6, 11, 12, 13, 16 ]
""" 题目描述 HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学。 今天测试组开完会后,他又发话了:在古老的一维模式识别中, 常常需要计算连续子向量的最大和,当向量全为正数的时候,问题很好解决。 但是,如果向量中包含负数,是否应该包含某个负数,并期望旁边的正数会弥补它呢? 例如:{6,-3,-2,7,-15,1,2,2},连续子向量的最大和为8(从第0个开始,到第3个为止)。 给一个数组,返回它的最大连续子序列的和,你会不会被他忽悠住?(子向量的长度至少是1) """ # -*- coding:utf-8 -*- class Solution: def FindGreatestSumOfSubArray(self, ar...
normal
{ "blob_id": "fcca845b60b050fa5dd0a3c50b3c36c154022f07", "index": 1467, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n\n def FindGreatestSumOfSubArray(self, array):\n dp = [array[0]]\n res = array[0]\n f...
[ 1, 2, 3, 4, 5 ]
"""Splits the google speech commands into train, validation and test sets. """ import os import shutil import argparse def move_files(src_folder, to_folder, list_file): with open(list_file) as f: for line in f.readlines(): line = line.rstrip() dirname = os.path.dirname(line) ...
normal
{ "blob_id": "6b2fc94d9a53b8f669cab5e1fb625dd01e20ba98", "index": 664, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef move_files(src_folder, to_folder, list_file):\n with open(list_file) as f:\n for line in f.readlines():\n line = line.rstrip()\n dirname = os.path.d...
[ 0, 1, 2, 3, 4 ]
""" Package for django_static_template. """
normal
{ "blob_id": "818623621b609d67f8f657be4ade6e3bb86a0bc5", "index": 4226, "step-1": "<mask token>\n", "step-2": "\"\"\"\r\nPackage for django_static_template.\r\n\"\"\"\r\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def check(data): global ss global s for line in data: s += int(line) if ss.get(s, False): return s ss[s] = True return None <|reserved_special_token_0|> <|reserved_special_...
flexible
{ "blob_id": "7e1dd242c60ee12dfc4130e379fa35ae626a4d63", "index": 5217, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef check(data):\n global ss\n global s\n for line in data:\n s += int(line)\n if ss.get(s, False):\n return s\n ss[s] = True\n return None...
[ 0, 1, 2, 3, 4 ]
from turtle import * while True: n=input("Right or left? ") if n == 'right': right(60) forward(100) elif n == 'left': left(60) forward(100)
normal
{ "blob_id": "6f698196e9391d73bd99cda0a098a5bf7a3832ff", "index": 963, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n n = input('Right or left? ')\n if n == 'right':\n right(60)\n forward(100)\n elif n == 'left':\n left(60)\n forward(100)\n", "step-3": ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class MyConnection(Connection): <|reserved_special_token_0|> def get_none1(self): """No return type is specified.""" pass <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|rese...
flexible
{ "blob_id": "82c3419679a93c7640eae48b543aca75f5ff086d", "index": 4880, "step-1": "<mask token>\n\n\nclass MyConnection(Connection):\n <mask token>\n\n def get_none1(self):\n \"\"\"No return type is specified.\"\"\"\n pass\n <mask token>\n <mask token>\n <mask token>\n <mask token>...
[ 19, 20, 21, 37, 39 ]
<|reserved_special_token_0|> class PG_Agent(object): def __init__(self, env, policy: torch.nn.modules.container.Sequential, learning_rate: float, n_policy: int, n_episode: int, max_timesteps: int ) ->None: super().__init__() self.env = env self.policy = policy self...
flexible
{ "blob_id": "b2cfd397e48213a540608fc232db2eab282935bb", "index": 1481, "step-1": "<mask token>\n\n\nclass PG_Agent(object):\n\n def __init__(self, env, policy: torch.nn.modules.container.Sequential,\n learning_rate: float, n_policy: int, n_episode: int, max_timesteps: int\n ) ->None:\n su...
[ 6, 7, 8, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class BmExam(db.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|...
flexible
{ "blob_id": "6be2cc99d03596715d76cda41d63b8c91c829498", "index": 2211, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BmExam(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask toke...
[ 0, 1, 2, 3, 4 ]
"""Utilties to access a column and one field of a column if the column is composite.""" from typing import TYPE_CHECKING, Optional from greenplumpython.db import Database from greenplumpython.expr import Expr from greenplumpython.type import DataType if TYPE_CHECKING: from greenplumpython.dataframe import DataFra...
normal
{ "blob_id": "a52edeec62a6849bda7e5a5481fb6e3d7d9a4c6a", "index": 8571, "step-1": "<mask token>\n\n\nclass Column(Expr):\n \"\"\"\n Inherited from :class:`~expr.Expr`.\n\n Representation of a Python object :class:`~col.Column`.\n \"\"\"\n\n def __init__(self, name: str, dataframe: 'DataFrame') ->No...
[ 6, 9, 10, 12, 13 ]
from ED63RDScenarioHelper import * def main(): SetCodePage("ms932") CreateScenaFile( FileName = 'C2219 ._SN', MapName = 'Ruan', Location = 'C2219.x', MapIndex = 84, MapDefaultBGM = "ed60015", Flags ...
normal
{ "blob_id": "55c2bf914a77c573d1b6835f54c82921d9fa6ad6", "index": 1010, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n SetCodePage('ms932')\n CreateScenaFile(FileName='C2219 ._SN', MapName='Ruan', Location=\n 'C2219.x', MapIndex=84, MapDefaultBGM='ed60015', Flags=0,\n ...
[ 0, 1, 2, 3, 4 ]
import torch.utils.data import torch import math from util.helpers import * from collections import defaultdict as ddict class _Collate: def __init__(self, ): pass def collate(self, batch): return torch.squeeze(torch.from_numpy(np.array(batch))) class PR: dataset = None eval_data = N...
normal
{ "blob_id": "606a6e7ecc58ecbb11aa53602599e671514bc537", "index": 3890, "step-1": "<mask token>\n\n\nclass PR:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def init(self, d...
[ 7, 8, 9, 11, 14 ]