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|> print('hello word!') <|reserved_special_token_1|> import ply.lex as lex print('hello word!') <|reserved_special_token_1|> import ply.lex as lex print("hello word!")
flexible
{ "blob_id": "84d0c439fcee4339250ced11dd2264740cc20d9c", "index": 9567, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('hello word!')\n", "step-3": "import ply.lex as lex\nprint('hello word!')\n", "step-4": "import ply.lex as lex\n\nprint(\"hello word!\")\n", "step-5": null, "step-ids": [ ...
[ 0, 1, 2, 3 ]
from django.db import models from django.db.models.base import Model # Create your models here. class Categoria(models.Model): categoria = models.CharField(max_length=40) def __str__(self): return self.categoria class Producto(models.Model): codigo = models.CharField(max_length=40) nombre = mo...
normal
{ "blob_id": "0e19d7251db3382c34ad2d38a7984b65325ecfbf", "index": 7584, "step-1": "<mask token>\n\n\nclass Descuento(models.Model):\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.codigo_descuento\n\n\nclass Venta(models.Model):\n descripcion = models.CharField(max_length=100...
[ 22, 29, 33, 34, 40 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': from numpy.distutils.core import setup setup(name='array-sqrt-openmp', description= 'Illustration of Python extensions using OpenMP', author= 'Mihai Duta', author_email='mihai.dut...
flexible
{ "blob_id": "c24bf42cfeaa1fb8ac188b9e08146762e0e86fed", "index": 1542, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n from numpy.distutils.core import setup\n setup(name='array-sqrt-openmp', description=\n 'Illustration of Python extensions using OpenMP', author=...
[ 0, 1, 2, 3, 4 ]
from datetime import datetime from app import db class Vocabulary(db.Model): _id = db.Column(db.Integer, primary_key=True) language = db.Column(db.String(64), index=True) word = db.Column(db.String(64), index=True, unique=True) date = db.Column(db.DateTime, index=True, default=datetime.utcnow)
normal
{ "blob_id": "834469f9c6e065fb29dfe1fd3e421fbb752f5094", "index": 7708, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Vocabulary(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Vocabulary(db.Model):\n _id = db.Column...
[ 0, 1, 2, 3 ]
import configparser config = configparser.ConfigParser() config.read('config.ini') settings=config['Settings'] colors=config['Colors'] import logging logger = logging.getLogger(__name__) logLevel = settings.getint('log-level') oneLevelUp = 20 #I don't know if this will work before loading the transformers module? #s...
normal
{ "blob_id": "e4fb932c476ca0222a077a43499bf9164e1f27d0", "index": 8896, "step-1": "<mask token>\n", "step-2": "<mask token>\nconfig.read('config.ini')\n<mask token>\nlogging.getLogger('transformers.tokenization_utils').setLevel(logLevel +\n oneLevelUp)\nlogging.getLogger('transformers.modeling_utils').setLev...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class BaseHandler(webapp2.RequestHandler): @webapp2.cached_property def auth(self): """Shortcut to access the auth instance as a property.""" return auth.get_auth() <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "fe7fb9a4a5ca2bb8dab0acf440eb2fac127264ce", "index": 2631, "step-1": "<mask token>\n\n\nclass BaseHandler(webapp2.RequestHandler):\n\n @webapp2.cached_property\n def auth(self):\n \"\"\"Shortcut to access the auth instance as a property.\"\"\"\n return auth.get_auth()\n <mask t...
[ 40, 42, 48, 49, 51 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in my_list: new_list.append(i ** 2) <|reserved_special_token_0|> print(my_dict) <|reserved_special_token_0|> print(new_list_round) <|reserved_special_token_1|> my_list = [1, 2, 3, 4, 5] new_list = [] for i in my_list:...
flexible
{ "blob_id": "e54eea2261517a2b15fde23c46b3fe75c0efec64", "index": 7746, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in my_list:\n new_list.append(i ** 2)\n<mask token>\nprint(my_dict)\n<mask token>\nprint(new_list_round)\n", "step-3": "my_list = [1, 2, 3, 4, 5]\nnew_list = []\nfor i in my_li...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class GPTD_fixedGrid: def __init__(self, env, sigma0, gamma, kernel, D, V_mu=[]): self.env = env self.gamma = gamma self.sigma0 = sigma0 self.kernel = kernel.kernel if not V_mu: V_mu = lambda s: np.zeros((s.shape[1], 1)) sel...
flexible
{ "blob_id": "92eaceb46974ba3a5944300139d5929d44673181", "index": 1223, "step-1": "<mask token>\n\n\nclass GPTD_fixedGrid:\n\n def __init__(self, env, sigma0, gamma, kernel, D, V_mu=[]):\n self.env = env\n self.gamma = gamma\n self.sigma0 = sigma0\n self.kernel = kernel.kernel\n ...
[ 3, 5, 6, 7, 8 ]
import cv2 import numpy as np import copy imgpath = 'D:\\DIP-Project1/b.jpg' img = cv2.imread(imgpath) img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.imshow('img', img) row = len(img) col = len(img[0]) def medianflt(img, i, j, msize, mr, mc): pxls = [] for a in range(msize): for b in range(msize): ...
normal
{ "blob_id": "cfcce8c760f6ba49ce450d78782cb8f3b5fc1188", "index": 2857, "step-1": "<mask token>\n\n\ndef medianflt(img, i, j, msize, mr, mc):\n pxls = []\n for a in range(msize):\n for b in range(msize):\n mi = i + a - mr\n mj = j + b - mc\n pxls.append(img[mi][mj])\n...
[ 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Post: def __init__(self, date, text, medias): self.date = date self.text = text self.medias = medias self.dcim = [] self.daterank = 0 self.extra = False def __lt__(self, other): return self.date < other.date @cla...
flexible
{ "blob_id": "6018f35afc6646d0302ca32de649ffe7d544a765", "index": 3377, "step-1": "<mask token>\n\n\nclass Post:\n\n def __init__(self, date, text, medias):\n self.date = date\n self.text = text\n self.medias = medias\n self.dcim = []\n self.daterank = 0\n self.extra =...
[ 79, 84, 88, 100, 110 ]
# Author: Sam Erickson # Date: 2/23/2016 # # Program Description: This program gives the integer coefficients x,y to the # equation ax+by=gcd(a,b) given by the extended Euclidean Algorithm. def extendedEuclid(a,b): """ Preconditions - a and b are both positive integers. Posconditions - The equation for ax...
normal
{ "blob_id": "36e5b0f40b8016f39120f839766db0ac518c9bed", "index": 4712, "step-1": "<mask token>\n", "step-2": "def extendedEuclid(a, b):\n \"\"\"\n Preconditions - a and b are both positive integers.\n Posconditions - The equation for ax+by=gcd(a,b) has been returned where\n x and y ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): def gcdOfStrings(self, str1, str2): if str1 == str2: return str1 elif not str1 or not str2: return ''...
flexible
{ "blob_id": "ab632c3c8a7f295a890de19af82fde87c6d600bc", "index": 1674, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def gcdOfStrings(self, str1, str2):\n if str1 == str2:\n return str1\n elif not str1 o...
[ 0, 1, 2 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from datetime import datetime archivo = open("salida2.csv", "a+") startTime = datetime.now() def mergeSort(alist): print("Splitting ",alist) if len(alist)>1: mid = len(alist)//2 lefthalf = alist[:mid] righthalf = alist[mid:] merge...
normal
{ "blob_id": "9e98c6b59433369bca3d4f7ae261f7e7ab3aae6b", "index": 4161, "step-1": "<mask token>\n\n\ndef mergeSort(alist):\n print('Splitting ', alist)\n if len(alist) > 1:\n mid = len(alist) // 2\n lefthalf = alist[:mid]\n righthalf = alist[mid:]\n mergeSort(lefthalf)\n m...
[ 1, 2, 3, 4, 5 ]
import sys sys.setrecursionlimit(10 ** 6) n, s = map(int, input().split()) value = list(map(int, input().split())) count = 0 def recursive(index, sum): global count if index == n: if sum == s: count += 1 return recursive(index + 1, sum + value[index]) recursive(index + 1, s...
normal
{ "blob_id": "f1aa12ec4ee2482db8abf1121a3443502544e1a2", "index": 2815, "step-1": "<mask token>\n\n\ndef recursive(index, sum):\n global count\n if index == n:\n if sum == s:\n count += 1\n return\n recursive(index + 1, sum + value[index])\n recursive(index + 1, sum)\n\n\n<mas...
[ 1, 2, 3, 4 ]
from setup import app, manager from Users.controller import user_controller from Test.controller import test_controller app.register_blueprint(test_controller, url_prefix="/test") #registeting test_controller blueprint with the main "app" and asking it to handle all url that begins with "/test". For eg: http://127.0.0...
normal
{ "blob_id": "afa22db946f77e9b33a443657592c20fbea21eb1", "index": 6146, "step-1": "<mask token>\n", "step-2": "<mask token>\napp.register_blueprint(test_controller, url_prefix='/test')\napp.register_blueprint(user_controller, url_prefix='/')\nif __name__ == '__main__':\n app.run(debug=True)\n", "step-3": "...
[ 0, 1, 2, 3 ]
# Copyright (c) 2017, Matt Layman import bisect import configparser import os import smartypants from werkzeug.contrib.atom import AtomFeed, FeedEntry from handroll import logger from handroll.exceptions import AbortError from handroll.extensions.base import Extension from handroll.i18n import _ class BlogPost(obj...
normal
{ "blob_id": "c3d9ad49b62c56dfbd9674cb1ac5c206e6401a27", "index": 830, "step-1": "<mask token>\n\n\nclass BlogBuilder(object):\n <mask token>\n\n def _generate_output(self):\n \"\"\"Generate output that belongs in the destination file.\n\n Subclasses must implement this method.\n \"\"\"...
[ 13, 24, 28, 32, 38 ]
<|reserved_special_token_0|> class StudentListView(ListView): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def get_queryset(self): return Student.objects.filter(course='Python') <|reserved_special_token_0|> <|reserved_special_token_0|> <|res...
flexible
{ "blob_id": "bcad9869e6bc9b17eee490897b4b706171381366", "index": 2093, "step-1": "<mask token>\n\n\nclass StudentListView(ListView):\n <mask token>\n <mask token>\n <mask token>\n\n def get_queryset(self):\n return Student.objects.filter(course='Python')\n <mask token>\n <mask token>\n",...
[ 2, 4, 5, 6, 7 ]
from flask import Blueprint, request, make_response from untils import restful, cacheuntil from untils.captcha import Captcha from exts import smsapi from .forms import SMSCaptchaForm from io import BytesIO bp = Blueprint('common', __name__, url_prefix='/c') # @bp.route('/sms_captcha/', methods=['post']) # def sms_c...
normal
{ "blob_id": "856beaf3b9dad333d5b48c1be3a8ad917f8d020c", "index": 3634, "step-1": "<mask token>\n\n\n@bp.route('/captcha/')\ndef CaptchaView():\n text, image = Captcha.gene_graph_captcha()\n cacheuntil.set(text.lower(), text.lower())\n out = BytesIO()\n image.save(out, 'png')\n out.seek(0)\n res...
[ 1, 2, 3, 4, 5 ]
from typing import Sized import pygame import time from pygame.locals import * import random SIZE = 20 BACKGROUND = (45, 34, 44) W = 800 H = 400 SCREEN = (W, H) class Snake: def __init__(self, parent_screen, length): self.parent_screen = parent_screen self.length = length self.snake = pyg...
normal
{ "blob_id": "935853a4afdb50a4652e14913d0cdb251a84ea14", "index": 6427, "step-1": "<mask token>\n\n\nclass Food:\n <mask token>\n\n def draw(self):\n seq = [self.food1, self.food2]\n self.parent_screen.blit(random.choice(seq), (self.food_x, self.food_y))\n pygame.display.flip()\n\n d...
[ 17, 26, 29, 30, 31 ]
TOTAL = 1306336 ONE = { '0': 1473, '1': 5936, '2': 3681, '3': 2996, '4': 2480, '5': 2494, '6': 1324, '7': 1474, '8': 1754, '9': 1740, 'a': 79714, 'b': 83472, 'c': 78015, 'd': 61702, 'e': 42190, 'f': 68530, 'g': 48942, 'h': 63661, 'i': 34947, 'j': 24312, 'k': 26724, 'l': 66351, 'm': 77245, 'n': 36942, 'o': 40744, 'p': ...
normal
{ "blob_id": "f254f93193a7cb7ed2e55e4481ed85821cafcd7b", "index": 4339, "step-1": "<mask token>\n", "step-2": "TOTAL = 1306336\nONE = {'0': 1473, '1': 5936, '2': 3681, '3': 2996, '4': 2480, '5': 2494,\n '6': 1324, '7': 1474, '8': 1754, '9': 1740, 'a': 79714, 'b': 83472, 'c':\n 78015, 'd': 61702, 'e': 4219...
[ 0, 1, 2 ]
import signal import time import sdnotify n = sdnotify.SystemdNotifier() if __name__ == '__main__': n.notify("READY=1") time.sleep(2)
normal
{ "blob_id": "78dc2193c05ddb4cd4c80b1c0322890eca7fcf19", "index": 789, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n n.notify('READY=1')\n time.sleep(2)\n", "step-3": "<mask token>\nn = sdnotify.SystemdNotifier()\nif __name__ == '__main__':\n n.notify('READY=1')\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class KaliteUI(object): def __init__(self, kaliteApp): dropdown = DropDown() dropdown_btn = Button(text='menu', size_hint_x=None, size_hint_y= None, size=(150, 40), font_size=18, color=(0.06, 0.6, 0.2, 1), bold=True, background_color=(1, 1, 1, ...
flexible
{ "blob_id": "35cd1c45294b826784eab9885ec5b0132624c957", "index": 4028, "step-1": "<mask token>\n\n\nclass KaliteUI(object):\n\n def __init__(self, kaliteApp):\n dropdown = DropDown()\n dropdown_btn = Button(text='menu', size_hint_x=None, size_hint_y=\n None, size=(150, 40), font_size=...
[ 9, 11, 14, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get(url): return requests.get(url).text <|reserved_special_token_1|> import requests def get(url): return requests.get(url).text
flexible
{ "blob_id": "671ecf23df1da659d186014afa738d0608ad404d", "index": 9251, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get(url):\n return requests.get(url).text\n", "step-3": "import requests\n\n\ndef get(url):\n return requests.get(url).text\n", "step-4": null, "step-5": null, "step...
[ 0, 1, 2 ]
# Testing import sys, os sys.dont_write_bytecode = True import argparse, socket from requestframe import RequestFrame if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--header-mutate-level", type=int, choices=range(11), nargs='?', help="Set the mutation level for the headers ...
normal
{ "blob_id": "350a79d6cead6814ad48292b14a204e753dc938c", "index": 4363, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n parser = argparse.ArgumentParser()\n parser.add_argument('--header-mutate-level', type=int, choices=range(11\n ), nargs='?', help=\n 'Set ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): str1 = 'パトカー' str2 = 'タクシー' print(''.join([(x[0] + x[1]) for x in zip(str1, str2)])) <|reserved_special_token_0|> <|reserved_special_token_1|> def question(): print('02. 「パトカー」+「タクシー」=「パタトクカシーー」'...
flexible
{ "blob_id": "32869a88bb59d47281249b6ebe2357328beb0359", "index": 3572, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n str1 = 'パトカー'\n str2 = 'タクシー'\n print(''.join([(x[0] + x[1]) for x in zip(str1, str2)]))\n\n\n<mask token>\n", "step-3": "def question():\n print('02. 「パトカ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Lenet(nn.Module): <|reserved_special_token_0|> def forward(self, x): layer_w = self.fc2.weight sigma = layer_w.std().data.cpu().numpy() layer_w_numpy = layer_w.data.cpu().numpy() scale = 0.17 noise = np.random.normal(0, scale * sigma,...
flexible
{ "blob_id": "a38a5010c9edbed0929da225b4288396bb0d814e", "index": 6989, "step-1": "<mask token>\n\n\nclass Lenet(nn.Module):\n <mask token>\n\n def forward(self, x):\n layer_w = self.fc2.weight\n sigma = layer_w.std().data.cpu().numpy()\n layer_w_numpy = layer_w.data.cpu().numpy()\n ...
[ 2, 4, 5, 6, 7 ]
b = int(input('enter anum ')) for a in range(1, 11, 1): print(b, 'x', a, '=', a * b)
normal
{ "blob_id": "bf83556b8e8855a0e410fcfb3b42161fbc681830", "index": 3075, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor a in range(1, 11, 1):\n print(b, 'x', a, '=', a * b)\n", "step-3": "b = int(input('enter anum '))\nfor a in range(1, 11, 1):\n print(b, 'x', a, '=', a * b)\n", "step-4": nul...
[ 0, 1, 2 ]
<|reserved_special_token_0|> @micropython.viper def viper_int(x: int, y: int) ->int: return x + y + 3 <|reserved_special_token_0|> @micropython.viper def viper_local(x: int) ->int: y = 4 return x + y <|reserved_special_token_0|> @micropython.viper def viper_no_annotation(x, y): return x * y ...
flexible
{ "blob_id": "eec52695e5afcc21e5fed6453e96cc3a58e7c1df", "index": 101, "step-1": "<mask token>\n\n\n@micropython.viper\ndef viper_int(x: int, y: int) ->int:\n return x + y + 3\n\n\n<mask token>\n\n\n@micropython.viper\ndef viper_local(x: int) ->int:\n y = 4\n return x + y\n\n\n<mask token>\n\n\n@micropyt...
[ 9, 10, 12, 14, 15 ]
def main(): num = int(input('dia: ')) dia(num) def dia(a): if a == 1: print('Domingo !') elif a == 2: print('Segunda !') else: print('valor invalido !') main()
normal
{ "blob_id": "07332e2da5458fda2112de2507037a759d3c62db", "index": 3382, "step-1": "<mask token>\n", "step-2": "def main():\n num = int(input('dia: '))\n dia(num)\n\n\n<mask token>\n", "step-3": "def main():\n num = int(input('dia: '))\n dia(num)\n\n\ndef dia(a):\n if a == 1:\n print('Dom...
[ 0, 1, 2, 3 ]
""" contains generic code for use in main menus. currently this is a function which turns dictionaries of functions into a menu. I envision any further menu functions being stored here so don't expect it to run like a pipeline but rather like a suite of individual menus. TODO - refactor spider selection function as je...
normal
{ "blob_id": "f28b47e1b07011ce9d0708331f68d7f16195c567", "index": 7225, "step-1": "<mask token>\n\n\ndef final_option(dict_of_options, back):\n \"\"\"\n adds the final option to the dictionary based on a boolean\n\n :param dict_of_options: dictionary with readable labels as keys and uncalled functions as...
[ 8, 10, 11, 12, 13 ]
<|reserved_special_token_0|> class Post(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __str__(self): return self.title class User(mo...
flexible
{ "blob_id": "3aa8c9b39174f0ed5799d6991516b34ca669b7d6", "index": 9765, "step-1": "<mask token>\n\n\nclass Post(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.title\n\n\nclass User(models.Mod...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> class Button: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def read_button(self): self.status = GPIO.input(self.button_pin) def light(self, stat): if stat: GPIO.out...
flexible
{ "blob_id": "878937e19d6a48a0d44309efbac1d41c208ce849", "index": 6195, "step-1": "<mask token>\n\n\nclass Button:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def read_button(self):\n self.status = GPIO.input(self.button_pin)\n\n def light(self, stat):\n if stat...
[ 4, 5, 6, 7, 8 ]
import os from flask import Flask, request, redirect, url_for, render_template, send_from_directory from werkzeug.utils import secure_filename import chardet as chardet import pandas as pd UPLOAD_FOLDER = os.path.dirname(os.path.abspath(__file__)) + '/uploads/' DOWNLOAD_FOLDER = os.path.dirname(os.path.abspath(__file_...
normal
{ "blob_id": "eb17de8828a600832253c4cfeeb91503b6876dd7", "index": 9963, "step-1": "<mask token>\n\n\ndef allowed_file(filename):\n return '.' in filename and filename.rsplit('.', 1)[1].lower(\n ) in ALLOWED_EXTENSIONS\n\n\n@app.route('/', methods=['GET', 'POST'])\ndef index():\n if request.method == ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> class SQLiteConnection(ConnectionBackend): <|reserved_special_token_0|> <|reserved_special_token_0|> async def connect(self): self.db = await aiosqlite.connect(self.db_name) self.db.row_factory = aiosqlite.Row async def disconnect(self): await sel...
flexible
{ "blob_id": "191a57d3f13fcbe217ff6d0bd92dea163d5fb3cf", "index": 4822, "step-1": "<mask token>\n\n\nclass SQLiteConnection(ConnectionBackend):\n <mask token>\n <mask token>\n\n async def connect(self):\n self.db = await aiosqlite.connect(self.db_name)\n self.db.row_factory = aiosqlite.Row\...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while no != 0: r = no % 10 no = no // 10 rev = rev * 10 + r print('reverse no is:', rev) <|reserved_special_token_1|> no = int(input('enter no:')) rev = 0 while no != 0: r = no % 10 no = no // 10 rev = r...
flexible
{ "blob_id": "b2371f9c774c605a52ff1a4fae2dd44a856076aa", "index": 5522, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile no != 0:\n r = no % 10\n no = no // 10\n rev = rev * 10 + r\nprint('reverse no is:', rev)\n", "step-3": "no = int(input('enter no:'))\nrev = 0\nwhile no != 0:\n r = no...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def process_std(standard_input_file): try: with open(standard_input_file, 'r') as in_handle: lin_reg_lst = [] for line in in_handle: line = line.strip('\n') lin_reg_lst.append(line) except IOError: print('Coul...
flexible
{ "blob_id": "19949b07c866d66b3ef00b6a386bf89f03e06294", "index": 7984, "step-1": "<mask token>\n\n\ndef process_std(standard_input_file):\n try:\n with open(standard_input_file, 'r') as in_handle:\n lin_reg_lst = []\n for line in in_handle:\n line = line.strip('\\n'...
[ 3, 4, 5, 6, 8 ]
# -*- coding: utf-8 -*- """ Created on Tue Oct 9 16:22:21 2018 @author: SDis """ #import Code.Members_module class Resources: """ Parent class for Books and eResources containg the main data fields and related setters and getters""" def __init__(self, title, author, publisher, year): self.title = tit...
normal
{ "blob_id": "0709d413ddbe41a0c97f94b7819fdfded241d3fc", "index": 691, "step-1": "<mask token>\n\n\nclass Resources:\n <mask token>\n\n def __init__(self, title, author, publisher, year):\n self.title = title\n self.author = author\n self.publisher = publisher\n self.year = year\...
[ 4, 8, 9, 10, 13 ]
from __future__ import unicode_literals import json, alice_static import logging from random import choice # Импортируем подмодули Flask для запуска веб-сервиса. from flask import Flask, request app = Flask(__name__) logging.basicConfig(level=logging.DEBUG) # Хранилище данных о сессиях. sessionStorage = {} # Задаем...
normal
{ "blob_id": "2df679fc3407c15f5d0c006e9da8d1fc74bcf875", "index": 5705, "step-1": "from __future__ import unicode_literals\nimport json, alice_static\nimport logging\nfrom random import choice\n# Импортируем подмодули Flask для запуска веб-сервиса.\nfrom flask import Flask, request\napp = Flask(__name__)\n\n\nlog...
[ 0 ]
<|reserved_special_token_0|> class BaseCollectionSerializer(ResolweBaseSerializer): <|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|> ...
flexible
{ "blob_id": "d6f8ec0fd8be0fa7019a84af47d08ab8b5b32d92", "index": 1449, "step-1": "<mask token>\n\n\nclass BaseCollectionSerializer(ResolweBaseSerializer):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def get_status(self, coll...
[ 6, 8, 9, 11, 12 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @pytest.mark.asyncio async def test_authenticator(aioresponse: aioresponses) ->None: with open('tests/fixtures/auth_pin_status.xml') as file: aioresponse.get('http://1.2.3.4:8080/ws/apps/CloudPINPage', body= ...
flexible
{ "blob_id": "e1448e62020f87e315d219be97d9af84607441df", "index": 9104, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.mark.asyncio\nasync def test_authenticator(aioresponse: aioresponses) ->None:\n with open('tests/fixtures/auth_pin_status.xml') as file:\n aioresponse.get('http://1....
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def parse_response(permission, response): return response <|reserved_special_token_1|> <|reserved_special_token_0|> def get_command(session, parsed_message): return 'stop', 'restart' def parse_response(permission,...
flexible
{ "blob_id": "acd5cf675522c90fc9fbc96bdeb52f66835626b4", "index": 3489, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_response(permission, response):\n return response\n", "step-3": "<mask token>\n\n\ndef get_command(session, parsed_message):\n return 'stop', 'restart'\n\n\ndef pars...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class USBHandler: <|reserved_special_token_0|> def __init__(self): self.initialized = False self.run_task = None self.waiters = {} self.queues = {} self.logger = logging.getLogger('.'.join((__name__, self.__class__. __name__))) ...
flexible
{ "blob_id": "50b630b762251f8646044b234ac4b82b8e4b645b", "index": 8460, "step-1": "<mask token>\n\n\nclass USBHandler:\n <mask token>\n\n def __init__(self):\n self.initialized = False\n self.run_task = None\n self.waiters = {}\n self.queues = {}\n self.logger = logging.ge...
[ 3, 7, 8, 9, 10 ]
"""Derivation of variable ``co2s``.""" import dask.array as da import iris import numpy as np import stratify from ._baseclass import DerivedVariableBase def _get_first_unmasked_data(array, axis): """Get first unmasked value of an array along an axis.""" mask = da.ma.getmaskarray(array) numerical_mask = ...
normal
{ "blob_id": "7c9b68b2d32d8e435f332d4412ea1ba899607ec4", "index": 9395, "step-1": "<mask token>\n\n\nclass DerivedVariable(DerivedVariableBase):\n <mask token>\n\n @staticmethod\n def required(project):\n \"\"\"Declare the variables needed for derivation.\"\"\"\n required = [{'short_name': ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class Solution: <|reserved_special_token_0|> class Solution: def isPowerOfTwo(self, n: int) ->bool: return n > 0 and n & n - 1 == 0 class Solution: def isPowerOfTwo(self, n: int) ->bool: return n > 0 and math.log10(n) / math.log10(2) % 1 == 0 class Solu...
flexible
{ "blob_id": "32066db8b43bc70c564cce5a33f50921285b3627", "index": 6477, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\nclass Solution:\n\n def isPowerOfTwo(self, n: int) ->bool:\n return n > 0 and n & n - 1 == 0\n\n\nclass Solution:\n\n def isPowerOfTwo(self, n: int) ->bool:\n ...
[ 11, 17, 19, 21, 22 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> ap.add_argument('-D', '--dir', required=False, help='Directory to sort') <|reserved_special_token_0|> if args['dir'] == None: DIR = os.getcwd() elif os.path.exists(args['dir']): DIR = args['dir'] for file in os.listdir(DIR...
flexible
{ "blob_id": "93737e4c409d0efb1ae2263cb60d4b03d9aad0d8", "index": 247, "step-1": "<mask token>\n", "step-2": "<mask token>\nap.add_argument('-D', '--dir', required=False, help='Directory to sort')\n<mask token>\nif args['dir'] == None:\n DIR = os.getcwd()\nelif os.path.exists(args['dir']):\n DIR = args['d...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def isSubsetSum(set, n, sum): subset = [[(False) for i in range(sum + 1)] for i in range(n + 1)] for i in range(n + 1): subset[i][0] = True for i in range(1, sum + 1): subset[0][i] = False for i in range(1, n + 1): for ...
flexible
{ "blob_id": "830e7e84eebd6a4adb411cc95c9e9c8ff7bdac30", "index": 778, "step-1": "<mask token>\n", "step-2": "def isSubsetSum(set, n, sum):\n subset = [[(False) for i in range(sum + 1)] for i in range(n + 1)]\n for i in range(n + 1):\n subset[i][0] = True\n for i in range(1, sum + 1):\n s...
[ 0, 1, 2, 3, 4 ]
import unittest from app.party import Party from app.guest import Guest from app.shoppingList import ShoppingList def test_aPartywithNoGuestsShouldHaveNoPartyGuests(): party = Party() assert 0 == party.numberOfGuests() def test_aPartywithOneGuestShouldHaveOnePartyGuest(): party = Party() lisa = Guest("Lisa", 'fe...
normal
{ "blob_id": "a8df6b575afbf6db415e0676a796623f2a9b7a70", "index": 8416, "step-1": "<mask token>\n\n\ndef test_aPartywithOneGuestShouldHaveOnePartyGuest():\n party = Party()\n lisa = Guest('Lisa', 'female')\n party.attendedBy(lisa)\n assert 1 == party.numberOfGuests()\n\n\ndef test_aPartywithThreeGuest...
[ 6, 8, 9, 10, 12 ]
#======================================================================= __version__ = '''0.0.01''' __sub_version__ = '''20130714221105''' __copyright__ = '''(c) Alex A. Naanou 2011''' #----------------------------------------------------------------------- import os import sha import md5 import base64 ...
normal
{ "blob_id": "d03f87b7dfa8fe2c63500effda1bea5e41f17ffc", "index": 3787, "step-1": "#=======================================================================\r\n\r\n__version__ = '''0.0.01'''\r\n__sub_version__ = '''20130714221105'''\r\n__copyright__ = '''(c) Alex A. Naanou 2011'''\r\n\r\n\r\n#---------------------...
[ 0 ]
import rdflib import csv from time import sleep gtypes = {} dtypes = {} atypes = {} g = rdflib.Graph() g.parse("http://geographicknowledge.de/vocab/CoreConceptData.rdf#") g.parse("./ontology.ttl", format="ttl") sleep(.5) results = g.query(""" prefix skos: <http://www.w3.org/2004/02/skos/core#> prefix ccd: ...
normal
{ "blob_id": "eb1fbe2de3c8548175eb3c8720353e466e3b68c7", "index": 7336, "step-1": "<mask token>\n", "step-2": "<mask token>\ng.parse('http://geographicknowledge.de/vocab/CoreConceptData.rdf#')\ng.parse('./ontology.ttl', format='ttl')\nsleep(0.5)\n<mask token>\nfor result in results:\n uri, geometry_type = re...
[ 0, 1, 2, 3, 4 ]
__path__.append( '/cvmfs/cms.cern.ch/slc6_amd64_gcc481/cms/cmssw-patch/CMSSW_7_0_6_patch3/python/ggAnalysis' )
normal
{ "blob_id": "0345c3c2049c972370cd7bde5a6e0a1dfa5dfe66", "index": 3719, "step-1": "<mask token>\n", "step-2": "__path__.append(\n '/cvmfs/cms.cern.ch/slc6_amd64_gcc481/cms/cmssw-patch/CMSSW_7_0_6_patch3/python/ggAnalysis'\n )\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0,...
[ 0, 1 ]
import logging import os import time from datetime import datetime from pathlib import Path from configargparse import ArgumentParser from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.x509.oid import ExtensionOID from cryptography.x509.extensions import ExtensionN...
normal
{ "blob_id": "83be35b79dcaa34f9273281976ebb71e81c58cdd", "index": 8673, "step-1": "<mask token>\n\n\nclass SslExporter(object):\n gauges = {}\n\n def __init__(self, cert_paths):\n self.cert_paths = cert_paths\n\n def collect(self):\n self.gauges['ssl_valid_days'] = GaugeMetricFamily('ssl_va...
[ 6, 7, 8, 9, 10 ]
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void findSubNode(Node root) { } public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
normal
{ "blob_id": "6d0a945c9eaf6564a327928880df1f0aeed2e5d0", "index": 9649, "step-1": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void findSubNode(Node root) {\n\n }\n\n public static void main(String args[]) throws ...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def bigquery(datafile, dataset=os.environ['BQDATASET'], project=os.environ[ 'GCPPROJECT'], schema=[{'name': 'conversation', 'type': 'STRING'}, { 'name': 'id', 'type': 'INTEGER'}, {'name': 'from', 'type': 'STRING'}, { ...
flexible
{ "blob_id": "d6046217308745b85455aed78734700b9622782c", "index": 7559, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bigquery(datafile, dataset=os.environ['BQDATASET'], project=os.environ[\n 'GCPPROJECT'], schema=[{'name': 'conversation', 'type': 'STRING'}, {\n 'name': 'id', 'type': 'INTEG...
[ 0, 1, 2, 3 ]
import numpy as np import cv2 from PIL import Image import pytesseract as tess #Function to check the area range and width-height ratio def ratio(area, width,height): ratio = float(width)/float(height) if ratio < 1: ratio = 1/ ratio if (area<1063.62 or area> 73862.5) or (ratio<3 or ratio> 6): return False...
normal
{ "blob_id": "ab610af97d2b31575ea496b8fddda693353da8eb", "index": 2870, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef ratio(area, width, height):\n ratio = float(width) / float(height)\n if ratio < 1:\n ratio = 1 / ratio\n if (area < 1063.62 or area > 73862.5) or (ratio < 3 or rat...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestSTCHANGE: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestSTCHANGE: def setup_method(self...
flexible
{ "blob_id": "87f8cc65cf7d0ea932de79a6daf5b29ad387ec6f", "index": 7103, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestSTCHANGE:\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TestSTCHANGE:\n\n def setup_method(self, method):\n self.d...
[ 0, 1, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def fetchsquare(request, id): try: therm = Therm.objects.get(id=id) except Therm.DoesNotExist: raise Http404('This item does not exist') return render(request, 'thermometer/fetchsquare.html', {'therm'...
flexible
{ "blob_id": "504d4afc4b3e708d43110a2d85676fb745f1aba8", "index": 9874, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fetchsquare(request, id):\n try:\n therm = Therm.objects.get(id=id)\n except Therm.DoesNotExist:\n raise Http404('This item does not exist')\n return render...
[ 0, 1, 2, 3, 4 ]
# Copyright 2011 Isaku Yamahata # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
normal
{ "blob_id": "d56e313318635788ae5b3d3a3f767450ab2f2296", "index": 4985, "step-1": "<mask token>\n\n\nclass BlockDeviceTestCase(test.NoDBTestCase):\n <mask token>\n\n def test_properties(self):\n root_device0 = '/dev/sda'\n root_device1 = '/dev/sdb'\n mappings = [{'virtual': 'root', 'dev...
[ 37, 38, 43, 46, 55 ]
from django.apps import AppConfig class ModuloConfig(AppConfig): name = 'modulo' verbose_name = 'TUM:JungeAkademie - Modulo' def ready(self): #start-up / initialization code here!!! from .recommender import Recommender Recommender.initialize()
normal
{ "blob_id": "31275ca9e20da9d2709ea396e55c113b3ff4f571", "index": 7738, "step-1": "<mask token>\n\n\nclass ModuloConfig(AppConfig):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ModuloConfig(AppConfig):\n <mask token>\n <mask token>\n\n def ready(self):\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class LogoutSerializer(ModelSerializer): <|reserved_special_token_0|> <|reserved_special_token_0|> class Meta: model = DeviceUser fields = ['device_user_token', 'device_os', 'is_active'] <|reserved_special_token_0|> <|reserved_special_token_0|> clas...
flexible
{ "blob_id": "01900c1d14a04ee43553c8602a07e0c6ecfabded", "index": 1803, "step-1": "<mask token>\n\n\nclass LogoutSerializer(ModelSerializer):\n <mask token>\n <mask token>\n\n\n class Meta:\n model = DeviceUser\n fields = ['device_user_token', 'device_os', 'is_active']\n <mask token>\n ...
[ 9, 11, 15, 17, 19 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "87e0b9dc518d439f71e261d5c5047153324919ba", "index": 9547, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def get_repo_url(repo): url = repo.replace('upstream:', 'git://git.baserock.org/delta/') url = url.replace('baserock:baserock/', 'git://git.baserock.org/baserock/baserock/') url = url.replace('freedesktop:', 'git://anongit.freedesktop.org/') url = url.replace('gith...
flexible
{ "blob_id": "955cf040aaf882328e31e6a943bce04cf721cb11", "index": 538, "step-1": "<mask token>\n\n\ndef get_repo_url(repo):\n url = repo.replace('upstream:', 'git://git.baserock.org/delta/')\n url = url.replace('baserock:baserock/',\n 'git://git.baserock.org/baserock/baserock/')\n url = url.replac...
[ 5, 7, 8, 10, 11 ]
import rospy #: the parameter namespace for the arni_countermeasure node ARNI_CTM_NS = "arni/countermeasure/" #: the parameter namespace for configuration files #: of the arni_countermeasure node ARNI_CTM_CFG_NS = ARNI_CTM_NS + "config/" def get_param_num(param): #dummy val value = 1 try: value...
normal
{ "blob_id": "70c9d75dabfa9eac23e34f94f34d39c08e21b3c0", "index": 6070, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_param_num(param):\n value = 1\n try:\n value = rospy.get_param(param)\n if not isinstance(value, (int, float, long)):\n err_msg = 'Param %s is n...
[ 0, 2, 3, 4, 5 ]
import sys filepath = 'input.txt' def intersection(list1, list2): return set(list1).intersection(list2) def computeSteps(x, y, step, steps): # build dictionary with steps for each point curr = 0 if (x,y) in steps: curr = steps.get((x,y)) steps[(x,y)] = step + curr ...
normal
{ "blob_id": "e9e119dd69f9416e007e748d7f494741140efc8e", "index": 8182, "step-1": "<mask token>\n\n\ndef intersection(list1, list2):\n return set(list1).intersection(list2)\n\n\ndef computeSteps(x, y, step, steps):\n curr = 0\n if (x, y) in steps:\n curr = steps.get((x, y))\n steps[x, y] = step...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def plot_loss(history): plt.plot(history.history['loss'], label='loss') plt.plot(history.history['val_loss'], label='val_loss') plt.ylim([0, 10]) plt.xlabel('Epoch') plt.ylabel('Error') plt.legend() plt.grid(True) <|reserved_special_token_0|> <|reserved_spe...
flexible
{ "blob_id": "196147d7b2b0cf7176b5baa50d7e7618f88df493", "index": 7911, "step-1": "<mask token>\n\n\ndef plot_loss(history):\n plt.plot(history.history['loss'], label='loss')\n plt.plot(history.history['val_loss'], label='val_loss')\n plt.ylim([0, 10])\n plt.xlabel('Epoch')\n plt.ylabel('Error')\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class MyLoop(dopehr_loopmodel): <|reserved_special_token_0|> def select_loop_atoms(self): return selection(self.residue_range('218:', '231:')) <|reserved_special_token_1|> <|reserved_special_token_0|> class...
flexible
{ "blob_id": "d058c3df8513e07e4ff7035aa5c5885819e43687", "index": 7295, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MyLoop(dopehr_loopmodel):\n <mask token>\n\n def select_loop_atoms(self):\n return selection(self.residue_range('218:', '231:'))\n", "step-3": "<mask token>\n\n\n...
[ 0, 2, 3, 4, 5 ]
from Config_paar import * from Envelopefkt import * from Kinematik import * def A_m_n(M,N,x_plus,p_el,p_pos,k_photon,k_laser): def f1(p): return -(m*a0)/(pk(p)) * g(phi,sigma,Envelope) *( pe(1,p) * cos(ksi) * cos(phi) + pe(2,p) * sin(ksi) * sin(phi) ) def f2(p): return -(m*a0)**2/(2....
normal
{ "blob_id": "ad170f67e5b9f54d950ead91dd60cd4f3b753eca", "index": 6660, "step-1": "from Config_paar import *\nfrom Envelopefkt import *\nfrom Kinematik import *\n\n\ndef A_m_n(M,N,x_plus,p_el,p_pos,k_photon,k_laser):\n\n def f1(p):\n return -(m*a0)/(pk(p)) * g(phi,sigma,Envelope) *( pe(1,p) * cos(ksi) *...
[ 0 ]
from django.core import management from django.conf import settings def backup_cron(): if settings.DBBACKUP_STORAGE is not '': management.call_command('dbbackup')
normal
{ "blob_id": "ae9f1c4f70801dace0455c051ba4d4bfb7f3fe67", "index": 4813, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef backup_cron():\n if settings.DBBACKUP_STORAGE is not '':\n management.call_command('dbbackup')\n", "step-3": "from django.core import management\nfrom django.conf impo...
[ 0, 1, 2 ]
import os import inspect import pytest from ._common import copy_default_profile_collection, patch_first_startup_file from bluesky_queueserver.manager.profile_tools import global_user_namespace, load_devices_from_happi from bluesky_queueserver.manager.profile_ops import load_profile_collection def create_local_impor...
normal
{ "blob_id": "ad1ec5dd8fae290ab6cb73b17c5522e062261359", "index": 6698, "step-1": "<mask token>\n\n\ndef create_local_imports_files(tmp_path):\n path_dir = os.path.join(tmp_path, 'dir_local_imports')\n fln_func = os.path.join(path_dir, 'file_func.py')\n fln_gen = os.path.join(path_dir, 'file_gen.py')\n ...
[ 5, 6, 7, 8, 9 ]
import RPi.GPIO as GPIO import time from datetime import datetime led1 = [('g', 40), ('f', 38), ('a', 36), ('b', 32), ('e', 26), ('d', 24), ('c', 22)] led2 = [('g', 19), ('f', 15), ('a', 13), ('b', 11), ('e', 7), ('d', 5), ('c', 3)] numbers = [ ('a', 'b', 'c', 'd', 'e', 'f'), ('b', 'c'), ('...
normal
{ "blob_id": "0d022291f9ace02ef1ee5c462657ea6376a0e6a4", "index": 9436, "step-1": "<mask token>\n\n\ndef setupLed1():\n for port in led1:\n GPIO.setup(port[1], GPIO.OUT)\n\n\ndef setupLed2():\n for port in led2:\n GPIO.setup(port[1], GPIO.OUT)\n\n\ndef statusLed(port, status):\n GPIO.output...
[ 10, 11, 12, 13, 15 ]
<|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": "8cdd7646dbf23259e160186f332b5cb02b67291b", "index": 5121, "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 = [('app1', '000...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ModD(Soppa): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ModD(Soppa): needs = ['test_project.modf'] something = 1 <|reser...
flexible
{ "blob_id": "13da16ba89e4743b12d9b8e24929864747f8bbf2", "index": 1308, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ModD(Soppa):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ModD(Soppa):\n needs = ['test_project.modf']\n something = 1\n", "step-4": "fro...
[ 0, 1, 2, 3 ]
''' This program will simulate leveling a DnD character, showing their ending HP, and stats. ''' import argparse import csv import json import re import time from openpyxl import load_workbook from pandas import DataFrame from src import classes, util def import_race_data(file_path): ''' This method imports d...
normal
{ "blob_id": "022c8d6c31ad5494b03bfe93d17396eac25b011e", "index": 8706, "step-1": "<mask token>\n\n\ndef update_mode(args):\n \"\"\"\n This method is the main method for running this program in Update mode.\n\n Update mode takes in a specifically formated XLSX file and outputs a JSON\n file containing...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Messages(SQLMixin, SQLBase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1...
flexible
{ "blob_id": "6fbf64e2dc2836a54e54ee009be1d0d8d7c7037a", "index": 1688, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Messages(SQLMixin, SQLBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Messages(SQLMixin...
[ 0, 1, 2, 3 ]
import re, os, nltk, pymorphy2, sys from suffix_trees.STree import STree def make_rules(folder): rules_dictionary = {} try: path = os.path.join(os.getcwd(), 'rules', 'data', folder) files = os.listdir(path) except: path = os.path.join(os.getcwd(), 'data', folder) files = os...
normal
{ "blob_id": "1bf9785135f6105301d02602e54cbbcbdd249144", "index": 9283, "step-1": "<mask token>\n\n\ndef make_rules(folder):\n rules_dictionary = {}\n try:\n path = os.path.join(os.getcwd(), 'rules', 'data', folder)\n files = os.listdir(path)\n except:\n path = os.path.join(os.getcwd...
[ 4, 5, 7, 8, 9 ]
# The project is based on Tensorflow's Text Generation with RNN tutorial # Copyright Petros Demetrakopoulos 2020 import tensorflow as tf import numpy as np import os import time # The project is based on Tensorflow's Text Generation with RNN tutorial # Copyright Petros Demetrakopoulos 2020 import tensorflow as tf impor...
normal
{ "blob_id": "5ff0c6bde8f3ffcb1f5988b0bbd1dfdd7fa2e818", "index": 8800, "step-1": "<mask token>\n\n\ndef yuh():\n corpus_path = '/tmp/data.txt'\n text = open(corpus_path, 'rb').read().decode(encoding='utf-8')\n text = preprocessText(text)\n corpus_words = corpusToList(text)\n map(str.strip, corpus_...
[ 6, 7, 8, 9, 11 ]
class CustomPrinter(object): def __init__(self, val): self.val = val def to_string(self): res = "{" for m in xrange(64): res += hex(int(self.val[m])) if m != 63: res += ", " res += " }" return res def lookup_type(val): if str...
normal
{ "blob_id": "4d5b2ed016cfc6740c3ee5397c894fabc1bec73f", "index": 6963, "step-1": "class CustomPrinter(object):\n <mask token>\n\n def to_string(self):\n res = '{'\n for m in xrange(64):\n res += hex(int(self.val[m]))\n if m != 63:\n res += ', '\n re...
[ 2, 3, 4, 5, 6 ]
# -*- coding:utf-8 -*- """ 逆波兰表达式,中缀表达式可以对应一棵二叉树,逆波兰表达式即该二叉树后续遍历的结果。 """ def isOperator(c): return c == '+' or c == '-' or c == '*' or c == '/' def reversePolishNotation(p): stack = list() for cur in p: if not isOperator(cur): stack.append(cur) else: b = float(sta...
normal
{ "blob_id": "93a47d6ba1f699d881f0d22c4775433e4a451890", "index": 6168, "step-1": "# -*- coding:utf-8 -*-\n\n\"\"\"\n逆波兰表达式,中缀表达式可以对应一棵二叉树,逆波兰表达式即该二叉树后续遍历的结果。\n\"\"\"\n\ndef isOperator(c):\n return c == '+' or c == '-' or c == '*' or c == '/'\n\n\ndef reversePolishNotation(p):\n stack = list()\n for cur ...
[ 0 ]
<|reserved_special_token_0|> class Cuneiform(pp.unicode_set): <|reserved_special_token_0|> _ranges: List[Tuple[int, ...]] = [(66432, 66517), (73728, 74751), ( 74752, 74879)] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Cuneiform(pp.unicode_set): ...
flexible
{ "blob_id": "bc1aefd0b0a87b80a10cecf00407b4608a6902b5", "index": 3897, "step-1": "<mask token>\n\n\nclass Cuneiform(pp.unicode_set):\n <mask token>\n _ranges: List[Tuple[int, ...]] = [(66432, 66517), (73728, 74751), (\n 74752, 74879)]\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Cuneif...
[ 1, 3, 4, 5, 6 ]
#!/usr/bin/python #_*_coding:utf-8_*_ import random def main(): source = "I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind ." words = source.strip().split(" ") new_str = list() for word in words: if len(word) > 4: shuff...
normal
{ "blob_id": "14b98186fbc9c275cea3c042cdb4899f6d0c54c6", "index": 3419, "step-1": "#!/usr/bin/python\n#_*_coding:utf-8_*_\n\nimport random\n\ndef main():\n source = \"I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind .\"\n words = source.strip()....
[ 0 ]
#!/usr/bin/python import platform from numpy import ctypeslib,empty,array,exp,ascontiguousarray,zeros,asfortranarray from ctypes import c_float,c_double,c_int from time import time def resize(img,scale): """ downsample img to scale """ sdims=img.shape datatype=c_double if img.dtype!=data...
normal
{ "blob_id": "816f4cfe98f5e5b23f2c8f9f42c5f3ed8458042f", "index": 3700, "step-1": "#!/usr/bin/python \n\nimport platform\nfrom numpy import ctypeslib,empty,array,exp,ascontiguousarray,zeros,asfortranarray\nfrom ctypes import c_float,c_double,c_int\nfrom time import time\n\ndef resize(img,scale):\n \"\"\"\n ...
[ 0 ]
#!/usr/bin/env python #coding:utf-8 """ Author: Wusf --<wushifan221@gmail.com> Purpose: Created: 2016/2/29 """ import os,sys,sqlite3 MyQtLibPath = os.path.abspath("D:\\MyQuantLib\\") sys.path.append(MyQtLibPath) import PCA.PCA_For_Stat_Arb2 as pca import pandas as pd import numpy as np import time def Compu...
normal
{ "blob_id": "70cda2d6d3928cd8008daf221cd78665a9b05eea", "index": 7064, "step-1": "#!/usr/bin/env python\n#coding:utf-8\n\"\"\"\n Author: Wusf --<wushifan221@gmail.com>\n Purpose: \n Created: 2016/2/29\n\"\"\"\n\nimport os,sys,sqlite3\nMyQtLibPath = os.path.abspath(\"D:\\\\MyQuantLib\\\\\")\nsys.path.append(M...
[ 0 ]
<|reserved_special_token_0|> class CNN(object): def __init__(self): self.model = tf.keras.Sequential([tf.keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(150, 150, 1)), tf.keras.layers. MaxPool2D((2, 2)), tf.keras.layers.Conv2D(64, (3, 3), activation='re...
flexible
{ "blob_id": "9535335c70129f997d7b8739444a503d0b984ac8", "index": 9753, "step-1": "<mask token>\n\n\nclass CNN(object):\n\n def __init__(self):\n self.model = tf.keras.Sequential([tf.keras.layers.Conv2D(32, (3, 3),\n activation='relu', input_shape=(150, 150, 1)), tf.keras.layers.\n ...
[ 12, 13, 14, 15, 16 ]
a=int(input()) s=0 t=0 while(a!=0): t=a%10 s=s+t a=a//10 print(s)
normal
{ "blob_id": "6050e83e73faaf40cbd5455efd3ad01e4e131188", "index": 2587, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile a != 0:\n t = a % 10\n s = s + t\n a = a // 10\nprint(s)\n", "step-3": "a = int(input())\ns = 0\nt = 0\nwhile a != 0:\n t = a % 10\n s = s + t\n a = a // 10\npri...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(type(data)) <|reserved_special_token_0|> print(data) <|reserved_special_token_1|> <|reserved_special_token_0|> url = 'http://icanhazdadjoke.com/' response = requests.get(url, headers={'Accept': 'application/json'}) data =...
flexible
{ "blob_id": "f94894e5d3e6a0ff367911c72f4d863ac32c8baa", "index": 1435, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(type(data))\n<mask token>\nprint(data)\n", "step-3": "<mask token>\nurl = 'http://icanhazdadjoke.com/'\nresponse = requests.get(url, headers={'Accept': 'application/json'})\ndata ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def segment_ts(): ts_len = len(x1) mod = ts_len % window_size rnge = 0 if skip_offset == 0: ts_len = int((ts_len - mod - window_size) / 1) rnge = int(ts_len / window_size) else: ts_len = int(math.ceil((ts_len - window_size) / skip_offset)) ...
flexible
{ "blob_id": "16215ee42c4ea284dca0ebb7372fef04c0cc54b9", "index": 2149, "step-1": "<mask token>\n\n\ndef segment_ts():\n ts_len = len(x1)\n mod = ts_len % window_size\n rnge = 0\n if skip_offset == 0:\n ts_len = int((ts_len - mod - window_size) / 1)\n rnge = int(ts_len / window_size)\n ...
[ 4, 5, 6, 7, 8 ]
def isSubsetSum(set, n, sum): subset =([[False for i in range(sum + 1)] for i in range(n + 1)]) for i in range(n + 1): subset[i][0] = True for i in range(1, sum + 1): subset[0][i]= False for i in range(1, n + 1): for j in range(1, sum + 1): if j<set[i-1]: ...
normal
{ "blob_id": "830e7e84eebd6a4adb411cc95c9e9c8ff7bdac30", "index": 778, "step-1": "<mask token>\n", "step-2": "def isSubsetSum(set, n, sum):\n subset = [[(False) for i in range(sum + 1)] for i in range(n + 1)]\n for i in range(n + 1):\n subset[i][0] = True\n for i in range(1, sum + 1):\n s...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def split_matrix(ratings, num_users, num_movies): X = np.zeros((num_users, num_movies)) for r in np.arange(len(ratings)): X[ratings[r, 0] - 1, ratings[r, 1] - 1] = ratings[r, 2] return X def mf_gd(ratings, num_users, num_movies): X_data = split_matrix(ratings, nu...
flexible
{ "blob_id": "b4267612e7939b635542099e1ba31e661720607a", "index": 3129, "step-1": "<mask token>\n\n\ndef split_matrix(ratings, num_users, num_movies):\n X = np.zeros((num_users, num_movies))\n for r in np.arange(len(ratings)):\n X[ratings[r, 0] - 1, ratings[r, 1] - 1] = ratings[r, 2]\n return X\n\...
[ 2, 3, 4, 5, 7 ]
<|reserved_special_token_0|> def on_identity_changed(app, identity): g.identity = identity session['identity'] = identity def configure_signals(app): identity_changed.connect(on_identity_changed, app) <|reserved_special_token_0|> def configure_before_handlers(app): @app.before_request def a...
flexible
{ "blob_id": "ef124e8c15ef347efd709a5e3fb104c7fd1bccde", "index": 2753, "step-1": "<mask token>\n\n\ndef on_identity_changed(app, identity):\n g.identity = identity\n session['identity'] = identity\n\n\ndef configure_signals(app):\n identity_changed.connect(on_identity_changed, app)\n\n\n<mask token>\n\n...
[ 6, 8, 9, 10, 13 ]
from PyQt5.QtWidgets import * import sys import math Data = '' class Button: def __init__(self, text, results): self.b = QPushButton(str(text)) self.text = text self.results = results self.b.clicked.connect(lambda: self.handleInput( self.text)) # Important because we ...
normal
{ "blob_id": "b08cface601ee07125090f3ae03a3120974688f2", "index": 8765, "step-1": "<mask token>\n\n\nclass Widget2:\n\n def setup(self, MainWindow, res):\n self.widget = QWidget()\n self.grid = QGridLayout()\n self.results = QLineEdit()\n self.results.setText(res)\n row = 3\n...
[ 8, 9, 11, 13, 17 ]
import random my_randoms = random.sample(100, 10) print(my_randoms)
normal
{ "blob_id": "d39f6fca80f32a4d13764eb5cfb29999785b1d16", "index": 1629, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(my_randoms)\n", "step-3": "<mask token>\nmy_randoms = random.sample(100, 10)\nprint(my_randoms)\n", "step-4": "import random\nmy_randoms = random.sample(100, 10)\nprint(my_rando...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def hdfs_get_filelist(blob_path, delimiter='_'): """ Lists hdfs dir and returns named tuples with information of file based on its filename. """ def hdfs_listdir(blob_path): command = 'hdfs dfs -ls ' + blob_path...
flexible
{ "blob_id": "6909e70db4f907e26ad604f95c79a405010907bd", "index": 2086, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef hdfs_get_filelist(blob_path, delimiter='_'):\n \"\"\" Lists hdfs dir and returns named tuples with information of file based on its filename. \"\"\"\n\n def hdfs_listdir(blo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def transform_word(word): """ 将低频词转为四种形式之一。 """ if any(c.isdigit() for c in word): return '_NUMERIC_' if word.isupper(): return '_ALL_CAP_' if word[-1].isupper(): return '_LAST_CAP...
flexible
{ "blob_id": "92a1f86ce8cc9563d455f9b1336dbcd298f01b6d", "index": 1747, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef transform_word(word):\n \"\"\"\n 将低频词转为四种形式之一。\n \"\"\"\n if any(c.isdigit() for c in word):\n return '_NUMERIC_'\n if word.isupper():\n return '_ALL_...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class CommentViewSet(viewsets.GenericViewSet, mixins.ListModelMixin, mixins .RetrieveModelMixin): queryset = Comment.objects.all() def get_serializer_class(self): if self.action == 'retrieve': if self.get_object().level < 3: return CommentS...
flexible
{ "blob_id": "9bc13c608c079cbf23ed04f29edd1fd836214cde", "index": 282, "step-1": "<mask token>\n\n\nclass CommentViewSet(viewsets.GenericViewSet, mixins.ListModelMixin, mixins\n .RetrieveModelMixin):\n queryset = Comment.objects.all()\n\n def get_serializer_class(self):\n if self.action == 'retrie...
[ 3, 4, 5, 6 ]
import numpy as np from scipy.stats import multivariate_normal from functions.io_data import read_data, write_data np.random.seed(0) class IsingModel(): def __init__(self, image, J, rate, sigma): self.width = image.shape[0] self.height = image.shape[1] self._J = J self._rate = rat...
normal
{ "blob_id": "6aa74826f9ca0803fa8c1d5af1d4cec4980e2ce6", "index": 9064, "step-1": "<mask token>\n\n\nclass IsingModel:\n\n def __init__(self, image, J, rate, sigma):\n self.width = image.shape[0]\n self.height = image.shape[1]\n self._J = J\n self._rate = rate\n self._sigma =...
[ 4, 5, 6, 7, 10 ]
from unittest import TestCase, main class Solution: def productExceptSelf(self, nums): right, rs = 1, [1]*len(nums) for i in range(1,len(nums)): rs[i] = nums[i-1]*rs[i-1] for i in range(len(nums)-1, -1, -1): rs[i], right = rs[i]*right, right*nums[i] return rs class testsolution(Tes...
normal
{ "blob_id": "9e34fcec3af746af37cb68fd8617c706cc1066f6", "index": 1743, "step-1": "<mask token>\n\n\nclass testsolution(TestCase):\n\n def setUp(self):\n self.solution = Solution()\n self.inout = [([1, 2, 3, 4], [24, 12, 8, 6]), ([4, 5, 1, 8, 2], [80,\n 64, 320, 40, 160])]\n\n def t...
[ 3, 4, 5, 6, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def divide_img(img_path, img_name, save_path): imgg = img_path + '\\' + img_name print(imgg) img = cv2.imread(imgg) print(img) h = img.shape[0] w = img.shape[1] n = 8 m = 8 print('h={},w={},n=...
flexible
{ "blob_id": "03f3fcb38877570dea830a56460061bd3ccb8927", "index": 8830, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef divide_img(img_path, img_name, save_path):\n imgg = img_path + '\\\\' + img_name\n print(imgg)\n img = cv2.imread(imgg)\n print(img)\n h = img.shape[0]\n w = img...
[ 0, 1, 2, 3, 4 ]
# import libraries import pandas as pd import matplotlib.pyplot as plt import numpy as np import warnings import pickle from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.metrics import accuracy_score from sklearn.metrics import mean_squared_error impor...
normal
{ "blob_id": "1508697f93114d7f20182a3e9c1df5617904529a", "index": 8725, "step-1": "<mask token>\n", "step-2": "<mask token>\nlr.fit(x_train, y_train)\n<mask token>\npickle.dump(lr, open('model.pkl', 'wb'))\n", "step-3": "<mask token>\ndataset = pd.read_csv('heart.csv')\ndf = dataset.copy()\nX = df.drop(['targ...
[ 0, 1, 2, 3, 4 ]
#! /usr/bin/env python import tensorflow as tf import numpy as np import os import time import datetime import data_helpers from text_rnn import TextRNN from tensorflow.contrib import learn # Parameters # ================================================== # Data loading params flags = tf.app.flags FLAGS = flags.FLA...
normal
{ "blob_id": "aa1a7de92b971b6d10d09b2f8ca2c55516e538e4", "index": 9904, "step-1": "<mask token>\n", "step-2": "<mask token>\ntf.flags.DEFINE_integer('embedding_dim', 100,\n 'Dimensionality of character embedding (default: 100)')\ntf.flags.DEFINE_float('dropout_keep_prob', 0.5,\n 'Dropout keep probability ...
[ 0, 1, 2, 3, 4 ]
# 1로 만들기 import sys N = int(sys.stdin.readline()) dp_table = [0 for _ in range(10**6 + 1)] dp_table[2], dp_table[3] = 1, 1 for i in range(4,N+1): two_per = 10**6 three_per = 10**6 if i % 3 ==0: three_per = dp_table[i//3] + 1 if i % 2 ==0: two_per = dp_table[i//2] + 1 minus = dp_tabl...
normal
{ "blob_id": "34a8fc38ed875e1c564f535348dc0d5d88c76ab1", "index": 7281, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(4, N + 1):\n two_per = 10 ** 6\n three_per = 10 ** 6\n if i % 3 == 0:\n three_per = dp_table[i // 3] + 1\n if i % 2 == 0:\n two_per = dp_table[i /...
[ 0, 1, 2, 3, 4 ]
import pyForp import pprint pp = pprint.PrettyPrinter(indent=4) def fib(n): if n < 2: return n return fib(n-2) + fib(n-1) forp = pyForp.pyForp() forp.start() print fib(2) forp.stop() pp.pprint(forp.dump())
normal
{ "blob_id": "80f9c4b7261a894aad2c738d976cfb8efc4d228c", "index": 4784, "step-1": "import pyForp\nimport pprint\npp = pprint.PrettyPrinter(indent=4)\ndef fib(n):\n if n < 2:\n return n\n return fib(n-2) + fib(n-1)\n\nforp = pyForp.pyForp()\nforp.start()\nprint fib(2)\nforp.stop()\npp.pprint(forp.dump...
[ 0 ]