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|> for topic in topics: i += 1 arts = os.listdir(os.path.join(path, topic)) j = 0 for art in arts: j += 1 with open(os.path.join(path, topic, art), encoding='UTF-8') as f: lines = f.read() ...
flexible
{ "blob_id": "977841e0bb73cec879fbb1868f1e64102c6d8c1a", "index": 2119, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor topic in topics:\n i += 1\n arts = os.listdir(os.path.join(path, topic))\n j = 0\n for art in arts:\n j += 1\n with open(os.path.join(path, topic, art), enco...
[ 0, 1, 2, 3, 4 ]
def solution(skill, skill_trees): answer = 0 for tree in skill_trees: able = True for i in range(len(skill) - 1, 0, -1): index = tree.find(skill[i]) if index != -1 and i > 0: if tree[:index].find(skill[i - 1]) == -1: able = False ...
normal
{ "blob_id": "a72d878d246a459038640bf9c1deff562994b345", "index": 7338, "step-1": "<mask token>\n", "step-2": "def solution(skill, skill_trees):\n answer = 0\n for tree in skill_trees:\n able = True\n for i in range(len(skill) - 1, 0, -1):\n index = tree.find(skill[i])\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Dripper(BoxLayout): def __init__(self, **kwargs): super(Dripper, self).__init__(**kwargs) self.index = 0.0 self.sections = 20 self.section_height = 1 self.lasttime = time.time() Clock.schedule_once(self.redraw) self.drip_h...
flexible
{ "blob_id": "96086885e5353f3b4b3277c1daf4ee74831c3b73", "index": 8841, "step-1": "<mask token>\n\n\nclass Dripper(BoxLayout):\n\n def __init__(self, **kwargs):\n super(Dripper, self).__init__(**kwargs)\n self.index = 0.0\n self.sections = 20\n self.section_height = 1\n self....
[ 10, 12, 14, 15, 19 ]
import os import lasagne import theano import theano.tensor as T import numpy as np from lasagne.layers import Conv2DLayer,\ MaxPool2DLayer,\ InputLayer from lasagne.nonlinearities import elu, sigmoid, rectify from lasagne.regularization import l2, regularize_layer_...
normal
{ "blob_id": "1dd5c25cd3b7bc933ba0b63d9a42fdddc92b8531", "index": 8737, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass FaceTrigger(CascadeBase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass FaceTrigger(CascadeBase):\n\n def build_network(self):\n net = lasagne.layers.batc...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url(regex='^(?P<pk>\\d+)$', view=views.UserDetailView. as_view(), name='user_detail'), url(regex='^update/(?P<pk>\\d+)$', view =views.UserUpdateView.as_view(), name='user_update'), url(regex= '^email/upd...
flexible
{ "blob_id": "1ac0f5c62ee3cb60d4443b65d429f4f0e6815100", "index": 5488, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url(regex='^(?P<pk>\\\\d+)$', view=views.UserDetailView.\n as_view(), name='user_detail'), url(regex='^update/(?P<pk>\\\\d+)$', view\n =views.UserUpdateView.as_view()...
[ 0, 1, 2, 3 ]
from matplotlib import pyplot as plt # Function for testing # Maps x => x*x def calculate(x): return x * x inputs = [-0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5] outputs = [calculate(x) for x in inputs] plt.plot(inputs, outputs) plt.savefig("plot.png")
normal
{ "blob_id": "1b3891565f776064cfcca02fb22ea65853f7e66f", "index": 3629, "step-1": "<mask token>\n\n\ndef calculate(x):\n return x * x\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef calculate(x):\n return x * x\n\n\n<mask token>\nplt.plot(inputs, outputs)\nplt.savefig('plot.png')\n", "step-3": "<...
[ 1, 2, 3, 4, 5 ]
"""This file parses vbulletin forums""" import re import logging from BeautifulSoup import BeautifulSoup as bs import imaget import pdb logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) date_marker = ["<!-- status icon and date -->", "<!-- / status icon and date -->"] message_marker = ["<!-- messa...
normal
{ "blob_id": "0846f73482ad86158c3f4e37713d6d965e21d796", "index": 2671, "step-1": "\"\"\"This file parses vbulletin forums\"\"\"\n\nimport re\nimport logging\nfrom BeautifulSoup import BeautifulSoup as bs\nimport imaget\nimport pdb\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.DEBUG)\n\n\ndate_...
[ 0 ]
from flask import Flask, url_for, render_template, request import os import blescan import sys import requests import logging from logging.handlers import RotatingFileHandler import json from datetime import datetime import bluetooth._bluetooth as bluez app = Flask(__name__) @app.route('/sivut/') def default_...
normal
{ "blob_id": "040942e2e09b5c2df5c08207b9c033471b117608", "index": 500, "step-1": " \nfrom flask import Flask, url_for, render_template, request\nimport os\nimport blescan\nimport sys\nimport requests\nimport logging\nfrom logging.handlers import RotatingFileHandler\nimport json\nfrom datetime import datetime\n...
[ 0 ]
<|reserved_special_token_0|> class SystemTrayIcon(QSystemTrayIcon): <|reserved_special_token_0|> <|reserved_special_token_0|> def set_icon_state(self, state): pixmap = QApplication.instance().windowIcon().pixmap(256, 256, state) self.setIcon(QIcon(pixmap)) <|reserved_special_token_1|> ...
flexible
{ "blob_id": "c6e315d7dd44b998f64eee079f2d8455ffecdc30", "index": 9931, "step-1": "<mask token>\n\n\nclass SystemTrayIcon(QSystemTrayIcon):\n <mask token>\n <mask token>\n\n def set_icon_state(self, state):\n pixmap = QApplication.instance().windowIcon().pixmap(256, 256, state)\n self.setIc...
[ 2, 3, 4, 5 ]
#"countinu" example : repeat printing "Too small" or "Input is..." according to input's lenth while True: s=raw_input('Enter something: ') if s == 'quit' : break if len(s) <3: print 'Too small' continue #continue : not exc...
normal
{ "blob_id": "915d6547057f43c1cc5d96d9cb4529c56bc85559", "index": 3412, "step-1": "#\"countinu\" example : repeat printing \"Too small\" or \"Input is...\" according to input's lenth\r\n\r\nwhile True:\r\n s=raw_input('Enter something: ')\r\n if s == 'quit' :\r\n break\r\n if l...
[ 0 ]
from src.testcase.case import Case from src.utils import * from src.protocol.register import get_conn from src.precondition import * class OneCase(object): """ Main flow of running one case's autotest """ PASS = True FAIL = False def __init__(self, case_path, *args, **kwargs): self._c...
normal
{ "blob_id": "f658959bf7fa5e02a577119930c9b9c1ef59f432", "index": 2845, "step-1": "<mask token>\n\n\nclass OneCase(object):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, case_path, *args, **kwargs):\n self._case_path = str(case_path)\n self._case_dict = {}\n ...
[ 7, 9, 10, 13, 14 ]
# # * Python 57, Correct Lineup # * Easy # * For the opening ceremony of the upcoming sports event an even number of # * athletes were picked. They formed a correct lineup, i.e. such a lineup in # * which no two boys or two girls stand together. The first person in the lineup # * was a girl. As a part of the perfor...
normal
{ "blob_id": "6c5f60e7a122e3da5e6705bfacf73a361f6c1362", "index": 1120, "step-1": "def correctLineup1(athletes: list) ->list:\n return [(athletes[i + 1] if i % 2 == 0 else athletes[i - 1]) for i in\n range(len(athletes))]\n\n\n<mask token>\n", "step-2": "def correctLineup1(athletes: list) ->list:\n ...
[ 1, 2, 3, 4, 5 ]
# coding=utf-8 # Copyright 2021-Present The THUCTC Authors from __future__ import absolute_import from __future__ import division from __future__ import print_function import math import torch import torch.nn as nn import thuctc.utils as utils from thuctc.modules.module import Module from thuctc.modules.layer_norm ...
normal
{ "blob_id": "c773b273ad6953bf9c74b11c44aff16e9fd0860e", "index": 3468, "step-1": "<mask token>\n\n\nclass Embedding(Module):\n\n def __init__(self, embed_nums, embed_dims, bias=False, name='embedding'):\n super(Embedding, self).__init__(name=name)\n self.embed_nums = embed_nums\n self.emb...
[ 7, 9, 10, 12, 13 ]
from __future__ import annotations import asyncio import signal from functools import wraps from typing import TYPE_CHECKING, Awaitable, Callable import click from .utils import import_obj if TYPE_CHECKING: from donald.manager import Donald from .types import TV def import_manager(path: str) -> Donald: ...
normal
{ "blob_id": "3da4896f368f067a339db5cc89201c93ba8166ce", "index": 6220, "step-1": "<mask token>\n\n\ndef process_await(fn: Callable[..., Awaitable[TV]]) ->Callable[..., TV]:\n\n @wraps(fn)\n @click.pass_context\n def wrapper(ctx, *args, **kwargs):\n loop = ctx.obj['loop']\n return loop.run_...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def project(X, U, p=None): if p == None: p = X.shape[1] Z = np.matmul(X, U) Z[:, p:] = np.mean(Z[:, p:], axis=0) X2 = np.matmul(Z, U.transpose()) return Z, X2 <|reserved_special_token_0|> def whiteningTransform(X, W, U): L = np.diag(W) Z = np.transp...
flexible
{ "blob_id": "c00db6d6fd903236de37ccc029ed30fd46dccdef", "index": 7711, "step-1": "<mask token>\n\n\ndef project(X, U, p=None):\n if p == None:\n p = X.shape[1]\n Z = np.matmul(X, U)\n Z[:, p:] = np.mean(Z[:, p:], axis=0)\n X2 = np.matmul(Z, U.transpose())\n return Z, X2\n\n\n<mask token>\n\...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class PayForList(LoginRequiredMixin, ListView): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class PayForDetailView(LoginRequiredMixin, DetailView): template_name = 'money_easy/payfor_detail.html' model = PayFor <|reserved_sp...
flexible
{ "blob_id": "dc9b5fbe082f7cf6cd0a9cb0d1b5a662cf3496f0", "index": 4768, "step-1": "<mask token>\n\n\nclass PayForList(LoginRequiredMixin, ListView):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass PayForDetailView(LoginRequiredMixin, DetailView):\n template_name = 'money_easy/payfor_detail.htm...
[ 22, 23, 28, 29, 31 ]
""" 进程对象属性 """ from multiprocessing import Process import time def tm(): for i in range(3): print(time.ctime()) time.sleep(2) p = Process(target=tm,name='Tarena') # 设置子进程随父进程退出 p.daemon = True p.start() print("Name:",p.name) # 进程名称 print("PID:",p.pid) # 进程PID print("is alive:",p.is_alive()) #...
normal
{ "blob_id": "9d7bc2d93b855fbd22a4707a6237ac51069beb53", "index": 9385, "step-1": "<mask token>\n\n\ndef tm():\n for i in range(3):\n print(time.ctime())\n time.sleep(2)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef tm():\n for i in range(3):\n print(time.ctime())\n ti...
[ 1, 2, 3, 4, 5 ]
from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User from . import models class RegisterForm(UserCreationForm): email = forms.EmailField(required=True) class Meta: model = User fields = ("username", "email", "password1", "...
normal
{ "blob_id": "503726cd2d70286189f4b8e02acaa3d5f6e29e12", "index": 8538, "step-1": "<mask token>\n\n\nclass ChangeEmail(forms.Form):\n <mask token>\n\n\nclass ChangePassword(forms.Form):\n oldPassword = forms.CharField(required=True, min_length=8, max_length=\n 80, widget=forms.PasswordInput(attrs={'n...
[ 3, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.8 on 2016-10-28 17:08 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('KYusers', '0017_caprofile_regs'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "12c3fe8a3ca1e660eeb90b16eca17eddd47e5de7", "index": 7124, "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 = [('KYusers', '...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.10 on 2018-02-26 13:14 from __future__ import unicode_literals import datetime from django.db import migrations, models import django.db.models.deletion from django.utils.timezone import utc class Migration(migrations.Migration): dependencies = [ ('user...
normal
{ "blob_id": "c6170678b523a105312d8ce316853859657d3c94", "index": 2235, "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 = [('user_detail...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- import cProfile import re import pstats import os import functools # cProfile.run('re.compile("foo|bar")') def do_cprofile(filename): """ decorator for function profiling :param filename: :return: """ def wrapper(func): @functools.wraps...
normal
{ "blob_id": "8c055816def1c0a19e672ab4386f9b9a345b6323", "index": 7837, "step-1": "<mask token>\n\n\nclass Memoized(object):\n\n def __init__(self, func):\n self.func = func\n self.results = {}\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Memoized...
[ 2, 4, 7, 8, 9 ]
with open('vocabulary.txt', 'r') as f: for line in f: information = line.strip().split(': ') # print(information[0], information[1]) question = information[1] answer = information[0] my_answer = input(f'{question}:') if my_answer == answer: print('맞았습니다!'...
normal
{ "blob_id": "34009d1aa145f4f5c55d0c5f5945c3793fbc6429", "index": 7823, "step-1": "<mask token>\n", "step-2": "with open('vocabulary.txt', 'r') as f:\n for line in f:\n information = line.strip().split(': ')\n question = information[1]\n answer = information[0]\n my_answer = input...
[ 0, 1, 2 ]
import unittest from theoktany.serializers import serialize class SerializerTest(unittest.TestCase): class TestObject(object): def __init__(self, **kwargs): for name, value in kwargs.items(): self.__setattr__(name, value) def test_serialize(self): object_dict = ...
normal
{ "blob_id": "4e4d6a9ed07aa03c79dade05e01f226017b13de5", "index": 9250, "step-1": "<mask token>\n\n\nclass SerializerTest(unittest.TestCase):\n\n\n class TestObject(object):\n\n def __init__(self, **kwargs):\n for name, value in kwargs.items():\n self.__setattr__(name, value)\n...
[ 3, 4, 5, 7 ]
import sys sys.stdin = open('줄긋기.txt') T = int(input()) for tc in range(1, T + 1): N = int(input()) dot = [list(map(int, input().split())) for _ in range(N)] ran = [] for a in range(N - 1): for b in range(a + 1, N): if dot[a][1] - dot[b][1] == 0: if 'inf' not in ran: ...
normal
{ "blob_id": "03854f48751460fdc27d42ee5c766934ee356cfd", "index": 6161, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor tc in range(1, T + 1):\n N = int(input())\n dot = [list(map(int, input().split())) for _ in range(N)]\n ran = []\n for a in range(N - 1):\n for b in range(a + 1, N)...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def write_csv(filename, train_acc, test_acc, train_loss, test_loss, train_error, test_error, epoch): if epoch == 0: with open(filename, 'w') as f: f.write( 'train_acc,test_acc,train_lo...
flexible
{ "blob_id": "93150eb1c6746e2b1967eb5305fa526ae36968fd", "index": 2003, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef write_csv(filename, train_acc, test_acc, train_loss, test_loss,\n train_error, test_error, epoch):\n if epoch == 0:\n with open(filename, 'w') as f:\n f.wr...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(fruits) <|reserved_special_token_1|> fruits = ['orange', ' apple', 'pear', 'banana', 'kiwi'] print(fruits) <|reserved_special_token_1|> # common methods to delete data from list fruits = ['orange', ' apple', 'pear', '...
flexible
{ "blob_id": "a245cb1f232b152edf40b6399686c6811c522d99", "index": 6458, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(fruits)\n", "step-3": "fruits = ['orange', ' apple', 'pear', 'banana', 'kiwi']\nprint(fruits)\n", "step-4": "# common methods to delete data from list\r\nfruits = ['orange', ' a...
[ 0, 1, 2, 3 ]
__author__ = "那位先生Beer" import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties import xlrd import numpy as np print('输入鲈鱼的先验概率例如:70,对应70%') a=input('输入鲈鱼的先验概率(鲑鱼对应的1减去剩余的):') font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=15) #根据生成的数据画出图像(横坐标为长度,纵坐标为亮度) data=xlrd.open_w...
normal
{ "blob_id": "077b6d3d7417bbc26e9f23af6f437ff05e3d5771", "index": 812, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('输入鲈鱼的先验概率例如:70,对应70%')\n<mask token>\nfor i in range(0, int(a) * 50):\n rowa_data = sh.row_values(i)\n L.append(rowa_data)\n<mask token>\nfor j in range(5000, 5000 + (100 - in...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestVCSBoxfill(basevcstest.VCSBaseTest): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestVCSBoxfill(basevcstest.VCSBaseTest): def testRobinsonBoxfill(self): ...
flexible
{ "blob_id": "c1475209d9c9a98d72d7f703e0516aceaeb13163", "index": 6820, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestVCSBoxfill(basevcstest.VCSBaseTest):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TestVCSBoxfill(basevcstest.VCSBaseTest):\n\n def testRobinsonBoxfill(self)...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Nov 18 18:21:37 2021 @author: benoitdeschrynmakers """ import requests url = 'http://127.0.0.1:8888/productionplan' if __name__ == "__main__": filename = "example_payloads/payload1.json" data = open(filename, 'rb').read() headers = {'Acc...
normal
{ "blob_id": "255130082ee5f8428f1700b47dee717465fed72f", "index": 4067, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n filename = 'example_payloads/payload1.json'\n data = open(filename, 'rb').read()\n headers = {'Accept': 'application/json', 'Content-Type': 'applicat...
[ 0, 1, 2, 3, 4 ]
import ambulance_game as abg import numpy as np import sympy as sym from sympy.abc import a, b, c, d, e, f, g, h, i, j def get_symbolic_pi(num_of_servers, threshold, system_capacity, buffer_capacity): Q_sym = abg.markov.get_symbolic_transition_matrix( num_of_servers=num_of_servers, threshold=thres...
normal
{ "blob_id": "9dd59fee46bd4bec87cc8c40099110b483ad0496", "index": 6990, "step-1": "<mask token>\n\n\ndef get_symbolic_state_probabilities_1222():\n num_of_servers = 1\n threshold = 2\n system_capacity = 2\n buffer_capacity = 2\n sym_pi_1222 = get_symbolic_pi(num_of_servers=num_of_servers, threshold...
[ 5, 12, 13, 16, 17 ]
#!/usr/bin/env python3 import os import subprocess import logging class color: PURPLE = '\033[95m' CYAN = '\033[96m' DARKCYAN = '\033[36m' BLUE = '\033[94m' GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' BOLD = '\033[1m' UNDERLINE = '\033[4m' END = '\033[0m' # Recov...
normal
{ "blob_id": "2c834c734de8f8740176bb5dbb6b123c49924718", "index": 1697, "step-1": "<mask token>\n\n\nclass color:\n PURPLE = '\\x1b[95m'\n CYAN = '\\x1b[96m'\n DARKCYAN = '\\x1b[36m'\n BLUE = '\\x1b[94m'\n GREEN = '\\x1b[92m'\n YELLOW = '\\x1b[93m'\n RED = '\\x1b[91m'\n BOLD = '\\x1b[1m'\n...
[ 5, 7, 9, 10, 12 ]
from estmd import ESTMD input_directory = "test.avi" e = ESTMD() e.open_movie(input_directory) e.run(by_frame=True) r = e.create_list_of_arrays() print "Done testing!"
normal
{ "blob_id": "1fd4d1a44270ef29512e601af737accb916dc441", "index": 974, "step-1": "from estmd import ESTMD\n\ninput_directory = \"test.avi\"\ne = ESTMD()\ne.open_movie(input_directory)\ne.run(by_frame=True)\nr = e.create_list_of_arrays()\n\nprint \"Done testing!\"\n", "step-2": null, "step-3": null, "step-4"...
[ 0 ]
__author__ = 'simon.hughes' from sklearn.feature_extraction import DictVectorizer from WindowFeatures import compute_middle_index from collections import Counter class WindowFeatureExtractor(object): """ A simple wrapper class that takes a number of window based feature extractor functions and applies the...
normal
{ "blob_id": "48677d73f6489ce789884a9dff5d50c23f47d8b3", "index": 260, "step-1": "<mask token>\n\n\nclass WindowFeatureExtractor(object):\n <mask token>\n <mask token>\n <mask token>\n\n def transform(self, X, y=None):\n return self.vectorizer.transform(X, y)\n <mask token>\n <mask token>...
[ 2, 7, 8, 9, 10 ]
# System import import os # Docutils import from docutils import nodes from docutils.parsers.rst.directives.admonitions import BaseAdmonition from docutils.statemachine import ViewList # Add node class link_to_block(nodes.Admonition, nodes.Element): """ Node for inserting a link to button.""" pass # Add di...
normal
{ "blob_id": "63cce356b792949b90b215e0a5826f7b33d2d375", "index": 8064, "step-1": "<mask token>\n\n\nclass link_to_block(nodes.Admonition, nodes.Element):\n <mask token>\n pass\n\n\nclass LinkToBlock(BaseAdmonition):\n \"\"\" Hidden technical block\"\"\"\n node_class = link_to_block\n has_content =...
[ 5, 6, 7, 9, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def clean_room(update): char, db_sess = get_data_character(update, return_sess=True) if char and char.room: if char.room.mobs: for mob in char.room.mobs: db_sess.delete(mob) if...
flexible
{ "blob_id": "4d57fa22282d7b3f8adabedd7a04e32767181890", "index": 5693, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef clean_room(update):\n char, db_sess = get_data_character(update, return_sess=True)\n if char and char.room:\n if char.room.mobs:\n for mob in char.room.mob...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('', views.index, name='listings'), path( '<int:listing_id>', views.listing, name='listing'), path('search', views.search, name='search')] <|reserved_special_token_1|> from django.urls import path fro...
flexible
{ "blob_id": "be894830bb0dde6bacaea6be823391e0445603c3", "index": 1192, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.index, name='listings'), path(\n '<int:listing_id>', views.listing, name='listing'), path('search',\n views.search, name='search')]\n", "step-3": "fr...
[ 0, 1, 2, 3 ]
import functools import shutil import tempfile import unittest import unittest.mock from pathlib import Path import numpy as np import pandas as pd import one.alf.io as alfio from ibllib.io.extractors import training_trials, biased_trials, camera from ibllib.io import raw_data_loaders as raw from ibllib.io.extractors...
normal
{ "blob_id": "f17d33f1d035da42dc9a2b4c0c60beefc6a48dea", "index": 64, "step-1": "<mask token>\n\n\nclass TestExtractTrialData(unittest.TestCase):\n\n def setUp(self):\n self.main_path = Path(__file__).parent\n self.training_lt5 = {'path': self.main_path / 'data' /\n 'session_training_l...
[ 27, 34, 37, 45, 49 ]
<|reserved_special_token_0|> class SnakeGame: def __init__(self, board_width=10, board_height=10, gui=False, enemy_epsilon=0.1): self.score = 0 self.board = {'width': board_width, 'height': board_height} self.gui = gui self.lives = LIVES self.player = [] se...
flexible
{ "blob_id": "3bb408f2b2ac63a2555258c05844881ccdfc5057", "index": 5428, "step-1": "<mask token>\n\n\nclass SnakeGame:\n\n def __init__(self, board_width=10, board_height=10, gui=False,\n enemy_epsilon=0.1):\n self.score = 0\n self.board = {'width': board_width, 'height': board_height}\n ...
[ 12, 14, 18, 22, 24 ]
#!/usr/bin/env python """ ############################################################################## Software Package Risk Analysis Development Environment Specific Work Book View ############################################################################## """ # -*- coding: utf-8 -*- # # rtk.softw...
normal
{ "blob_id": "327371d373819273a2f77f63e0cedee6950dbc46", "index": 976, "step-1": "<mask token>\n\n\nclass RiskAnalysis(gtk.VPaned):\n <mask token>\n <mask token>\n\n def create_risk_analysis_page(self, notebook):\n \"\"\"\n Method to create the development environment risk analysis page and...
[ 4, 5, 7, 9, 10 ]
# -*- coding: utf-8 -*- import logging from django.contrib.auth import authenticate, login as django_login, logout as django_logout from django.contrib.auth.models import User from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.core.urlresolvers import reverse from django.db.utils imp...
normal
{ "blob_id": "b739a5d359b4d1c0323c7cd8234e4fe5eb9f3fcb", "index": 6286, "step-1": "<mask token>\n\n\n@require_superuser\ndef index(request):\n template_name = 'users/index.html'\n msg = ''\n try:\n users = User.objects.exclude(id=request.user.id)\n except:\n msg = _('Unable to list users...
[ 8, 9, 10, 11, 12 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> client.request(method='POST', url='/', body=post_data.encode('utf-8'), headers=head_dict) <|reserved_special_token_0|> client.close() print(content) <|reserved_special_token_1|> <|reserved_special_token_0|> client = http.cl...
flexible
{ "blob_id": "ee1ce3ea4b31246703530478d6550b0c8866197e", "index": 1190, "step-1": "<mask token>\n", "step-2": "<mask token>\nclient.request(method='POST', url='/', body=post_data.encode('utf-8'),\n headers=head_dict)\n<mask token>\nclient.close()\nprint(content)\n", "step-3": "<mask token>\nclient = http.c...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def longest_substring(string1, string2): mat = np.zeros(shape=(len(string1), len(string2))) for x in range(len(string1)): for y in range(len(string2)): if x == 0 or y == 0: if string1[...
flexible
{ "blob_id": "6bb7dafea73aff7aca9b0ddc1393e4db6fcf0151", "index": 4828, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef longest_substring(string1, string2):\n mat = np.zeros(shape=(len(string1), len(string2)))\n for x in range(len(string1)):\n for y in range(len(string2)):\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def run_main(): """ Main function to process user input and then generate the description files for each run :return: exit code -- 0 on success, 1 otherwise """ parser = argparse.ArgumentParser(description= ...
flexible
{ "blob_id": "6e6c6c5795e8723a86ae5dfc8f40df57d3dd10f7", "index": 3336, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run_main():\n \"\"\"\n Main function to process user input and then generate the description files for each run\n\n :return: exit code -- 0 on success, 1 otherwise\n \...
[ 0, 1, 2, 3, 4 ]
from typing import Dict, List, Sequence, Iterable, Tuple from allennlp.data.dataset_readers.dataset_reader import DatasetReader from allennlp.data.instance import Instance from allennlp.common.file_utils import cached_path import logging from overrides import overrides import itertools from allennlp.data.tokenizers imp...
normal
{ "blob_id": "21172985bf36302f6b0b2101e353d9fbcafb0673", "index": 6653, "step-1": "<mask token>\n\n\n@DatasetReader.register('bertclassification')\nclass ClassificationReader(DatasetReader):\n <mask token>\n\n @overrides\n def _read(self, file_path: str) ->Iterable[Instance]:\n file_path = cached_...
[ 3, 4, 5, 6, 7 ]
# ARGS: # 1: total train reviews # 2: number of iterations (for csv output) # 3: size of vector # 4: good/bad sizes # import dependencies from gensim import utils from gensim.models.doc2vec import LabeledSentence from gensim.models import Doc2Vec from matplotlib import pyplot as plt from sklearn.manifold import TSNE f...
normal
{ "blob_id": "95015c467dd6371f575fb5535fe652a914650ef1", "index": 2016, "step-1": "<mask token>\n\n\ndef compute_accuracy(model, good, bad):\n train_arrays = numpy.zeros((25000, 400))\n train_labels = numpy.zeros(25000)\n classifier = LogisticRegression()\n for i in range(25000 / 2):\n prefix_t...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for _ in stack_numbers: stacks.append([]) for line in stacks_input_lines[:-1]: for stack_index, i in enumerate(range(1, len(line), 4)): crate = line[i] if crate != ' ': stacks[stack_index].inser...
flexible
{ "blob_id": "4927a440093e822250af25dfd6a2ce62d7cc099e", "index": 8786, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in stack_numbers:\n stacks.append([])\nfor line in stacks_input_lines[:-1]:\n for stack_index, i in enumerate(range(1, len(line), 4)):\n crate = line[i]\n if cra...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def test_relative_path(session_app_data, monkeypatch): sys_executable = Path(PythonInfo.current_system(app_data= session_app_data).system_executable) cwd = sys_executable.parents[1] monkeypatch.chdir(str(cwd)) relative = str(sys_executable.relative_to(cwd)) res...
flexible
{ "blob_id": "55d4f4bba2b72ec93cb883527d2a9c2ebe8ec337", "index": 4910, "step-1": "<mask token>\n\n\ndef test_relative_path(session_app_data, monkeypatch):\n sys_executable = Path(PythonInfo.current_system(app_data=\n session_app_data).system_executable)\n cwd = sys_executable.parents[1]\n monkeyp...
[ 1, 4, 5, 6, 7 ]
''' You're playing casino dice game. You roll a die once. If you reroll, you earn the amount equal to the number on your second roll otherwise, you earn the amount equal to the number on your first roll. Assuming you adopt a profit-maximizing strategy, what would be the expected amount of money you would win? This qu...
normal
{ "blob_id": "e5d704541acd0f68a7885d7323118e1552e064c9", "index": 6170, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor threshold in range(1, 6):\n rolls = np.random.randint(1, 7, size=10 ** 7)\n rerolls = np.random.randint(1, 7, size=10 ** 7)\n avg_roll = np.mean(np.where(rolls <= threshold, ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def __line_into_col__(line): tokens = dl_style_transfer.workspace.data_helpers.clean_str(line).split(' ' ) for wor in tokens: if col.get(wor) is None: col[wor] = 1 else: col[wor] = col[wor] + 1 <|reserved_special_token_0|> def vo...
flexible
{ "blob_id": "2317a2fff493588ad6cc3a4ac2b600fbf1c5583c", "index": 8594, "step-1": "<mask token>\n\n\ndef __line_into_col__(line):\n tokens = dl_style_transfer.workspace.data_helpers.clean_str(line).split(' '\n )\n for wor in tokens:\n if col.get(wor) is None:\n col[wor] = 1\n ...
[ 2, 4, 6, 8, 10 ]
<|reserved_special_token_0|> class WRITE_TO_FILE(tarr.compiler_base.Instruction): @property def __name__(self): return 'POINT OF INTEREST - WRITE("{}")'.format(self.filename) def __init__(self, filename, formatter=format_data): self.format = formatter self.filename = filename ...
flexible
{ "blob_id": "75393d39b147097a7ac1d82938ac102491ea9441", "index": 8469, "step-1": "<mask token>\n\n\nclass WRITE_TO_FILE(tarr.compiler_base.Instruction):\n\n @property\n def __name__(self):\n return 'POINT OF INTEREST - WRITE(\"{}\")'.format(self.filename)\n\n def __init__(self, filename, formatte...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class _ab_test_plotting(_ab_test_utils): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def plot_pos...
flexible
{ "blob_id": "3eaa898d1428e48aeb0449c7216d0a994262f76a", "index": 9107, "step-1": "<mask token>\n\n\nclass _ab_test_plotting(_ab_test_utils):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def plot_positive_lift(self, variant_on...
[ 2, 5, 7, 10, 12 ]
<|reserved_special_token_0|> class StereoBM: <|reserved_special_token_0|> def runAsync(self, left_img, right_img): self.m_runStartTime = int(round(time.time() * 1000000)) if left_img is None: raise RuntimeError('Invalid left image') if right_img is None: raise ...
flexible
{ "blob_id": "66f3590381fe96c49a8926a806b4a845f0d7e25d", "index": 4681, "step-1": "<mask token>\n\n\nclass StereoBM:\n <mask token>\n\n def runAsync(self, left_img, right_img):\n self.m_runStartTime = int(round(time.time() * 1000000))\n if left_img is None:\n raise RuntimeError('Inv...
[ 4, 5, 6, 7, 8 ]
# Generated by Django 3.2.4 on 2021-06-16 13:41 import ckeditor.fields from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('FAQ', '0004_auto_20210616_1253'), ] operations = [ migrations.RemoveField( model_name='question', nam...
normal
{ "blob_id": "a4c4a5cc63c345d1fa8cbf426f7857a0f3d4357f", "index": 8360, "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 = [('FAQ', '0004...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def findNearestPoint(points, no_used, src): dest = src minDist = sys.float_info.max for i in range(len(points)): if no_used[i] and i != src: dist = utils.length(points[src], points[i]) ...
flexible
{ "blob_id": "943db90aa7721ddad3d7f5103c4d398fbf4e143b", "index": 2768, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef findNearestPoint(points, no_used, src):\n dest = src\n minDist = sys.float_info.max\n for i in range(len(points)):\n if no_used[i] and i != src:\n dist ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class projectile(pygame.sprite.Sprite): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class enemy(pygame.sprite.Sprite): im = pygame.image.load(os.path.join(path, 'Gallery', 'stateczek.png')) im2 = pygame.image.load(os.path.jo...
flexible
{ "blob_id": "0dd5511c0e39f113c46785be78a898e79bc45a21", "index": 5188, "step-1": "<mask token>\n\n\nclass projectile(pygame.sprite.Sprite):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass enemy(pygame.sprite.Sprite):\n im = pygame.image.load(os.path.join(path, 'Gallery', 'stateczek.png'))\n ...
[ 6, 9, 13, 14, 18 ]
######################################################### # Author: Todd A. Reisel # Date: 2/24/2003 # Class: StaticTemplateList ######################################################### from BaseClasses.TemplateList import *; class StaticTemplateList(TemplateList): def __init__(self, viewMode = None): Te...
normal
{ "blob_id": "7de3c0ab2e7c8ac00d37f1dfb5948027cfa7806c", "index": 5084, "step-1": "<mask token>\n\n\nclass StaticTemplateList(TemplateList):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass StaticTemplateList(TemplateList):\n\n def __init__(self, viewMode=None):\n ...
[ 1, 3, 4, 5, 6 ]
""" A module to generate simulated 2D time-series SOSS data Authors: Joe Filippazzo """ import os from pkg_resources import resource_filename import multiprocessing import time from functools import partial import warnings import numpy as np from astropy.io import fits from bokeh.plotting import figure, show from ho...
normal
{ "blob_id": "9f478df4ff19cfe6c6559b6489c874d49377b90e", "index": 4949, "step-1": "<mask token>\n\n\ndef calculate_psf_tilts():\n \"\"\"\n Calculate the tilt of the psf at the center of each column\n using all binned pixels in the given wavelength calibration file\n for both orders and save to file\n ...
[ 7, 10, 11, 13, 14 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class CameraResponse(Response): pass <|reserved_special_token_1|> from platypush.message.response import Response class CameraResponse(Response): pass <|reserved_special_token_1|> from platypush.message.response ...
flexible
{ "blob_id": "4c38d0487f99cdc91cbce50079906f7336e51482", "index": 5462, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CameraResponse(Response):\n pass\n", "step-3": "from platypush.message.response import Response\n\n\nclass CameraResponse(Response):\n pass\n", "step-4": "from platypu...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_ticket(): ticket = '' s = 'abcdefghijkrmnopqrstuvwxyz1234567890' for i in range(28): r_num = random.choice(s) ticket += r_num return ticket <|reserved_special_token_1|> import random ...
flexible
{ "blob_id": "d2a9a2fd3a1118c0855b8f77ce4c25cc6b4e8f87", "index": 4328, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_ticket():\n ticket = ''\n s = 'abcdefghijkrmnopqrstuvwxyz1234567890'\n for i in range(28):\n r_num = random.choice(s)\n ticket += r_num\n return tick...
[ 0, 1, 2 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/4/14 14:31 # @Author : lixiaofeng # @File : page_zaojiao.py # @Software: PyCharm # @desc : from common.basics import Crazy class Zaojiaopage(Crazy): """早教小程序""" zao_btn_loc = ('xpath', '//*[@resource-id="com.tencent.mm:id/cx" and @text="...
normal
{ "blob_id": "1980fb4d6e7d3c6fe51f4a242610b5489e553859", "index": 128, "step-1": "<mask token>\n\n\nclass Zaojiaopage(Crazy):\n <mask token>\n <mask token>\n\n def click_zao(self):\n self.click(self.zao_btn_loc)\n <mask token>\n <mask token>\n\n def click_find(self):\n self.click(s...
[ 73, 89, 121, 148, 152 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def select_from_model(dataframe): X = dataframe.iloc[:, :-1] y = dataframe.iloc[:, -1] np.random.seed(9) model = RandomForestClassifier() sfm = SelectFromModel(model) sfm = sfm.fit(X, y) feature_idx =...
flexible
{ "blob_id": "d6791c8122129a46631582e7d9339ea08bd2e92b", "index": 3183, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef select_from_model(dataframe):\n X = dataframe.iloc[:, :-1]\n y = dataframe.iloc[:, -1]\n np.random.seed(9)\n model = RandomForestClassifier()\n sfm = SelectFromMode...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class State(DocumentTemplate): _key = ValueHashKey() country: 'Country' name: str <|reserved_special_token_1|> <|reserved_special_token_0|> class Address(DocumentTemplate): <|reserved_special_token_0|> city: 'City' coordinates: List['Coordinates'] postal_c...
flexible
{ "blob_id": "f702cdef3782ddc96244f3cf8e2026581d60baa9", "index": 1537, "step-1": "<mask token>\n\n\nclass State(DocumentTemplate):\n _key = ValueHashKey()\n country: 'Country'\n name: str\n", "step-2": "<mask token>\n\n\nclass Address(DocumentTemplate):\n <mask token>\n city: 'City'\n coordin...
[ 2, 13, 14, 15, 16 ]
import json import boto3 import os from helper import getEC2Regions, sendDataToSNS, OPTOUT_TAG, SNS_NOTIFICATION_IIAS_EC2 def getEC2FilteredRegionalInstanceInfo(region): ec2RegionalClient = boto3.client('ec2', region_name = region) paginator = ec2RegionalClient.get_paginator('describe_instances') page_ite...
normal
{ "blob_id": "d5f1601d11eb54e6c3dafab0137ec8f2358bb568", "index": 4101, "step-1": "<mask token>\n\n\ndef getEC2FilteredRegionalInstanceInfo(region):\n ec2RegionalClient = boto3.client('ec2', region_name=region)\n paginator = ec2RegionalClient.get_paginator('describe_instances')\n page_iterator = paginato...
[ 3, 4, 5, 6, 7 ]
#coding=utf-8 from django import template from classytags.helpers import InclusionTag from classytags.core import Tag, Options from classytags.arguments import Argument from ratings.models import RatedItem from blogs.permissions import Permissions class RatingBlock(InclusionTag): name = 'rating' template = '...
normal
{ "blob_id": "1a05817c4c16f2d9234e504b0c98f9c9ae2dc3f7", "index": 1525, "step-1": "<mask token>\n\n\nclass RatingBlock(InclusionTag):\n name = 'rating'\n template = 'ratings/rating.html'\n options = Options(Argument('obj', required=True))\n\n def get_context(self, context, obj):\n if not hasatt...
[ 3, 4, 5, 6, 7 ]
from pynput.keyboard import Listener import logging import daemon import socket import thread logging.basicConfig(format="%(asctime)s:%(message)s") file_logger = logging.FileHandler("/home/user0308/logger.log", "a") logger = logging.getLogger() logger.addHandler(file_logger) logger.setLevel(logging.DEBUG) def press(...
normal
{ "blob_id": "3dc2d9a5e37ce1f546c0478de5a0bb777238ad00", "index": 4306, "step-1": "<mask token>\n\n\ndef press(key):\n logging.info(key)\n\n\ndef work():\n with Listener(on_press=press) as listener:\n listener.join()\n\n\n<mask token>\n", "step-2": "<mask token>\nlogging.basicConfig(format='%(ascti...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @pytest.fixture(scope='session', autouse=True) def set_up(request): """ conftest.py set_up - the first to start.... """ print('\nSETUP before all tests') request.addfinalizer(tear_down) <|reserved_special_token_1|>...
flexible
{ "blob_id": "816b1a932208a4525230dd886adf8c67dec3af3e", "index": 349, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.fixture(scope='session', autouse=True)\ndef set_up(request):\n \"\"\" conftest.py set_up - the first to start.... \"\"\"\n print('\\nSETUP before all tests')\n request...
[ 0, 1, 2, 3, 4 ]
import os from dataclasses import dataclass from dotenv import load_dotenv from fastapi.security import OAuth2PasswordBearer from passlib.context import CryptContext load_dotenv() @dataclass class Settings: SECRET_KEY = os.getenv("SECRET_KEY", "mysecret") ALGORITHM = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES ...
normal
{ "blob_id": "a1c5d86a3f042d9e5ba522726191c8aeb9b738ed", "index": 8018, "step-1": "<mask token>\n\n\n@dataclass\nclass Settings:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\nload_dotenv()\n\n\n@dataclass\nclass Settings:...
[ 1, 3, 4, 5, 6 ]
def solution(name): Len = len(name) nameList = [name[i] for i in range(Len)] nameField = ['A' for i in range(Len)] answer = 0 # 정방향 for i in range(Len): a = ord(nameField[i]) b = ord(nameList[i]) if b-a <= 13 : # 절반 이하면 그냥 더하고 answer += b-a ...
normal
{ "blob_id": "8766003a85b1ed83927988df147b0b3004cb91f9", "index": 7691, "step-1": "<mask token>\n", "step-2": "def solution(name):\n Len = len(name)\n nameList = [name[i] for i in range(Len)]\n nameField = ['A' for i in range(Len)]\n answer = 0\n for i in range(Len):\n a = ord(nameField[i]...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def inverse_rescale(y): return tf.round(tf.multiply(tf.add(y, 1), 127.5)) <|reserved_special_token_1|> <|reserved_special_token_0|> def data_rescale(x): return tf.subtract(tf.divide(x, 127.5), 1) def inverse_resca...
flexible
{ "blob_id": "1a09b38838f40c4c6049da8e6a72ba3d56806c07", "index": 3703, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef inverse_rescale(y):\n return tf.round(tf.multiply(tf.add(y, 1), 127.5))\n", "step-3": "<mask token>\n\n\ndef data_rescale(x):\n return tf.subtract(tf.divide(x, 127.5), 1)\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class coreGetHome(TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> def test_200_template_home(self): self.assertEqual(200, self.resp.status_code) <|reserved_special_token_1|> <|reserved_special_token_0|> class coreGetHome(TestCase): def s...
flexible
{ "blob_id": "d20e41dd7054ff133be264bebf13e4e218710ae5", "index": 933, "step-1": "<mask token>\n\n\nclass coreGetHome(TestCase):\n <mask token>\n <mask token>\n\n def test_200_template_home(self):\n self.assertEqual(200, self.resp.status_code)\n", "step-2": "<mask token>\n\n\nclass coreGetHome(T...
[ 2, 3, 4, 5 ]
<|reserved_special_token_0|> class QueueOutputMJPEG(object): def __init__(self, queue, finished): self.queue = queue self.finished = finished self.stream = io.BytesIO() def write(self, buf): if buf.startswith(b'\xff\xd8'): size = self.stream.tell() if ...
flexible
{ "blob_id": "ffd034eb5f0482c027dcc344bddb01b90249511c", "index": 3198, "step-1": "<mask token>\n\n\nclass QueueOutputMJPEG(object):\n\n def __init__(self, queue, finished):\n self.queue = queue\n self.finished = finished\n self.stream = io.BytesIO()\n\n def write(self, buf):\n i...
[ 12, 13, 16, 17, 18 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_sendto_cli_runs_ok(): runner = CliRunner() result = runner.invoke(cli, ['sendto']) assert result.exit_code == 0 <|reserved_special_token_1|> from click.testing import CliRunner from apitest.actions.cli im...
flexible
{ "blob_id": "7537deb4560e880365b23a99584d0b1f8fa3daf4", "index": 5675, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_sendto_cli_runs_ok():\n runner = CliRunner()\n result = runner.invoke(cli, ['sendto'])\n assert result.exit_code == 0\n", "step-3": "from click.testing import CliR...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if x > 0 and y > 0: print('1') elif x > 0 and y < 0: print('4') elif x < 0 and y > 0: print('2') else: print('3') <|reserved_special_token_1|> x = int(input()) y = int(input()) if x > 0 and y > 0: print('1')...
flexible
{ "blob_id": "e9908e32204da8973f06d98430fc660c90b5e303", "index": 3987, "step-1": "<mask token>\n", "step-2": "<mask token>\nif x > 0 and y > 0:\n print('1')\nelif x > 0 and y < 0:\n print('4')\nelif x < 0 and y > 0:\n print('2')\nelse:\n print('3')\n", "step-3": "x = int(input())\ny = int(input()...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(0, y): list.append(randint(1, 10)) <|reserved_special_token_0|> print(f'Исходный список: {list}') print(f'Новый список список: {new}') <|reserved_special_token_1|> <|reserved_special_token_0|> list = [] y = i...
flexible
{ "blob_id": "bfc4f5e90b7c22a29d33ae9b4a5edfb6086d79f4", "index": 2344, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(0, y):\n list.append(randint(1, 10))\n<mask token>\nprint(f'Исходный список: {list}')\nprint(f'Новый список список: {new}')\n", "step-3": "<mask token>\nlist = []\ny =...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def parse_doc_line(line): parsed = re.search('\\d[\\d\\s]+\\d', line) return 'empty' if parsed is None else parsed[0] def get_roc_point(clf, x_set, y_set, threshold): loo = LeaveOneOut() vectorizer = CountVectorizer(ngram_range=n_gram_range) roc_predictions = np.empt...
flexible
{ "blob_id": "8bb67317ede277e03e8cbdefefeffa3d206ece65", "index": 9434, "step-1": "<mask token>\n\n\ndef parse_doc_line(line):\n parsed = re.search('\\\\d[\\\\d\\\\s]+\\\\d', line)\n return 'empty' if parsed is None else parsed[0]\n\n\ndef get_roc_point(clf, x_set, y_set, threshold):\n loo = LeaveOneOut(...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def create_file(out_path, ref_path): os.makedirs(out_path, exist_ok=True) copyfile(os.path.join(ref_path, 'attributes.json'), os.path.join( out_path, 'attributes.json')) def copy_to_scratch(in_path, out_path, out_key): if out_key in z5py.File(out_path, 'r'): ...
flexible
{ "blob_id": "9d3db4ca5bf964c68e9778a3625c842e74bf9dbd", "index": 1228, "step-1": "<mask token>\n\n\ndef create_file(out_path, ref_path):\n os.makedirs(out_path, exist_ok=True)\n copyfile(os.path.join(ref_path, 'attributes.json'), os.path.join(\n out_path, 'attributes.json'))\n\n\ndef copy_to_scratch...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> plt.plot([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 'go-', label='line 1', linewidth=2) plt.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25], 'rs--', label='line 2', linewidth=4) plt.axis([0, 6, 0, 26]) plt.legend(loc='upper right') plt.show() ...
flexible
{ "blob_id": "7eeba06e78bd1e7139b1706574c4d040465d4566", "index": 4178, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.plot([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 'go-', label='line 1', linewidth=2)\nplt.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25], 'rs--', label='line 2',\n linewidth=4)\nplt.axis([0, 6, 0, ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def flatten(l): return [j for i in l for j in i] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def flatten(l): return [j for i in l for j in i] def filter_sequences_by_le...
flexible
{ "blob_id": "1fdb9db4c1c8b83c72eeb34f10ef9d289b43b79f", "index": 3166, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef flatten(l):\n return [j for i in l for j in i]\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef flatten(l):\n return [j for i in l for j in i]\n\n\ndef filter_sequen...
[ 0, 1, 2, 3 ]
input = open('input').read() stacks_input, instructions = input.split('\n\n') stacks_input_lines = stacks_input.split('\n') stack_numbers = map(int, stacks_input_lines[-1].split()) stacks = [] for _ in stack_numbers: stacks.append([]) for line in stacks_input_lines[:-1]: for stack_index, i in enumerate(range(1...
normal
{ "blob_id": "4927a440093e822250af25dfd6a2ce62d7cc099e", "index": 8786, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in stack_numbers:\n stacks.append([])\nfor line in stacks_input_lines[:-1]:\n for stack_index, i in enumerate(range(1, len(line), 4)):\n crate = line[i]\n if cra...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> st.write('hi') <|reserved_special_token_1|> import streamlit as st st.write('hi')
flexible
{ "blob_id": "62ca95a871c16191fb8f56213646e8173f400630", "index": 8017, "step-1": "<mask token>\n", "step-2": "<mask token>\nst.write('hi')\n", "step-3": "import streamlit as st\nst.write('hi')\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
<|reserved_special_token_0|> class Rank: class Stats(object): """Holds info used to calculate amount of xp a player gets""" post_likes = 0 post_dislikes = 0 comment_likes = 0 comment_dislikes = 0 usage = 0 class Interval(object): """A class represent...
flexible
{ "blob_id": "cd0b55e163851344273ad020d434cc8662083d19", "index": 6593, "step-1": "<mask token>\n\n\nclass Rank:\n\n\n class Stats(object):\n \"\"\"Holds info used to calculate amount of xp a player gets\"\"\"\n post_likes = 0\n post_dislikes = 0\n comment_likes = 0\n comment...
[ 5, 6, 7, 9, 11 ]
<|reserved_special_token_0|> class channel(gr.hier_block2): <|reserved_special_token_0|> <|reserved_special_token_0|> def set_k(self, k): self.k = k self.channels_fading_model_0.set_K(self.k) def get_tchannel(self): return self.tchannel def set_tchannel(self, tchannel): ...
flexible
{ "blob_id": "8adf25fbffc14d6927d665931e54a7d699a3b439", "index": 6202, "step-1": "<mask token>\n\n\nclass channel(gr.hier_block2):\n <mask token>\n <mask token>\n\n def set_k(self, k):\n self.k = k\n self.channels_fading_model_0.set_K(self.k)\n\n def get_tchannel(self):\n return ...
[ 5, 6, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(grade) print(total) print(avg) <|reserved_special_token_1|> <|reserved_special_token_0|> total = totalMarks(85, 67, 56, 45, 78) avg = average(total) grade = findGrade(avg) print(grade) print(total) print(avg) <|reserved...
flexible
{ "blob_id": "05f77472625e902b66c4a97a4c640835826bd494", "index": 3635, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(grade)\nprint(total)\nprint(avg)\n", "step-3": "<mask token>\ntotal = totalMarks(85, 67, 56, 45, 78)\navg = average(total)\ngrade = findGrade(avg)\nprint(grade)\nprint(total)\npri...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> app_name = 'orders' urlpatterns = [path('checkout', views.order_checkout_view, name= 'orders-checkout')] <|reserved_special_token_1|> from django.urls import path from . import views app_name = 'orders' urlpatterns = [path(...
flexible
{ "blob_id": "031f668fbf75b54ec874a59f53c60ceca53779cf", "index": 8942, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'orders'\nurlpatterns = [path('checkout', views.order_checkout_view, name=\n 'orders-checkout')]\n", "step-3": "from django.urls import path\nfrom . import views\napp_name...
[ 0, 1, 2, 3 ]
# Created by MechAviv # [Maestra Fiametta] | [9390220] # Commerci Republic : San Commerci if sm.hasItem(4310100, 1): sm.setSpeakerID(9390220) sm.sendSayOkay("You can't start your voyage until you finish the tutorial quest!") else: sm.setSpeakerID(9390220) sm.sendNext("What? You threw away the coins wi...
normal
{ "blob_id": "c4b9fdba9e9eeccc52999dab9232302f159c882a", "index": 588, "step-1": "<mask token>\n", "step-2": "if sm.hasItem(4310100, 1):\n sm.setSpeakerID(9390220)\n sm.sendSayOkay(\n \"You can't start your voyage until you finish the tutorial quest!\")\nelse:\n sm.setSpeakerID(9390220)\n sm....
[ 0, 1, 2 ]
<|reserved_special_token_0|> class Lang: def __init__(self): super(Lang, self).__init__() self.word2index = {} self.word2count = {} self.index2word = {} self.n_words = 0 def index_words(self, sentence): for word in sentence: self.index_word(word) ...
flexible
{ "blob_id": "2da7892722afde5a6f87e3bd6d5763c895ac96c9", "index": 284, "step-1": "<mask token>\n\n\nclass Lang:\n\n def __init__(self):\n super(Lang, self).__init__()\n self.word2index = {}\n self.word2count = {}\n self.index2word = {}\n self.n_words = 0\n\n def index_word...
[ 5, 8, 9, 11, 13 ]
import API.enum as enum import re class ObjectValidator(): def __init__(self, validationData={}, *args, **kwargs): self.data = validationData self.statusCode = 200 self.validationPipeline = [] self.errors = {} self.invalidFields = [] def flush(self): self = Obj...
normal
{ "blob_id": "e8daf03f987c7512ff245bfbe16c447acd6b5986", "index": 7574, "step-1": "<mask token>\n\n\nclass FieldValidator:\n\n def __init__(self, validationData={}, *args, **kwargs):\n self.data = validationData\n self.validationPipeline = []\n self.statusCode = 200\n self.errors = ...
[ 40, 58, 62, 63, 65 ]
from django.test import TestCase from .models import Post, Category, Tag # Create your tests here. class TestPost(TestCase): def test_str(self): my_title = Post(title='This is a basic title for a basic test case') self.assertEquals(str(my_title), 'This is a basic title for a basic test case') c...
normal
{ "blob_id": "825c9510b055c0fa570f577b1c9616e8bde9c98b", "index": 7653, "step-1": "<mask token>\n\n\nclass TestCategory(TestCase):\n\n def test_str(self):\n category = Category(name='Test Category')\n self.assertEquals(str(category), 'Test Category')\n\n\nclass TestTag(TestCase):\n\n def test_...
[ 4, 5, 6, 7, 8 ]
import os , sys , time print(""" ███████████████████████████████ █ █ █═╬═════════════════════════╬═█ █ ║░░░░░░░░░░░░░░░░░░░░░░░░░║ █ █ ║░░░░Wi-fi Fucker Tool░░░░║ █ █ ║░░░░░░░░░░░░░░░░░░░░░░░░░║ █ █ ║░░░░░coded by arda6░░░░░░║ █ █ ║░░░░░░░░░░░░░░░░░...
normal
{ "blob_id": "15eb205e6bd36844fdfc8c05efbc3a3d584c122d", "index": 7238, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\n \"\"\"\n\n ███████████████████████████████\n █ █\n █═╬═════════════════════════╬═█\n █ ║░░░░░░░░░░░░░░░░░░░░░░░░░║ █\n █ ║░░░░Wi-fi ...
[ 0, 1, 2, 3, 4 ]
import math import torch from torch import nn from d2l import torch as d2l def masked_softmax(X, valid_lens): """通过在最后一个轴上掩蔽元素来执行softmax操作""" # X:3D张量,valid_lens:1D或2D张量 if valid_lens is None: return nn.functional.softmax(X, dim=-1) else: shape = X.shape if valid_lens.dim() == ...
normal
{ "blob_id": "cda01bc7b0ebcfaf010bb87e7d9be34fd310d7a7", "index": 9626, "step-1": "<mask token>\n\n\nclass AdditiveAttention(nn.Module):\n <mask token>\n\n def __init__(self, key_size, query_size, num_hiddens, dropout, **kwargs):\n super(AdditiveAttention, self).__init__(**kwargs)\n self.W_k =...
[ 7, 9, 10, 11, 13 ]
########################################################### # 2019-02-07: 删除了marginalized prior # ########################################################### import sys,os import numpy as np import matplotlib.pylab as plt from scipy.linalg import eig from scipy.stats import norm, kstest, normaltest # use default col...
normal
{ "blob_id": "ac35672661e1dd0b97567ae4335f537dc69f98f7", "index": 6240, "step-1": "<mask token>\n\n\ndef read_jla_mock(mock_filename):\n fp = open(mock_filename, 'r')\n lines = fp.readlines()\n fp.close()\n jla = []\n for line in lines:\n sn = line.split()\n temp = []\n temp.ap...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 class interceptThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.curPkt = None self.seq = 0 self.foundUAV = False def run(self): sniff(prn=self.interceptPkt, filter='udp port 5556') def interceptPkt(self, pkt): ...
normal
{ "blob_id": "d9908d1ff155390dcd456dd15f92db03f093089e", "index": 8146, "step-1": "#!/usr/bin/env python3\n\nclass interceptThread(threading.Thread):\n def __init__(self):\n threading.Thread.__init__(self)\n self.curPkt = None\n self.seq = 0\n self.foundUAV = False\n def run(self...
[ 0 ]
<|reserved_special_token_0|> def filtername(name): if len(name) > 3: return name[:3] elif len(name) < 3: return name + ' ' * (3 - len(name)) return name def filternames(names): re = [] for n in names: if len(n) != 3: re += [filtername(n)] return re <|res...
flexible
{ "blob_id": "917241482dc1f234d5fae9c107a5f21b018fe6d4", "index": 9843, "step-1": "<mask token>\n\n\ndef filtername(name):\n if len(name) > 3:\n return name[:3]\n elif len(name) < 3:\n return name + ' ' * (3 - len(name))\n return name\n\n\ndef filternames(names):\n re = []\n for n in ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> random.seed(int(sys.argv[3])) <|reserved_special_token_0|> print('%d' % n) <|reserved_special_token_1|> <|reserved_special_token_0|> randmin = int(sys.argv[1]) randmax = int(sys.argv[2]) random.seed(int(sys.argv[3])) n = random...
flexible
{ "blob_id": "83e1c86095de88692d0116f7e32bd485ab381b29", "index": 7040, "step-1": "<mask token>\n", "step-2": "<mask token>\nrandom.seed(int(sys.argv[3]))\n<mask token>\nprint('%d' % n)\n", "step-3": "<mask token>\nrandmin = int(sys.argv[1])\nrandmax = int(sys.argv[2])\nrandom.seed(int(sys.argv[3]))\nn = rand...
[ 0, 1, 2, 3, 4 ]
import datetime import calendar import re def cardinal(ordinal): return int(''.join([char for char in ordinal if char.isdigit()])) def meetup_day(year, month, day_of_week, ordinal): days = { 0: 'Monday', 1: 'Tuesday', 2: 'Wednesday', 3: 'Thursday', 4: 'Friday', ...
normal
{ "blob_id": "d4b1b6bdf125f2791c219b7db579c234eda0a73c", "index": 9220, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef cardinal(ordinal):\n return int(''.join([char for char in ordinal if char.isdigit()]))\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef cardinal(ordinal):\n return i...
[ 0, 1, 2, 3, 4 ]
import random print(random.choice(['python', 'c++', 'java'])) print(random.choice((1.1, -5, 6, 4, 7)))
normal
{ "blob_id": "44f18d7e7713073c27fec38f0b847803eceefbc9", "index": 2687, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(random.choice(['python', 'c++', 'java']))\nprint(random.choice((1.1, -5, 6, 4, 7)))\n", "step-3": "import random\nprint(random.choice(['python', 'c++', 'java']))\nprint(random.cho...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def find_neighbors(): previous_zero_index = -1 count = 0 result = [] for index, value in enumerate(source): count += 1 if value == 0: if index == 0: previous_zero_index...
flexible
{ "blob_id": "6d362b87b595fc59df31d1f0bb561dc83633a2ac", "index": 9216, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_neighbors():\n previous_zero_index = -1\n count = 0\n result = []\n for index, value in enumerate(source):\n count += 1\n if value == 0:\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class NeuralNetwork: def __init__(self, input_size, hidden_size, output_size): self.input_size = input_size self.hidden_size = hidden_size self.output_size = output_size reshape = partial(fn.translate, start1=0, stop1=1, start2=-1, stop2=1) sel...
flexible
{ "blob_id": "f24516d8977b10b1ccece2f8eaec6e08ce0c2e16", "index": 9689, "step-1": "<mask token>\n\n\nclass NeuralNetwork:\n\n def __init__(self, input_size, hidden_size, output_size):\n self.input_size = input_size\n self.hidden_size = hidden_size\n self.output_size = output_size\n ...
[ 5, 6, 7, 8, 9 ]
import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.model_selection import GroupKFold from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_squared_log_error from sklearn.preprocessing import OneHotEncoder from sklearn.linear_model import...
normal
{ "blob_id": "6028b46eab422dea02af24e9cf724fe0d8b3ecc4", "index": 9531, "step-1": "<mask token>\n\n\ndef test_lasso():\n test = pd.read_csv('./data/test.csv')\n building_metadata = pd.read_csv('./data/building_metadata.csv')\n weather_test = pd.read_csv('./data/weather_test.csv')\n test.sort_values(by...
[ 1, 2, 3, 4, 5 ]
from .. import db class Account(db.Model): id = db.Column(db.Integer, primary_key=True) acc = db.Column(db.String(50), unique=True)#TODO 调整长度 pwd = db.Column(db.String(50))#TODO 调整长度 name = db.Column(db.String(20)) sex = db.Column(db.SmallInteger) idno = db.Column(db.String(20)) phone = db...
normal
{ "blob_id": "b6824251b1165ca6c66049d40c79fccee6bc7d3a", "index": 159, "step-1": "<mask token>\n\n\nclass Consignor(db.Model):\n id = db.Column(db.Integer, db.ForeignKey('account.id'), primary_key=True)\n account = db.relationship('Account', uselist=False)\n indents = db.relationship('Indent', lazy='dyna...
[ 8, 14, 15, 16, 18 ]