code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|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": "adff75857a1de24267e771c599e4d89486a6ad32", "index": 7439, "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 = [('assessment'...
[ 0, 1, 2, 3, 4 ]
# Question : determine whether given number is power of 2 # logic : every no. of the form 2^i has bit represetntaion of the form : # 2 -> 10 1->01 # 4 -> 100 3->011 # 8 -> 1000 7->0111 # 16 -> 10000 15->01111 # 32 -> 100000 31->011111 # ... and so on # Thus there is a pattern here, ever p...
normal
{ "blob_id": "676aec735dd7441b0c481956ad18b012b8d98ea4", "index": 8459, "step-1": "<mask token>\n", "step-2": "def is_power(n):\n if n == 0:\n return 'not power of two'\n if n & n - 1 == 0:\n return 'power of 2'\n return 'not power of 2'\n\n\n<mask token>\n", "step-3": "def is_power(n):...
[ 0, 1, 2, 3 ]
def decorate(): print('hi') @decorate def decorated(): print('decorated') decorate()
normal
{ "blob_id": "1328d62769ee2a0309021ff40fdbf78a2c5570c9", "index": 9678, "step-1": "<mask token>\n", "step-2": "def decorate():\n print('hi')\n\n\n<mask token>\n", "step-3": "def decorate():\n print('hi')\n\n\n@decorate\ndef decorated():\n print('decorated')\n\n\n<mask token>\n", "step-4": "def deco...
[ 0, 1, 2, 3 ]
from ryu.base import app_manager from ryu.controller import ofp_event from ryu.controller.handler import MAIN_DISPATCHER from ryu.controller.handler import set_ev_cls from ryu.ofproto import ofproto_v1_0 from ryu.lib.mac import haddr_to_bin from ryu.lib.packet import packet from ryu.lib.packet import ethernet from ryu...
normal
{ "blob_id": "86d032a3cd67118eb46073c996f1c9a391f8dfe0", "index": 1608, "step-1": "<mask token>\n\n\nclass SimpleSwitch(app_manager.RyuApp):\n <mask token>\n <mask token>\n <mask token>\n print('PACKET_OUT...')\n", "step-2": "<mask token>\n\n\nclass SimpleSwitch(app_manager.RyuApp):\n\n def __ini...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class FASTGIString(GIPlatformInterface): <|reserved_special_token_0|> def __init__(self, number, sender): """Initialise GI string. TODO: Need to implement the enable_relay and control which strings are dimmable. """ self.log = logging.getL...
flexible
{ "blob_id": "91cf6d08be2ad86c08de4dd48b2f35dedc55b4bb", "index": 2177, "step-1": "<mask token>\n\n\nclass FASTGIString(GIPlatformInterface):\n <mask token>\n\n def __init__(self, number, sender):\n \"\"\"Initialise GI string.\n\n TODO: Need to implement the enable_relay and control which stri...
[ 3, 4, 5, 6, 7 ]
# MIT LICENSE # # Copyright 1997 - 2019 by IXIA Keysight # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify,...
normal
{ "blob_id": "4b78c99dd6156afe960effcacb25804446310f7c", "index": 9708, "step-1": "<mask token>\n\n\nclass VirtualChassis(Base):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, parent):\n super(VirtualChassis, self).__init__(parent)\n <mask token>\n\n @property\n de...
[ 12, 13, 16, 17, 19 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def longestValidParentheses(s): stack = [] maxLength = 0 stack.append(-1) for i in range(len(s)): if s[i] == '(': stack.append(i) else: stack.pop() if len(stack...
flexible
{ "blob_id": "0f03ff63662b82f813a18cc8ece3d377716ce678", "index": 2318, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef longestValidParentheses(s):\n stack = []\n maxLength = 0\n stack.append(-1)\n for i in range(len(s)):\n if s[i] == '(':\n stack.append(i)\n el...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Action(dict): <|reserved_special_token_0|> <|reserved_special_token_1|> class Action(dict): def __init__(self, action, player=None, target=None): self['action'] = action self['player'] = player if target != None: ...
flexible
{ "blob_id": "1c9345923fe83aa0ee7165ce181ce05ac55e2b2f", "index": 7773, "step-1": "<mask token>\n", "step-2": "class Action(dict):\n <mask token>\n", "step-3": "class Action(dict):\n\n def __init__(self, action, player=None, target=None):\n self['action'] = action\n self['player'] = player...
[ 0, 1, 2 ]
wage=5 print("%d시간에 %d%s 벌었습니다." %(1, wage*1, "달러")) print("%d시간에 %d%s 벌었습니다." %(5, wage*5, "달러")) print("%d시간에 %.1f%s 벌었습니다" %(1,5710.8,"원")) print("%d시간에 %.1f%s 벌었습니다" %(5, 28554.0, "원"))
normal
{ "blob_id": "2092ead8b8f268a22711b8af8052241c1ac00c15", "index": 14, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('%d시간에 %d%s 벌었습니다.' % (1, wage * 1, '달러'))\nprint('%d시간에 %d%s 벌었습니다.' % (5, wage * 5, '달러'))\nprint('%d시간에 %.1f%s 벌었습니다' % (1, 5710.8, '원'))\nprint('%d시간에 %.1f%s 벌었습니다' % (5, 28554.0,...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def escape_maze(maze): end = len(maze) - 1 step_counter = 0 offset = 0 while True: cur_index = offset offset = offset + maze[cur_index] if maze[cur_index] >= 3: maze[cur_index]...
flexible
{ "blob_id": "a4dfac7e15064d92c806a4e3f972f06e4dca6b11", "index": 5181, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef escape_maze(maze):\n end = len(maze) - 1\n step_counter = 0\n offset = 0\n while True:\n cur_index = offset\n offset = offset + maze[cur_index]\n ...
[ 0, 1, 2, 3, 4 ]
n_m_q=input().split(" ") n=int(n_m_q[0]) m=int(n_m_q[1]) q=int(n_m_q[2]) dcc=[] for i in range(n): a=[] dcc.append(a) available=[] for i in range(m): x=input().split(" ") a=int(x[0]) b=int(x[1]) available.append([a,b]) dcc[a-1].append(b) dcc[b-1].append(a) for i in range(q): x=input(...
normal
{ "blob_id": "062b6133ba4de24f7eaf041e4b6c039501b47b9a", "index": 8873, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n a = []\n dcc.append(a)\n<mask token>\nfor i in range(m):\n x = input().split(' ')\n a = int(x[0])\n b = int(x[1])\n available.append([a, b])\n dc...
[ 0, 1, 2, 3 ]
# -*- coding:utf-8 -*- # Classe com os dados de um cliente que entra no sistema simulado. class Client: def __init__(self, id, color): # Identificador do cliente, usada para o teste de correção. self.id = id # Tempo de chegada ao servidor (fila 1 e fila 2) self.arrival = {} ...
normal
{ "blob_id": "5dc201f743705d6a57dfb61ec2cc2a827db0ba25", "index": 7234, "step-1": "class Client:\n\n def __init__(self, id, color):\n self.id = id\n self.arrival = {}\n self.leave = {}\n self.server = {}\n self.queue = 0\n self.served = 0\n self.color = color\n\...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> class BaseTickSchema(BaseSchema): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_...
flexible
{ "blob_id": "6cc23a3e2fa3b1baddf05b30a1054a7faf0371a6", "index": 5528, "step-1": "<mask token>\n\n\nclass BaseTickSchema(BaseSchema):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass BaseTickSchema(BaseSchema):\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for _ in range(int(input())): noe = int(input()) arr = [int(x) for x in input().split()] left = arr[0] rite = sum(arr) - left mins = abs(rite - left) for i in range(1, noe - 1): left += arr[i] ...
flexible
{ "blob_id": "825f3b930fee319314d520a32c2f9dcd718505ab", "index": 2424, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(int(input())):\n noe = int(input())\n arr = [int(x) for x in input().split()]\n left = arr[0]\n rite = sum(arr) - left\n mins = abs(rite - left)\n for i i...
[ 0, 1, 2 ]
import os import RPi.GPIO as GPIO import time import neopixel import board GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) #Setup button pins GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(19, GPIO.I...
normal
{ "blob_id": "4a711642af753ba2c82ce3351b052a4973e17e7d", "index": 9672, "step-1": "<mask token>\n\n\ndef setStep(w1, w2, w3, w4):\n GPIO.output(A1Pin, w1)\n GPIO.output(A2Pin, w2)\n GPIO.output(B1Pin, w3)\n GPIO.output(B2Pin, w4)\n\n\ndef wheel(pos):\n if pos < 0 or pos > 255:\n r = g = b = ...
[ 4, 5, 6, 7, 8 ]
import pathlib from setuptools import setup # The directory containing this file HERE = pathlib.Path(__file__).parent # The text of the README file README = (HERE / "README.md").read_text() # Version: major.minor.patch VERSION = "1.0.1" REQUIREMENTS = (HERE / "requirements.txt").read_text() REQUIREMENTS = REQUIREME...
normal
{ "blob_id": "f563bb5bb32d3653d8a4115c75eda80b676ae3c6", "index": 5759, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='Antennass', version=VERSION, description=\n 'A class project that plots far field antenna array patterns',\n long_description=README, long_description_content_type='text...
[ 0, 1, 2, 3, 4 ]
import random a=input("enter 'r' to roll the dice and 'q' to quit") while True: if (a=="r"): print(random.randint(1,6)) elif(a=="q"): print("bye!") exit() else: print("give either 'r' or 'q'")
normal
{ "blob_id": "7e1f77210b3beb4e496ff95686d65bd7d79561a3", "index": 170, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n if a == 'r':\n print(random.randint(1, 6))\n elif a == 'q':\n print('bye!')\n exit()\n else:\n print(\"give either 'r' or 'q'\")\n", "s...
[ 0, 1, 2, 3, 4 ]
# (c) 2019, Ansible by Red Hat, inc # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible_collections.arista.eos.tests.unit.compat.mock import patch from ansible_collections.ari...
normal
{ "blob_id": "6efe3975f4d5d9f431391b3560c37a3e89e27f3d", "index": 9172, "step-1": "<mask token>\n\n\nclass TestEosLacpInterfacesModule(TestEosModule):\n <mask token>\n\n def setUp(self):\n super(TestEosLacpInterfacesModule, self).setUp()\n self.mock_get_config = patch(\n 'ansible_co...
[ 4, 8, 11, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(myfavoritenumber) <|reserved_special_token_0|> print(x) <|reserved_special_token_0|> print(x, y, z) <|reserved_special_token_1|> myfavoritenumber = 5 print(myfavoritenumber) x = 5 x = x + 1 print(x) x, y, z = 1, 2, 3 prin...
flexible
{ "blob_id": "e6c7b15e5b42cfe6c5dec2eaf397b67afd716ebd", "index": 3858, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(myfavoritenumber)\n<mask token>\nprint(x)\n<mask token>\nprint(x, y, z)\n", "step-3": "myfavoritenumber = 5\nprint(myfavoritenumber)\nx = 5\nx = x + 1\nprint(x)\nx, y, z = 1, 2, 3...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @router.post('/account/register', summary='register to create a new store', response_model=store_schema.Store, status_code=201) async def account_register(StoreName: str=Body(...), OwnerFirstName: str= Body(...), OwnerLa...
flexible
{ "blob_id": "64bbf2e3b961a6e0b5d7e551278bb21990df2ed9", "index": 5526, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@router.post('/account/register', summary='register to create a new store',\n response_model=store_schema.Store, status_code=201)\nasync def account_register(StoreName: str=Body(.....
[ 0, 1, 2, 3, 4 ]
################################################################################ # # titleStrip.py # # Generates an output file with the titles of the input stripped # Usage: # python titleStrip.py [input filename] [output filename] # ################################################################################ im...
normal
{ "blob_id": "9c09309d23510aee4409a6d9021c2991afd2d349", "index": 521, "step-1": "<mask token>\n\n\ndef clearConsole():\n os.system('cls' if os.name == 'nt' else 'clear')\n\n\ndef main():\n checkArgs()\n rfile = open(sys.argv[1], 'r')\n wfile = open(output_name, 'w')\n parseAndStrip(rfile, wfile)\n...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Solution: def destCity(self, paths: List[List[str]]) ->str: departCity = set() destCity =...
flexible
{ "blob_id": "03cc3bf37ea8d971550a89107161005901d842de", "index": 2514, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def destCity(self, paths: List[List[str]]) ->str:\n departCity = set()\n dest...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Solution: def findDuplicates(self, nums: List[int]) ->List[int]: res = [] for num in nums: if nums[abs(num) - 1] < 0: res....
flexible
{ "blob_id": "5cfd7744f98c80483cb4dd318c17a7cd83ed3ae3", "index": 758, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n\n def findDuplicates(self, nums: List[int]) ->List[int]:\n res = []\n for num in nums:\n if nums[ab...
[ 1, 2, 3, 4, 5 ]
from .embedpeek import EmbedPeek __red_end_user_data_statement__ = "This cog does not persistently store data or metadata about users." def setup(bot): bot.add_cog(EmbedPeek(bot))
normal
{ "blob_id": "b66142e0b674d3920b8e3ad74e0d0b753f0a78c3", "index": 3471, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef setup(bot):\n bot.add_cog(EmbedPeek(bot))\n", "step-3": "<mask token>\n__red_end_user_data_statement__ = (\n 'This cog does not persistently store data or metadata about u...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(str1 + str2) <|reserved_special_token_1|> str1 = 'py' str2 = 'thon' print(str1 + str2) <|reserved_special_token_1|> # 文字列(結合) str1 = "py" str2 = "thon" print(str1+str2)
flexible
{ "blob_id": "d95cbca8e892f18f099b370e139176770ce0c1b7", "index": 8270, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(str1 + str2)\n", "step-3": "str1 = 'py'\nstr2 = 'thon'\nprint(str1 + str2)\n", "step-4": "# 文字列(結合)\n\nstr1 = \"py\"\nstr2 = \"thon\"\nprint(str1+str2)\n", "step-5": null, "...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def test_1(monkeypatch): monkeypatch.setattr('builtins.input', lambda x: 'list') f = StringIO() with redirect_stdout(f): input_name() testdata = f.getvalue() assert testdata == '\n\nJohn Doe\nJane Doe\nJohn Smith\nJane Smith\nBilly Jo Jones\n\n\n' <|reserved_...
flexible
{ "blob_id": "286a47cece7002a88f34ace3e08d013e2d14801a", "index": 2793, "step-1": "<mask token>\n\n\ndef test_1(monkeypatch):\n monkeypatch.setattr('builtins.input', lambda x: 'list')\n f = StringIO()\n with redirect_stdout(f):\n input_name()\n testdata = f.getvalue()\n assert testdata == '\...
[ 9, 11, 14, 17, 20 ]
from __future__ import unicode_literals from django.db import models from django.utils import timezone # Create your models here. class Article(models.Model): title = models.CharField(max_length=200) author = models.CharField(max_length=100, default='admin') content = models.TextField(max_length=5000) ...
normal
{ "blob_id": "0bc53130a4248178f4c3fabbae7d2546f0d5b8fd", "index": 5996, "step-1": "<mask token>\n\n\nclass Search_record(models.Model):\n title = models.CharField(max_length=100)\n url = models.CharField(max_length=100)\n searchCount = models.IntegerField(blank=True)\n zhihu_type = models.IntegerField...
[ 18, 24, 25, 27, 29 ]
<|reserved_special_token_0|> @app.route('/') def hello(): return render_template('form.html') @app.route('/submit', methods=['POST']) def form_data(): user_data = request.form.get('user_data') user_data1 = [user_data] vector = tfidf.transform(user_data1) my_pred = model.predict(vector) if my...
flexible
{ "blob_id": "df92166378c8a8cc0ba02d0ba33d75bbd94510a7", "index": 4754, "step-1": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return render_template('form.html')\n\n\n@app.route('/submit', methods=['POST'])\ndef form_data():\n user_data = request.form.get('user_data')\n user_data1 = [user_data]\n ...
[ 2, 3, 4, 5, 6 ]
import pyglet import math from lvl1_resources import fireball class Fire(pyglet.sprite.Sprite): def __init__( self, *args, **kwargs): super(Fire, self).__init__(img= fireball, *args, **kwargs) self.rotation= 45 self.rotate_speed= 5 self.velocity_x= 5 def check_bounds(self): max_x= 1000 + self.image.width/...
normal
{ "blob_id": "cf2bbe332237bd849df62be099f1719eaf1f2082", "index": 1523, "step-1": "<mask token>\n\n\nclass Fire(pyglet.sprite.Sprite):\n <mask token>\n <mask token>\n\n def update(self):\n self.rotation += self.rotate_speed\n self.x += self.velocity_x\n self.check_bounds()\n\n def...
[ 5, 6, 7, 8, 9 ]
<|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": "5db450424dc143443839e24801ece444d0d7e162", "index": 3611, "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 = [('rrhh', '001...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def getUSMeasure(): bus.write_byte(address_arduino, 1) distance = bus.read_byte(address_arduino) return distance def forward(): bus.write_byte(address_arduino, 2) <|reserved_special_token_0|> <|reserved_spe...
flexible
{ "blob_id": "6fa7aef7c2b91de409a0e8574e362efefa642ee7", "index": 1715, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getUSMeasure():\n bus.write_byte(address_arduino, 1)\n distance = bus.read_byte(address_arduino)\n return distance\n\n\ndef forward():\n bus.write_byte(address_arduino...
[ 0, 2, 3, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @codepipeline_lambda_handler def lambda_handler(event, context): """ Prepares for an AMI deployment. """ job = event['CodePipeline.job'] input_bucket, input_key = get_input_artifact_location(job) output_...
flexible
{ "blob_id": "4c59e5fab2469af3f40cafaac226a993f6628290", "index": 3624, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@codepipeline_lambda_handler\ndef lambda_handler(event, context):\n \"\"\"\n Prepares for an AMI deployment.\n\n \"\"\"\n job = event['CodePipeline.job']\n input_bucket...
[ 0, 1, 2, 3, 4 ]
import logging from xdcs.app import xdcs logger = logging.getLogger(__name__) def asynchronous(func): def task(*args, **kwargs): try: func(*args, **kwargs) except Exception as e: logger.exception('Exception during asynchronous execution: ' + str(e)) raise e ...
normal
{ "blob_id": "1b529d8bafc81ef4dd9ff355de6abbd6f4ebddf1", "index": 706, "step-1": "<mask token>\n\n\ndef lazy(func):\n\n\n class Lazy:\n\n def __init__(self, original) ->None:\n self._value_computed = False\n self._value = None\n self._original = [original]\n\n def...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class FitWidget(object): def __init__(self, plotter_widget, analyzer=None): self.plotter_widget = plotter_widget self.plotter = plotter_widget.plotter self.hists = self.plotter.all_hists self.layout = QVBoxLayout() params_labels = ['A', mu_str,...
flexible
{ "blob_id": "aa51b2d4bfe4051f3302d14cf2123a3881a8a2e3", "index": 5668, "step-1": "<mask token>\n\n\nclass FitWidget(object):\n\n def __init__(self, plotter_widget, analyzer=None):\n self.plotter_widget = plotter_widget\n self.plotter = plotter_widget.plotter\n self.hists = self.plotter.al...
[ 2, 5, 6, 7, 8 ]
""" 定义函数,根据年、月、日计算星期。 0 星期一 1 星期二 .... """ import time def get_week(year, month, day): str_time = "%d-%d-%d" % (year, month, day) time_tuple = time.strptime(str_time, "%Y-%m-%d") tuple_week = ("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日") return tuple_week[time_tuple[6]] ...
normal
{ "blob_id": "012d9b5aa13c557ad958343cadf935b73c808a56", "index": 4535, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_week(year, month, day):\n str_time = '%d-%d-%d' % (year, month, day)\n time_tuple = time.strptime(str_time, '%Y-%m-%d')\n tuple_week = '星期一', '星期二', '星期三', '星期四', '星期...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Customer(User): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Customer(User): def __init__(self, first_name: str, last_name: str, user_name: str, email: ...
flexible
{ "blob_id": "254f34c923d49374e09b579c5bc1b17b8c69c0e4", "index": 2661, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Customer(User):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Customer(User):\n\n def __init__(self, first_name: str, last_name: str, user_name: str,\n em...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def generarPares(limite): num = 1 milista = [] while num < limite: milista.append(num * 2) num += 1 return milista <|reserved_special_token_0|> def devuelveCiudades2(*ciudades): for e in ciudades: for subelemento in e: yield sube...
flexible
{ "blob_id": "29abcfc010453e3a67346ea2df238e07b85502a8", "index": 3107, "step-1": "<mask token>\n\n\ndef generarPares(limite):\n num = 1\n milista = []\n while num < limite:\n milista.append(num * 2)\n num += 1\n return milista\n\n\n<mask token>\n\n\ndef devuelveCiudades2(*ciudades):\n ...
[ 2, 5, 6, 7, 8 ]
import cv2 import numpy as np cap = cv2.VideoCapture("./vStream.h264") count = 0 while True: ret, frame = cap.read() if ret: print("Decoded frame") # cv2.imshow("frame", frame) cv2.imwrite("fr_"+str(count)+".png", frame) count += 1 else: print("Couldn\'t decoded fra...
normal
{ "blob_id": "40ac3292befa2354878927ada0e10c24368a9d73", "index": 2643, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n ret, frame = cap.read()\n if ret:\n print('Decoded frame')\n cv2.imwrite('fr_' + str(count) + '.png', frame)\n count += 1\n else:\n prin...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html import csv from bookstoscrapy import settings def write_to_csv(item): writer = csv.writer(open(settings.csv_file_path, '...
normal
{ "blob_id": "f0c621583caf6eea6f790649862a03a464f6574b", "index": 3727, "step-1": "<mask token>\n\n\nclass WriteToCsv(object):\n <mask token>\n\n def process_item(self, item, spider):\n write_to_csv(item)\n return item\n", "step-2": "<mask token>\n\n\nclass WriteToCsv(object):\n item_coun...
[ 2, 3, 4, 5, 6 ]
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf tf.__version__ import glob import imageio import matplotlib.pyplot as plt import numpy as np import os import PIL from tensorflow.keras import layers import time import pathlib from IPython import display ###---...
normal
{ "blob_id": "e007e2d32fa799e7658813f36911616f7bf58b48", "index": 3972, "step-1": "<mask token>\n\n\ndef preprocess_image(image):\n image = tf.image.decode_jpeg(image, channels=3)\n image = tf.image.resize(image, [280, 280])\n image /= 255.0\n return image\n\n\n<mask token>\n\n\ndef make_generator_mod...
[ 8, 10, 12, 13, 14 ]
<|reserved_special_token_0|> def check_answer(player_guess, guess_value): """ Compares a player's guess and the number to guess Returns True if the player guessed correctly Returns False by default """ end_game = False if player_guess > guess_value: print('guess too high!') elif player_gue...
flexible
{ "blob_id": "a1e54a0f593149c1d97e64342c99f0ab8aa28fa9", "index": 6215, "step-1": "<mask token>\n\n\ndef check_answer(player_guess, guess_value):\n \"\"\"\n\tCompares a player's guess and the number to guess\n\tReturns True if the player guessed correctly\n\tReturns False by default\n\t\"\"\"\n end_game = F...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.route('/') def hello(): return make_response(render_template('chat.html'), 200) if __name__ == '__main__': app.run(debug=True) <|reserved_special_token_1|> <|reserved_special_token_0|> app = Flask(__name__) @...
flexible
{ "blob_id": "98841630964dd9513e51c3f13bfdb0719600712d", "index": 6941, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return make_response(render_template('chat.html'), 200)\n\n\nif __name__ == '__main__':\n app.run(debug=True)\n", "step-3": "<mask token>\napp ...
[ 0, 2, 3, 4, 5 ]
import os import telebot bot = telebot.TeleBot(os.environ.get('TELEGRAM_ACCESS_TOCKEN', 'TOKEN'))
normal
{ "blob_id": "ce7b7980d1e93f23e7e3ef048ddadc0c779ef9ce", "index": 7981, "step-1": "<mask token>\n", "step-2": "<mask token>\nbot = telebot.TeleBot(os.environ.get('TELEGRAM_ACCESS_TOCKEN', 'TOKEN'))\n", "step-3": "import os\nimport telebot\nbot = telebot.TeleBot(os.environ.get('TELEGRAM_ACCESS_TOCKEN', 'TOKEN'...
[ 0, 1, 2 ]
# # In development by Jihye Sofia Seo https://www.linkedin.com/in/jihyeseo # forked from the code of Al Sweigart # http://inventwithpython.com/pygame/chapter10.html # whose books are very helpful for learning Python and PyGame. Many thanks! # Main change is that his version uses flood fill algorithm, which coul...
normal
{ "blob_id": "ec200ee66e3c4a93bbd8e75f0e8b715f54b5479d", "index": 6781, "step-1": "<mask token>\n\n\nclass Queue:\n\n def __init__(self):\n self.items = []\n\n def isEmpty(self):\n return self.items == []\n\n def enqueue(self, item):\n self.items.insert(0, item)\n\n def dequeue(se...
[ 11, 12, 13, 16, 17 ]
<|reserved_special_token_0|> def dragC2(mousePos): global cx2, cy2 cx2 = mousePos.x cy2 = mousePos.y drawCurve() def dragC3(mousePos): global cx3, cy3 cx3 = mousePos.x cy3 = mousePos.y drawCurve() def drawCurve(): qbezdata = ['M', x1, y1, 'Q', cx1, cy1, x2, y2] qbez = cgo.c...
flexible
{ "blob_id": "3b19ee0bbd24b76dd8b933859f6a56c459926861", "index": 5615, "step-1": "<mask token>\n\n\ndef dragC2(mousePos):\n global cx2, cy2\n cx2 = mousePos.x\n cy2 = mousePos.y\n drawCurve()\n\n\ndef dragC3(mousePos):\n global cx3, cy3\n cx3 = mousePos.x\n cy3 = mousePos.y\n drawCurve()\...
[ 3, 5, 6, 7, 8 ]
#python -m marbles test_clean_rangos.py import unittest from marbles.mixins import mixins import pandas as pd import requests from pyspark.sql import SparkSession import psycopg2 as pg import pandas as pd from pyspark.sql.types import StructType, StructField, StringType from src.features.build_features import get_clea...
normal
{ "blob_id": "f7c6990b4ddbe5ef9d79ef2326e60cdf1f761db3", "index": 4542, "step-1": "<mask token>\n\n\nclass Test_Ranges_Case(unittest.TestCase, mixins.CategoricalMixins):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Test_Ranges_Case(unittest.TestCase, mixins.CategoricalMixins):\n ...
[ 1, 2, 3, 4, 5 ]
''' Created on 2018-9-8 @author: weij ''' from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import os.path import sys import time import numpy as np from numpy import shape from scipy import linalg from sklearn import datas...
normal
{ "blob_id": "49995e60b817e2c5a2ea7e85e4fe96ca95363cb2", "index": 2148, "step-1": "<mask token>\n\n\ndef test_linearSVC(*data):\n X_train, X_test, y_train, y_test = data\n cls = svm.LinearSVC()\n cls.fit(X_train, y_train)\n print('Coefficients:%s,Intercept:%s' % (cls.coef_, cls.intercept_))\n print...
[ 5, 6, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @udy.cod_cmd(pattern='as$', command=('as', plugin_category), info={'header': 'salam.', 'usage': '{tr}as'}) async def _(event): """animation command""" event = await edit_or_reply(event, 'as') await event.edit('yu...
flexible
{ "blob_id": "a78bbb85f4912e5f7ea23f689de65cb16a38d814", "index": 9787, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@udy.cod_cmd(pattern='as$', command=('as', plugin_category), info={'header':\n 'salam.', 'usage': '{tr}as'})\nasync def _(event):\n \"\"\"animation command\"\"\"\n event = aw...
[ 0, 1, 2, 3, 4 ]
import pandas import pytest from tns_watcher import get_tns from utils import load_config, log, Mongo """ load config and secrets """ config = load_config(config_file="config.yaml")["kowalski"] class TestTNSWatcher: """ Test TNS monitoring """ @pytest.mark.xfail(raises=pandas.errors.ParserError) ...
normal
{ "blob_id": "e7ffa852d16e8e55b4e2b6ab2383561fe359a169", "index": 1778, "step-1": "<mask token>\n\n\nclass TestTNSWatcher:\n <mask token>\n\n @pytest.mark.xfail(raises=pandas.errors.ParserError)\n def test_tns_watcher(self):\n log('Connecting to DB')\n mongo = Mongo(host=config['database'][...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> @shared_task(name='clean_tweetdb') def clean_tweetdb(): tweets = Tweet.objects.all() for tweets.tweet_date in tweets: if tweets.tweet_date <= datetime.now() - timedelta(days=8): tweets.delet() @shared_task(name='get_tweets') def get_tweets(): """Get some ...
flexible
{ "blob_id": "d4d19411f0c48ffb99bd17e8387f1741144e43b4", "index": 870, "step-1": "<mask token>\n\n\n@shared_task(name='clean_tweetdb')\ndef clean_tweetdb():\n tweets = Tweet.objects.all()\n for tweets.tweet_date in tweets:\n if tweets.tweet_date <= datetime.now() - timedelta(days=8):\n twe...
[ 2, 3, 4, 5, 6 ]
class PriorityQueue: <|reserved_special_token_0|> def __init__(self): """Initially empty priority queue.""" self.heap = [None] def __len__(self): return len(self.heap) - 1 def append(self, key): """Inserts an element in the priority queue.""" if key is None: ...
flexible
{ "blob_id": "f0630d248cfa575ee859e5c441deeb01b68c8150", "index": 3741, "step-1": "class PriorityQueue:\n <mask token>\n\n def __init__(self):\n \"\"\"Initially empty priority queue.\"\"\"\n self.heap = [None]\n\n def __len__(self):\n return len(self.heap) - 1\n\n def append(self,...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TODOItemForm(forms.ModelForm): class Meta: model = TODOItem fields = ['job', 'due_date', 'medication_details', 'completed'] <|reserved_special_token_1|> <|reserved_special_token_0|> class Diagnos...
flexible
{ "blob_id": "aa6464c53176be9d89c6c06997001da2b3ee1e5c", "index": 6583, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TODOItemForm(forms.ModelForm):\n\n\n class Meta:\n model = TODOItem\n fields = ['job', 'due_date', 'medication_details', 'completed']\n", "step-3": "<mask tok...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class animal: def __init__(self, nombre, descripcion, foto): self.nombre = nombre self.descripcion = descripcion self.foto = foto self.database = True def tipo(self): return 'animal' class enfermedad: def __init__(self, nombre, desc...
flexible
{ "blob_id": "b46a14c821777873eb60df609d9f112c737a3635", "index": 6255, "step-1": "<mask token>\n\n\nclass animal:\n\n def __init__(self, nombre, descripcion, foto):\n self.nombre = nombre\n self.descripcion = descripcion\n self.foto = foto\n self.database = True\n\n def tipo(sel...
[ 10, 11, 12, 15, 17 ]
""" Given two strings, a and b, that may or may not be of the same length, determine the minimum number of character deletions required to make a and b anagrams. Any characters can be deleted from either of the strings. """ from collections import Counter import math import os import random import re import sys # Com...
normal
{ "blob_id": "3b15767988f1d958fc456f7966f425f93deb9017", "index": 8302, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef makeAnagram(a, b):\n ct_a = Counter(a)\n ct_b = Counter(b)\n ct_a.subtract(ct_b)\n return sum(abs(i) for i in ct_a.values())\n\n\n<mask token>\n", "step-3": "<mask t...
[ 0, 1, 2, 3, 4 ]
from flask import Flask, request, redirect, render_template, session, flash from mysqlconnection import MySQLConnector import re EMAIL_REGEX = re.compile(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)") app = Flask(__name__) app.secret_key = "ThisIsSecret" mysql = MySQLConnector(app,'mydb') @app.route('/') def ...
normal
{ "blob_id": "187cf160b520001b6fe3a8d343391de1c04b3acd", "index": 1754, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('index.html')\n\n\n@app.route('/process', methods=['POST'])\ndef process():\n if len(request.form['email']) < 1:\n flash('Email cannot be blank!'...
[ 4, 5, 6, 7, 8 ]
""" Benchmark module: can also compare multiple functions """ import gc from inspect import ( signature, getsourcelines ) from operator import itemgetter from time import perf_counter from SpeedIT.ProjectErr import Err from SpeedIT.Utils import ( format_time, get_table_rst_formatted_lines ) def _helper_...
normal
{ "blob_id": "b2d3ebe4b1ce8f6f0fde8495fb90542080b810ce", "index": 1390, "step-1": "<mask token>\n\n\nclass _TimeIT(object):\n <mask token>\n\n def __init__(self, func, args_list, kwargs_dict, setup_line_list,\n check_too_fast, run_sec, name, perf_counter_reference_time):\n \"\"\" Constructor. ...
[ 4, 6, 7, 8, 9 ]
from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS import urllib from flask import Flask ########################################################################################DataBase@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 #connection string params = urllib.parse.quote_plus('Driv...
normal
{ "blob_id": "6928ff58ddb97883a43dfd867ff9a89db72ae348", "index": 6567, "step-1": "<mask token>\n\n\nclass Entity_list_user(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 token>\n <mask token>...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- # # Copyright (C) Red Hat, Inc # # 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 # # Unless required by applicable law or ...
normal
{ "blob_id": "8410ff0806766a09d346e930123a2696bebb4b60", "index": 2821, "step-1": "<mask token>\n", "step-2": "<mask token>\nGERRIT_PORT = 29418\nGERRIT_USERNAME = 'dci-ci-bot'\nGERRIT_HOSTNAME = 'softwarefactory-project.io'\nGERRIT_SSH_KEY_FILENAME = os.getenv('GERRIT_SSH_KEY_FILENAME',\n '/home/dci/dci-ci-...
[ 0, 1, 2, 3 ]
import scraperwiki html = scraperwiki.scrape('http://www.denieuwereporter.nl/') # scrape headlines van denieuwereporter-alle h1 koppen import lxml.html root = lxml.html.fromstring(html) tds = root.cssselect('h1') for h1 in tds: #print lxml.html.tostring(h1) print h1.text_content() record = {'h1': h1.text_c...
normal
{ "blob_id": "107b09696ac671e689235da55aaf4c26ae7c321c", "index": 6353, "step-1": "import scraperwiki\nhtml = scraperwiki.scrape('http://www.denieuwereporter.nl/')\n# scrape headlines van denieuwereporter-alle h1 koppen\n\nimport lxml.html\nroot = lxml.html.fromstring(html)\ntds = root.cssselect('h1')\nfor h1 in ...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> setup(name='Arkanoid', version='1.0', description='Python Game', options= options, executables=executables) <|reserved_special_token_1|> <|reserved_special_token_0|> PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os._...
flexible
{ "blob_id": "f317d67b98eab1f0f192fa41f9bcc32b0c1e8eb0", "index": 8301, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='Arkanoid', version='1.0', description='Python Game', options=\n options, executables=executables)\n", "step-3": "<mask token>\nPYTHON_INSTALL_DIR = os.path.dirname(os.pat...
[ 0, 1, 2, 3, 4 ]
# Downloads images from http://www.verseoftheday.com/ and saves it into a DailyBibleVerse folder import requests, os, bs4 os.chdir('c:\\users\\patty\\desktop') #modify location where you want to create the folder if not os.path.isdir('DailyBibleVerse'): os.makedirs('DailyBibleVerse') res = request...
normal
{ "blob_id": "a8fb8ac3c102e460d44e533b1e6b3f8780b1145d", "index": 4609, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.chdir('c:\\\\users\\\\patty\\\\desktop')\nif not os.path.isdir('DailyBibleVerse'):\n os.makedirs('DailyBibleVerse')\n<mask token>\nres.raise_for_status()\n<mask token>\nwhile os.pat...
[ 0, 1, 2, 3, 4 ]
from math import degrees, sqrt, sin, cos, atan, radians from pygame import Surface, draw from pygame.sprite import Sprite from constants import ARROW_MAX_SPEED, FLOOR_Y from game_types import Radian, Degree class Arrow(Sprite): def __init__(self, color, screen, character, click_position): Sprite.__in...
normal
{ "blob_id": "359db73de2c2bb5967723dfb78f98fb84b337b9d", "index": 343, "step-1": "<mask token>\n\n\nclass Arrow(Sprite):\n\n def __init__(self, color, screen, character, click_position):\n Sprite.__init__(self)\n self.color = color\n self.screen = screen\n self.character = character...
[ 9, 10, 11, 13, 14 ]
<|reserved_special_token_0|> def opstr(op): if op == 'RSHIFT': return '>>' if op == 'LSHIFT': return '<<' if op == 'OR': return '|' if op == 'AND': return '&' if op == 'NOT': return '~' raise RuntimeError('Unknown {0}'.format(op)) def funstr(fun): ...
flexible
{ "blob_id": "e68588dff0e54fa03dbb1c629c39d8312a0df26d", "index": 7230, "step-1": "<mask token>\n\n\ndef opstr(op):\n if op == 'RSHIFT':\n return '>>'\n if op == 'LSHIFT':\n return '<<'\n if op == 'OR':\n return '|'\n if op == 'AND':\n return '&'\n if op == 'NOT':\n ...
[ 3, 4, 5, 6, 7 ]
""" MAIN IDEA --> Keep 2 pointers. i points to current 0 element and j searches for first non zero element which comes after i. As soon as we get a j, we swap i and j. So index i now becomes non zero. Now move i to next index i.e i+1 and now check if i is zero or non zero. If i is still zero, then again search for 1st...
normal
{ "blob_id": "8855747f58b48bedc362930662e147b1fc4ebd63", "index": 4182, "step-1": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution(object):\n\n def moveZeroes(self, nums):\n \"\"\"\n :type nums: List[int]\n :rt...
[ 1, 2, 3, 4, 5 ]
#Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd #importing the data dataset=pd.read_csv('Social_Network_Ads.csv') X=dataset.iloc[:,0:2].values y=dataset.iloc[:,2].values #spiliting the data into training data and testing data from sklearn.model_selection impo...
normal
{ "blob_id": "149f8b453786ec54668a55ec349ac157d2b93b5d", "index": 2397, "step-1": "<mask token>\n", "step-2": "<mask token>\nlog.fit(X_train, y_train)\nlog.predict(sc.transform([[45, 87000]]))\n<mask token>\nnp.set_printoptions(precision=2)\nnp.concatenate((y_pred.reshape(len(y_pred), 1), y_test.reshape(len(y_t...
[ 0, 1, 2, 3, 4 ]
class Solution(object): def maxSubArrayLen(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ sums = [0] * (len(nums) + 1) seen = {} seen[0] = -1 res = 0 for idx, n in enumerate(nums): sums[idx + 1] = su...
normal
{ "blob_id": "1ccaedb6e79101764db1907634ba627a0f9f2bb2", "index": 5500, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def maxSubArrayLen(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n ...
[ 0, 1, 2 ]
#!/usr/bin/python3 import i3ipc if __name__ == "__main__": i3 = i3ipc.Connection() wp = [int(w["name"]) for w in i3.get_workspaces() if w["num"] != -1] for k in range(1, 16): if k not in wp: i3.command("workspace {}".format(k)) break
normal
{ "blob_id": "cd07dd596f760e232db5c0fd8e27360d61bda635", "index": 8947, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n i3 = i3ipc.Connection()\n wp = [int(w['name']) for w in i3.get_workspaces() if w['num'] != -1]\n for k in range(1, 16):\n if k not in wp:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class RequestCreateKeypair(Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class ResponseKeypair(Model): name = KubeName(required=True, min_length=3) public_key = StringType(required=True) created_at = ArrowType(requ...
flexible
{ "blob_id": "a521220ac287a840b5c69e2d0f33daa588132083", "index": 4983, "step-1": "<mask token>\n\n\nclass RequestCreateKeypair(Model):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass ResponseKeypair(Model):\n name = KubeName(required=True, min_length=3)\n public_key = StringType(required=T...
[ 4, 6, 10, 11, 12 ]
from django.shortcuts import render from django.views.generic import View #导入View from .models import UpdateDbData,User from wanwenyc.settings import DJANGO_SERVER_YUMING from .forms import UpdateDbDataForm # Create your views here. #添加场景的view class UpdateDbDataView(View): #继承View """ 测试数据复制编写页面处理 ...
normal
{ "blob_id": "129c7f349e2723d9555da44ae62f7cfb7227b9ae", "index": 5618, "step-1": "<mask token>\n\n\nclass UpdateDbDataView(View):\n <mask token>\n\n def get(self, request, testupdatadb_id):\n if request.user.username == 'check':\n return render(request, 'canNotAddupdatedbdata.html', {\n ...
[ 2, 3, 4, 5, 6 ]
from django.apps import AppConfig class BooksaleConfig(AppConfig): name = 'booksale'
normal
{ "blob_id": "e642054dad8a2de5b01f2994348e10e9c7574ee0", "index": 4581, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BooksaleConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass BooksaleConfig(AppConfig):\n name = 'booksale'\n", "step-4": "from django.apps import ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class H264Packet: <|reserved_special_token_0|> def __init__(self, packet): self.packet = packet self.type = None self.data = None if len(packet) > 3: self.type, = struct.unpack('H', packet[0:2]) self.data = packet[2:] d...
flexible
{ "blob_id": "ff1db5981a0163df1dfb44869a3d4af2be03c10a", "index": 2745, "step-1": "<mask token>\n\n\nclass H264Packet:\n <mask token>\n\n def __init__(self, packet):\n self.packet = packet\n self.type = None\n self.data = None\n if len(packet) > 3:\n self.type, = struc...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class ProductSerializer(serializers.ModelSerializer): class Meta: model = Product fields = '__all__' def to_representation(self, instance): data = super().to_representation(instance) data['detail'] = strip_tags(instance.detail) return dat...
flexible
{ "blob_id": "b8fa36ed3587511e0c64f0ffc87ea6e7857725d7", "index": 4595, "step-1": "<mask token>\n\n\nclass ProductSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Product\n fields = '__all__'\n\n def to_representation(self, instance):\n data = super().to_representati...
[ 5, 6, 8, 9, 10 ]
# -*- coding: utf-8 -*- """ Created on Fri Sep 13 10:18:35 2019 @author: zehra """ import numpy as np import pickle import matplotlib.pyplot as plt from scipy.special import expit X_train, y_train, X_val, y_val, X_test, y_test = pickle.load(open("data.pkl", "rb")) id2word, word2id = pickle.load( open("dicts.pkl", "r...
normal
{ "blob_id": "3accf1c066547c4939c104c36247370b4a260635", "index": 8959, "step-1": "<mask token>\n\n\ndef sigmoid(x):\n return expit(x)\n\n\ndef LRcost(t, pred):\n pred[pred == 0.0] = 10 ** -10\n cost_per_sample = -t * np.log(pred) - (1 - t) * np.log(1 - pred)\n avg_cost = np.mean(cost_per_sample)\n ...
[ 3, 4, 5, 6, 7 ]
from sense_hat import SenseHat import time sense = SenseHat() b = (0, 0, 204) #Blue w = (255, 255, 255) #White e = (0, 0, 0) #Empty y = (255, 255, 0) #Yellow r = (255, 0, 0) #red prenume = [ e, e, e, e, e, e, e, e, e, e, e, e, e, e, e, e, e, b, e, y, y, e, r, e, b, e, b, y, e, y, r, e, b, b, b, y,...
normal
{ "blob_id": "b9eeccbed63aa42afa09fe7ef782066f300255a1", "index": 2173, "step-1": "<mask token>\n", "step-2": "<mask token>\nsense.set_pixels(prenume)\n", "step-3": "<mask token>\nsense = SenseHat()\nb = 0, 0, 204\nw = 255, 255, 255\ne = 0, 0, 0\ny = 255, 255, 0\nr = 255, 0, 0\nprenume = [e, e, e, e, e, e, e,...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_json_products_data(file_path): with open(file_path, encoding='utf-8-sig') as file: json_data = json.load(file) return json_data <|reserved_special_token_1|> <|reserved_special_token_0|> def get_json_...
flexible
{ "blob_id": "08b53ba116b0c5875d39af4ce18296d547d5891d", "index": 5692, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_json_products_data(file_path):\n with open(file_path, encoding='utf-8-sig') as file:\n json_data = json.load(file)\n return json_data\n", "step-3": "<mask token...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> subprocess.call(['chmod', '+w', 'maclist']) subprocess.call(['chmod', '+w', 'arptable']) subprocess.call(['chmod', '+w', 'maclookup']) subprocess.Popen(['arp', '-a'], stdout=f_arptable) <|reserved_special_token_0|> for line in ope...
flexible
{ "blob_id": "d566104b00ffd5f08c564ed554e0d71279a93047", "index": 6394, "step-1": "<mask token>\n", "step-2": "<mask token>\nsubprocess.call(['chmod', '+w', 'maclist'])\nsubprocess.call(['chmod', '+w', 'arptable'])\nsubprocess.call(['chmod', '+w', 'maclookup'])\nsubprocess.Popen(['arp', '-a'], stdout=f_arptable...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while g > 0: num = num + g g = g - 1 print(num) <|reserved_special_token_1|> g = int(input()) num = 0 while g > 0: num = num + g g = g - 1 print(num) <|reserved_special_token_1|> g=int(input()) num=0 while(g>...
flexible
{ "blob_id": "8b18f098080c3f5773aa04dffaff0639fe7fa74f", "index": 8886, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile g > 0:\n num = num + g\n g = g - 1\nprint(num)\n", "step-3": "g = int(input())\nnum = 0\nwhile g > 0:\n num = num + g\n g = g - 1\nprint(num)\n", "step-4": "g=int(in...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.8 on 2018-04-27 08:05 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('talk', '0023_auto_20180207_1121'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "f85a703b47d981397ed6048e941030a3fbee7b6d", "index": 229, "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 = [('talk', '0023...
[ 0, 1, 2, 3, 4 ]
from gym_mag.envs.mag_control_env import MagControlEnv
normal
{ "blob_id": "dd7896e3beb5e33282b38efe0a4fc650e629b185", "index": 5081, "step-1": "<mask token>\n", "step-2": "from gym_mag.envs.mag_control_env import MagControlEnv\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
"""Datasets, Dataloaders, and utils for dataloading""" from enum import Enum import torch from torch.utils.data import Dataset class Partition(Enum): """Names of dataset partitions""" TRAIN = 'train' VAL = 'val' TEST = 'test' class RandomClassData(Dataset): """Standard normal distributed feature...
normal
{ "blob_id": "4c0c88f46c2d4607d9ac00755bf122e847ea2f6a", "index": 6221, "step-1": "<mask token>\n\n\nclass Partition(Enum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass RandomClassData(Dataset):\n \"\"\"Standard normal distributed features and uniformly sampled discrete ta...
[ 6, 7, 8, 9, 10 ]
age=int(input('请输入您的年龄:')) subject=input('请输入您的专业:') college=input('请输入您是否毕业于重点大学:(是/不是)') if (subject=='电子信息工程' and age>25) or (subject=='电子信息工程' and college=='是') or (age<28 and subject=='计算机'): print('恭喜您被录取!') else: print('抱歉,您未达到面试要求')
normal
{ "blob_id": "4282303e3e6ee122f1379bea73c619870f983f61", "index": 8580, "step-1": "<mask token>\n", "step-2": "<mask token>\nif subject == '电子信息工程' and age > 25 or subject == '电子信息工程' and college == '是' or age < 28 and subject == '计算机':\n print('恭喜您被录取!')\nelse:\n print('抱歉,您未达到面试要求')\n", "step-3": "age...
[ 0, 1, 2, 3 ]
# Generated by Django 2.2.2 on 2019-07-30 01:25 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('usuarios', '0001_initial'), ] operations = [ migrations.AlterField( model_name='usuario', name='inicio', ...
normal
{ "blob_id": "5e4a334b373d912ba37b18f95e4866450bda5570", "index": 3938, "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 = [('usuarios', ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin python3 # coding: utf-8 """ AUTHOR: bovenson EMAIL: szhkai@qq.com FILE: 03.py DATE: 17-9-25 下午7:59 DESC: """ from socket import socket
normal
{ "blob_id": "74d1491280eba1ceb06ccf6f45546cdb41149687", "index": 5642, "step-1": "<mask token>\n", "step-2": "<mask token>\nfrom socket import socket\n", "step-3": "#!/usr/bin python3\n# coding: utf-8\n\n\"\"\"\nAUTHOR: bovenson\nEMAIL: szhkai@qq.com\nFILE: 03.py\nDATE: 17-9-25 下午7:59\nDESC:\n\"\"\"\n\nfrom ...
[ 0, 1, 2 ]
from flask import Flask, abort, url_for, render_template, request app = Flask(__name__) @app.route('/') def index(): return render_template('login.html') # #redirect demo # @app.route('/login', methods=['POST', 'GET']) # def login(): # if request.method == 'POST' and request.form['username'] == 'admin': # ...
normal
{ "blob_id": "82f8bfd95fea3025bed2b4583c20526b0bd5484f", "index": 3535, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('login.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('login.html')\n\n\n@app.route(...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if aax == aay and aay == bbx and bby == ccx and ccx == ccy and ccy == ddx and ddy == aax: print('yes') else: print('no') <|reserved_special_token_1|> aax = int(input('enter aa-x')) aay = int(input('enter aa-y')) bbx = i...
flexible
{ "blob_id": "bd0cc8cf059440f8fd7ad135894d82c9b18ebc80", "index": 4583, "step-1": "<mask token>\n", "step-2": "<mask token>\nif aax == aay and aay == bbx and bby == ccx and ccx == ccy and ccy == ddx and ddy == aax:\n print('yes')\nelse:\n print('no')\n", "step-3": "aax = int(input('enter aa-x'))\naay = ...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import sys import yaml def add_sub_path(yaml_path): file = open(yaml_path, "r", encoding="utf-8") file_data = file.read() file.close() data = yaml.safe_load(file_data) for p, p_info in data.get("paths", {}).items(): for method, m_info in p_info.items(): ...
normal
{ "blob_id": "bbd50c40bc0897fe7a93f277bcfdcba3ba6d6f2a", "index": 1531, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef add_sub_path(yaml_path):\n file = open(yaml_path, 'r', encoding='utf-8')\n file_data = file.read()\n file.close()\n data = yaml.safe_load(file_data)\n for p, p_info...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def save_new_dataset_by_ids(old_json, ecg_ids_to_save, name_new_dataset): """ Saves json only with selected (by id) patients. :param old_json: initail dataset dict :param ecg_ids_to_save: which patient we want to...
flexible
{ "blob_id": "445ae195edfe9fe9ee58c6c5a14ec787719d698c", "index": 7454, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef save_new_dataset_by_ids(old_json, ecg_ids_to_save, name_new_dataset):\n \"\"\"\n Saves json only with selected (by id) patients.\n :param old_json: initail dataset dict\n...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TriangleError(Exception): pass <|reserved_special_token_1|> def triangle(a, b, c): """ Determines the number of non-matching sides using len(set()). Then uses dictionary mapping to return the typ...
flexible
{ "blob_id": "5c8628e41c0dd544ade330fdd37841beca6c0c91", "index": 3986, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TriangleError(Exception):\n pass\n", "step-3": "def triangle(a, b, c):\n \"\"\"\n Determines the number of non-matching sides using len(set()). Then uses dictiona...
[ 0, 1, 2, 3 ]
from odoo import models, fields, api, _ import odoo.addons.decimal_precision as dp class netdespatch_config(models.Model): _name = 'netdespatch.config' name = fields.Char(String='Name') url = fields.Char(string='URL') # Royal Mail rm_enable = fields.Boolean('Enable Royal Mail') domestic_name =...
normal
{ "blob_id": "407f549cf68660c8f8535ae0bed373e2f54af877", "index": 5731, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass netdespatch_config(models.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>...
[ 0, 1, 2, 3, 4 ]
class Restaurant(): """A restaurant model.""" def __init__(self, restaurant_name, cuisine_type): """Initialize name and type.""" self.name = restaurant_name self.type = cuisine_type def describe_restaurant(self): """Prints restaurant information.""" print("The restaurant's name is " + self.name.title())...
normal
{ "blob_id": "4ecf976a7d655efb5af427083ec1943cae6fe56d", "index": 3672, "step-1": "class Restaurant:\n <mask token>\n <mask token>\n <mask token>\n\n def open_restaurant(self):\n \"\"\"Message indicating the restaurant is open.\"\"\"\n print('The restaurant is now open!')\n", "step-2":...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class LockedClass: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class LockedClass: <|reserved_special_token_0|> __slots__ = 'first_name'...
flexible
{ "blob_id": "d90a4b00d97cecf3612915a72e48a363c5dcc97b", "index": 5006, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LockedClass:\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LockedClass:\n <mask token>\n __slots__ = 'first_name'\n", "step-4": "<mask tok...
[ 0, 1, 2, 3, 4 ]
from __future__ import division from collections import deque import os import warnings import numpy as np import keras.backend as K import keras.layers as layers import keras.optimizers as optimizers from rl.core import Agent from rl.util import * def mean_q(y_true, y_pred): return K.mean(K.max(y_pred, axis=-1...
normal
{ "blob_id": "a2fe62b6bbb6b753ef6aec6f44758b8aceeeafe6", "index": 9691, "step-1": "<mask token>\n\n\nclass UBDDPGAgent(Agent):\n <mask token>\n <mask token>\n <mask token>\n\n def compile(self, optimizer, metrics=[]):\n metrics += [mean_q]\n if type(optimizer) in (list, tuple):\n ...
[ 9, 12, 15, 17, 18 ]
<|reserved_special_token_0|> def print_stats(trial_id, dl): wrist_device, _, true_device = dl.load_oxygen(trial_id, iid=False) print('Length of Dataframe: ' + str(data.get_df_length(wrist_device))) wrist_oxygen = wrist_device.values.flatten() true_oxygen = true_device.values.flatten() sample_count...
flexible
{ "blob_id": "836e2fd6eca7453ab7a3da2ecb21705552b5f627", "index": 5157, "step-1": "<mask token>\n\n\ndef print_stats(trial_id, dl):\n wrist_device, _, true_device = dl.load_oxygen(trial_id, iid=False)\n print('Length of Dataframe: ' + str(data.get_df_length(wrist_device)))\n wrist_oxygen = wrist_device.v...
[ 4, 6, 7, 8, 9 ]
from bs4 import BeautifulSoup from cybersource.constants import CHECKOUT_BASKET_ID, CHECKOUT_ORDER_NUM, CHECKOUT_SHIPPING_CODE, CHECKOUT_ORDER_ID from cybersource.tests import factories as cs_factories from decimal import Decimal as D from django.core import mail from django.core.urlresolvers import reverse from mock i...
normal
{ "blob_id": "9155b3eed8ac79b94a033801dbf142392b50720b", "index": 5123, "step-1": "<mask token>\n\n\nclass CheckoutIntegrationTest(BaseCheckoutTest):\n <mask token>\n\n def test_checkout_process(self):\n \"\"\"Full checkout process using minimal api calls\"\"\"\n product = self.create_product(...
[ 19, 25, 29, 32, 33 ]
import joblib import os import shutil import re from scipy import stats from functools import partial import pandas as pd from multiprocessing import Process, Pool from nilearn import masking, image import nibabel as nib import numpy as np from tqdm import tqdm import matplotlib matplotlib.use('Agg') import matplotlib...
normal
{ "blob_id": "2e9d71b8055e1bab107cedae69ca3bc4219e7d38", "index": 7460, "step-1": "<mask token>\n\n\ndef get_paths(debug, dataset):\n if debug and dataset == 'OASIS':\n project_wd = os.getcwd()\n project_data = os.path.join(project_wd, 'data')\n project_sink = os.path.join(project_data, 'o...
[ 16, 17, 18, 21, 23 ]
<|reserved_special_token_0|> def secondItem(ls): return ls[2] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def FirstLetter(string): return string[0] <|reserved_special_token_0|> def secondItem(ls): return ls[2] <|reserved_special_token_0|> <|reserve...
flexible
{ "blob_id": "0e0e51904f05b41b4769b730c836568b8bb63869", "index": 9564, "step-1": "<mask token>\n\n\ndef secondItem(ls):\n return ls[2]\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef FirstLetter(string):\n return string[0]\n\n\n<mask token>\n\n\ndef secondItem(ls):\n return ls[2]\n\n\n<mask tok...
[ 1, 2, 3, 4, 5 ]
from selenium import webdriver import time import datetime import os import openpyxl as vb from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.action_chains import ActionChains def deconnexion(Chrome): """登陆""" """初始化""" global web, actions web = webdriver.Chrome(Ch...
normal
{ "blob_id": "d2c31d9c3cc66b43966cfd852582539d4e4bea17", "index": 321, "step-1": "<mask token>\n\n\ndef deconnexion(Chrome):\n \"\"\"登陆\"\"\"\n \"\"\"初始化\"\"\"\n global web, actions\n web = webdriver.Chrome(Chrome)\n web.maximize_window()\n web.implicitly_wait(10)\n web.get(\n 'http://...
[ 10, 14, 16, 18, 20 ]
"Base class for tests." import argparse import http.client import json import os import re import sys import unittest import jsonschema import requests SCHEMA_LINK_RX = re.compile(r'<([^>])+>; rel="([^"]+)') JSON_MIMETYPE = 'application/json' DEFAULT_SETTINGS = { 'ROOT_URL': 'http://127.0.0.1:5002/api', 'U...
normal
{ "blob_id": "c455de70a79f70f5f0e21391511f5035f1b4feb9", "index": 646, "step-1": "<mask token>\n\n\nclass Base(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n self.schemas = {}\n self.session = requests.Session()\n self.session.headers.update({'x-apikey': SETTINGS['APIKEY']})\...
[ 8, 12, 13, 14, 16 ]
<|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": "bf05a096956ca4f256832e2fc6659d42c5611796", "index": 6712, "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 = [('post', '001...
[ 0, 1, 2, 3, 4 ]
import pandas as pd import time from datetime import datetime from sklearn import metrics from sklearn import cross_validation from sklearn.multiclass import OneVsRestClassifier from sklearn.tree import DecisionTreeClassifier, export_graphviz from sklearn.naive_bayes import MultinomialNB,BernoulliNB,GaussianNB ...
normal
{ "blob_id": "78615f6b020e2547e5d9a08d8b4c414184106bb3", "index": 6465, "step-1": "import pandas as pd\r\nimport time\r\nfrom datetime import datetime\r\nfrom sklearn import metrics\r\nfrom sklearn import cross_validation\r\nfrom sklearn.multiclass import OneVsRestClassifier\r\nfrom sklearn.tree import DecisionTr...
[ 0 ]