code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
import time import unittest from unittest import TestCase from selenium import webdriver from simon.accounts.pages import LoginPage from simon.header.pages import HeaderPage from simon.pages import BasePage class RegistrationBaseTestCase(TestCase): def setUp(self): self.driver = webdriver.Firefox() ...
normal
{ "blob_id": "380a28958fc6d1b403b29ede229860bf5f709572", "index": 2550, "step-1": "<mask token>\n\n\nclass LoginPageTests(RegistrationBaseTestCase):\n\n def test_can_open_whatsapp_login_page(self):\n self.assertTrue(self.login_page.is_title_matches())\n self.assertTrue(self.login_page.is_instruct...
[ 8, 10, 12, 13, 14 ]
<|reserved_special_token_0|> class Team(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> def __str__(self): return self.name + ' ' + str(self.id) class Leaderboard(models.Model): end_date = models.DateField(auto_now=True) submit_deadline = models.DateField(auto_n...
flexible
{ "blob_id": "dc27781d0c3129d11aa98a5889aea0383b5a49d6", "index": 3571, "step-1": "<mask token>\n\n\nclass Team(models.Model):\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.name + ' ' + str(self.id)\n\n\nclass Leaderboard(models.Model):\n end_date = models.DateField(auto_no...
[ 8, 9, 10, 13, 15 ]
from typing import List from uuid import uuid4 from fastapi import APIRouter, Depends, FastAPI, File, UploadFile from sqlalchemy.orm import Session from starlette.requests import Request from Scripts.fastapp.common.consts import UPLOAD_DIRECTORY from Scripts.fastapp.database.conn import db # from Scripts.fastapp.data...
normal
{ "blob_id": "349581774cded59ece6a5e8178d116c166a4a6b3", "index": 6841, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@router.get('/getIsPID', response_model=List[m.GetIsPID])\nasync def show_data(request: Request, ispid):\n \"\"\"\n no params\n\n :return\n\n [\n\n {\n\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Null(torch.optim.Optimizer): <|reserved_special_token_0|> <|reserved_special_token_0|> class NoOp(object): def __init__(self, parameters: typing.Iterator[torch.nn.Parameter]): self.optimizers = [Null(parameters)] def step(self, closure=None): retu...
flexible
{ "blob_id": "3c7237e5770dd5552c327dbf53451a2889ea8c6b", "index": 7198, "step-1": "<mask token>\n\n\nclass Null(torch.optim.Optimizer):\n <mask token>\n <mask token>\n\n\nclass NoOp(object):\n\n def __init__(self, parameters: typing.Iterator[torch.nn.Parameter]):\n self.optimizers = [Null(paramete...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_param_num(param): value = 1 try: value = rospy.get_param(param) if not isinstance(value, (int, float, long)): err_msg = 'Param %s is not an number' % param rospy.logerr(err...
flexible
{ "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 ]
table = None width = 1000 height = 1000 def setup(): global table table = loadTable("flights.csv", "header") size(width, height) noLoop() noStroke() def draw(): global table background(255, 255, 255) for row in table.rows(): from_x = map(row.getFloat('from_long'), -180, 1...
normal
{ "blob_id": "a2eabf4dae931d82e4e9eda87d79031711faf1aa", "index": 2221, "step-1": "<mask token>\n\n\ndef mouseMoved():\n redraw()\n", "step-2": "<mask token>\n\n\ndef setup():\n global table\n table = loadTable('flights.csv', 'header')\n size(width, height)\n noLoop()\n noStroke()\n\n\n<mask t...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class CropRecord(db.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "01a6283d2331590082cdf1d409ecdb6f93459882", "index": 4861, "step-1": "<mask token>\n\n\nclass CropRecord(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass CropRecord(db.Model):\n year = db...
[ 1, 5, 9, 10, 11 ]
import os from test.test_unicode_file_functions import filenames def writeUniquerecords(dirpath,filenames): sourcepath=os.path.join(dirpath,filenames) with open(sourcepath,'r') as fp: lines= fp.readlines() destination_lines=[] for line in lines: if line not in destination_l...
normal
{ "blob_id": "4ed730369cf065936569a8515de44042829c2143", "index": 1201, "step-1": "<mask token>\n\n\ndef writeUniquerecords(dirpath, filenames):\n sourcepath = os.path.join(dirpath, filenames)\n with open(sourcepath, 'r') as fp:\n lines = fp.readlines()\n destination_lines = []\n for li...
[ 1, 2, 3, 4, 5 ]
import mclient from mclient import instruments import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl #from pulseseq import sequencer, pulselib mpl.rcParams['figure.figsize']=[6,4] qubit_info = mclient.get_qubit_info('qubit_info') qubit_ef_info = mclient.get_qubit_info('qubit_ef_info') ...
normal
{ "blob_id": "ba13bcf9e89ae96e9a66a42fc4e6ae4ad33c84b4", "index": 4497, "step-1": "import mclient\r\nfrom mclient import instruments\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib as mpl\r\n#from pulseseq import sequencer, pulselib\r\n\r\nmpl.rcParams['figure.figsize']=[6,4]\r\n\r\n...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def Mac(SystemArray=[], ProcessorArray=[]): OSName = str() OSVersionMajor = str() OSArchitecture = str() command = '/usr/sbin/sysctl -n machdep.cpu.brand_string' ProcInfo = os.popen(command).read().strip() ...
flexible
{ "blob_id": "f652fa6720582d50f57f04d82fb2f5af17859ebd", "index": 8211, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Mac(SystemArray=[], ProcessorArray=[]):\n OSName = str()\n OSVersionMajor = str()\n OSArchitecture = str()\n command = '/usr/sbin/sysctl -n machdep.cpu.brand_string'\n...
[ 0, 1, 2, 3 ]
# %% import pandas as pd import numpy as np from dataprep.eda import plot from dataprep.eda import plot_correlation from dataprep.eda import plot_missing import matplotlib.pyplot as plt import seaborn as sns sns.set(style="whitegrid", color_codes=True) sns.set(font_scale=1) # %% # Minimal Processing wines = pd.read...
normal
{ "blob_id": "79e8ed64058dda6c8d7bacc08727bc978088ad2d", "index": 4963, "step-1": "<mask token>\n", "step-2": "<mask token>\nsns.set(style='whitegrid', color_codes=True)\nsns.set(font_scale=1)\n<mask token>\nwines.columns\nwines.drop(columns='Unnamed: 0', inplace=True)\nwines.dropna(axis='index', subset=['price...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(20, 1090): X_train.append(training_set[i - 20:i, 0]) y_train.append(training_set[i, 0]) <|reserved_special_token_0|> classifier.add(Dense(output_dim=35, init='uniform', activation='relu', input_dim=20)) ...
flexible
{ "blob_id": "28a3763715f5405f8abe2de17ed5f9df1019278b", "index": 6878, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(20, 1090):\n X_train.append(training_set[i - 20:i, 0])\n y_train.append(training_set[i, 0])\n<mask token>\nclassifier.add(Dense(output_dim=35, init='uniform', activat...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class SimpleHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): def log_message(*args, **kwargs): pass <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SimpleHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): ...
flexible
{ "blob_id": "e839eba2514c29a8cfec462f8d5f56d1d5712c34", "index": 7413, "step-1": "<mask token>\n\n\nclass SimpleHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):\n\n def log_message(*args, **kwargs):\n pass\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass SimpleHTTPRequestHandler(http...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def pdf_to_png(filename): doc = fitz.open('pdf_files\\{}'.format(filename)) zoom = 4 page = doc.loadPage(0) mat = fitz.Matrix(zoom, zoom) pix = page.getPixmap(matrix=mat) new_filename = filename.replace('pdf', 'png') pix.writePNG('photo_files\\{}'.format(new_fi...
flexible
{ "blob_id": "84980b8923fa25664833f810a906d27531145141", "index": 1066, "step-1": "<mask token>\n\n\ndef pdf_to_png(filename):\n doc = fitz.open('pdf_files\\\\{}'.format(filename))\n zoom = 4\n page = doc.loadPage(0)\n mat = fitz.Matrix(zoom, zoom)\n pix = page.getPixmap(matrix=mat)\n new_filena...
[ 4, 5, 6, 7, 8 ]
""" Generates a temperature celsius to fahrenheit conversion table AT 11-10-2018 """ __author__ = "Aspen Thompson" header = "| Celsius | Fahrenheit |" line = "-" * len(header) print("{0}\n{1}\n{0}".format(line, header)) for i in range(-10, 31): print("| {:^7} | {:^10.10} |".format(i, i * 1.8 + 32))
normal
{ "blob_id": "591d0a166af5b8d0bed851c2f56ecc3da4f3a5eb", "index": 4367, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('{0}\\n{1}\\n{0}'.format(line, header))\nfor i in range(-10, 31):\n print('| {:^7} | {:^10.10} |'.format(i, i * 1.8 + 32))\n", "step-3": "<mask token>\n__author__ = 'Aspen Thom...
[ 0, 1, 2, 3 ]
from PyQt5.QtWidgets import QApplication, QWidget import sys class Calculator(QWidget): def __init__(self): self.number_str = "" self.version = "小树计算器 V1.0" super().__init__() self.resize(400,400) from PyQt5.uic import loadUi # 需要导入的模块 #loadUi("record.ui", self) ...
normal
{ "blob_id": "4df9af863a857c3bbc3c266d745a49b6ef78ba9b", "index": 1994, "step-1": "<mask token>\n\n\nclass Calculator(QWidget):\n <mask token>\n\n def accept_button_value(self, number):\n if number == 'Clean':\n self.number_str = ''\n elif number == 'Backspace':\n self.nu...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open('README.rst') as f: long_description = f.read() setup(name='logging_exceptions', version='0.1.8', py_modules=[ 'logging_exceptions'], author='Bernhard C. Thiel', author_email= 'thiel@tbi.univie.ac.at', descri...
flexible
{ "blob_id": "7f7adc367e4f3b8ee721e42f5d5d0770f40828c9", "index": 9365, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('README.rst') as f:\n long_description = f.read()\nsetup(name='logging_exceptions', version='0.1.8', py_modules=[\n 'logging_exceptions'], author='Bernhard C. Thiel', auth...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class CNN: def __init__(self, inputSize, hitLearn=0.1, momentum=0.9, weigthDecay= 0.5, multip=1.0): file = '%s/%s' % (DIR_LIBRARY, 'gpu_function.cl') file = file.encode('utf-8') self.cnn = c_Pointer() clib.createCnnWrapper(c.addressof(self.cnn)...
flexible
{ "blob_id": "32db21ed7f57f29260d70513d8c34de53adf12d7", "index": 5740, "step-1": "<mask token>\n\n\nclass CNN:\n\n def __init__(self, inputSize, hitLearn=0.1, momentum=0.9, weigthDecay=\n 0.5, multip=1.0):\n file = '%s/%s' % (DIR_LIBRARY, 'gpu_function.cl')\n file = file.encode('utf-8')\n...
[ 7, 12, 20, 21, 27 ]
import json from test.test_basic import BaseCase class TestUserRegister(BaseCase): """ TestClass to test the register function. """ def test_successful_register(self): # Given payload = json.dumps({ "username": "userjw", "password": "1q2w3e4r" }) ...
normal
{ "blob_id": "486362463dc07bdafea85de39a4a6d58cb8c8f26", "index": 9643, "step-1": "<mask token>\n\n\nclass TestUserRegister(BaseCase):\n <mask token>\n <mask token>\n\n def test_signup_with_non_existing_field(self):\n payload = json.dumps({'username': 'userjw', 'password': '1q2w3e4r',\n ...
[ 3, 5, 6, 8, 9 ]
""" Version information for NetworkX, created during installation. Do not add this file to the repository. """ import datetime version = '2.3' date = 'Thu Apr 11 20:57:18 2019' # Was NetworkX built from a development version? If so, remember that the major # and minor versions reference the "target" (rather than "...
normal
{ "blob_id": "814191a577db279389975e5a02e72cd817254275", "index": 9444, "step-1": "<mask token>\n", "step-2": "<mask token>\nversion = '2.3'\ndate = 'Thu Apr 11 20:57:18 2019'\ndev = False\nversion_info = 'networkx', '2', '3', None\ndate_info = datetime.datetime(2019, 4, 11, 20, 57, 18)\nvcs_info = None, (None,...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def LDOS_up(omega, E, u, Damping): t = sum(u ** 2 / (omega - E + 1.0j * Damping)) tt = -1 / pi * np.imag(t) return tt def LDOS_down(omega, E, v, Damping): t = sum(v ** 2 / (omega + E + 1.0j * Damping)) tt = -1 / pi * np.imag(t) return tt <|reserved_special_toke...
flexible
{ "blob_id": "f2ad95574b65b4d3e44b85c76f3a0150a3275cec", "index": 2356, "step-1": "<mask token>\n\n\ndef LDOS_up(omega, E, u, Damping):\n t = sum(u ** 2 / (omega - E + 1.0j * Damping))\n tt = -1 / pi * np.imag(t)\n return tt\n\n\ndef LDOS_down(omega, E, v, Damping):\n t = sum(v ** 2 / (omega + E + 1.0...
[ 2, 3, 4, 5, 6 ]
import csv import os with open("sample.csv") as rf: csv_reader=csv.DictReader(rf) with open("sample1.csv","w") as wf: csv_headers=['fname','lname','email'] if os.path.isfile('sample1.csv'): q=input("File already exists. Do you want to overwrite?") if q.lower()=='yes':...
normal
{ "blob_id": "43196258b61801799b8d6b7d23f5816d84cb5dff", "index": 7294, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('sample.csv') as rf:\n csv_reader = csv.DictReader(rf)\n with open('sample1.csv', 'w') as wf:\n csv_headers = ['fname', 'lname', 'email']\n if os.path.isfile...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def vel_det(file, legend_label, line_color): fps = 60 data_df = pd.read_hdf(path_or_buf=file) bodyparts = data_df.columns.get_level_values(1) coords = data_df.columns.get_level_values(2) bodyparts2plot = bodyparts scorer = data_df.columns.get_level_values(0)[0] ...
flexible
{ "blob_id": "ba5171d3de87ec01770a7174d9783d5058b0fced", "index": 9896, "step-1": "<mask token>\n\n\ndef vel_det(file, legend_label, line_color):\n fps = 60\n data_df = pd.read_hdf(path_or_buf=file)\n bodyparts = data_df.columns.get_level_values(1)\n coords = data_df.columns.get_level_values(2)\n b...
[ 1, 2, 3, 4, 5 ]
from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import RequestContext from django.db.models import Q from cvmo import settings from cvmo.context.models import ContextDefinition, Machines, ClusterDefinition, MarketplaceContextEntry from cvmo.context.plugins im...
normal
{ "blob_id": "4db8b4403dd9064b7d5f935d4b9d111508c965fb", "index": 1268, "step-1": "<mask token>\n\n\ndef dashboard(request):\n context = {'context_list': ContextDefinition.objects.filter(Q(owner=\n request.user) & Q(inherited=False) & Q(abstract=False)).order_by(\n '-public', 'name'), 'full_abstr...
[ 1, 3, 4, 5, 6 ]
import requests import sxtwl import datetime from datetime import date import lxml from lxml import etree # 日历中文索引 ymc = [u"十一", u"十二", u"正", u"二", u"三", u"四", u"五", u"六", u"七", u"八", u"九", u"十"] rmc = [u"初一", u"初二", u"初三", u"初四", u"初五", u"初六", u"初七", u"初八", u"初九", u"初十", \ u"十一", u"十二", u"十三", u"十四", u"十五", u"十...
normal
{ "blob_id": "e1d0648825695584d3ea518db961a9178ea0c66a", "index": 50, "step-1": "<mask token>\n\n\ndef china_lunar():\n today = str(date.today())\n today_list = today.split('-')\n lunar_day = lunar.getDayBySolar(int(datetime.datetime.now().year), int(\n datetime.datetime.now().month), int(datetime...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def householder_reflection(A): size = len(A) Q = np.identity(size) R = np.copy(A) for i in range(size - 1): x = R[i:, i] e = np.zeros_like(x) e[0] = np.linalg.norm(x) u = x - e v = u / np.linalg.norm(u) Q_count = np.identity(...
flexible
{ "blob_id": "0d1fda864edc73cc6a9853727228c6fa3dfb19a1", "index": 3039, "step-1": "<mask token>\n\n\ndef householder_reflection(A):\n size = len(A)\n Q = np.identity(size)\n R = np.copy(A)\n for i in range(size - 1):\n x = R[i:, i]\n e = np.zeros_like(x)\n e[0] = np.linalg.norm(x)...
[ 1, 2, 3, 4, 5 ]
# Takes in a word and makes a list containing individual characters def split(word): return [char for char in word] # Removes empty strings from a list def removeEmptyStrings(lst): while "" in lst: lst.remove("") ints = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] tokenList = [] class Token:...
normal
{ "blob_id": "8d5b75dc945844d48f52159be08fc1e6aa51fdf5", "index": 497, "step-1": "<mask token>\n\n\nclass Lexer:\n\n def __init__(self, items):\n self.items = split(items)\n self.index = 0\n self.item = ''\n self.stringOn = False\n self.stringList = ''\n self.intOn = F...
[ 8, 10, 14, 18, 19 ]
#proper clarification for requirement is required import boto3 s3_resource = boto3.resource('s3') s3_resource.create_bucket(Bucket=YOUR_BUCKET_NAME, CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'}) s3_resource.Bucket(first_bucket_name).upload_file(Filename=first_file_name, Key=first_file_name) s3_resource...
normal
{ "blob_id": "44097da54a0bb03ac14196712111a1489a956689", "index": 5387, "step-1": "<mask token>\n", "step-2": "<mask token>\ns3_resource.create_bucket(Bucket=YOUR_BUCKET_NAME,\n CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'})\ns3_resource.Bucket(first_bucket_name).upload_file(Filename=first_fi...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python L=['ABC','ABC'] con1=[] for i in range (0,len(L[1])): #con.append(L[1][i]) con=[] for j in range (0, len(L)): print(L[j][i]) con.append(L[j][i]) con1.append(con) con2=[] for k in range (0,len(con1)): if con1[k].count('A')==2: con2.append('a') elif con1[k].count('B')...
normal
{ "blob_id": "beb9fe8e37a4f342696a90bc624b263e341e4de5", "index": 5459, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(0, len(L[1])):\n con = []\n for j in range(0, len(L)):\n print(L[j][i])\n con.append(L[j][i])\n con1.append(con)\n<mask token>\nfor k in range(0, len...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Vehicle(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Vehicle(object): <|reserved_special_token_0|> def __init__(self, registration_number): self.registration_number = r...
flexible
{ "blob_id": "8b9336113f64a88eeabe6e45021938fac9efd1c6", "index": 6442, "step-1": "<mask token>\n", "step-2": "class Vehicle(object):\n <mask token>\n <mask token>\n", "step-3": "class Vehicle(object):\n <mask token>\n\n def __init__(self, registration_number):\n self.registration_number = ...
[ 0, 1, 2, 3 ]
from os import environ from flask import Flask from flask_restful import Api from flask_migrate import Migrate from applications.db import db from applications.gamma_api import add_module_gamma app = Flask(__name__) app.config["DEBUG"] = True app.config['SQLALCHEMY_DATABASE_URI'] = environ.get('DATABASE') app.config...
normal
{ "blob_id": "fbb081fd52b14336ab4537bb795105bcd6a03070", "index": 3045, "step-1": "<mask token>\n\n\n@app.before_first_request\ndef create_tables():\n pass\n\n\n<mask token>\n", "step-2": "<mask token>\ndb.init_app(app)\n<mask token>\n\n\n@app.before_first_request\ndef create_tables():\n pass\n\n\nadd_mod...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class MonteCarloGameDriver: def __init__(self): self.default_moves = np.array(['w', 'a', 's', 'd']) self.probability_distribution = np.array([0.25, 0.25, 0.25, 0.25]) <|reserved_special_token_0|> def simulate(self, game, simulation_size): from collect...
flexible
{ "blob_id": "aeb986360c6990f9375f2552cbdeef595af815b4", "index": 6432, "step-1": "<mask token>\n\n\nclass MonteCarloGameDriver:\n\n def __init__(self):\n self.default_moves = np.array(['w', 'a', 's', 'd'])\n self.probability_distribution = np.array([0.25, 0.25, 0.25, 0.25])\n <mask token>\n\n...
[ 5, 6, 7, 8, 9 ]
from django.shortcuts import render, get_object_or_404, redirect from django.contrib.contenttypes.models import ContentType from User.forms import EditProfileForm from User import forms from django.db.models import Q from django.contrib import messages from django.urls import reverse from django.http import HttpRespons...
normal
{ "blob_id": "e9fab2bb49cfda00b8cfedafab0009f691d11ec9", "index": 9924, "step-1": "<mask token>\n\n\ndef post_create(request):\n form = PostForm(request.POST or None, request.FILES or None)\n if request.method == 'POST':\n user = request.POST.get('user')\n title = request.POST.get('title')\n ...
[ 5, 6, 7, 8, 10 ]
from rest_framework import status from rest_framework.response import Response from rest_framework.decorators import api_view, permission_classes from rest_framework.permissions import IsAuthenticated from playlist.models import Song, AccountSong, Genre, AccountGenre from account.models import Account from play...
normal
{ "blob_id": "ff53a549222b0d5e2fcb518c1e44b656c45ce76e", "index": 5183, "step-1": "<mask token>\n\n\n@api_view(['POST'])\n@permission_classes((IsAuthenticated,))\ndef create_account_genre_view(request):\n title = request.data.get('title', '0')\n try:\n genre = Genre.objects.get(title=title)\n exce...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> @app.route('/login/') def login(): return render_template('login.html', name=None) @app.route('/chat/') def chat(): return render_template('chat.html', name=None) @app.route('/messages/') def msg_search(): return render_template('search.html', name=None) <|reserved_speci...
flexible
{ "blob_id": "a945d7f673d009a59e597cd3c99a886094ea9e57", "index": 2639, "step-1": "<mask token>\n\n\n@app.route('/login/')\ndef login():\n return render_template('login.html', name=None)\n\n\n@app.route('/chat/')\ndef chat():\n return render_template('chat.html', name=None)\n\n\n@app.route('/messages/')\nde...
[ 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def make_id2class(args): if args.dataset == 'caltech101': return caltech.id2class <|reserved_special_token_1|> <|reserved_special_token_0|> def make_data_loader(args, **kwargs): if args.dataset == 'caltech10...
flexible
{ "blob_id": "1ea71f7b17809189eeacf19a6b7c4c7d88a5022c", "index": 1070, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef make_id2class(args):\n if args.dataset == 'caltech101':\n return caltech.id2class\n", "step-3": "<mask token>\n\n\ndef make_data_loader(args, **kwargs):\n if args.d...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Sat Mar 21 09:46:47 2020 @author: Carlos Jose Munoz """ # se importa el modelo y vista para que sesten comunicados por medio del controlador from Modelo import ventanadentrada from Vista import Ventanainicio,dosventana import sys from PyQt5.QtWidgets import QApplication clas...
normal
{ "blob_id": "3329db63552592aabb751348efc5d983f2cc3f36", "index": 1828, "step-1": "<mask token>\n\n\nclass Controlador(object):\n\n def __init__(self, vista, modelo, vista2):\n self._mi_vista = vista\n self._mi_modelo = modelo\n self._mi2_ventana = vista2\n\n def recibirruta(self, r):\n...
[ 7, 8, 9, 10, 12 ]
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 # # This code is sample only. Not for use in production. # # Author: Babu Srinivasan # Contact: babusri@amazon.com, babu.b.srinivasan@gmail.com # # Spark Streaming ETL script # Input: # 1/ Kinesis Data Strea...
normal
{ "blob_id": "fcccbc8d582b709aa27500ef28d86103e98eee4c", "index": 7980, "step-1": "<mask token>\n\n\ndef populateTimeInterval(rec):\n out_ts = (rec['event_time'] - TEMP_TS) // DELTA_MINS * DELTA_MINS + TEMP_TS\n rec['intvl_date'] = datetime.datetime.strftime(out_ts, '%Y-%m-%d')\n rec['intvl_hhmm'] = date...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class Shape(ABC): @abstractmethod def area(self): pass <|reserved_special_token_0|> class Square(Shape): def __init__(self, length): self.length = length <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class...
flexible
{ "blob_id": "520b9246c3c617b18ca57f31ff51051cc3ff51ca", "index": 5517, "step-1": "<mask token>\n\n\nclass Shape(ABC):\n\n @abstractmethod\n def area(self):\n pass\n <mask token>\n\n\nclass Square(Shape):\n\n def __init__(self, length):\n self.length = length\n\n\n<mask token>\n", "ste...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class PersistableClassificationModel(Classification): <|reserved_special_token_0|> def __init__(self, output_dir, origin): self.originModel = origin if not os.path.isdir(output_dir): os.mkdir(output_dir) self.path_to_persist = os.path.join(outp...
flexible
{ "blob_id": "a4697f0a0d0cc264b28a58bcc28528c221b4cb49", "index": 3807, "step-1": "<mask token>\n\n\nclass PersistableClassificationModel(Classification):\n <mask token>\n\n def __init__(self, output_dir, origin):\n self.originModel = origin\n if not os.path.isdir(output_dir):\n os....
[ 3, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('^buildings_csv/$', buildings_upload, name= 'buildings_upload'), url('^keytype_csv/$', keytype_upload, name= 'keytype_upload'), url('^key_csv/$', key_upload, name='key_upload'), url('^keystatus_csv/$...
flexible
{ "blob_id": "4a0d8e6b6205fa57b8614857e1462203a2a7d2c5", "index": 3002, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^buildings_csv/$', buildings_upload, name=\n 'buildings_upload'), url('^keytype_csv/$', keytype_upload, name=\n 'keytype_upload'), url('^key_csv/$', key_upload, ...
[ 0, 1, 2, 3 ]
""" Copyright © 2017 Bilal Elmoussaoui <bil.elmoussaoui@gmail.com> This file is part of Authenticator. Authenticator is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at ...
normal
{ "blob_id": "a7d8efe3231b3e3b9bfc5ef64a936816e8b67d6c", "index": 3127, "step-1": "<mask token>\n\n\n@Gtk.Template(resource_path=\n '/com/github/bilelmoussaoui/Authenticator/settings.ui')\nclass SettingsWindow(Handy.PreferencesWindow):\n <mask token>\n dark_theme_switch: Gtk.Switch = Gtk.Template.Child()...
[ 10, 11, 13, 19, 21 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while m != 0: m = int(input()) if m > maximum: maximum = m count = 1 elif m == maximum: count += 1 print(count) <|reserved_special_token_1|> count = 0 maximum = -1 m = -1 while m != 0: m ...
flexible
{ "blob_id": "0e1ea8c7fba90c1b5d18eaa399b91f237d4defee", "index": 2568, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile m != 0:\n m = int(input())\n if m > maximum:\n maximum = m\n count = 1\n elif m == maximum:\n count += 1\nprint(count)\n", "step-3": "count = 0\nmaxi...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('register/', register, name='register'), path( 'channel/', channel, name='channel'), path('login/', auth_views. LoginView.as_view(template_name='user/login.html'), name='login'), path ('logout/', au...
flexible
{ "blob_id": "d76c1507594bb0c1ed7a83e6c5961097c7fbf54a", "index": 9859, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('register/', register, name='register'), path(\n 'channel/', channel, name='channel'), path('login/', auth_views.\n LoginView.as_view(template_name='user/login.h...
[ 0, 1, 2, 3 ]
""" All rights reserved to cnvrg.io http://www.cnvrg.io cnvrg.io - Projects Example last update: Nov 07, 2019. ------------- rnn.py ============================================================================== """ import argparse import numpy as np import pandas as pd import tensorflow as tf from tensorflow i...
normal
{ "blob_id": "fbac2d66f4d69a52c3df5d665b622659e4d8dacd", "index": 5733, "step-1": "<mask token>\n\n\ndef cast_types(args):\n args.epochs = int(args.epochs)\n args.batch_size = int(args.batch_size)\n args.input_shape = args.input_shape.split(' ')\n for num in args.input_shape:\n if num != '':\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def check_cookie(request): result = {'status': True} try: user_id = request.GET.get('user_id') user = User.objects.get(pk=user_id) cookie_status = user.profile.cookie_status if cookie_status is Status.DEACTIVATE: result['cookie_status'] ...
flexible
{ "blob_id": "2bc3b0df720788e43da3d9c28adb22b3b1be8c58", "index": 5002, "step-1": "<mask token>\n\n\ndef check_cookie(request):\n result = {'status': True}\n try:\n user_id = request.GET.get('user_id')\n user = User.objects.get(pk=user_id)\n cookie_status = user.profile.cookie_status\n ...
[ 1, 2, 3, 4, 5 ]
from Adafruit_LSM9DS0 import Adafruit_LSM9DS0 import math imu = Adafruit_LSM9DS0() pi = 3.14159265358979323846 # Written here to increase performance/ speed r2d = 57.2957795 # 1 radian in degrees loop = 0.05 # tuning = 0.98 # Constant for tuning Complimentary filter # Converting accelerometer readings to degrees ax ...
normal
{ "blob_id": "973a58013160cbc71ca46f570bde61eaff87f6a7", "index": 7489, "step-1": "from Adafruit_LSM9DS0 import Adafruit_LSM9DS0\nimport math\n\nimu = Adafruit_LSM9DS0()\n\npi = 3.14159265358979323846 # Written here to increase performance/ speed\nr2d = 57.2957795 # 1 radian in degrees\nloop = 0.05 #\ntuning = 0....
[ 0 ]
<|reserved_special_token_0|> def generateLog(ctime1, request_obj): log_file.write(ctime1 + '\t') log_file.write('Status code: ' + str(request_obj.status_code)) log_file.write('\n') def is_internet(): """Internet function""" print(time.ctime()) current_time = time.ctime() try: r =...
flexible
{ "blob_id": "f229f525c610d9925c9300ef22208f9926d6cb69", "index": 9985, "step-1": "<mask token>\n\n\ndef generateLog(ctime1, request_obj):\n log_file.write(ctime1 + '\\t')\n log_file.write('Status code: ' + str(request_obj.status_code))\n log_file.write('\\n')\n\n\ndef is_internet():\n \"\"\"Internet ...
[ 2, 3, 4, 5, 6 ]
"""Unit test for int install """ import math import pytest ROUND_OFF_ERROR = 0.001 def int_installs(x): try: return int(x.replace(',', '').replace('+', '')) except: raise ValueError("Cannot transform to int.") def test_int_install_1(): """Unit test to showcase functionality of int...
normal
{ "blob_id": "b874bfe9590a3eaff4298d6f9cc72be92000dc30", "index": 1108, "step-1": "<mask token>\n\n\ndef int_installs(x):\n try:\n return int(x.replace(',', '').replace('+', ''))\n except:\n raise ValueError('Cannot transform to int.')\n\n\ndef test_int_install_1():\n \"\"\"Unit test to sho...
[ 2, 4, 5, 6, 7 ]
# These are instance types to make available to all AWS EC2 systems, except the . # PostgreSQL server, until the auto tuning playbook can tune for systems that # small. AWSGlobalInstanceChoices = [ 't2.nano', 't2.micro', 't3.nano', 't3.micro', 't3a.nano', 't3a.micro', ] class SpecValidator: ...
normal
{ "blob_id": "4db93bdab2d73e7226dcad61827f5faea8513767", "index": 9888, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SpecValidator:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass SpecValidator:\n\n def __init__(self, type=None, default=None, choices=[], min=Non...
[ 0, 1, 2, 3, 4 ]
import os from google.cloud import bigquery def csv_loader(data, context): client = bigquery.Client() dataset_id = os.environ['DATASET'] dataset_ref = client.dataset(dataset_id) job_config = bigquery.LoadJobConfig() job_config.schema = [ bigquery.SchemaField('id'...
normal
{ "blob_id": "01467a4dad3255a99025c347469881a71ffbae7c", "index": 8179, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef csv_loader(data, context):\n client = bigquery.Client()\n dataset_id = os.environ['DATASET']\n dataset_ref = client.dataset(dataset_id)\n job_config = bigquery.LoadJob...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Game(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|> <|reserved_special_token_0|> class Player(models.Model): ...
flexible
{ "blob_id": "2fd33439d4403ec72f890a1d1b4f35f2b38d033b", "index": 9268, "step-1": "<mask token>\n\n\nclass Game(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Player(models.Model):\n \"\"\" Model that descr...
[ 4, 7, 9, 10, 11 ]
#manual forward propagation #based on a course I got from Datacamp.com 'Deep Learning in Python' #python3 ~/Documents/pyfiles/dl/forward.py #imports import numpy as np #we are going to simulate a neural network forward propagation algorithm #see the picture forwardPropagation.png for more info #the basics are it mov...
normal
{ "blob_id": "6a09311b5b3b876fd94ed0a9cce30e070528f22c", "index": 2993, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(weights)\n<mask token>\nprint(hidden_layer_vals)\n<mask token>\nprint(output_val)\n<mask token>\n", "step-3": "<mask token>\ninput_data = np.array([2, 3])\nweights = {'node_0': np...
[ 0, 1, 2, 3, 4 ]
from bs4 import BeautifulSoup import requests res = requests.get('http://quotes.toscrape.com/') #print(res.content) #proper ordered printing #print(res.text) #lxml -> parser library soup = BeautifulSoup(res.text , 'lxml') #print(soup) quote = soup.find_all('div',{'class' : 'quote'}) with open('Quotes.txt...
normal
{ "blob_id": "777c08876a2de803fc95de937d9e921044545ef8", "index": 3674, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('Quotes.txt', 'w') as ff:\n for q in quote:\n msg = q.find('span', {'class': 'text'})\n print(msg.text)\n ff.write(msg.text)\n author = q.find('sm...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class CpmsConnector: <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, config): """initialize with config config(dict): must supply username, api_key, api_url """ self.username = config['username'] self.api_ke...
flexible
{ "blob_id": "5bd2cf2ae68708d2b1dbbe0323a5f83837f7b564", "index": 7842, "step-1": "<mask token>\n\n\nclass CpmsConnector:\n <mask token>\n <mask token>\n\n def __init__(self, config):\n \"\"\"initialize with config\n config(dict): must supply username, api_key, api_url\n \"\"\"\n ...
[ 13, 16, 17, 19, 20 ]
# [SIG Python Task 1] """ Tasks to performs: a) Print 'Hello, World! From SIG Python - <your name>' to the screen b) Calculate Volume of a Sphere c) Create a customised email template for all students, informing them about a workshop. PS: This is called a docstring... and it will not be interepreted ...
normal
{ "blob_id": "150e0180567b74dfcd92a6cd95cf6c6bf36f6b5d", "index": 4228, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('hello, World! From SIG Python - Gaurangi Rawat')\n<mask token>\nprint('volume=', volume)\n<mask token>\nprint(email_msg)\n", "step-3": "<mask token>\nprint('hello, World! From SI...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class MovieSerializer(serializers.Serializer): <|reserved_special_token_0|> class FilmSerializer(serializers.ModelSerializer): class Meta: model = Movie fields = '__all__' <|reserved_special_token_1...
flexible
{ "blob_id": "0509afdce0d28cc04f4452472881fe9c5e4fbcc4", "index": 7825, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MovieSerializer(serializers.Serializer):\n <mask token>\n\n\nclass FilmSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Movie\n fields = ...
[ 0, 2, 3, 4 ]
import torch from torch import nn import torch.nn.functional as F import numpy as np from config_pos import config from backbone.resnet50 import ResNet50 from backbone.fpn import FPN from module.rpn import RPN from layers.pooler import roi_pooler from det_oprs.bbox_opr import bbox_transform_inv_opr from det_oprs.bbox_...
normal
{ "blob_id": "6ac13665c2348bf251482f250c0fcc1fc1a8af75", "index": 4721, "step-1": "<mask token>\n\n\nclass Network(nn.Module):\n\n def __init__(self):\n super().__init__()\n self.resnet50 = ResNet50(config.backbone_freeze_at, False)\n self.FPN = FPN(self.resnet50, 2, 6)\n self.RPN =...
[ 5, 6, 7, 8, 11 ]
#!/usr/local/bin/python import cgi import pymysql import pymysql.cursors import binascii import os from mylib import siteLines import threading def checkStringLine(ip, host, pagel, objects, title): onlyIp = ip.split(":")[0] connection = siteLines() with connection.cursor() as cursor: #...
normal
{ "blob_id": "6c5c07dadbe7ec70a210ee42e756be0d710c0993", "index": 5272, "step-1": "<mask token>\n\n\ndef checkStringLine(ip, host, pagel, objects, title):\n onlyIp = ip.split(':')[0]\n connection = siteLines()\n with connection.cursor() as cursor:\n sql = f\"SELECT `IP` FROM `sites` WHERE `IP`='{o...
[ 1, 2, 4, 5, 6 ]
# 12.02.17 """ nomencalura a__b__c a: parametro t-temperatura tm-temperatura minima tM-teperatura massima b: intervallo di tempo a-anno c: tabella fonte dati g-giornaliero """ import db_02 as DB def t_tm_tM__a__g(db, anno): cmd = """ SELECT data, t, tmin, tmax FROM Giornaliero WHERE strft...
normal
{ "blob_id": "26b0a762b8eb30f0ef3c5a914f032c2a7d24f750", "index": 5606, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef t_tm_tM__a__g(db, anno):\n cmd = (\n \"\\nSELECT data, t, tmin, tmax\\nFROM Giornaliero\\nWHERE strftime('%Y') = '{}'\\n \"\n .format(anno))\n dati = db.cur...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @application.route('/') def hello_world(): return jsonify({'Hello': 'World'}) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> load_dotenv(dotenv_path='./.env') <|reserved_special_token_0|> @application.route('/') def hello_world(): ret...
flexible
{ "blob_id": "72e03e7199044f3ed1d562db622a7b884fa186b0", "index": 2206, "step-1": "<mask token>\n\n\n@application.route('/')\ndef hello_world():\n return jsonify({'Hello': 'World'})\n\n\n<mask token>\n", "step-2": "<mask token>\nload_dotenv(dotenv_path='./.env')\n<mask token>\n\n\n@application.route('/')\nde...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class NestableBlueprint(Blueprint): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class NestableBlueprint(Blueprint): def register_blueprint(self, blueprint, **options): ...
flexible
{ "blob_id": "2c505f3f1dfdefae8edbea0916873229bcda901f", "index": 764, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass NestableBlueprint(Blueprint):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass NestableBlueprint(Blueprint):\n\n def register_blueprint(self, blueprint, **options):\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_logger(): _logger = logging.getLogger('EduNLP') _logger.setLevel(logging.INFO) _logger.propagate = False ch = logging.StreamHandler() ch.setFormatter(logging.Formatter('[%(name)s, %(levelname)s] %(mes...
flexible
{ "blob_id": "41f71589d3fb9f5df218d8ffa0f608a890c73ad2", "index": 8486, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_logger():\n _logger = logging.getLogger('EduNLP')\n _logger.setLevel(logging.INFO)\n _logger.propagate = False\n ch = logging.StreamHandler()\n ch.setFormatter(...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class TestFeatureReader(unittest.TestCase): <|reserved_special_token_0|> def testRFEFull(self): feat = ['column1', 'column2', 'column3'] read_data = 'Header\n---- column1\n---- column2\n---- column3\n' mock_open = mock.mock_open(read_data=read_data) ...
flexible
{ "blob_id": "5436e9270e61f5f9ab41fc1f35a80f4b8def65ee", "index": 2048, "step-1": "<mask token>\n\n\nclass TestFeatureReader(unittest.TestCase):\n <mask token>\n\n def testRFEFull(self):\n feat = ['column1', 'column2', 'column3']\n read_data = 'Header\\n---- column1\\n---- column2\\n---- colum...
[ 14, 16, 17, 18, 19 ]
<|reserved_special_token_0|> def detail(request, post_id): po = get_object_or_404(post, pk=post_id) ratelist = [1, 2, 3, 4, 5] return render(request, 'detail.html', {'post': po, 'ratelist': ratelist}) @login_required(login_url='/login/') def delet(request, post_id): po = get_object_or_404(post, pk=p...
flexible
{ "blob_id": "2b88bec388f3872b63d6bfe200e973635bb75054", "index": 5418, "step-1": "<mask token>\n\n\ndef detail(request, post_id):\n po = get_object_or_404(post, pk=post_id)\n ratelist = [1, 2, 3, 4, 5]\n return render(request, 'detail.html', {'post': po, 'ratelist': ratelist})\n\n\n@login_required(login...
[ 2, 4, 5, 6, 7 ]
#Bingo Game #Anthony Swift #06/05/2019 ''' A simple bingo game. Player is presented with a randomly generated grid of numbers. Player is asked to enter the number called out by the caller, each time a number is called out. A chip ('X') is placed on the grid when the number entered (that has been called) match...
normal
{ "blob_id": "7be62ce45f815c4f4cf32df696cc444f92ac6d5c", "index": 8901, "step-1": "<mask token>\n\n\ndef welcome():\n print('\\nWelcome to the Bingo Game.')\n\n\ndef initialise_grid():\n grid = [['', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''\n ], ['', '', '', '', ''], ['', '', '', ''...
[ 14, 15, 16, 17, 18 ]
from . import views from django.urls import path, re_path app_name = "blogs" urlpatterns = [ path('', views.index, name='index'), re_path(r'^blogs/(?P<blog_id>\d+)/$', views.blog, name='blog'), path('new_blog/', views.new_blog, name='new_blog'), re_path(r'^edit_blog/(?P<blog_id>\d+)/$', views.edit_blog, name='edit_bl...
normal
{ "blob_id": "d73491d6673abdabad85176c5f75a191995c806d", "index": 1260, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'blogs'\nurlpatterns = [path('', views.index, name='index'), re_path(\n '^blogs/(?P<blog_id>\\\\d+)/$', views.blog, name='blog'), path(\n 'new_blog/', views.new_blog, nam...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def update_key(data_base, url, kkey): keys_saved = regex.get_data('<key>\\s(.+?)\\s<', data_base[url]['key']) if kkey not in keys_saved: data_base[url]['key'] = data_base[url]['key'][:-1] data_base[url]['...
flexible
{ "blob_id": "50a5d3431693b402c15b557357eaf9a85fc02b0b", "index": 2921, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef update_key(data_base, url, kkey):\n keys_saved = regex.get_data('<key>\\\\s(.+?)\\\\s<', data_base[url]['key'])\n if kkey not in keys_saved:\n data_base[url]['key'] =...
[ 0, 7, 8, 9, 11 ]
<|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": "1e83fedb8a5ed51704e991aeaa4bde20d5316d11", "index": 2351, "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 = [('account', '...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class EventMQTTHandler(BaseMQTTHandler): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, mqtt_server, qos=QOS_0, callback_ms=None): super(EventMQTTHandler, self).__init__(mqtt_server) callback_ms = ...
flexible
{ "blob_id": "b3f72bc12f85724ddcdaf1c151fd2a68b29432e8", "index": 6545, "step-1": "<mask token>\n\n\nclass EventMQTTHandler(BaseMQTTHandler):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, mqtt_server, qos=QOS_0, callback_ms=None):\n super(EventMQTTHandler, self).__init__(m...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> def setup(data): common.access_golem(data.env.url, data.env.admin) api.project.using_project('test_builder_code') data.test = api.test.create_access_test_code(data.project) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def setup(...
flexible
{ "blob_id": "d4cdc4f1995eab7f01c970b43cb0a3c5ed4a2711", "index": 3673, "step-1": "<mask token>\n\n\ndef setup(data):\n common.access_golem(data.env.url, data.env.admin)\n api.project.using_project('test_builder_code')\n data.test = api.test.create_access_test_code(data.project)\n\n\n<mask token>\n", "...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Note: num: int @classmethod def choice(cls, *args: int): return Note(choice(args)) @classmethod def from_midi(cls, midi: int, root: int): note = midi_to_note.get(midi % root) if isinstance(note, int): return cls(note) ...
flexible
{ "blob_id": "d70f77713abf4b35db9de72c1edbf4bf4580b2a4", "index": 8795, "step-1": "<mask token>\n\n\nclass Note:\n num: int\n\n @classmethod\n def choice(cls, *args: int):\n return Note(choice(args))\n\n @classmethod\n def from_midi(cls, midi: int, root: int):\n note = midi_to_note.ge...
[ 24, 26, 28, 33, 34 ]
d = { 1 : 'I', 5 : 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M' } e = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, ...
normal
{ "blob_id": "1a29b3138f6a33fbe2781f044c1bcccd03ecd48d", "index": 7590, "step-1": "<mask token>\n\n\ndef convert2numeral(rom):\n cur = 0\n num = 0\n while cur < len(rom):\n if cur + 1 == len(rom):\n num += e[rom[cur]]\n elif e[rom[cur]] > e[rom[cur + 1]]:\n num += e[ro...
[ 1, 2, 3, 4, 5 ]
from jox_api import label_image,Mysql,Utils from jox_config import api_base_url import json class Menu(): def __init__(self): self.mysqlClass = Mysql.MySQL() self.timeClass = Utils.Time() def get_menu(self,type,openid): try: if type == 'mine': self.sql = "SEL...
normal
{ "blob_id": "4fa9d16f979acf3edce05a209e1c6636e50fc315", "index": 222, "step-1": "<mask token>\n\n\nclass Menu:\n <mask token>\n\n def get_menu(self, type, openid):\n try:\n if type == 'mine':\n self.sql = (\n \"SELECT * FROM get_menu WHERE openid='%s' ord...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python # -*- coding:utf-8 -*- #allisnone 20200403 #https://github.com/urllib3/urllib3/issues/1434 #https://github.com/dopstar/requests-ntlm2 #https://github.com/requests/requests-ntlm #base on python3 #if you request https website, you need to add ASWG CA to following file: #/root/.pyenv/versio...
normal
{ "blob_id": "a7fae2da8abba6e05b4fc90dec8826194d189853", "index": 2758, "step-1": "<mask token>\n\n\ndef get_random_ip_or_user(start, end, prefix='172.16.90.', type='ip'):\n if type == 'ip' and max(start, end) > 255:\n end = 255\n i = random.randint(start, end)\n return prefix + str(i)\n\n\ndef ge...
[ 6, 7, 8, 9, 11 ]
<|reserved_special_token_0|> class Replacer: <|reserved_special_token_0|> <|reserved_special_token_0|> def __new__(cls, *args, **kwargs): subs = WeightedList(cls.__subclasses__(), [sub.subclass_weight for sub in cls.__subclasses__()]) if subs and cls.go_deeper(subs): ...
flexible
{ "blob_id": "3a878c91218dfbf23477ae5b7561e9eecfcd1350", "index": 5053, "step-1": "<mask token>\n\n\nclass Replacer:\n <mask token>\n <mask token>\n\n def __new__(cls, *args, **kwargs):\n subs = WeightedList(cls.__subclasses__(), [sub.subclass_weight for\n sub in cls.__subclasses__()])\...
[ 7, 10, 11, 13, 15 ]
""" Quick select (randomized selection algorithm) - based on quick sort (ch8_sorting); used to obtain the ith-smallest element in an unordered list of items (e.g.numbers) """ def swap(unsorted_array, a, b): temp = unsorted_array[a] unsorted_array[a] = unsorted_array[b] unsorted_array[b] = temp def part...
normal
{ "blob_id": "f9234741c6356b4677b5d32ffea86549d001c258", "index": 5625, "step-1": "<mask token>\n\n\ndef swap(unsorted_array, a, b):\n temp = unsorted_array[a]\n unsorted_array[a] = unsorted_array[b]\n unsorted_array[b] = temp\n\n\n<mask token>\n\n\ndef quick_select_helper(unsorted_array, left, right, k)...
[ 3, 4, 5, 6, 7 ]
#颜色选择对话框 import tkinter import tkinter.colorchooser root = tkinter.Tk() root.minsize(300,300) #添加颜色选择按钮 def select(): #打开颜色选择器 result = tkinter.colorchooser.askcolor(title = '内裤颜色种类',initialcolor = 'purple') print(result) #改变按钮颜色 btn1['bg'] = result[1] btn1 = tkinter.Button(root,text = '请选择你的内裤颜色...
normal
{ "blob_id": "dc261b29c1c11bb8449ff20a7f2fd120bef9efca", "index": 6090, "step-1": "<mask token>\n\n\ndef select():\n result = tkinter.colorchooser.askcolor(title='内裤颜色种类', initialcolor=\n 'purple')\n print(result)\n btn1['bg'] = result[1]\n\n\n<mask token>\n", "step-2": "<mask token>\nroot.minsi...
[ 1, 2, 3, 4, 5 ]
# Generated by Django 2.2.5 on 2020-01-05 04:05 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='News', fields=[ ('id', models.AutoField(aut...
normal
{ "blob_id": "d40e1cfa2ef43f698e846c25ac9f5471d69e71a0", "index": 5253, "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|> <|reserved_special_token_1|> <|reserved_special_token_0|> for _ in range(N): mix_ind = np.random.choice(len(mix_prob), p=mix_prob) data_point = np.random.multivariate_normal(clust_means[mix_ind], clust_gammas[mix_ind]) data_set.append(data_point) true_labels.appen...
flexible
{ "blob_id": "5807d1c2318ffa19d237d77fbe3f4c1d51da8601", "index": 7634, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(N):\n mix_ind = np.random.choice(len(mix_prob), p=mix_prob)\n data_point = np.random.multivariate_normal(clust_means[mix_ind],\n clust_gammas[mix_ind])\n da...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Agent(object): <|reserved_special_token_0|> def __init__(self, q, epsilon=0.8, discount=0.9, learningRate=0.5, traceDecay=0.3): possibleChangesPerMagnet = 0.01, 0.001, 0, -0.01, -0.001 self.actionSet = tuple(torch.tensor((x, y), dtype=torch.float) fo...
flexible
{ "blob_id": "63edbbbad9561ddae005d2b5e22a089819dc34c5", "index": 1821, "step-1": "<mask token>\n\n\nclass Agent(object):\n <mask token>\n\n def __init__(self, q, epsilon=0.8, discount=0.9, learningRate=0.5,\n traceDecay=0.3):\n possibleChangesPerMagnet = 0.01, 0.001, 0, -0.01, -0.001\n ...
[ 8, 9, 10, 12, 13 ]
<|reserved_special_token_0|> def energy2(n): return (n * h / L) ** 2 / (8 * m) * convert def factorial(n): out = 1 for x in range(n): out = out * (x + 1) return out <|reserved_special_token_0|> def configs(x, elvl, particle='boson', out=None): """ Generate configs for bosons or f...
flexible
{ "blob_id": "42f656898481768ea0bf1ca0b6afbe06de9dd597", "index": 4132, "step-1": "<mask token>\n\n\ndef energy2(n):\n return (n * h / L) ** 2 / (8 * m) * convert\n\n\ndef factorial(n):\n out = 1\n for x in range(n):\n out = out * (x + 1)\n return out\n\n\n<mask token>\n\n\ndef configs(x, elvl,...
[ 7, 10, 12, 14, 15 ]
from data import constants from data.action import Action from data.point import Point class MoveActorsAction(Action): """A code template for moving actors. The responsibility of this class of objects is move any actor that has a velocity more than zero. Stereotype: Controller Attributes:...
normal
{ "blob_id": "3be7183b5c1d86ee0ebfdea89c6459efe89510f8", "index": 6103, "step-1": "<mask token>\n\n\nclass MoveActorsAction(Action):\n <mask token>\n\n def execute(self, cast):\n \"\"\"Executes the action using the given actors.\n\n Args:\n cast (dict): The game actors {key: tag, va...
[ 2, 3, 4, 5, 6 ]
from django.test import TestCase, Client from django.urls import reverse from django.contrib.auth import get_user_model from tweets.models import Tweet from ..models import UserProfile User = get_user_model() class TestAccountsViews(TestCase): def setUp(self): self.username = 'masterbdx' self.ema...
normal
{ "blob_id": "888a5847beca2470f4063da474da1f05079abca9", "index": 5579, "step-1": "<mask token>\n\n\nclass TestAccountsViews(TestCase):\n <mask token>\n <mask token>\n\n def test_logout_view(self):\n response = self.client.get(reverse('accounts:logout'))\n self.assertEqual(response.status_c...
[ 9, 10, 11, 12, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def e_greedy(steps: [Step], actions: [Action], value_estimator: ValueEstimator, e: float) ->int: return random.sample(actions, 1) if random.uniform(0, 1) < e else greedy( steps, actions, value_estimator) <|rese...
flexible
{ "blob_id": "eab45dafd0366af8ab904eb33719b86777ba3d65", "index": 2925, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef e_greedy(steps: [Step], actions: [Action], value_estimator:\n ValueEstimator, e: float) ->int:\n return random.sample(actions, 1) if random.uniform(0, 1) < e else greedy(\n ...
[ 0, 1, 2, 3, 4 ]
from customer_service.model.customer import Customer def get_customer(customer_id, customer_repository): return customer_repository.fetch_by_id(customer_id) def create_customer(first_name, surname, customer_repository): customer = Customer(first_name=first_name, surname=surname) customer_repository.stor...
normal
{ "blob_id": "f5e60f2d384242b9675e756f67391ea09afcc262", "index": 5408, "step-1": "<mask token>\n\n\ndef update_customer(first_name, surname, cid, customer_repository):\n customer = customer_repository.fetch_by_id(cid)\n customer.first_name = first_name\n customer.surname = surname\n customer_reposito...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Ui_KEY(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Ui_KEY(object): def setupUi(self, KEY): KEY.setObjectName('KEY') KEY.resize(419, 106) self.Key1 = QtWid...
flexible
{ "blob_id": "1dab0084666588f61d0f9f95f88f06ed9d884e5b", "index": 3892, "step-1": "<mask token>\n\n\nclass Ui_KEY(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Ui_KEY(object):\n\n def setupUi(self, KEY):\n KEY.setObjectName('KEY')\n KEY.resize(419, 106)\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class AcademyConfig(AppConfig): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class AcademyConfig(AppConfig): name = 'academy' verbose_na...
flexible
{ "blob_id": "619d2df45d0823930484f030a9a78e71ec718cb7", "index": 6661, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AcademyConfig(AppConfig):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AcademyConfig(AppConfig):\n name = 'academy'\n verbose_name = u'Акад...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python import sys sys.path.append('./spec') # FIXME: make the spec file an argument to this script from dwarf3 import * def mandatory_fragment(mand): if mand: return "mandatory" else: return "optional" def super_attrs(tag): #sys.stderr.write("Calculating super attrs for...
normal
{ "blob_id": "223d96806631e0d249e8738e9bb7cf5b1f48a8c1", "index": 4252, "step-1": "#!/usr/bin/env python\n\nimport sys\n\nsys.path.append('./spec')\n\n# FIXME: make the spec file an argument to this script\nfrom dwarf3 import *\n\ndef mandatory_fragment(mand):\n if mand: \n return \"mandatory\"\n els...
[ 0 ]
<|reserved_special_token_0|> class Ubiquitination: <|reserved_special_token_0|> def load_R(self): pass def data_path(self, name): exp_path = './web_app/data/disease/exp_data/{}.txt'.format(name) clinical_path = './web_app/data/disease/clinical/{}.txt'.format(name) ubiquit...
flexible
{ "blob_id": "a6ae4324580a8471969e0229c02ea1670728f25b", "index": 3767, "step-1": "<mask token>\n\n\nclass Ubiquitination:\n <mask token>\n\n def load_R(self):\n pass\n\n def data_path(self, name):\n exp_path = './web_app/data/disease/exp_data/{}.txt'.format(name)\n clinical_path = '...
[ 7, 8, 10, 12, 13 ]
<|reserved_special_token_0|> class RandomIPv4Waiter(WaiterInterface): <|reserved_special_token_0|> <|reserved_special_token_0|> def generator(self): while self.limit_generate != 0: randomIPv4 = generateRandomIPv4() yield randomIPv4, self.ports if self.limit_gen...
flexible
{ "blob_id": "bd3b1263d7d657fe2edd3c7198f63821a3d1d1e5", "index": 319, "step-1": "<mask token>\n\n\nclass RandomIPv4Waiter(WaiterInterface):\n <mask token>\n <mask token>\n\n def generator(self):\n while self.limit_generate != 0:\n randomIPv4 = generateRandomIPv4()\n yield ra...
[ 2, 4, 5, 6, 7 ]
#!/usr/bin/env python import rospy import cv2 from geometry_msgs.msg import PoseStamped class PositionReader: def __init__(self): self.image_sub = rospy.Subscriber( "/visp_auto_tracker/object_position", PoseStamped, self.callback) self.pub = rospy.Publisher('object_position', PoseSta...
normal
{ "blob_id": "26ac0c94d0ab70d90854ca2c913ef0f633b54a3c", "index": 4527, "step-1": "<mask token>\n\n\nclass PositionReader:\n\n def __init__(self):\n self.image_sub = rospy.Subscriber('/visp_auto_tracker/object_position',\n PoseStamped, self.callback)\n self.pub = rospy.Publisher('objec...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def twitter_auth(): consumer_key = 'IqsuEo5xfTdWwjD1GZNSA' consumer_secret = 'dtYmqEekw53kia3MJhvDagdByWGxuTiqJfcdGkXw8A' request_token_url = 'https://api.twitter.com/oauth/request_token' access_token_url = 'http://api.twitter.com/oauth/access_token' authorize_url = 'h...
flexible
{ "blob_id": "afa20d7e9c7843a03090c00cc888d44a77fc29f3", "index": 9205, "step-1": "<mask token>\n\n\ndef twitter_auth():\n consumer_key = 'IqsuEo5xfTdWwjD1GZNSA'\n consumer_secret = 'dtYmqEekw53kia3MJhvDagdByWGxuTiqJfcdGkXw8A'\n request_token_url = 'https://api.twitter.com/oauth/request_token'\n acces...
[ 4, 6, 8, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if apiKey == '<your api key>' and sys.argv[1]: apiKey = sys.argv[1] <|reserved_special_token_0|> print(json.dumps(r.json())) <|reserved_special_token_0|> print(r.json()['total']) for i in np.arange(0, len(r.json()['rows'])): ...
flexible
{ "blob_id": "b4593b3229b88db26c5e200431d00838c357c8e0", "index": 2359, "step-1": "<mask token>\n", "step-2": "<mask token>\nif apiKey == '<your api key>' and sys.argv[1]:\n apiKey = sys.argv[1]\n<mask token>\nprint(json.dumps(r.json()))\n<mask token>\nprint(r.json()['total'])\nfor i in np.arange(0, len(r.js...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 import math from PIL import Image as Image # NO ADDITIONAL IMPORTS ALLOWED! def in_bound(dim , s): """Get inbound pixel coordinate for out-of-bound Args: dim (int): Image height or width s (int): Coordinate Returns: int: Inbound """ if s <= -1: ...
normal
{ "blob_id": "591b1a2e245ae0f3c9b2a81769bbf5988574ed07", "index": 8253, "step-1": "<mask token>\n\n\ndef in_bound(dim, s):\n \"\"\"Get inbound pixel coordinate for out-of-bound\n\n Args:\n dim (int): Image height or width\n s (int): Coordinate \n\n Returns:\n int: Inbound\n \"\"\"...
[ 8, 10, 13, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class DummyTriggerFactory(DjangoModelFactory): class Meta: model = DummyTrigger <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "813354c9c294c0323c1b54cda7074fbffa49cdb3", "index": 442, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass DummyTriggerFactory(DjangoModelFactory):\n\n\n class Meta:\n model = DummyTrigger\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask tok...
[ 0, 1, 2, 3 ]
from time import sleep import requests import json import pymysql db = pymysql.connect(host="localhost", user="root", password="root", db="xshop", port=33061) def getCursor(): cursor = db.cursor() return cursor class Classify(object): def __init__(self, **args): self.cl_name = args['cl_name'] ...
normal
{ "blob_id": "6d51a088ba81cfc64c2e2a03f98b0ee354eda654", "index": 4292, "step-1": "<mask token>\n\n\ndef getCursor():\n cursor = db.cursor()\n return cursor\n\n\nclass Classify(object):\n\n def __init__(self, **args):\n self.cl_name = args['cl_name']\n self.cl_grade = args['cl_grade'] is No...
[ 7, 8, 9, 10, 12 ]
#Matthew Shrago #implementation of bisection search. import math low = 0 high = 100 ans = int((high + low)/2) print "Please think of a number between 0 and 100!" while ans != 'c': #print high, low print "Is your secret number " + str(ans) + "?", number = raw_input("Enter 'h' to indicate the guess is too hi...
normal
{ "blob_id": "39abda1dd8b35889405db1b3971917d2a34180e3", "index": 6428, "step-1": "#Matthew Shrago\n#implementation of bisection search.\nimport math\nlow = 0\nhigh = 100\nans = int((high + low)/2)\n\nprint \"Please think of a number between 0 and 100!\"\nwhile ans != 'c':\n #print high, low\n print \"Is yo...
[ 0 ]
from django.apps import AppConfig class BuyerSellerAppConfig(AppConfig): name = 'buyer_seller_app'
normal
{ "blob_id": "0b730314fef31e7304a8f5d8bb998581b021a610", "index": 1798, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BuyerSellerAppConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass BuyerSellerAppConfig(AppConfig):\n name = 'buyer_seller_app'\n", "step-4": "from...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def write_video(fps, input_folder='output', video_name='video.mp4'): fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') video = cv2.VideoWriter(video_name, fourcc, fps, (1280, 720)) path = os.getcwd() files = os...
flexible
{ "blob_id": "ca0c38cf2a55b2311a254b09cb693516c3d0ab10", "index": 1763, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef write_video(fps, input_folder='output', video_name='video.mp4'):\n fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')\n video = cv2.VideoWriter(video_name, fourcc, fps, (12...
[ 0, 1, 2, 3, 4 ]