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|>
def rotate_left3(nums):
if len(nums) < 3:
return 0
nums.append(nums[0])
del nums[0]
return nums
<|reserved_special_token_1|>
'''
Given an array of ints length 3, return an array with the elements "rota... | flexible | {
"blob_id": "b7ebee3c96fd9cd3d8ddc69838363925085a944d",
"index": 1347,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef rotate_left3(nums):\n if len(nums) < 3:\n return 0\n nums.append(nums[0])\n del nums[0]\n return nums\n",
"step-3": "'''\nGiven an array of ints length 3, ret... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 18 21:03:43 2019
@author: 00124175
"""
"""
读取txt文件
该文本中的分割符既有空格又有制表符('/t'),sep参数用'/s+',可以匹配任何空格。
"""
#header=None:没有每列的column name,可以自己设定
#encoding='gb2312':其他编码中文显示错误
#sep=',':用逗号来分隔每行的数据
#index_col=0:设置第1列数据作为index
import pandas as pd
data = pd.read_table("1206sjl.txt"... | normal | {
"blob_id": "ab760ec4cbb9f616f38b0f0f2221987460c6f618",
"index": 6492,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmydata.rename(columns=lambda x: x.strip(' '), inplace=True)\n<mask token>\nprint(my_need_data.iloc[:, 0:3])\nmy_need_data.to_csv('result_csv.csv', index=0)\n",
"step-3": "<mask token>\n... | [
0,
1,
2,
3,
4
] |
from rest_framework import viewsets
from .models import *
from serializer import *
from django.http import HttpResponse
from django.views import View
from django.core import serializers
# Create your views here.
class ProyectoViewSet(viewsets.ModelViewSet):
queryset = Proyecto.objects.all()
serializer_class =... | normal | {
"blob_id": "bedae2621bfcc64deb0d13d7cbce3cfb89720245",
"index": 4346,
"step-1": "<mask token>\n\n\nclass ProyectoSistemaViewSet(viewsets.ModelViewSet):\n queryset = ProyectoSistema.objects.all()\n serializer_class = ProyectoSistemaSerializer\n\n\nclass UsuarioProyectoSistemaViewSet(viewsets.ModelViewSet):... | [
6,
8,
9,
12,
14
] |
"""
Writes day of the week and time to a file.
Script written for crontab tutorial.
Author: Jessica Yung 2016
"""
import time
filename = "record_time.txt"
# Records time in format Sun 10:00:00
current_time = time.strftime('%a %H:%M:%S')
# Append output to file. 'a' is append mode.
with open(filename, 'a') as hand... | normal | {
"blob_id": "1f0695f0e9745912d8ee3a87e6c9b1272e9ebbae",
"index": 218,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(filename, 'a') as handle:\n handle.write(str(current_time))\n handle.write('\\n')\n",
"step-3": "<mask token>\nfilename = 'record_time.txt'\ncurrent_time = time.strftime(... | [
0,
1,
2,
3,
4
] |
import discord
from app.vars.client import client
from app.helpers import delete, getUser, getGuild
@client.command()
async def inviteInfo(ctx, link):
try:
await delete.byContext(ctx)
except:
pass
linkData = await client.fetch_invite(url=link)
if (linkData.inviter):
inviterData... | normal | {
"blob_id": "b8f9633ab3110d00b2f0b82c78ad047fca0d3eee",
"index": 6999,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@client.command()\nasync def inviteInfo(ctx, link):\n try:\n await delete.byContext(ctx)\n except:\n pass\n linkData = await client.fetch_invite(url=link)\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def dac_voltage_set_handle(params):
help_info = ('dac set(<channel>,<value>)$\r\n \t channel(' +
help_str +
')\tvalue: (if ad5761: (0~10000) unit:mv,else :(0~5000) unit:mv) $\r\n'
)
""" params init """
""" help """
if Utility.is_ask_for_help(pa... | flexible | {
"blob_id": "10e1756dc1d6c7b6b7e3569de78e9fa4cdfb0d7e",
"index": 7136,
"step-1": "<mask token>\n\n\ndef dac_voltage_set_handle(params):\n help_info = ('dac set(<channel>,<value>)$\\r\\n \\t channel(' +\n help_str +\n ')\\tvalue: (if ad5761: (0~10000) unit:mv,else :(0~5000) unit:mv) $\\r\\n'... | [
2,
3,
4,
5,
6
] |
# coding=utf-8
# oscm_app/cart/models
# django imports
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.translation import ugettext_lazy as _
# OSCM imports
from ...constants import CARTS, CART_STATUSES, DEFAULT_CART_STATUS
from ...utils import get_attr
from ..cart_manager i... | normal | {
"blob_id": "ae0ccbb9b0a2c61d9ee9615ba8d0c1a186a81c34",
"index": 3177,
"step-1": "<mask token>\n\n\nclass Cart(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>\n <mask token>\n <mask token>\n\n\n ... | [
6,
8,
9,
11,
12
] |
<|reserved_special_token_0|>
class CPU(DistantEnum):
k8 = 'k8'
piii = 'piii'
darwin = 'darwin'
freebsd = 'freebsd'
armeabi = 'armeabi-v7a'
arm = 'arm'
aarch64 = 'aarch64'
x64_windows = 'x64_windows'
x64_windows_msvc = 'x64_windows_msvc'
s390x = 's390x'
ppc = 'ppc'
ppc64... | flexible | {
"blob_id": "5e86e97281b9d18a06efc62b20f5399611e3510d",
"index": 8000,
"step-1": "<mask token>\n\n\nclass CPU(DistantEnum):\n k8 = 'k8'\n piii = 'piii'\n darwin = 'darwin'\n freebsd = 'freebsd'\n armeabi = 'armeabi-v7a'\n arm = 'arm'\n aarch64 = 'aarch64'\n x64_windows = 'x64_windows'\n ... | [
4,
5,
7,
8,
9
] |
from datapackage_pipelines.wrapper import ingest, spew
params, datapackage, res_iter = ingest()
columns = params['columns']
for resource in datapackage['resources']:
fields = resource.get('schema', {}).get('fields')
if fields is not None:
fields = [field for field in fields if field['name'] not in colum... | normal | {
"blob_id": "17b3fb44d9e7a09fe3b807b47bdc0248b6960634",
"index": 4022,
"step-1": "<mask token>\n\n\ndef process_resources(_res_iter):\n for rows in _res_iter:\n\n def process_rows(_rows):\n for row in _rows:\n for column in columns:\n if column in row:\n ... | [
1,
2,
3,
4
] |
#!/usr/bin/env python
# This file just executes its arguments, except that also adds OUT_DIR to the
# environ. This is for compatibility with cargo.
import subprocess
import sys
import os
os.environ["OUT_DIR"] = os.path.abspath(".")
assert os.path.isdir(os.environ["OUT_DIR"])
sys.exit(subprocess.call(sys.argv[1:], env... | normal | {
"blob_id": "be238268b9fdd565f3cb0770839789b702940ef9",
"index": 8248,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nassert os.path.isdir(os.environ['OUT_DIR'])\nsys.exit(subprocess.call(sys.argv[1:], env=os.environ))\n",
"step-3": "<mask token>\nos.environ['OUT_DIR'] = os.path.abspath('.')\nassert os... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def find_entities(corpus):
doc = nlp(corpus)
entities = {}
for ent in doc.ents:
entity_type = ent.label_
entity_name = ent.text
values = entities.get(entity_type, set())
values.add(ent... | flexible | {
"blob_id": "3a0bf031b76d2df03cdb5b37861cb8942307709c",
"index": 7601,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef find_entities(corpus):\n doc = nlp(corpus)\n entities = {}\n for ent in doc.ents:\n entity_type = ent.label_\n entity_name = ent.text\n values = enti... | [
0,
1,
2,
3,
4
] |
from typing import Any, List
__all__: List[str]
record: Any
recarray: Any
format_parser: Any
fromarrays: Any
fromrecords: Any
fromstring: Any
fromfile: Any
array: Any
| normal | {
"blob_id": "2e1ad83bcd16f59338032f8ad5ca8ebd74e92200",
"index": 6664,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__: List[str]\nrecord: Any\nrecarray: Any\nformat_parser: Any\nfromarrays: Any\nfromrecords: Any\nfromstring: Any\nfromfile: Any\narray: Any\n",
"step-3": "from typing import Any, ... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
from fw.api import dadata_proxy
from flask import current_app
from fw.cache.cache_wrapper import CacheWrapper
cache = CacheWrapper()
def dadata_suggest(method, data):
return dadata_proxy.dadata_suggest(method, data)
def dadata_clean(method, data):
return dadata_proxy.dadata_clean(... | normal | {
"blob_id": "af4d2380f92ea636594695e5ad4ba766d6874dd3",
"index": 1355,
"step-1": "<mask token>\n\n\ndef dadata_clean(method, data):\n return dadata_proxy.dadata_clean(method, data)\n\n\ndef get_detailed_address(address):\n from fw.utils.address_utils import get_detailed_address as _get_detailed_address\n ... | [
9,
11,
12,
13,
14
] |
import numpy as np
import os
pwd = os.path.dirname(os.path.realpath(__file__))
train_data = np.load(os.path.join(pwd, 'purchase2_train.npy'), allow_pickle
=True)
test_data = np.load(os.path.join(pwd, 'purchase2_test.npy'), allow_pickle=True)
train_data = train_data.reshape((1,))[0]
test_data = test_data.reshape((1,... | normal | {
"blob_id": "8c364a518ab615803ea99520e90ee1dd24d37a8c",
"index": 2524,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef load(indices, category='train'):\n if category == 'train':\n if max(indices) < len(X_train) and max(indices) < len(y_train):\n return X_train[indices], y_trai... | [
0,
1,
2,
3
] |
from models import Person
from models import Skeleton
from models import Base_dolni
from models import Dolen_vrata
st = Person("Stoian")
Stoian = Person("Ivanov")
dolni = Skeleton(st, 900, 600, 2, 18, 28, 40)
dolni_st = Skeleton(Stoian, 900, 590, 2, 18, 28, 40)
dol_001 = Base_dolni(dolni_st, 550)
dol_001.set_descrip... | normal | {
"blob_id": "3d10f8810594303beb0ccabce3497de86149b2e5",
"index": 6666,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndol_001.set_description('dolen do mivkata')\ndol_001.rendModul()\n<mask token>\ndol_002.set_description('долен втори с 2 врати')\ndol_002.rendModul()\n",
"step-3": "<mask token>\nst = P... | [
0,
1,
2,
3,
4
] |
"""
Ниже на четырёх языках программирования записана программа, которая вводит натуральное число 𝑥,
выполняет преобразования, а затем выводит результат. Укажите наименьшее значение 𝑥,
при вводе которого программа выведет число 10.
Тупо вручную ввёл. Крч 9. Хз, как на экзамене делать))
"""
x = int(input())
a = 3 * x ... | normal | {
"blob_id": "181e9ac4acf0e69576716f3589359736bfbd9bef",
"index": 2380,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile a != b:\n if a > b:\n a -= b\n else:\n b -= a\nprint(a)\nprint('---')\n<mask token>\nwhile number < 100:\n x = number\n a = 3 * x + 23\n b = 3 * x - 17\... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class TestView(BaseView):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class TestView(BaseView):
<|reserved_special_token_0|>
template_name = 'test/music-1.html'
<|reserved_special_token_1|>
<|r... | flexible | {
"blob_id": "dc2b074d7d0e87105b2479bb60b46c73dce6c069",
"index": 6113,
"step-1": "<mask token>\n\n\nclass TestView(BaseView):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass TestView(BaseView):\n <mask token>\n template_name = 'test/music-1.html'\n",
"step-3": "<mask token>\n... | [
1,
2,
3,
4,
5
] |
from django.http import request
from restapp.ExcelSheet import *
'''ApiHomeDict={}
class LoadDict():
e = ExcelSheetAll()
ApiHomeDict = e.apiHomeDict()
print ApiHomeDict
class ReturnApi:
def returnDict(self):
return ApiHomeDict'''
'''if "ApiDictionary" in request.session:
print... | normal | {
"blob_id": "ff924b803a875d3f6201baa2c1251a6c5b8cde61",
"index": 5903,
"step-1": "<mask token>\n",
"step-2": "from django.http import request\nfrom restapp.ExcelSheet import *\n<mask token>\n",
"step-3": "from django.http import request\r\nfrom restapp.ExcelSheet import *\r\n\r\n\r\n'''ApiHomeDict={}\r\nclas... | [
0,
1,
2
] |
from enum import Enum
from roll.input import Input
from roll.network import Server, Client
from assets.game_projects.fighter.src.game_properties import GameProperties
from assets.game_projects.fighter.src.network_message import NetworkMessage
class InputBuffer:
"""
Responsible for collecting game input from... | normal | {
"blob_id": "4789546128263bd298f8f5827734f8402747b9ac",
"index": 67,
"step-1": "<mask token>\n\n\nclass OutgoingNetworkInputBuffer(InputBuffer):\n <mask token>\n <mask token>\n\n\nclass IncomingNetworkInputBuffer(InputBuffer):\n\n def __init__(self, frame_limit=12):\n super().__init__(left_action... | [
5,
12,
13,
15,
21
] |
#!/usr/bin/env python3
print(sum([row[lineNumber * 3 % len(row)] == '#' for lineNumber, row in enumerate(open('input.txt').read().splitlines())])) | normal | {
"blob_id": "b2fecadbd99edb89379f82a935aa1622f043eeac",
"index": 9099,
"step-1": "<mask token>\n",
"step-2": "print(sum([(row[lineNumber * 3 % len(row)] == '#') for lineNumber, row in\n enumerate(open('input.txt').read().splitlines())]))\n",
"step-3": "#!/usr/bin/env python3\n\nprint(sum([row[lineNumber *... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@register.filter(name='phone_number')
def phone_number(number):
first = number[0:3]
second = number[3:6]
third = number[6:10]
return '(' + first + ')' + ' ' + second + '-' + third
<|reserved_special_token_1|>
... | flexible | {
"blob_id": "5e79a8a8fe79aac900fc0c2ff1caaa73ea08ada2",
"index": 5697,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@register.filter(name='phone_number')\ndef phone_number(number):\n first = number[0:3]\n second = number[3:6]\n third = number[6:10]\n return '(' + first + ')' + ' ' + sec... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
tf.disable_v2_behavior()
<|reserved_special_token_0|>
print('Loading video {video_path}...'.format(video_path=video_path))
if not os.path.exists(video_path):
print('File does not exist. Exited.')
exit()
<|reserved_special_... | flexible | {
"blob_id": "7b01e81c3e31e0a315ee01f36bf1b1f7384a9d10",
"index": 3597,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntf.disable_v2_behavior()\n<mask token>\nprint('Loading video {video_path}...'.format(video_path=video_path))\nif not os.path.exists(video_path):\n print('File does not exist. Exited.')... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class Solution(object):
def removeStones(self, stones):
"""
:type stones: List[List[int]]
:rtype: int
"""
stones_share_list = []
for i in range(len(stones)):
stones_share_list.append(0)
for i in range(len(stones)):
... | flexible | {
"blob_id": "896329a8b14d79f849e4a8c31c697f3981395790",
"index": 3327,
"step-1": "<mask token>\n\n\nclass Solution(object):\n\n def removeStones(self, stones):\n \"\"\"\n :type stones: List[List[int]]\n :rtype: int\n \"\"\"\n stones_share_list = []\n for i in range(le... | [
2,
3,
4,
5,
6
] |
t = eval(input())
while t:
t -= 1
y = []
z = []
x = str(input())
for i in range(len(x)):
if (not int(i)%2):
y.append(x[i])
else:
z.append(x[i])
print("".join(y) + " " + "".join(z))
| normal | {
"blob_id": "ac32fb5fcd71790f9dbf0794992a9dc92a202c9b",
"index": 7972,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile t:\n t -= 1\n y = []\n z = []\n x = str(input())\n for i in range(len(x)):\n if not int(i) % 2:\n y.append(x[i])\n else:\n z.appen... | [
0,
1,
2,
3
] |
from abc import abstractmethod
class Environment:
@abstractmethod
def __init__(self, agent):
pass
@abstractmethod
def execute_step(self, n=1):
pass
@abstractmethod
def execute_all(self):
pass
@abstractmethod
def set_delay(self, delay):
pass
| normal | {
"blob_id": "8698aedc5c8671f46c73898a7188440254b79bbf",
"index": 307,
"step-1": "<mask token>\n\n\nclass Environment:\n\n @abstractmethod\n def __init__(self, agent):\n pass\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Environment:\n\n @abstractme... | [
2,
4,
5,
6
] |
<|reserved_special_token_0|>
class CB030Ticker(Device):
def __init__(self, args, **options):
super().__init__(args=args, name='CB030Ticker', required_options=[
'address'], **options)
self.size = 4096
self._tick_cycles = int(self.emu.cycle_rate / 100)
self.reset()
... | flexible | {
"blob_id": "9eef202a42bfc10b2f52d1b9153d664c5046c13f",
"index": 1965,
"step-1": "<mask token>\n\n\nclass CB030Ticker(Device):\n\n def __init__(self, args, **options):\n super().__init__(args=args, name='CB030Ticker', required_options=[\n 'address'], **options)\n self.size = 4096\n ... | [
7,
11,
13,
14,
15
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def is_good(arr):
for i in range(1, len(arr) // 2 + 1):
if arr[-i:] == arr[-(i * 2):-i]:
return False
return True
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def solve(bt):
if l... | flexible | {
"blob_id": "65d5cee6899b0b75474e3898459bf2cfa8b3635b",
"index": 1042,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef is_good(arr):\n for i in range(1, len(arr) // 2 + 1):\n if arr[-i:] == arr[-(i * 2):-i]:\n return False\n return True\n\n\n<mask token>\n",
"step-3": "de... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class ClientConnector(object):
<|reserved_special_token_0|>
def __init__(self, host=None, port=None):
self._host = host
if port:
self._port = port
else:
from quartjes.connector.server import default_port
self._port = def... | flexible | {
"blob_id": "a8f200e0ae1252df4ad6560e5756347cd0e4c8ba",
"index": 5034,
"step-1": "<mask token>\n\n\nclass ClientConnector(object):\n <mask token>\n\n def __init__(self, host=None, port=None):\n self._host = host\n if port:\n self._port = port\n else:\n from quartj... | [
12,
16,
19,
20,
21
] |
# fonction pour voir quel est le plus grand entre l'energie limite et l'enerve potentiel
def ep (m,h,el,g=9.8):
E=m*h*g
if E<el:
print ("le plus grand est : el")
else:
print ("le plus grand est : E")
ep(3,4,5)
#fontion fibonaci 0 1 1 2 3 5 8 13
def fibonaci(n):
for i in range(0,n,):
... | normal | {
"blob_id": "869284fa531a93c1b9812ed90a560d0bb2f87e97",
"index": 255,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef fibonaci(n):\n for i in range(0, n):\n j = 1\n i = i + j\n j = i\n return fibonaci\n",
"step-3": "def ep(m, h, el, g=9.8):\n E = m * h * g\n if E... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def four_Ow_four(error):
"""
method to render the 404 error page
"""
return render_template('fourOwfour.html'), 404
<|reserved_special_token_1|>
def four_Ow_four(error):
'''
method to render the 404 error page
'''
return ren... | flexible | {
"blob_id": "851cfd4e71ffd2d5fed33616abca4444474669a3",
"index": 4508,
"step-1": "<mask token>\n",
"step-2": "def four_Ow_four(error):\n \"\"\"\n method to render the 404 error page\n \"\"\"\n return render_template('fourOwfour.html'), 404\n",
"step-3": "def four_Ow_four(error):\n '''\n met... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "6cd250b3bffd87657ec7cc28eaffe817c6d9f73f",
"index": 9794,
"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 = [('threads', '... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def ispalindrome(s):
if len(s) <= 1:
return True
elif s[0] != s[-1]:
return False
else:
return ispalindrome(s[1:-1])
| flexible | {
"blob_id": "c20a414f7f96a96f6e458fc27e5d2c7ac7ab05cf",
"index": 8574,
"step-1": "<mask token>\n",
"step-2": "def ispalindrome(s):\n if len(s) <= 1:\n return True\n elif s[0] != s[-1]:\n return False\n else:\n return ispalindrome(s[1:-1])\n",
"step-3": null,
"step-4": null,
... | [
0,
1
] |
from fastapi import FastAPI
from app.router.routes import initRoutes
from app.cors.cors import initCors
app = FastAPI(debug=True,title="Recipe API")
initCors(app)
initRoutes(app)
| normal | {
"blob_id": "1857d76b8c68c58d2d721de529811a6aeb09fcbb",
"index": 5407,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ninitCors(app)\ninitRoutes(app)\n",
"step-3": "<mask token>\napp = FastAPI(debug=True, title='Recipe API')\ninitCors(app)\ninitRoutes(app)\n",
"step-4": "from fastapi import FastAPI\nf... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class LoginForm(FlaskForm):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class LoginForm(FlaskForm):
<|reserved_special_token_0|>
username = StringField('用户名', vali... | flexible | {
"blob_id": "6ad2014191215dac97ad6fc6a026512c3d1866dc",
"index": 8244,
"step-1": "<mask token>\n\n\nclass LoginForm(FlaskForm):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass LoginForm(FlaskForm):\n <mask token>\n username = StringField('用户名', validators=[Dat... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def GetDateTimeString():
dt = str(datetime.datetime.now()).split('.')[0]
clean = dt.replace(' ', '_').replace(':', '_')
return clean
def GetBackground(bgNumber):
bgImage = '/home/pi/pibooth/backgrounds/space.jpg'
return cv2.imread(bgImage)
def GetImage(bg):
ret... | flexible | {
"blob_id": "a14c23398bbf42832a285d29c1b80aefc5fdaf6c",
"index": 9031,
"step-1": "<mask token>\n\n\ndef GetDateTimeString():\n dt = str(datetime.datetime.now()).split('.')[0]\n clean = dt.replace(' ', '_').replace(':', '_')\n return clean\n\n\ndef GetBackground(bgNumber):\n bgImage = '/home/pi/piboot... | [
3,
4,
5,
6,
7
] |
from pymarketo.client import MarketoClientFactory
import os
import sys #@UnusedImport
import time #@UnusedImport
import datetime #@UnusedImport
from pprint import pprint #@UnresolvedImport
TESTDIR = os.path.split(__file__)[0]
PACKAGEDIR = os.path.join(TESTDIR,"..")
INIFILE = os.path.join(PACKAGEDIR,"marketo.ini")
DATA... | normal | {
"blob_id": "b05a5fcbba74bf4108bc953c6f868eb1f5ca298f",
"index": 638,
"step-1": "from pymarketo.client import MarketoClientFactory\nimport os\nimport sys #@UnusedImport\nimport time #@UnusedImport\nimport datetime #@UnusedImport\nfrom pprint import pprint #@UnresolvedImport\n\nTESTDIR = os.path.split(__file__)[0... | [
0
] |
<|reserved_special_token_0|>
class Root(Controller):
def index(self):
return 'Hello World!'
def request_body(self):
return self.request.body.read()
def response_body(self):
return 'ä'
def request_headers(self):
return self.request.headers['A']
def response_head... | flexible | {
"blob_id": "eb891341488e125ae8c043788d7264fff4018614",
"index": 6585,
"step-1": "<mask token>\n\n\nclass Root(Controller):\n\n def index(self):\n return 'Hello World!'\n\n def request_body(self):\n return self.request.body.read()\n\n def response_body(self):\n return 'ä'\n\n def... | [
8,
9,
11,
12,
15
] |
<|reserved_special_token_0|>
class Test(unittest.TestCase):
<|reserved_special_token_0|>
def test_take_comparison(self):
x = np.arange(1000000.0)
idx = np.random.random_integers(0, 100000.0, 1000000.0)
indexing.take(x, idx)
np.take(x, idx)
with Timer('numba') as nbtime... | flexible | {
"blob_id": "ee80169afd4741854eff8619822a857bbf757575",
"index": 291,
"step-1": "<mask token>\n\n\nclass Test(unittest.TestCase):\n <mask token>\n\n def test_take_comparison(self):\n x = np.arange(1000000.0)\n idx = np.random.random_integers(0, 100000.0, 1000000.0)\n indexing.take(x, i... | [
5,
7,
8,
11,
12
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
print('Hello world')
print('Hello again')
print('Hello again')
<|reserved_special_token_1|>
print("""Hello world""")
print("Hello again")
print('Hello again') | flexible | {
"blob_id": "fe82a46a7965b27729ff5bd61c1059416c96cae7",
"index": 8015,
"step-1": "<mask token>\n",
"step-2": "print('Hello world')\nprint('Hello again')\nprint('Hello again')\n",
"step-3": "print(\"\"\"Hello world\"\"\")\nprint(\"Hello again\")\nprint('Hello again')",
"step-4": null,
"step-5": null,
"s... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
__all__ = ('__title__', '__summary__', '__version__', '__author__',
'__license__', '__copyright__')
__title__ = 'mupub'
__summary__ = 'Musical score publishing utility for the Mutopia Project'
<|reserved_special_token_0|>
__ve... | flexible | {
"blob_id": "eabf06481509962652812af67ad59da5cfe30fae",
"index": 1,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ('__title__', '__summary__', '__version__', '__author__',\n '__license__', '__copyright__')\n__title__ = 'mupub'\n__summary__ = 'Musical score publishing utility for the Mutopia... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test_backfill_totals_works_for_correct_dates(mocker, notify_api):
send_mock = mocker.patch(
'app.commands.send_total_sent_notifications_to_performance_platform')
backfill_performance_platform_totals.callback.... | flexible | {
"blob_id": "fcb1285648f6728e3dad31ad4b602fa4e5c5b422",
"index": 9230,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_backfill_totals_works_for_correct_dates(mocker, notify_api):\n send_mock = mocker.patch(\n 'app.commands.send_total_sent_notifications_to_performance_platform')\n ... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# coding: utf-8
# # import re
# # import urllib
# #
# #
# # def getHtml(url):
# # page = urllib.urlopen(url)
# # html = page.read()
# # return html
# #
# #
# # def getMp4(html):
# # r = r"href='(http.*\.mp4)'"
# # re_mp4 = re.compile(r)
# # mp4List = re.findall(re_mp4, html)
... | normal | {
"blob_id": "ad94118b43e130aec5df3976fd0460164de17511",
"index": 8361,
"step-1": "<mask token>\n\n\ndef _not_divisible(n):\n return lambda x: x % n > 0\n\n\ndef primes():\n yield 2\n it = _odd_iter()\n while True:\n n = next(it)\n yield n\n it = filter(_not_divisible(n), it)\n\n\... | [
6,
9,
10,
11,
13
] |
class Solution:
# @param arrive : list of integers
# @param depart : list of integers
# @param K : integer
# @return a boolean
def hotel(self, arrive, depart, K):
self.count = 0
self.temp = 0
for i in range(len(arrive)):
for j in range(i, len(depart)):
... | normal | {
"blob_id": "de6a6c2dc7bea255e5674663616c962c1d1625e0",
"index": 4138,
"step-1": "class Solution:\n # @param arrive : list of integers\n # @param depart : list of integers\n # @param K : integer\n # @return a boolean\n def hotel(self, arrive, depart, K):\n self.count = 0\n self.temp ... | [
0
] |
<|reserved_special_token_0|>
class UploadCommand(Command):
<|reserved_special_token_0|>
description = 'Build and publish the package.'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
@staticmethod
def status(s):
"""Prints thi... | flexible | {
"blob_id": "58438a1fb0b9e620717ba262c25a43bfbf6b8824",
"index": 8100,
"step-1": "<mask token>\n\n\nclass UploadCommand(Command):\n <mask token>\n description = 'Build and publish the package.'\n user_options = []\n\n def initialize_options(self):\n pass\n\n def finalize_options(self):\n ... | [
6,
7,
9,
10,
11
] |
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from app import app
layout = html.Div([
html.H3('Node 6'),
dcc.Dropdown(
id='node-6-dropdown',
options=[
{'label': 'Node 6 - {}'.format(i), 'value': i} for ... | normal | {
"blob_id": "632b90ea5a2ac35539e589af297c04b31bbf02d0",
"index": 3443,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@app.callback(Output('node-6-display-value', 'children'), [Input(\n 'node-6-dropdown', 'value')])\ndef display_value(value):\n return 'You have selected \"{}\"'.format(value)\n"... | [
0,
1,
2,
3,
4
] |
# Given two binary trees, write a function to check if they are equal or not.
#
# Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
#
# Return 0 / 1 ( 0 for false, 1 for true ) for this problem
#
# Example :
#
# Input :
#
# 1 1
# / \ / \
# 2 3 ... | normal | {
"blob_id": "4a0eca90de3ce7fb0ab6decb0ec6aadb32c1a9fa",
"index": 601,
"step-1": "<mask token>\n\n\nclass Solution:\n\n def solution(self, rootA, rootB):\n if rootA == rootB:\n print('h')\n return True\n if rootA is None or rootB is None:\n return False\n r... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
def getUTC_TIME():
return datetime.datetime.utcnow()
def pushSample(sample, topic):
global client
client.publish(topic, str(sample))
<|reserved_special_token_0|>
def on_connect(client, userdata, flags, rc):
print('Connected with result code ' + str(rc))
client.su... | flexible | {
"blob_id": "0295d6ba962d099e76110c7a0e39748e3163e300",
"index": 5541,
"step-1": "<mask token>\n\n\ndef getUTC_TIME():\n return datetime.datetime.utcnow()\n\n\ndef pushSample(sample, topic):\n global client\n client.publish(topic, str(sample))\n\n\n<mask token>\n\n\ndef on_connect(client, userdata, flag... | [
13,
15,
16,
17,
18
] |
#!/usr/bin/env python3
# This is a tool to export the WA framework answers to a XLSX file
#
# This code is only for use in Well-Architected labs
# *** NOT FOR PRODUCTION USE ***
#
# Licensed under the Apache 2.0 and MITnoAttr License.
#
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Lice... | normal | {
"blob_id": "c5e003d625d7798eaf4ef5bca28f6311edccb316",
"index": 7235,
"step-1": "<mask token>\n\n\nclass DateTimeEncoder(json.JSONEncoder):\n\n def default(self, z):\n if isinstance(z, datetime.datetime):\n return str(z)\n else:\n return super().default(z)\n\n\n<mask token... | [
13,
15,
16,
18,
19
] |
from wasserstoff.wasserstoff import Config, Environment
__all__ = ['Config', 'Environment']
| normal | {
"blob_id": "862b529741d9c3e6cf7ca50272c8af724c56ac62",
"index": 404,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['Config', 'Environment']\n",
"step-3": "from wasserstoff.wasserstoff import Config, Environment\n__all__ = ['Config', 'Environment']\n",
"step-4": null,
"step-5": null,
... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'find_result_window.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_FindResultWindow(object):
def setupUi(self, FindResultW... | normal | {
"blob_id": "2fdbf418b5cec50ee6568897e0e749681efeef6b",
"index": 6584,
"step-1": "<mask token>\n\n\nclass Ui_FindResultWindow(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Ui_FindResultWindow(object):\n <mask token>\n\n def retranslateUi(self, FindResultWindow):\n ... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python2
# A basic example of sending Blue a command in cartesian space.
from blue_interface import BlueInterface
import numpy as np
import time
import sys
import argparse
import Leap
from utils.rotations import quat2euler, euler2quat, mat2euler
from utils.leap_listener import SampleListener
import mat... | normal | {
"blob_id": "b34e293b509328c728909262594bdf3d3ecf5360",
"index": 4364,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nparser.add_argument('--IK', default=False, action='store_true', help=\n 'switch to IK-control')\n<mask token>\nblue.calibrate_gripper()\n<mask token>\nwhile True:\n hands_data = lis... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('Tuple: ', new_tuple)
print('List: ', new_list)
<|reserved_special_token_0|>
print('Converted tuple from the list : ', tuple_2)
<|reserved_special_token_1|>
new_tuple = 11, 12, 13, 14, 15, 16, 17
new_list = ['one', 12, 't... | flexible | {
"blob_id": "889fdca3f92f218e6d6fd3d02d49483f16a64899",
"index": 9117,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Tuple: ', new_tuple)\nprint('List: ', new_list)\n<mask token>\nprint('Converted tuple from the list : ', tuple_2)\n",
"step-3": "new_tuple = 11, 12, 13, 14, 15, 16, 17\nnew_list ... | [
0,
1,
2,
3
] |
def memo(fn):
cache = {}
missed = object()
def query(*args):
result = cache.get(args, missed)
if result is missed:
result = cache[args] = fn(*args)
return result
return query
@memo
def cal_edit_distance(ori, tar):
def edit_tuple(old, distance, path):
r... | flexible | {
"blob_id": "88390f411af90d494284617ef8f5fb0e9bb8890e",
"index": 8039,
"step-1": "def memo(fn):\n cache = {}\n missed = object()\n\n def query(*args):\n result = cache.get(args, missed)\n if result is missed:\n result = cache[args] = fn(*args)\n return result\n return ... | [
2,
3,
4,
5,
6
] |
<|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 = [m... | flexible | {
"blob_id": "8b4bc312bf4b64f98c4f84f4bf89984291be0428",
"index": 6033,
"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 = [migrations.sw... | [
0,
1,
2,
3,
4
] |
class BaseException(Exception):
def __init__(self, message=""):
super(BaseException, self).__init__()
self.message = message
| normal | {
"blob_id": "2ee1539e051677ad38ab7727ff5edefb1aebd015",
"index": 9946,
"step-1": "<mask token>\n",
"step-2": "class BaseException(Exception):\n <mask token>\n",
"step-3": "class BaseException(Exception):\n\n def __init__(self, message=''):\n super(BaseException, self).__init__()\n self.me... | [
0,
1,
2,
3
] |
from arcade.sprite_list.sprite_list import SpriteList
import GamePiece as gp
from Errors import *
class GameConfig:
WINDOW_TITLE = "MyPyTris"
SCREEN_WIDTH = 450
SCREEN_HEIGHT = 900
BLOCK_PX = 45 # 45px blocks on screen
SPRITE_PX = 64 # 64px sprite
BLOCK_SCALE = BLOCK_PX/SPRITE_PX # sprite scal... | normal | {
"blob_id": "2d7431996bc8d1099c08fddc815b4706deb4f023",
"index": 4393,
"step-1": "<mask token>\n\n\nclass GameBoard:\n <mask token>\n <mask token>\n\n def draw(self):\n self.playerSprites.draw()\n self.groundSprites.draw()\n <mask token>\n <mask token>\n\n def moveGamePiece(self, ... | [
7,
12,
13,
17,
18
] |
<|reserved_special_token_0|>
class Player:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class Bullet:
def __init__(self, color):
self.x = 0
self.y = 0
self.angle = 0
self.color = color
def draw(self):
pygame.draw... | flexible | {
"blob_id": "54e04d740ef46fca04cf4169d2e7c05083414bd8",
"index": 11,
"step-1": "<mask token>\n\n\nclass Player:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Bullet:\n\n def __init__(self, color):\n self.x = 0\n self.y = 0\n self.angle = 0\n self.color = color\n\... | [
14,
17,
19,
20,
21
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def lcs2(a, b):
dp_result = [[(0) for j in range(b + 1)] for i in range(a + 1)]
for x in range(1, a + 1):
for y in range(1, b + 1):
if a[x - 1] == b[y - 1] and b[y - 1] == c[z - 1]:
dp... | flexible | {
"blob_id": "d20b336c6588c3cfc4393256b660d6e4ff56b84e",
"index": 1543,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef lcs2(a, b):\n dp_result = [[(0) for j in range(b + 1)] for i in range(a + 1)]\n for x in range(1, a + 1):\n for y in range(1, b + 1):\n if a[x - 1] == b[y ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def qs(li):
n, p = len(li), len(li) // 2 - 1
if n <= 1:
return li
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def qs(li):
n, p = len(li), len(li) // 2 - 1
if n <= 1:
return li
print(qs([11, 45, 23, 81, 28, ... | flexible | {
"blob_id": "605d8144d18207314981872ec57cec6cb2510601",
"index": 7457,
"step-1": "<mask token>\n",
"step-2": "def qs(li):\n n, p = len(li), len(li) // 2 - 1\n if n <= 1:\n return li\n\n\n<mask token>\n",
"step-3": "def qs(li):\n n, p = len(li), len(li) // 2 - 1\n if n <= 1:\n return... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(2000):
squares[i * i] = i
<|reserved_special_token_0|>
for a in range(1, 1001):
for b in range(a + 1, 1001):
if a * a + b * b not in squares:
continue
c = squares[a * a + b * b]
... | flexible | {
"blob_id": "a3299a2945a638c74c2d16bc28079ed692718fbd",
"index": 2703,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(2000):\n squares[i * i] = i\n<mask token>\nfor a in range(1, 1001):\n for b in range(a + 1, 1001):\n if a * a + b * b not in squares:\n continue\n ... | [
0,
1,
2,
3
] |
from django.db import models
from django.utils.translation import ugettext_lazy as _
from apps.sources.models.mixins.page_numbers import PageNumbersMixin
from apps.sources.models.source import Source
PIECE_TYPES = (('essay', 'Essay'),)
TYPE_MAX_LENGTH: int = 10
class Piece(Source, PageNumbersMixin):
"""A piece ... | normal | {
"blob_id": "30c24b9a4738c1952fc5d36a4bc36d8d3576ed3b",
"index": 7201,
"step-1": "<mask token>\n\n\nclass Piece(Source, PageNumbersMixin):\n \"\"\"A piece (e.g., essay).\"\"\"\n type = models.CharField(verbose_name=_('piece type'), max_length=\n TYPE_MAX_LENGTH, choices=PIECE_TYPES, default=PIECE_TY... | [
4,
5,
6,
7,
8
] |
ii = [('CoolWHM.py', 1), ('SoutRD.py', 1), ('BrewDTO.py', 2), (
'FitzRNS2.py', 1), ('LyelCPG3.py', 1), ('TaylIF.py', 2)]
| normal | {
"blob_id": "fbba928d51ccd08dbac25fcf2098be3a0d494d34",
"index": 6659,
"step-1": "<mask token>\n",
"step-2": "ii = [('CoolWHM.py', 1), ('SoutRD.py', 1), ('BrewDTO.py', 2), (\n 'FitzRNS2.py', 1), ('LyelCPG3.py', 1), ('TaylIF.py', 2)]\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
... | [
0,
1
] |
import socket
from time import time, sleep
from threading import Thread
# Define drone
class dm107s():
# Default control value
def __init__(self):
# 4 values for flight
self.roll = 128
self.pitch = 128
self.throttle = 128
self.yaw = 128
# 0 - normal mode, 2 - eme... | normal | {
"blob_id": "ee8e117db0348aa37d6aa37e6c06255101f1cff4",
"index": 2752,
"step-1": "<mask token>\n\n\nclass dm107s:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def incremt(self, rl, pt, th, yw):\n self._value_to_change ... | [
23,
29,
33,
39,
43
] |
<|reserved_special_token_0|>
class SequenceList(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
@staticmethod
def del... | flexible | {
"blob_id": "2e744c0cbddf64a9c538c9f33fa19ff78c515012",
"index": 6797,
"step-1": "<mask token>\n\n\nclass SequenceList(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def delete_old_and_unattached(cur... | [
8,
14,
15,
16,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('circumference is ', circumference)
print('diameter is: ', diameter)
print('area is ', area)
<|reserved_special_token_1|>
radius = int(input('enter the value for the radius of the cycle: '))
circumference = 2 * 3.14159 * ... | flexible | {
"blob_id": "ab5412a3d22bd53a592c93bad4870b06fd9f0720",
"index": 4080,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('circumference is ', circumference)\nprint('diameter is: ', diameter)\nprint('area is ', area)\n",
"step-3": "radius = int(input('enter the value for the radius of the cycle: '))\... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def _find_warnings(filename, lines, ast_list, static_is_optional):
def print_warning(node, name):
print("{}:{}: static data '{}'".format(filename, lines.
get_line_number(node.start), name))
def find_static(function_node):
tokens = []
static_fo... | flexible | {
"blob_id": "57d1fb805fce2ba75ea2962598e809ba35fd7eb6",
"index": 3490,
"step-1": "<mask token>\n\n\ndef _find_warnings(filename, lines, ast_list, static_is_optional):\n\n def print_warning(node, name):\n print(\"{}:{}: static data '{}'\".format(filename, lines.\n get_line_number(node.start),... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
@authentication.route('/register', methods=['GET', 'POST'])
def register():
form = Register()
if form.validate_on_submit():
data = {'first_name': request.form.get('first_name'), 'last_name':
request.form.get('last_name'), 'email': request.form.get(
... | flexible | {
"blob_id": "74faeb1c09fe136ec4d9578173aeebe54b451e33",
"index": 2406,
"step-1": "<mask token>\n\n\n@authentication.route('/register', methods=['GET', 'POST'])\ndef register():\n form = Register()\n if form.validate_on_submit():\n data = {'first_name': request.form.get('first_name'), 'last_name':\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
@register.simple_tag()
def multiplication(value, arg, *args, **kwargs):
return value * arg
@register.filter
def in_category(things, category):
return things.filter(category=category)
@register.simple_tag()
def division(value, arg, *args, **kwargs):
return value / arg
<|r... | flexible | {
"blob_id": "9339d3bc0c3005880b1c8d1c9914d6e28d39dbbd",
"index": 7285,
"step-1": "<mask token>\n\n\n@register.simple_tag()\ndef multiplication(value, arg, *args, **kwargs):\n return value * arg\n\n\n@register.filter\ndef in_category(things, category):\n return things.filter(category=category)\n\n\n@registe... | [
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Command(BaseCommand):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Command(BaseCommand):
def handle(self, *args, **options):
print('Loading article sett... | flexible | {
"blob_id": "a3d27561488c38e1256eb33abad108ad42081eb6",
"index": 9253,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Command(BaseCommand):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Command(BaseCommand):\n\n def handle(self, *args, **options):\n print('Loading article... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def reader():
with open('possibilities.txt', 'r') as file1:
file_lines = [x.strip() for x in file1.readlines()]
for e in file_lines:
n = e.replace('Python', 'C++')
print(n)
<|reserve... | flexible | {
"blob_id": "6d80a89a47b68fd8d81739787897355671ca94e9",
"index": 5815,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef reader():\n with open('possibilities.txt', 'r') as file1:\n file_lines = [x.strip() for x in file1.readlines()]\n for e in file_lines:\n n = e.replace(... | [
0,
1,
2,
3
] |
'''
Encontrar el valor mas alto el mas rapido, el mas lento
para eso son los algoritmos de optimizacion
Para eso debemos pensar en una funcion que queramos maximizar o minimizar
Se aplican mas que todo para empresas como despegar, en donde se pueden generar buenas empresas
Empresas a la optimizacion... | normal | {
"blob_id": "7163be250ae3a22931de037cb6896c2e6d5f00a8",
"index": 584,
"step-1": "<mask token>\n",
"step-2": "'''\n Encontrar el valor mas alto el mas rapido, el mas lento\n para eso son los algoritmos de optimizacion\n Para eso debemos pensar en una funcion que queramos maximizar o minimizar\n Se a... | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def colorful(A):
sA = str(A)
len_sA = len(sA)
if len_sA == 1:
return 1
dig_list = []
for i in range(len_sA):
for j in range(i, len_sA):
dig_list.append(int(sA[i:j + 1]))
mul = ... | flexible | {
"blob_id": "41013469e65e45f6c909d66c2a54eaf11dfd474c",
"index": 3077,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef colorful(A):\n sA = str(A)\n len_sA = len(sA)\n if len_sA == 1:\n return 1\n dig_list = []\n for i in range(len_sA):\n for j in range(i, len_sA):\n ... | [
0,
1,
2,
3
] |
# Generated by Django 2.1.5 on 2019-08-03 23:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('crm', '0003_auto_20190802_2211'),
]
operations = [
migrations.AlterModelOptions(
name='customerinfo',
options={'verbose_name... | normal | {
"blob_id": "b90fb1e657d4c7e186a7b889eee586527bec4413",
"index": 2040,
"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 = [('crm', '0003... | [
0,
1,
2,
3,
4
] |
"""
Merkle: Implementation of Merkle Trees over Blake2
"""
from typing import List, Any
from hashlib import blake2b
class Merkle:
"""
We consider the merkle tree as a commitment protocol implementing
the interface:
* commit_() : commits to a list by computing the merkle tree.
* open_() : opens the... | normal | {
"blob_id": "547926904f9a4b88a988e3b59c49b94fe0e30de4",
"index": 1955,
"step-1": "<mask token>\n\n\nclass Merkle:\n <mask token>\n <mask token>\n\n def commit_(leafs):\n assert len(leafs) & len(leafs\n ) - 1 == 0, 'List must be of a power two length'\n if len(leafs) == 1:\n ... | [
6,
7,
9,
10,
11
] |
from flask import (Flask, g, render_template, flash, redirect, url_for)
from flask_login import (LoginManager, login_user, logout_user,
login_required, current_user)
import forms
import models
import sqlite3
DEBUG = True
app = Flask(__name__)
app.secret_key = 'auoesh.bouoastuh.43,uoausoehuos... | normal | {
"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
] |
n = int(input())
a = oct(n)
b = hex(n)
print(a[2:],b[2:].upper())
#.upper : 소문자 -> 대문자
| normal | {
"blob_id": "d6cea40e907a0424b2b1b8162f19aa8203443e55",
"index": 4360,
"step-1": "n = int(input())\n\na = oct(n)\nb = hex(n)\n\nprint(a[2:],b[2:].upper())\n\n#.upper : 소문자 -> 대문자\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
<|reserved_special_token_0|>
def train_validate_test_split(df, train_percent=0.8, validate_percent=0.2,
seed=None):
np.random.seed(seed)
perm = np.random.permutation(df.index)
m = len(df.index)
train_end = int(train_percent * m)
train = df.iloc[:train_end]
validate = df.iloc[train_end:]
... | flexible | {
"blob_id": "c18c407476375fb1647fefaedb5d7ea0e0aabe3a",
"index": 929,
"step-1": "<mask token>\n\n\ndef train_validate_test_split(df, train_percent=0.8, validate_percent=0.2,\n seed=None):\n np.random.seed(seed)\n perm = np.random.permutation(df.index)\n m = len(df.index)\n train_end = int(train_pe... | [
2,
3,
4,
5,
6
] |
"""
Visualize the predictions of a GQCNN on a dataset Visualizes TP, TN, FP, FN..
Author: Vishal Satish
"""
import copy
import logging
import numpy as np
import os
import sys
from random import shuffle
import autolab_core.utils as utils
from autolab_core import YamlConfig, Point
from perception import BinaryImage, Co... | normal | {
"blob_id": "806bdb75eed91d1429d8473a50c136b58a736147",
"index": 8852,
"step-1": "\"\"\"\nVisualize the predictions of a GQCNN on a dataset Visualizes TP, TN, FP, FN..\nAuthor: Vishal Satish \n\"\"\"\nimport copy\nimport logging\nimport numpy as np\nimport os\nimport sys\nfrom random import shuffle\n\nimport aut... | [
0
] |
<|reserved_special_token_0|>
def scoreBarChart(names, score):
plt.bar(names, score)
plt.show()
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def scoreBarChart(names, score):
plt.bar(names, score)
plt.show()
def multiBarChart(names, score):
plt.plot... | flexible | {
"blob_id": "542602a42eb873508ce2ec39d0856f10cc1e04ff",
"index": 8426,
"step-1": "<mask token>\n\n\ndef scoreBarChart(names, score):\n plt.bar(names, score)\n plt.show()\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef scoreBarChart(names, score):\n plt.bar(names, score)\n plt.show()\n\n\ndef... | [
1,
2,
3,
4,
5
] |
import itertools
n = int(input())
a = [list(map(int, input().split(" "))) for i in range(n)]
ans = 0
for [ix,iy], [jx, jy] in itertools.combinations(a, 2):
ans += ((jx-ix)**2+(jy-iy)**2)**0.5*2
print(ans/n) | normal | {
"blob_id": "a210a015284130f23bfec99898f2f21163a33a67",
"index": 9897,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor [ix, iy], [jx, jy] in itertools.combinations(a, 2):\n ans += ((jx - ix) ** 2 + (jy - iy) ** 2) ** 0.5 * 2\nprint(ans / n)\n",
"step-3": "<mask token>\nn = int(input())\na = [list... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def find_answer(answer, sents):
for s_idx, sent in enumerate(sents):
if answer in sent:
return s_idx
return -1
<|reserved_special_token_0|>
def docred_refiner():
DOCRED_OUTPUT_PROCESSED_para_file = join(DATASET_FOLDER,
'data_processed/docred/doc... | flexible | {
"blob_id": "a179d3d2f04a101eaa60b5964c2b1cd77071633f",
"index": 5344,
"step-1": "<mask token>\n\n\ndef find_answer(answer, sents):\n for s_idx, sent in enumerate(sents):\n if answer in sent:\n return s_idx\n return -1\n\n\n<mask token>\n\n\ndef docred_refiner():\n DOCRED_OUTPUT_PROCES... | [
3,
5,
6,
7,
8
] |
from collections import defaultdict
# The order of the steps doesn't matter, so the distance
# function is very simple
def dist(counts):
n = abs(counts["n"] - counts["s"])
nw = abs(counts["nw"] - counts["se"])
ne = abs(counts["ne"] - counts["sw"])
return n + max(ne,nw)
if __name__ == "__main__":
c... | normal | {
"blob_id": "ac2e9145e3345e5448683d684b69d2356e3214ce",
"index": 9999,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef dist(counts):\n n = abs(counts['n'] - counts['s'])\n nw = abs(counts['nw'] - counts['se'])\n ne = abs(counts['ne'] - counts['sw'])\n return n + max(ne, nw)\n\n\n<mask ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def solve_model(K, R, N, L_max, G):
print(
'parameters==| k=%d \t |R=%s \t |N=%d \t |eta=%f \t |L_max=%f \t |G=%f'
% (K, R, N, eta, L_max, G))
R_sum = sum(R.values())
gamma = c0 * d0 * 1 / R_sum
... | flexible | {
"blob_id": "2ed9eafb6e26971f642d1e33cbb3d1f3df34990a",
"index": 3401,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef solve_model(K, R, N, L_max, G):\n print(\n 'parameters==| k=%d \\t |R=%s \\t |N=%d \\t |eta=%f \\t |L_max=%f \\t |G=%f'\n % (K, R, N, eta, L_max, G))\n R_sum ... | [
0,
1,
2,
3,
4
] |
"""
Duck typing
Ref: http://www.voidspace.org.uk/python/articles/duck_typing.shtml
"""
##########
# mathmatic operator (syntactic sugar)
print 3 + 3
# same as >>>
print int.__add__(3, 3)
# <<<
# overload '+' operator
class Klass1(object):
def __init__(self, a, b):
self.a = a
self.b = b
def __a... | normal | {
"blob_id": "776470546585257bf06073e2d894e8a04cf2376d",
"index": 727,
"step-1": "\"\"\"\nDuck typing\nRef: http://www.voidspace.org.uk/python/articles/duck_typing.shtml\n\"\"\"\n\n##########\n# mathmatic operator (syntactic sugar)\nprint 3 + 3\n# same as >>>\nprint int.__add__(3, 3)\n# <<<\n\n# overload '+' oper... | [
0
] |
import tensorflow as tf
from keras import layers, Model, Input
from keras.utils import Progbar, to_categorical
from keras.datasets.mnist import load_data
import numpy as np
import matplotlib.pyplot as plt
import config
import datetime
img_height, img_width, _ = config.IMAGE_SHAPE
(X, Y), (_, _) = load_data()
X = X.re... | normal | {
"blob_id": "e265b2b2ccc0841ccb8b766de4ae2a869f2d280d",
"index": 8326,
"step-1": "<mask token>\n\n\nclass Generator(Model):\n\n def __init__(self, name):\n super(Generator, self).__init__(name=name)\n self.dense = layers.Dense(7 * 7 * 128)\n self.conv1 = layers.Conv2DTranspose(128, kernel... | [
8,
12,
13,
15,
19
] |
<|reserved_special_token_0|>
def _mako_generate_namespaces(context):
ns = runtime.TemplateNamespace('__anon_0x88e2e50', context.
_clean_inheritance_tokens(), templateuri=u'/message.mako',
callables=None, calling_uri=_template_uri)
context.namespaces[__name__, '__anon_0x88e2e50'] = ns
ns = ... | flexible | {
"blob_id": "fd54bbfbc81aec371ad6c82bf402a5a3673a9f24",
"index": 8892,
"step-1": "<mask token>\n\n\ndef _mako_generate_namespaces(context):\n ns = runtime.TemplateNamespace('__anon_0x88e2e50', context.\n _clean_inheritance_tokens(), templateuri=u'/message.mako',\n callables=None, calling_uri=_te... | [
3,
5,
7,
9,
10
] |
<|reserved_special_token_0|>
def main():
keep_going = 'y'
while keep_going == 'y':
guess = int(input('\nGuess a number between 1 and 100: '))
if guess > randomNumber:
print('\nToo high, try again.')
elif guess < randomNumber:
print('\nToo low, try again')
... | flexible | {
"blob_id": "c09c02a36a64e9522cfc8c0951bd6c98f404f09c",
"index": 367,
"step-1": "<mask token>\n\n\ndef main():\n keep_going = 'y'\n while keep_going == 'y':\n guess = int(input('\\nGuess a number between 1 and 100: '))\n if guess > randomNumber:\n print('\\nToo high, try again.')\n... | [
1,
2,
3,
4,
5
] |
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path impo... | normal | {
"blob_id": "a6670d0d09f02b674bc31b770f42d4d8a01a4a4e",
"index": 9884,
"step-1": "<mask token>\n\n\nclass SoapySDRSizeList(_object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def iterator(self):\n return _SoapySDR.SoapySDRSizeList_iterator(self)\n\n ... | [
177,
316,
400,
419,
427
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import json
import urllib2
# Es importante agregar la variable de ambiente:
# export PYTHONIOENCODING='UTF-8'
# para redireccionar la salida std a un archivo.
def call(url):
try:
request = urllib2.Request(url)
response = urllib2.urlopen(req... | normal | {
"blob_id": "c81fde7fb5d63233c633b8e5353fe04477fef2af",
"index": 4770,
"step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\nimport json\nimport urllib2\n\n# Es importante agregar la variable de ambiente:\n# export PYTHONIOENCODING='UTF-8'\n# para redireccionar la salida std a un archivo.\n\nd... | [
0
] |
import re
rule_regex = re.compile(r'([\.#]{5}) => ([\.#])')
grid_regex = re.compile(r'initial state: ([\.#]+)')
class Rule:
def __init__(self, template, alive):
self.template = template
self.alive = alive
def parse(string):
match = rule_regex.match(string)
if match:
template = match.group(... | normal | {
"blob_id": "8c683c109aba69f296b8989915b1f3b3eecd9745",
"index": 4274,
"step-1": "<mask token>\n\n\nclass Rule:\n\n def __init__(self, template, alive):\n self.template = template\n self.alive = alive\n\n def parse(string):\n match = rule_regex.match(string)\n if match:\n ... | [
5,
7,
9,
10,
12
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
ALL_COMMANDS = (agent, clean, config, create, dep, env, meta, release, run,
test, validate)
<|reserved_special_token_1|>
from .agent import agent
from .clean import clean
from .config import config
from .create import creat... | flexible | {
"blob_id": "7a69a9fd6ee5de704a580e4515586a1c1d2b8017",
"index": 5874,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nALL_COMMANDS = (agent, clean, config, create, dep, env, meta, release, run,\n test, validate)\n",
"step-3": "from .agent import agent\nfrom .clean import clean\nfrom .config import c... | [
0,
1,
2,
3
] |
from vector3 import vec3
class ray:
def __init__(self, *args):
if len(args) == 0:
self.A = vec3(0,0,0)
self.B = vec3(1,0,0)
elif len(args) == 2:
if type(args[0]) != vec3 or type(args[1]) != vec3:
raise ValueError("Expected two vec3s")
else:
self.A = args[0]
self.B = args[1]
else:
rais... | normal | {
"blob_id": "a73e3a07ab0ebb90fa744d3dfc8d9da119f99283",
"index": 2070,
"step-1": "<mask token>\n\n\nclass ray:\n\n def __init__(self, *args):\n if len(args) == 0:\n self.A = vec3(0, 0, 0)\n self.B = vec3(1, 0, 0)\n elif len(args) == 2:\n if type(args[0]) != vec3 ... | [
4,
5,
6,
7,
8
] |
from django.test import TestCase
from core.factories import CompanyFactory, EmployeeFactory
from core.pair_matcher import MaximumWeightGraphMatcher
class PairMatcherTestCase(TestCase):
def setUp(self):
self.company = CompanyFactory.create()
def test_simple(self):
employees = EmployeeFactory.... | normal | {
"blob_id": "0c68bd65cac3c8b9fd080900a00991b2d19260ee",
"index": 534,
"step-1": "<mask token>\n\n\nclass PairMatcherTestCase(TestCase):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass PairMatcherTestCase(TestCase):\n <mask token>\n\n def test_simple(self):\n employees = ... | [
1,
2,
3,
4
] |
import tensorflow as tf
import numpy as np
import tensorflow.contrib.layers as layers
class Model(object):
def __init__(self, batch_size=128, learning_rate=0.01, num_labels=10, keep_prob=0.5, scope="model"):
self._batch_size = batch_size
self._learning_rate = learning_rate
self._num_labels ... | normal | {
"blob_id": "e9a1fd8464f6c1e65aa2c1af60becbfcbf050814",
"index": 7390,
"step-1": "<mask token>\n\n\nclass Model(object):\n\n def __init__(self, batch_size=128, learning_rate=0.01, num_labels=10,\n keep_prob=0.5, scope='model'):\n self._batch_size = batch_size\n self._learning_rate = learn... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class PrometeoAPI:
def __init__(self, user, pwd):
self.base_url = 'https://prometeoapi.com'
self.session = requests.Session()
self.__user = user
self.__pwd = pwd
self._login()
def _generate_csrf_token(self, url):
"""
This f... | flexible | {
"blob_id": "f3e654a589cc1c16b36203dd358671d0426556e6",
"index": 2676,
"step-1": "<mask token>\n\n\nclass PrometeoAPI:\n\n def __init__(self, user, pwd):\n self.base_url = 'https://prometeoapi.com'\n self.session = requests.Session()\n self.__user = user\n self.__pwd = pwd\n ... | [
5,
6,
8,
9,
10
] |
import time
class Block:
def __init__(self, index, transactions, previous_hash, nonce=0):
self.index = index
self.transaction = transactions
self.timestamp = time.time()
self.previous_hash = previous_hash
self.nonce = nonce
self.hash = None
| normal | {
"blob_id": "43a23958b8c8779e3292f0f523a37b6d712fdbac",
"index": 4448,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Block:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Block:\n\n def __init__(self, index, transactions, previous_hash, nonce=0):\n self.index = index\n ... | [
0,
1,
2,
3
] |
from sklearn import preprocessing
from random import shuffle
import numpy as np
import collections
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from tensorflow.keras.layers import Dense, Dropout, Activation, Conv1D, GlobalMaxPooling1D
from tensorflow.keras.models import Sequential, model_from_json
from t... | normal | {
"blob_id": "23f491bbf26ede9052ecdab04b8c00cc78db5a7e",
"index": 8831,
"step-1": "<mask token>\n\n\ndef read_csv_json(file_name) ->pandas.DataFrame:\n if file_name.endswith('json') or file_name.endswith('jsonl'):\n df = pandas.read_json(file_name, lines=True)\n elif file_name.endswith('csv'):\n ... | [
9,
13,
16,
18,
19
] |
class A(object):
_a ='d'
@staticmethod
def func_1():
A._a = 'b'
print A._a
@classmethod
def func_3(cls):
print cls._a
def func_2(self):
# self._a = 'c'
print self._a
# print A._a
#
# class B(object):
# @staticmethod
# def func_1():
# ... | normal | {
"blob_id": "2ab3adb4d0ed7e6e48afb2a8dab8f9250d335723",
"index": 2253,
"step-1": "class A(object):\n _a ='d'\n\n\n @staticmethod\n def func_1():\n A._a = 'b'\n print A._a\n\n @classmethod\n def func_3(cls):\n print cls._a\n\n def func_2(self):\n # self._a = 'c'\n ... | [
0
] |
"""
Author: Yudong Qiu
Functions for solving unrestricted Hartree-Fock
"""
import numpy as np
from qc_python import basis_integrals
from qc_python.common import chemical_elements, calc_nuclear_repulsion
def solve_unrestricted_hartree_fock(elems, coords, basis_set, charge=0, spinmult=1, maxiter=150, enable_DIIS=True... | normal | {
"blob_id": "ccc2a976d06e2fa6c91b25c4f95a8f0da32e9b5e",
"index": 7878,
"step-1": "<mask token>\n\n\ndef DIIS_extrapolate_F(diis_err_mats, diis_fmats):\n n_diis = len(diis_err_mats)\n assert n_diis == len(diis_fmats\n ), 'Number of Fock matrices should equal to number of error matrices'\n Bmat = -... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def possibleWords(a, N, index=0, s=''):
if index == N:
final.append(s)
print(s, end=' ')
return
possible_chars = refer[a[0]]
for i in possible_chars:
s += i
possibleWords(a[1:]... | flexible | {
"blob_id": "5f237a820832181395de845cc25b661878c334e4",
"index": 9965,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef possibleWords(a, N, index=0, s=''):\n if index == N:\n final.append(s)\n print(s, end=' ')\n return\n possible_chars = refer[a[0]]\n for i in possibl... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.