code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
# Cookies Keys class Cookies: USER_TOKEN = "utoken" # Session Keys class Session: USER_ROOT_ID = "x-root-id" class APIStatisticsCollection: API_ACTION = "x-stats-api-action" DICT_PARAMS = "x-stats-param-dict" DICT_RESPONSE = "x-stats-resp-dict" SUCCESS = "x-stats-success" ...
normal
{ "blob_id": "d0e5a3a6db0e27ecf157294850a48a19750a5ac2", "index": 1667, "step-1": "<mask token>\n\n\nclass Session:\n <mask token>\n\n\n class APIStatisticsCollection:\n API_ACTION = 'x-stats-api-action'\n DICT_PARAMS = 'x-stats-param-dict'\n DICT_RESPONSE = 'x-stats-resp-dict'\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class FitTemplate: def __init__(self, fit_function, log_dir=None): self.fit_function = fit_function self.parameters = Parameters() self.fit_result = None if log_dir is not None: logging.basicConfig(filename=log_dir + 'log.log', level=loggin...
flexible
{ "blob_id": "9e16921d83a5f62aad694b26a92b57b97ccda461", "index": 1651, "step-1": "<mask token>\n\n\nclass FitTemplate:\n\n def __init__(self, fit_function, log_dir=None):\n self.fit_function = fit_function\n self.parameters = Parameters()\n self.fit_result = None\n if log_dir is no...
[ 6, 7, 8, 9, 10 ]
import uuid from aliyunsdkcore.client import AcsClient from aliyunsdkcore.profile import region_provider # 注意:不要更改 from celery_tasks.sms.dysms_python.build.lib.aliyunsdkdysmsapi.request.v20170525 import SendSmsRequest class SendMes(object): REGION = "cn-hangzhou" PRODUCT_NAME = "Dysmsapi" DOMAIN = "dysmsapi.aliy...
normal
{ "blob_id": "daecbf5280c199b31f3b9d9818df245d9cd165a7", "index": 4295, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SendMes(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n region_provider.add_endpoint(PRODUCT_NAME, REGI...
[ 0, 1, 3, 4, 5 ]
from flask import Flask, render_template, url_for, request, redirect, session, flash import os, json from usuarios import crearUsuario, comprobarUsuario from busqueda import filtrado from compra import procesarCompra, Dinero app = Flask(__name__) catalogo_data = json.loads(open(os.path.join(app.root_path,'json/catalo...
normal
{ "blob_id": "ebb4cf1ec2baa7bd0d29e3ae88b16e65cf76a88a", "index": 3679, "step-1": "<mask token>\n\n\n@app.route('/info/<pelicula>', methods=['GET', 'POST'])\ndef informacionPelicula(pelicula):\n peliculas = catalogo_data['peliculas']\n if request.method == 'POST':\n return redirect(url_for('index'), ...
[ 9, 12, 13, 15, 16 ]
#processes are described by generator functions #during the lifetime of a process, the process function(generator function) #creates events and yields them #when a process yields an event, it gets suspended #Simpy resumes the process when the event is triggered #multiple processes waiting on the same event is resumed...
normal
{ "blob_id": "892eb8d1802b01c035993232cc80c710211ab102", "index": 802, "step-1": "<mask token>\n\n\ndef car(env):\n while True:\n print('The car will start parking at: ', env.now)\n parking_timeout = 5\n yield env.timeout(parking_timeout)\n print('The car will start driving at: ', e...
[ 1, 2, 3, 4, 5 ]
def domain_name(url): while "https://" in url or "http://" in url or "www." in url: url = url.replace("https://", ' ') if "https://" in url else url.replace("http://", ' ') if "http://" in url else url.replace("www.", ' ') url = list(url) for i in range(len(url)): if url[i] == ".": ...
normal
{ "blob_id": "2b9dfd0cfd62276330f1a4f983f318076f329437", "index": 5026, "step-1": "<mask token>\n", "step-2": "def domain_name(url):\n while 'https://' in url or 'http://' in url or 'www.' in url:\n url = url.replace('https://', ' '\n ) if 'https://' in url else url.replace('http://', ' '\n...
[ 0, 1, 2, 3 ]
# Import this.
normal
{ "blob_id": "1f69bcd204c9be26756d964f4deb61296e40ff10", "index": 9658, "step-1": "# Import this.\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 1 ] }
[ 1 ]
"""Secret Garden tests.""" from secret_garden import Decoder, SecretGarden import random filename = "pr08_example_data.txt" key = "Fat Chocobo" d = Decoder(filename, key) s = SecretGarden(filename, key) def test_read_from_file(): """ Test of function of reading data from file. :return: """ readi...
normal
{ "blob_id": "8cfab525ab3a86dd6964475d5621fdc7c6413e38", "index": 8019, "step-1": "<mask token>\n\n\ndef test_read_from_file():\n \"\"\"\n Test of function of reading data from file.\n\n :return:\n \"\"\"\n reading_file = d.read_code_from_file()\n assert type(reading_file) == list\n assert le...
[ 5, 6, 7, 8, 9 ]
#打印ckpt或pb模型的tensor # ckpt模型 #第一种方法: from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file checkpoint_path="/your/path" print_tensors_in_checkpoint_file(checkpoint_path,tensor_name='', all_tensors=True, all_tensor_names=True) #第二种方法: from tensorflow.python import pywrap...
normal
{ "blob_id": "50fab726b90f65a82c1206a8c7df955a8b76da99", "index": 1572, "step-1": "<mask token>\n\n\ndef create_graph():\n with tf.gfile.FastGFile(out_pb_path, 'rb') as f:\n graph_def = tf.GraphDef()\n graph_def.ParseFromString(f.read())\n tf.import_graph_def(graph_def, name='')\n\n\n<mask...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def medianflt(img, i, j, msize, mr, mc): pxls = [] for a in range(msize): for b in range(msize): mi = i + a - mr mj = j + b - mc pxls.append(img[mi][mj]) pxls.sort() return pxls[msize * msize // 2] def orderstatistic(img, row, ...
flexible
{ "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 DocUploadForm(forms.ModelForm): tags = forms.ModelMultipleChoiceField(queryset=Tag.objects.all()) class Meta: model = Document exclude = ['organization', 'private_user', 'is_public', 'is_user_private', 'display'] class ShopForm(forms.Form): ...
flexible
{ "blob_id": "d2c5d306591216e100b5bd8e8822b24fd137d092", "index": 9208, "step-1": "<mask token>\n\n\nclass DocUploadForm(forms.ModelForm):\n tags = forms.ModelMultipleChoiceField(queryset=Tag.objects.all())\n\n\n class Meta:\n model = Document\n exclude = ['organization', 'private_user', 'is_p...
[ 23, 24, 32, 34, 37 ]
def interseccao_chaves(lis_dic): lista = [] for dic1 in lis_dic[0]: for cahves in dic1: lista.append(dic1) for dic2 in lis_dic[1]: for cahves in dic2: lista.append(dic2) return lista
normal
{ "blob_id": "f3ff453655d7938cb417ce212f3836fabafaea43", "index": 1696, "step-1": "<mask token>\n", "step-2": "def interseccao_chaves(lis_dic):\n lista = []\n for dic1 in lis_dic[0]:\n for cahves in dic1:\n lista.append(dic1)\n for dic2 in lis_dic[1]:\n for cahves in dic2:\n ...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(cv2.__version__) <|reserved_special_token_0|> print(image) print(image.shape) print(image[0]) print('~~~~~~~~~~~~~~~') print(image.shape[0]) print('~~~~~~~~~~~~~~~') print(len(image)) <|reserved_special_token_1|> <|reserv...
flexible
{ "blob_id": "0b0ae6101fd80bdbcf37b935268f3e49230599fb", "index": 5715, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(cv2.__version__)\n<mask token>\nprint(image)\nprint(image.shape)\nprint(image[0])\nprint('~~~~~~~~~~~~~~~')\nprint(image.shape[0])\nprint('~~~~~~~~~~~~~~~')\nprint(len(image))\n", ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def load_a_affirm_target(gfe_path=GFE_PATH): csv_targeta = os.path.join(gfe_path, 'a_affirmative_targets.csv') print(gfe_path) return pd.read_csv(csv_targeta) def load_a_cond_data(gfe_path=GFE_PATH): csv_pathc = os.path.join(gfe_path, 'a_conditional_datapoints.csv') ...
flexible
{ "blob_id": "2fb8bce3a64787dbaf5a3bb3da53f70005048467", "index": 4104, "step-1": "<mask token>\n\n\ndef load_a_affirm_target(gfe_path=GFE_PATH):\n csv_targeta = os.path.join(gfe_path, 'a_affirmative_targets.csv')\n print(gfe_path)\n return pd.read_csv(csv_targeta)\n\n\ndef load_a_cond_data(gfe_path=GFE_...
[ 19, 27, 29, 30, 40 ]
# -*- Python -*- # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # California Institute of Technology # (C) 2008 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ...
normal
{ "blob_id": "721e014bc5bf53a39556e31f281b77b90508cf12", "index": 7138, "step-1": "<mask token>\n\n\nclass Retriever(base):\n\n def _retrieveResultsFor(self, computation):\n director = self.director\n db = director.clerk.db\n orm = director.clerk.orm\n analysisObj = orm.record2objec...
[ 2, 3, 4, 5, 6 ]
from plumbum import local, FG, ProcessExecutionError import logging import os.path from task import app kubectl = local["kubectl"] @app.task def create_kube_from_template(file_name, *aargs): args = {} for a in aargs: args.update(a) template = open(os.path.join('..', file_name)).read() % args logging.info...
normal
{ "blob_id": "137e80b3bfdc0dba33a3108b37d21d298a8f251d", "index": 1544, "step-1": "<mask token>\n\n\n@app.task\ndef delete_kube_by_name(name):\n try:\n logging.info(kubectl['delete', name]())\n return True\n except ProcessExecutionError:\n return False\n", "step-2": "<mask token>\n\n\...
[ 1, 2, 3, 4, 5 ]
import pandas as pd import numpy as np import matplotlib.pyplot as plt data=pd.read_csv('regression.csv') print(data) x=data.iloc[:,0] y=data.iloc[:,1] mx=data['X1'].mean() my=data['Y'].mean() print(mx,my) num, den = 0,0 for i in range(len(x)): num += (x[i] - mx)*(y[i]-my) den += (x[i]-mx)**2 be...
normal
{ "blob_id": "ca6b064dbd8200c49665eaa944fdf1fc80c25726", "index": 1047, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(data)\n<mask token>\nprint(mx, my)\n<mask token>\nfor i in range(len(x)):\n num += (x[i] - mx) * (y[i] - my)\n den += (x[i] - mx) ** 2\n<mask token>\nprint(beta1, beta0)\n<mas...
[ 0, 1, 2, 3, 4 ]
# coding: utf-8 import numpy as np import pandas as pd import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import time import random csvfilename = 'data/0901/exp1/xiaoxiong.csv' df = pd.read_csv(csvfilename, header=None, names=['abstime','posx','posy','posz','roty','rotx','anim'...
normal
{ "blob_id": "d0adbcd60727c2c68e06dc5e796f2676f927c45a", "index": 4593, "step-1": "<mask token>\n", "step-2": "<mask token>\ndf.head()\n<mask token>\nprint(m)\n<mask token>\nprint(mean)\nfor i in mean:\n random.seed(1)\n randomFactor = [(random.random() * 0.01 + (i - 0.005)) for _ in range(m)]\n for id...
[ 0, 1, 2, 3, 4 ]
import requests from os.path import join, exists import os import fitz from tqdm import tqdm from pathlib import Path import tempfile def download_pdf(url, folder, name): r = requests.get(url, allow_redirects=True) file_path = join(folder, name + ".pdf") open(file_path, 'wb').write(r.content) return f...
normal
{ "blob_id": "c6113088f45951bc4c787760b6ca0138265fb83f", "index": 9966, "step-1": "<mask token>\n\n\ndef download_pdf(url, folder, name):\n r = requests.get(url, allow_redirects=True)\n file_path = join(folder, name + '.pdf')\n open(file_path, 'wb').write(r.content)\n return file_path\n\n\n<mask token...
[ 2, 3, 4, 5, 6 ]
import Ploneboard import PloneboardForum import PloneboardConversation import PloneboardComment
normal
{ "blob_id": "abdf5aee77ee879c50d0e605d5fd95e28a7ef7aa", "index": 5631, "step-1": "<mask token>\n", "step-2": "import Ploneboard\nimport PloneboardForum\nimport PloneboardConversation\nimport PloneboardComment\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> class BaseTestCloudAuth: """ Required setup: initialize test case teardown: del items for test decode: check decoded token and assigned info """ ACCESS_TOKEN = '' SCOPE_ACCESS_TOKEN = '' ID_TOKEN = '' TESTCLIENT = None <|reserved_speci...
flexible
{ "blob_id": "9a2b5b9b2b2f9532b5d0749147aca644c2ac26e3", "index": 2878, "step-1": "<mask token>\n\n\nclass BaseTestCloudAuth:\n \"\"\"\n Required\n setup: initialize test case\n teardown: del items for test\n decode: check decoded token and assigned info\n \"\"\"\n ACCESS_TOKEN = ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Person: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Person: <|reserved_special_token_0|> def GetName(self): return self.fname + ' ' + self.lname <|reserved_special_token_1|> ...
flexible
{ "blob_id": "ff358136bc96fa7f3eb41d019ddfd10fc4db8f0d", "index": 5558, "step-1": "<mask token>\n", "step-2": "class Person:\n <mask token>\n <mask token>\n", "step-3": "class Person:\n <mask token>\n\n def GetName(self):\n return self.fname + ' ' + self.lname\n", "step-4": "class Person:...
[ 0, 1, 2, 3, 4 ]
# ================================================== # # MAIN WINDOW # # ================================================== # # Author: Brady Hammond # # Created: 11/21/2017 # # Last Edited: N/A ...
normal
{ "blob_id": "a555226b14223dca688d10b811eb36fb229360ce", "index": 2457, "step-1": "<mask token>\n\n\nclass UIMainWindow(object):\n <mask token>\n\n def retranslateUI(self):\n _translate = QtCore.QCoreApplication.translate\n self.main_window.setWindowTitle(_translate('main_window',\n ...
[ 4, 6, 7, 8, 9 ]
import time from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC def open_browser(browser="chrome"): driver = None if browser == "chrome": driver = webdriver.Chrome() elif browser == "firefox": ...
normal
{ "blob_id": "82fc86e44d02c45d7904139e4dfdff069e2bdb90", "index": 5634, "step-1": "<mask token>\n\n\nclass Base:\n <mask token>\n\n def open_url(self, url):\n self.driver.get(url)\n self.driver.maximize_window()\n\n def find_element(self, locator, timeout=10):\n element = WebDriverWa...
[ 6, 9, 11, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Trainer: def html_escape(self, text): html_escape_table = {'"': '&quot;', "'": '&apos;'} return escape(text, html_escape_table) def train(self, preprocessedxml, xmlname): f = open('../Trai...
flexible
{ "blob_id": "22e24e8dd49367ae57d1980c4addf48d65c5e897", "index": 7851, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Trainer:\n\n def html_escape(self, text):\n html_escape_table = {'\"': '&quot;', \"'\": '&apos;'}\n return escape(text, html_escape_table)\n\n def train(self...
[ 0, 3, 4, 6, 7 ]
<|reserved_special_token_0|> def func(x): return x ** c def der_func(x): return c * x ** (c - 1) <|reserved_special_token_0|> def main(): x = 100 v_min = func(x) for i in range(10): cur_v = func(x) x = na_value(x) if cur_v < v_min: v_min = cur_v pr...
flexible
{ "blob_id": "fa7246a4e7595393ca9aaec777fa85d782bb816e", "index": 4815, "step-1": "<mask token>\n\n\ndef func(x):\n return x ** c\n\n\ndef der_func(x):\n return c * x ** (c - 1)\n\n\n<mask token>\n\n\ndef main():\n x = 100\n v_min = func(x)\n for i in range(10):\n cur_v = func(x)\n x ...
[ 3, 4, 5, 6, 7 ]
#!/bin/python3 import sys from collections import deque def connectedCell(matrix,n,m): # Complete this function visit = [] for j in range(n): a = [] for i in range(m): a.append(True) visit.append(a) #print(visit) path = 0 for i in range(n): for j in ...
normal
{ "blob_id": "25a159ca2abf0176135086324ab355d6f5d9fe9e", "index": 5054, "step-1": "<mask token>\n\n\ndef connectedCell(matrix, n, m):\n visit = []\n for j in range(n):\n a = []\n for i in range(m):\n a.append(True)\n visit.append(a)\n path = 0\n for i in range(n):\n ...
[ 1, 2, 3, 4, 5 ]
from utilities.MatplotlibUtility import * from utilities.PlotDefinitions.DrainSweep.OutputCurve import plot as importedOutputCurvePlot plotDescription = { 'name':'Chip Output Curves', 'plotCategory': 'chip', 'priority': 40, 'dataFileDependencies': ['DrainSweep.json'], 'plotDefaults': { 'figsize':(2,2.5), 'co...
normal
{ "blob_id": "49ae9e90402d784fc3af3b47e96842fbfe842104", "index": 9480, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef plot(identifiers, chipIndexes, firstRunChipHistory,\n recentRunChipHistory, specificRunChipHistory, groupedChipHistory,\n mode_parameters=None):\n if mode_parameters is N...
[ 0, 1, 2, 3, 4 ]
import os WOO_HOST = os.environ.get('WOO_HOST') #WooCommerce key credentials WOO_CONSUMER_KEY = os.environ.get('WOO_CONSUMER_KEY') WOO_CONSUMER_SECRET = os.environ.get('WOO_CONSUMER_SECRET') #XML feed fields and settings XML_FEED_FILENAME = os.environ.get('XML_FEED_FILENAME', 'feedXML') XML_SITE_NAME = os.environ.ge...
normal
{ "blob_id": "386fa51b9b285d36c75d6446f9348f6713e0dbaa", "index": 2794, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n from local_settings import *\nexcept ImportError:\n pass\nif SENTRY_URL:\n import sentry_sdk\n sentry_sdk.init(SENTRY_URL)\n", "step-3": "<mask token>\nWOO_HOST = os....
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> cv2.namedWindow('mathches', 1) cv2.imshow('mathches', a) cv2.waitKey() <|reserved_special_token_0|> for m, n in matches: if m.distance < 0.45 * n.distance: good.append(m) print(len(good)) <|reserved_special_token_0|> c...
flexible
{ "blob_id": "60953878c377382f1c7f25ce284c9fa12b8eb25f", "index": 4667, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.namedWindow('mathches', 1)\ncv2.imshow('mathches', a)\ncv2.waitKey()\n<mask token>\nfor m, n in matches:\n if m.distance < 0.45 * n.distance:\n good.append(m)\nprint(len(goo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def main(): counts = open(sys.argv[1]).readlines() for line in open(sys.argv[1]): line = line.strip('\n') url = line try: r = requests.get(url, verify=True, timeout=3) print(url + ' ' + str(r.status_code)) print(str(r.tex...
flexible
{ "blob_id": "96a4659f03879e051af95b5aa9c1e1364015fb86", "index": 8723, "step-1": "<mask token>\n\n\ndef main():\n counts = open(sys.argv[1]).readlines()\n for line in open(sys.argv[1]):\n line = line.strip('\\n')\n url = line\n try:\n r = requests.get(url, verify=True, timeo...
[ 1, 2, 3, 4, 5 ]
# Generated by Django 2.2.3 on 2019-07-14 13:34 from django.db import migrations, models def forwards_func(apps, schema_editor): """ Add Theater Rooms """ TheaterRoom = apps.get_model("main", "TheaterRoom") db_alias = schema_editor.connection.alias TheaterRoom.objects.using(db_alias).bulk_create([ ...
normal
{ "blob_id": "a4b61a5a79e314e56ba25c6e2e735bd2ee4ef0d3", "index": 4551, "step-1": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\ndef reverse_func(apps, schema_editor):\n \"\"\" No need to do anything since the t...
[ 1, 3, 4, 5, 6 ]
class Line: def __init__(self,coor1,coor2): self.coor1 = coor1 self.coor2 = coor2 def slope(self): pass def distance(self): #x = self.coor1[0]-self.coor2[0] #y = self.coor2[1]-self.coor2[1] #return ((x**2)+(y**2))**0.5 return ((((self.coor2[0]-s...
normal
{ "blob_id": "f91e997b305348485698d180b97138b040285b60", "index": 9440, "step-1": "<mask token>\n\n\nclass Account:\n\n def __init__(self, name, balance):\n self.name = name\n self.balance = balance\n\n def deposit(self, money):\n self.balance += money\n return 'Deposit accepted'...
[ 5, 15, 16, 19, 20 ]
# -*- coding: utf-8 -*- import scrapy from scrapy.linkextractors import LinkExtractor from scrapy.spiders import CrawlSpider, Rule from scrapy.selector import Selector from meizi.items import MeiziItem class MztspiderSpider(CrawlSpider): name = 'mztspider2' allowed_domains = ['meizitu.com'] start_urls = [...
normal
{ "blob_id": "a1ce43c3f64667619c4964bc4dc67215d3ecc1a0", "index": 9215, "step-1": "<mask token>\n\n\nclass MztspiderSpider(CrawlSpider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass MztspiderSpider(CrawlSpider):\n <mask token...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def blink_connected_to_wifi(pin=23): _blink_pattern(pin, [[3, 0.5, 0.5], [4, 0.2, 0.2]]) <|reserved_special_token_0|> def _blink_pattern(pin, pattern): p = Pin(pin, Pin.OUT) try: for item in pattern: for j in range(item[0]): p.value(1) ...
flexible
{ "blob_id": "c0bd060990d00ab50c9f2d3060b7f975ff16e1ab", "index": 4105, "step-1": "<mask token>\n\n\ndef blink_connected_to_wifi(pin=23):\n _blink_pattern(pin, [[3, 0.5, 0.5], [4, 0.2, 0.2]])\n\n\n<mask token>\n\n\ndef _blink_pattern(pin, pattern):\n p = Pin(pin, Pin.OUT)\n try:\n for item in patt...
[ 2, 3, 4, 5, 6 ]
class Rectangle(): def __init__(self,length,breadth): self.length=length self.breadth=breadth def area(self): return(self.length*self.breadth) def perimeter(self): return(2*(self.length+self.breadth)) r1=Rectangle(4,5) r2=Rectangle(5,7) a1=r1.area() a2=r2.area() p1=r1.perim...
normal
{ "blob_id": "d5691403812cd3742f8e8b74d4ca613eca784ffd", "index": 9677, "step-1": "class Rectangle:\n <mask token>\n <mask token>\n\n def perimeter(self):\n return 2 * (self.length + self.breadth)\n\n\n<mask token>\n", "step-2": "class Rectangle:\n\n def __init__(self, length, breadth):\n ...
[ 2, 3, 4, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> assert os.path.isdir(os.environ['OUT_DIR']) sys.exit(subprocess.call(sys.argv[1:], env=os.environ)) <|reserved_special_token_1|> <|reserved_special_token_0|> os.environ['OUT_DIR'] = os.path.abspath('.') assert os.path.isdir(os....
flexible
{ "blob_id": "be238268b9fdd565f3cb0770839789b702940ef9", "index": 8248, "step-1": "<mask token>\n", "step-2": "<mask token>\nassert os.path.isdir(os.environ['OUT_DIR'])\nsys.exit(subprocess.call(sys.argv[1:], env=os.environ))\n", "step-3": "<mask token>\nos.environ['OUT_DIR'] = os.path.abspath('.')\nassert os...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> CONSUMER_KEY = '' CONSUMER_SECRET = '' <|reserved_special_token_0|> TOKENS_PATH = '/tmp/twitter-tokens.json' REDIRECT_TO = '' FLASK_SECRET = 'S$2[ShC-=BKKOQ.Z-|fa 6f;,5 <[QngmG)}5,s%0vX>B}?o-0X9PM;.dN{jo7' <|reserved_special_tok...
flexible
{ "blob_id": "9cc64edc81ab39b0ab2cd47661c9809545b03ac6", "index": 3230, "step-1": "<mask token>\n", "step-2": "<mask token>\nCONSUMER_KEY = ''\nCONSUMER_SECRET = ''\n<mask token>\nTOKENS_PATH = '/tmp/twitter-tokens.json'\nREDIRECT_TO = ''\nFLASK_SECRET = 'S$2[ShC-=BKKOQ.Z-|fa 6f;,5 <[QngmG)}5,s%0vX>B}?o-0X9PM;....
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while True: ret, frame = cap.read() frame = np.float32(frame) / 255 average_stack = average_stack * frames + frame frames += 1.0 average_stack = average_stack / frames cv2.imshow('frame', np.uint8(average_s...
flexible
{ "blob_id": "7fd89272d3d3584f35fd8f552cb7b14e57b7ed1b", "index": 1591, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n ret, frame = cap.read()\n frame = np.float32(frame) / 255\n average_stack = average_stack * frames + frame\n frames += 1.0\n average_stack = average_stack / f...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python if __name__ == '__main__': import sys import os sys.path.insert(0, os.path.abspath('config')) import configure configure_options = [ 'CC=icc', 'CXX=icpc', 'FC=ifort', '--with-blas-lapack-dir=/soft/com/packages/intel/13/update5/mkl/', '--with-mkl_pardiso-dir=/soft/com/pack...
normal
{ "blob_id": "43eb221758ebcf1f01851fc6cda67b72f32a73c7", "index": 6992, "step-1": "<mask token>\n", "step-2": "if __name__ == '__main__':\n import sys\n import os\n sys.path.insert(0, os.path.abspath('config'))\n import configure\n configure_options = ['CC=icc', 'CXX=icpc', 'FC=ifort',\n '...
[ 0, 1, 2 ]
from dependency_injector import containers, providers from src.repositories import MemcachedRepository from src.services import FibonacciService class Container(containers.DeclarativeContainer): config = providers.Configuration() cache_repository = providers.Singleton(MemcachedRepository, ...
normal
{ "blob_id": "e8ba1ae98b247eaf90d83339e5fdc27287a70c73", "index": 2561, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Container(containers.DeclarativeContainer):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Container(containers.DeclarativeContai...
[ 0, 1, 2, 3, 4 ]
import requests import json base_url = f"https://api.telegram.org/bot" def get_url(url): response = requests.get(url) content = response.content.decode("utf8") return content def get_json_from_url(url): content = get_url(url) js = json.loads(content) return js def get_updates(TOKEN): ...
normal
{ "blob_id": "501614f9c7df3c862c9951ea343964b6ed47e74a", "index": 3204, "step-1": "<mask token>\n\n\ndef get_url(url):\n response = requests.get(url)\n content = response.content.decode('utf8')\n return content\n\n\ndef get_json_from_url(url):\n content = get_url(url)\n js = json.loads(content)\n ...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> class User: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class Customer(User): def __init__(self, name, email, age): self.name = name self.email = email self.age = age self.balance = 0 def ge...
flexible
{ "blob_id": "ea045d04b40341f34c780dceab1f21df93b7207a", "index": 7689, "step-1": "<mask token>\n\n\nclass User:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Customer(User):\n\n def __init__(self, name, email, age):\n self.name = name\n self.email = email\n self.age = a...
[ 4, 5, 8, 10, 11 ]
<|reserved_special_token_0|> def smart_open(file, mode='rt', encoding='utf-8'): """Convenience function for reading compressed or plain text files. :param file: The file to read. :param mode: The file mode (read, write). :param encoding: The file encoding. """ if file.endswith('.gz'): ...
flexible
{ "blob_id": "8adcd75e925fe0c5a50b2fc7dc8c472a9610b4f2", "index": 9575, "step-1": "<mask token>\n\n\ndef smart_open(file, mode='rt', encoding='utf-8'):\n \"\"\"Convenience function for reading compressed or plain text files.\n :param file: The file to read.\n :param mode: The file mode (read, write).\n ...
[ 27, 29, 31, 37, 42 ]
from django.shortcuts import render,redirect from . import download_function from django.http import HttpResponse # Create your views here. def download(request): if request.method == "GET": session = request.GET['session'] title = request.GET['download_title'] download_quality = request.GET...
normal
{ "blob_id": "339506777f5471ec99b39c67c28df8ec3d06ce19", "index": 3084, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef download(request):\n if request.method == 'GET':\n session = request.GET['session']\n title = request.GET['download_title']\n download_quality = request.GE...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Processing: <|reserved_special_token_0|> @property def vocab_size(self): return self.__vocab_size def normalize(self, s): s = s.lower() replacements = ('á', 'a'), ('é', 'e'), ('í', 'i'), ('ó', 'o'), ('ú', 'u'), ('ñ', 'n') ...
flexible
{ "blob_id": "326b2dcbef339aeb196bef23debad75fa079b121", "index": 6435, "step-1": "<mask token>\n\n\nclass Processing:\n <mask token>\n\n @property\n def vocab_size(self):\n return self.__vocab_size\n\n def normalize(self, s):\n s = s.lower()\n replacements = ('á', 'a'), ('é', 'e'...
[ 12, 16, 17, 18, 19 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme: README = readme.read() os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup(name='django-themes', version=__version__,...
flexible
{ "blob_id": "6e557c2b85031a0038afd6a9987e3417b926218f", "index": 6184, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:\n README = readme.read()\nos.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))\nse...
[ 0, 1, 2, 3 ]
## 허프변환에 의한 직선 검출 # cv2.HoughLines(image, rho, theta, threshold, lines=None, srn=None, stn=None, min-theta=None, max-theta=None) => lines # image : 에지 입력 영상(Canny 연산을 이용한 에지 영상) # rho(로우) : 축적 배열에서 rho 값의 간격(보통 1.0 사용) # theta(세타) : 축적 배열에서 theta 값의 간격(보통 np.pi/180) # rho, theta 값이 커지면 축적배열의 크기는 작아지고, 값이 작으면 축적배...
normal
{ "blob_id": "ff7cb8261f3abb70599725fe7c598c571d037226", "index": 9535, "step-1": "<mask token>\n", "step-2": "<mask token>\nif src is None:\n print('Image load failed')\n sys.exit()\n<mask token>\nif lines is not None:\n for i in range(lines.shape[0]):\n pt1 = lines[i][0][0], lines[i][0][1]\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_should_config_start_correctly(): c = Config(mock) assert c._entities == mock['entities'] assert c._synonimous == mock['synonimous'] assert c.templates == mock['templates'] assert c.get_value('synonim...
flexible
{ "blob_id": "987f8ce668f2002b731822fa5f3de143a80aaafe", "index": 9807, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_should_config_start_correctly():\n c = Config(mock)\n assert c._entities == mock['entities']\n assert c._synonimous == mock['synonimous']\n assert c.templates == ...
[ 0, 1, 2, 3, 4 ]
import unittest from common.ReqLogin import req import os import yaml from common import util from TestCase.runnerBase import TestInterfaceCase import paramunittest PATH = lambda p: os.path.abspath( os.path.join(os.path.dirname(__file__), p) ) def getYam(homeyaml): try: with open(homeyaml, encoding='ut...
normal
{ "blob_id": "aea196566bbbe9d37bf03b9b17a4062659a27bb6", "index": 1446, "step-1": "<mask token>\n\n\nclass UserinfoTest(TestInterfaceCase):\n\n def setUp(self):\n login = req.reqData(req)\n self.infoma = {}\n self.response = ''\n self.infoma['id'] = x['testinfo'][0]['id']\n s...
[ 10, 11, 13, 15, 17 ]
from haven import haven_utils as hu import itertools, copy EXP_GROUPS = {} EXP_GROUPS['starter_issam'] = hu.cartesian_exp_group({ 'batch_size': 32, 'opt': {'name': 'adamW', 'lr': 0.0001, 'wd': 1e-6}, 'model': {'name': 'resnext50_32x4d_ssl'}, ...
normal
{ "blob_id": "dafefc65335a0d7e27057f51b43e52b286f5bc6b", "index": 6067, "step-1": "<mask token>\n", "step-2": "<mask token>\nEXP_GROUPS = {}\nEXP_GROUPS['starter_issam'] = hu.cartesian_exp_group({'batch_size': 32,\n 'opt': {'name': 'adamW', 'lr': 0.0001, 'wd': 1e-06}, 'model': {'name':\n 'resnext50_32x4d_...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def add_frame_id(video, output_dir): reader = cv2.VideoCapture(video) if not reader.isOpened(): return -1 os.makedirs(output_dir, exist_ok=True) frame_count = int(reader.get(cv2.CAP_PROP_FRAME_COUNT)) for frame_id in tqdm(range(frame_count)): has_frame,...
flexible
{ "blob_id": "f8f538773693b9d9530775094d9948626247a3bb", "index": 6950, "step-1": "<mask token>\n\n\ndef add_frame_id(video, output_dir):\n reader = cv2.VideoCapture(video)\n if not reader.isOpened():\n return -1\n os.makedirs(output_dir, exist_ok=True)\n frame_count = int(reader.get(cv2.CAP_PR...
[ 2, 3, 4, 5, 6 ]
"""Get pandas dataframes for a given data and month. *get_dataframes(csvfile, spec=SPEC)* is a function to get dataframes from *csvfile* connection under *spec* parsing instruction. *Vintage* class addresses dataset by year and month: Vintage(year, month).save() Vintage(year, month).validate() *Collecti...
normal
{ "blob_id": "e78c4f65d84d5b33debb415005e22f926e14d7d4", "index": 1203, "step-1": "<mask token>\n\n\nclass Vintage:\n <mask token>\n\n def __init__(self, year, month):\n self.year, self.month = year, month\n self.csv = LocalCSV(year, month)\n <mask token>\n <mask token>\n <mask token>...
[ 9, 13, 14, 15, 19 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('Welcome aboard, Oleksij!')
flexible
{ "blob_id": "2b1ec29d665aa93cd53644b62efcd1305b34e13e", "index": 2636, "step-1": "<mask token>\n", "step-2": "print('Welcome aboard, Oleksij!')\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def fileMD(self): salt_ = os.urandom(32).hex() hash_object = hashlib.md5() hash_object.update(('%s%s' % (salt_, self.theFile)).encode('utf-8')) print('MD5 Hash: ' + hash_object.hexdigest()) <|reserved_special_t...
flexible
{ "blob_id": "bc9718fa57046888961d1b5245abefa8f752e983", "index": 8103, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fileMD(self):\n salt_ = os.urandom(32).hex()\n hash_object = hashlib.md5()\n hash_object.update(('%s%s' % (salt_, self.theFile)).encode('utf-8'))\n print('MD5 Hash: ' ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class ClassRoom: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def Name2Id(room_id, name): bool_n = bool(re.match('教\\d{1}-\\d{3}', name)) bool_id = bool(re.match('B\\d{1}R\\d{3}', room_id)) if not (bool_id ...
flexible
{ "blob_id": "8dae8a89d08bc522f9a5fdde8aeb9e322fafcbec", "index": 3251, "step-1": "<mask token>\n\n\nclass ClassRoom:\n <mask token>\n <mask token>\n <mask token>\n\n def Name2Id(room_id, name):\n bool_n = bool(re.match('教\\\\d{1}-\\\\d{3}', name))\n bool_id = bool(re.match('B\\\\d{1}R\\...
[ 7, 8, 10, 11, 12 ]
import shelve def quantity_posts(): try: data = shelve.open('data') except Exception: print(Exception) else: for key, value in sorted(data.items()): print(key, ': \t', value, '\n') finally: data.close() if __name__ == "__main__": print('b...
normal
{ "blob_id": "41c44b32ce3329cbba5b9b336c4266bb20de31f0", "index": 5151, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef quantity_posts():\n try:\n data = shelve.open('data')\n except Exception:\n print(Exception)\n else:\n for key, value in sorted(data.items()):\n ...
[ 0, 1, 2, 3, 4 ]
import os,sys,glob sys.path.append("../../../../libs/VASNet/") from VASNet_frame_scoring_lib import * sys.path.append("../../../config") from config import * if __name__ == '__main__': #************************************************************************ # Purpose: frame scoring (Summarizing Videos with A...
normal
{ "blob_id": "ce97da4aab2b9de40267730168690475c899526d", "index": 3924, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('../../../../libs/VASNet/')\n<mask token>\nsys.path.append('../../../config')\n<mask token>\nif __name__ == '__main__':\n path_pretrained_model = cfg.PATH_DRDSN_PRETRAI...
[ 0, 1, 2, 3 ]
#from graph import * #ex = open('ex_K.py', 'r') #ex.read() import ex_K ex = ex_K print "digraph K {" print (str(ex.K)) print "}"
normal
{ "blob_id": "44dbb7587530fac9e538dfe31c7df15b1a016251", "index": 7091, "step-1": "#from graph import *\r\n#ex = open('ex_K.py', 'r')\r\n#ex.read()\r\nimport ex_K\r\nex = ex_K\r\n\r\nprint \"digraph K {\"\r\nprint (str(ex.K))\r\nprint \"}\"\r\n", "step-2": null, "step-3": null, "step-4": null, "step-5": n...
[ 0 ]
# -*- coding: utf-8 -*- # # RPi.Spark KeyButton Demo # # Author: Kunpeng Zhang # 2018.6.6 # # See LICENSE for details. from time import sleep import RPi.GPIO as GPIO from JMRPiSpark.Drives.Key.RPiKeyButtons import RPiKeyButtons from JMRPiSpark.Drives.Key.RPiKeyButtons import DEF_BOUNCE_TIME_SHORT_MON from JMRPiSpark....
normal
{ "blob_id": "50c274e0365f2556a46eb58edcd1f0a7301e89db", "index": 8716, "step-1": "<mask token>\n\n\nclass demo:\n <mask token>\n\n def __init__(self):\n self._myKey = RPiKeyButtons()\n\n def _getKeyButtonName(self, keyBtn):\n if keyBtn == CONFIG_KEY.BUTTON_ACT_A:\n return 'BUTTO...
[ 6, 12, 15, 16, 17 ]
import tensorflow as tf import numpy as np def safe_nanmax(x): with np.warnings.catch_warnings(): np.warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered') return np.nanmax(x) def safe_nanargmax(x): try: return np.nanargmax(x) ex...
normal
{ "blob_id": "16bf4583b872f038edccbac4e567c1854d65e216", "index": 4962, "step-1": "<mask token>\n\n\nclass OfflineMetric:\n\n def __init__(self, *args, **kwargs):\n self.__name__ = self.name()\n <mask token>\n\n def handle_batch(self, model, x, labels, pred):\n raise NotImplementedError()\n...
[ 18, 20, 32, 39, 46 ]
<|reserved_special_token_0|> class NamingConvention: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class NamingConvention: <|reserved_special_token_0|> def __init__(self): namingconventions = os.path.join(os.path.dirna...
flexible
{ "blob_id": "d2a153fffccd4b681eebce823e641e195197cde7", "index": 54, "step-1": "<mask token>\n\n\nclass NamingConvention:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass NamingConvention:\n <mask token>\n\n def __init__(self):\n namingconventions = os.path.join(os.path.d...
[ 1, 2, 3, 4, 5 ]
''' Problem Description Given two numbers n1 and n2 1. Find prime numbers between n1 and n2, then 2. Make all possible unique combinations of numbers from the prime numbers list you found in step 1. 3. From this new list, again find all prime numbers. 4. Find smallest (a) and largest (b) number from the 2nd gener...
normal
{ "blob_id": "fe5050fdf010ce1c4d458b8a52ac92485a7d8cea", "index": 5706, "step-1": "<mask token>\n\n\ndef isPrime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/python3 # encoding: utf-8 """ @author: ShuoChang @license: (C) MIT. @contact: changshuo@bupt.edu.cn @software: CRNN_STN_SEQ @file: decoder_base.py @time: 2019/7/22 17:21 @blog: https://www.zhihu.com/people/chang-shuo-59/activities """ from abc import ABCMeta from abc import abstractmethod class DecoderBas...
normal
{ "blob_id": "0d8a26ef4077b40e8255d5bb2ce9217b51118780", "index": 7364, "step-1": "<mask token>\n\n\nclass DecoderBase(object):\n <mask token>\n <mask token>\n\n def __init__(self):\n self._predictor = 'decoder'\n self._label = None\n pass\n\n @abstractmethod\n def set_label(se...
[ 4, 5, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for s1, s2 in zip(A[:-1], A[1:]): if s1 < s2: stockNum = g // s1 g += stockNum * (s2 - s1) print(g) <|reserved_special_token_1|> n = int(input()) A = list(map(int, input().split())) g = 1000 for s1, s2 in zi...
flexible
{ "blob_id": "da903409d75ba2a07443317e30bce568444fbca5", "index": 9956, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor s1, s2 in zip(A[:-1], A[1:]):\n if s1 < s2:\n stockNum = g // s1\n g += stockNum * (s2 - s1)\nprint(g)\n", "step-3": "n = int(input())\nA = list(map(int, input().sp...
[ 0, 1, 2 ]
#!/usr/bin/python # coding=UTF-8 import sys import subprocess import os def printReportTail(reportHtmlFile): reportHtmlFile.write(""" </body> </html> """) def printReportHead(reportHtmlFile): reportHtmlFile.write("""<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" ...
normal
{ "blob_id": "b5cbb73c152dd60e9063d5a19f6182e2264fec6d", "index": 15, "step-1": "#!/usr/bin/python\n# coding=UTF-8\n\nimport sys\nimport subprocess\nimport os\n\ndef printReportTail(reportHtmlFile):\n reportHtmlFile.write(\"\"\"\n</body>\n</html>\n\"\"\")\n\ndef printReportHead(reportHtmlFile):\n reportHtml...
[ 0 ]
import ROOT from PhysicsTools.NanoAODTools.postprocessing.framework.datamodel import Collection from PhysicsTools.NanoAODTools.postprocessing.framework.eventloop import Module from TreeProducer import * from TreeProducerCommon import * from CorrectionTools.PileupWeightTool import * from CorrectionTools.BTaggingTool i...
normal
{ "blob_id": "1721bba2cae1e330bffeb9df05341df9522ff885", "index": 4394, "step-1": "import ROOT\nfrom PhysicsTools.NanoAODTools.postprocessing.framework.datamodel import Collection \nfrom PhysicsTools.NanoAODTools.postprocessing.framework.eventloop import Module\n\nfrom TreeProducer import *\nfrom TreeProducerComm...
[ 0 ]
# -*- coding: utf-8 -*- import logging from django.shortcuts import render, redirect, HttpResponse from django.core.urlresolvers import reverse from django.conf import settings from django.contrib.auth import logout, login, authenticate from django.contrib.auth.hashers import make_password from django.core.paginator im...
normal
{ "blob_id": "0b1e6a95ee008c594fdcff4e216708c003c065c8", "index": 4873, "step-1": "# -*- coding: utf-8 -*-\nimport logging\nfrom django.shortcuts import render, redirect, HttpResponse\nfrom django.core.urlresolvers import reverse\nfrom django.conf import settings\nfrom django.contrib.auth import logout, login, au...
[ 0 ]
def coroutine(func): def start_coroutine(*args, **kwargs): cr = func(*args, **kwargs) next(cr) #cr.send(None) return cr return start_coroutine @coroutine def grep(pattern): print('start grep') try: while True: line = yield if pattern in line: print(line) except GeneratorExit: print('stop grep'...
normal
{ "blob_id": "bebe098c5abb579eb155a1dc325347d100ddfa8f", "index": 1805, "step-1": "def coroutine(func):\n\n def start_coroutine(*args, **kwargs):\n cr = func(*args, **kwargs)\n next(cr)\n return cr\n return start_coroutine\n\n\n<mask token>\n", "step-2": "def coroutine(func):\n\n d...
[ 1, 2, 3, 4, 6 ]
from django.contrib import admin from .models import Recipe, Ingredient, ChosenIngredient, timezone # Register your models here.) admin.site.register(Ingredient) admin.site.site_header = "Chef's Apprentice Admin" admin.site.site_title = "Chef's Apprentice Admin Portal" admin.site.index_title = "Welcome to Chef's Appre...
normal
{ "blob_id": "65bb3743ca569c295d85016c82c4f6f043778d3f", "index": 8848, "step-1": "<mask token>\n\n\nclass RecipeAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n model = Recipe\n\n def make_visible(self, request, queryset):\n ...
[ 3, 5, 6, 8, 10 ]
<|reserved_special_token_0|> class Submit(webapp2.RequestHandler): <|reserved_special_token_0|> def post(self): if self.request.get('submit'): updated_handphone = self.request.get('handphone') updated_tickets_csjh = self.request.get('tickets_csjh') updated_tickets_...
flexible
{ "blob_id": "aeef27d667f95e3818f73533439385ea949b96a4", "index": 2445, "step-1": "<mask token>\n\n\nclass Submit(webapp2.RequestHandler):\n <mask token>\n\n def post(self):\n if self.request.get('submit'):\n updated_handphone = self.request.get('handphone')\n updated_tickets_cs...
[ 2, 8, 11, 12, 13 ]
<|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": "722739086d2777085fdbfdbddef205aaf025580d", "index": 4291, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('user', '000...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def main(): print('Output') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): print('Output') <|reserved_special_token_0|> if __name__ == '__main__': main() <|reserved_special_token_0|> print('Run time: {}'.format(end -...
flexible
{ "blob_id": "cdb07241e08f8ac85a427c5b2bc3effca3917c85", "index": 2188, "step-1": "<mask token>\n\n\ndef main():\n print('Output')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n print('Output')\n\n\n<mask token>\nif __name__ == '__main__':\n main()\n<mask token>\nprint('Run time: {}'....
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> __all__ = ['average', 'extract_ocean_scalar', 'git', 'gmeantools', 'merge', 'netcdf', 'xrtools'] <|reserved_special_token_1|> <|reserved_special_token_0|> from . import average from . import extract_ocean_scalar from . impo...
flexible
{ "blob_id": "ab6450ee9038e0c58ca8becf6d2518d5e00b9c90", "index": 9393, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['average', 'extract_ocean_scalar', 'git', 'gmeantools', 'merge',\n 'netcdf', 'xrtools']\n", "step-3": "<mask token>\nfrom . import average\nfrom . import extract_ocean_sca...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> cv2.line(image, (0, 0), (512, 0), (255, 255, 255), 5) cv2.line(image, (0, 50), (512, 50), (255, 255, 255), 5) cv2.rectangle(image, (256, 0), (400, 256), (0, 255, 0), 3) <|reserved_special_token_0|> cv2.putText(image, 'ROS OpenCV',...
flexible
{ "blob_id": "f6c5c2180a1a4b05b3f103c330b455e7387713a6", "index": 8125, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.line(image, (0, 0), (512, 0), (255, 255, 255), 5)\ncv2.line(image, (0, 50), (512, 50), (255, 255, 255), 5)\ncv2.rectangle(image, (256, 0), (400, 256), (0, 255, 0), 3)\n<mask token>\nc...
[ 0, 1, 2, 3, 4 ]
from os import listdir from os.path import isfile, join from datetime import date mypath = '/Users/kachunfung/python/codewars/' onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] py_removed = [i.replace('.py','') for i in onlyfiles] file_counter_removed = py_removed.remove('file_counter') day_removed...
normal
{ "blob_id": "592d5074eeca74a5845d26ee2ca6aba8c3d0f989", "index": 8929, "step-1": "from os import listdir\nfrom os.path import isfile, join\nfrom datetime import date\n\nmypath = '/Users/kachunfung/python/codewars/'\nonlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]\n\npy_removed = [i.replace('....
[ 0 ]
<|reserved_special_token_0|> class Scrapper: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Scrapper: <|reserved_special_token_0|> def scrapper(prov): scrapper = importlib.import_module('scrappers.{}'.format(prov)...
flexible
{ "blob_id": "67e06b6dddbd3f26295eaff921d1ad4a8b0e5487", "index": 5580, "step-1": "<mask token>\n\n\nclass Scrapper:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Scrapper:\n <mask token>\n\n def scrapper(prov):\n scrapper = importlib.import_module('scrappers.{}'.format...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> logging.basicConfig(level=logging.INFO) <|reserved_special_token_0|> for extension in rdf_file_extension.keys(): files_to_check = '**/*' + extension for filename in glob.iglob(root_path + files_to_check, recursive=True): ...
flexible
{ "blob_id": "fe406f40b48bf4982e7a48737b6b30514ae1fa71", "index": 7915, "step-1": "<mask token>\n", "step-2": "<mask token>\nlogging.basicConfig(level=logging.INFO)\n<mask token>\nfor extension in rdf_file_extension.keys():\n files_to_check = '**/*' + extension\n for filename in glob.iglob(root_path + fil...
[ 0, 1, 2, 3, 4 ]
from .compat import reverse, action from rest_framework.response import Response from rest_framework.viewsets import ModelViewSet from rest_framework import pagination from rest_framework import renderers from . import registry from .serializers import RunSerializer, RecordSerializer from .models import Run from .setti...
normal
{ "blob_id": "11a0c3307994a90d1d4de67d442ffa355e11e13b", "index": 6836, "step-1": "<mask token>\n\n\nclass RunViewSet(ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @property\n def template_na...
[ 11, 13, 17, 18, 22 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> def cal_sum(self, root, L, R, result): if not root: return result ...
flexible
{ "blob_id": "8e1de62f2490d2276a834ae1ab0f1958649fa821", "index": 5503, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n <mask token>\n", "step-3": "class Solution:\n <mask token>\n\n def cal_sum(self, root, L, R, result):\n if not root:\n return result\n ...
[ 0, 1, 2, 3, 4 ]
import sys from domain import * from fuzzy_set import * from parser import * class FuzzyControler(object): def __init__(self, angle_rules, acc_rules, domains_angle, domains_acc): self.angle_rules = angle_rules self.acc_rules = acc_rules self.domains_angle = domains_angle self.domains_acc = domains_acc s...
normal
{ "blob_id": "7451b09c54734fb02167d43b96df972420d86853", "index": 7776, "step-1": "import sys\n\nfrom domain import *\nfrom fuzzy_set import *\nfrom parser import *\n\nclass FuzzyControler(object):\n\n\tdef __init__(self, angle_rules, acc_rules, domains_angle, domains_acc):\n\n\t\tself.angle_rules = angle_rules\n...
[ 0 ]
class Sala: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Sala: <|reserved_special_token_0|> <|reserved_special_token_0|> def __str__(self): return str(self.numero) <|reserved_special_token_1|> class Sala:...
flexible
{ "blob_id": "e41df44db92e2ef7f9c20a0f3052e1c8c28b76c7", "index": 6174, "step-1": "class Sala:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Sala:\n <mask token>\n <mask token>\n\n def __str__(self):\n return str(self.numero)\n", "step-3": "class Sala:\n <mask t...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # vim: set fileencoding=utf-8 : # Andre Anjos <andre.anjos@idiap.ch> # Sat Dec 17 14:41:56 2011 +0100 # # Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland """Run tests on the libsvm machine infrastructure. """ import os import numpy import tempfile import pkg_resources imp...
normal
{ "blob_id": "c24be05700e5ee043d09d6f2e78cb3de1e7088f1", "index": 6242, "step-1": "<mask token>\n\n\ndef F(f):\n \"\"\"Returns the test file on the \"data\" subdirectory\"\"\"\n return pkg_resources.resource_filename(__name__, os.path.join('data', f))\n\n\n<mask token>\n\n\ndef load_expected(filename):\n ...
[ 8, 9, 12, 13, 17 ]
import pymysql from app_module.models import User, Vehicle, Address, Customer, Location, Coupon, VehicleClass, Corporation, Corporate from datetime import datetime HOSTNAME = 'localhost' USERNAME = 'root' PASSWORD = '123456' DATABASE = 'proj_p2' def get_connection(): my_sql_connection = pymysql.connect(host=HOST...
normal
{ "blob_id": "62bad8eeb3b51a5012dad761a60639d36429d8e8", "index": 7660, "step-1": "<mask token>\n\n\ndef run_query(query, args=None):\n conn = get_connection()\n cur = conn.cursor()\n cur.execute(query, args)\n rs = cur.fetchall()\n if len(rs) != 0:\n return rs\n conn.commit()\n cur.cl...
[ 25, 27, 37, 40, 41 ]
import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader from torchvision import datasets, transforms, models from torchvision.utils import make_grid import numpy as np import pandas as pd import matplotlib.pyplot as plt import os from PIL import Image from...
normal
{ "blob_id": "7821b07a49db9f3f46bedc30f2271160e281806f", "index": 4814, "step-1": "<mask token>\n\n\nclass ConvolutionalNetwork(nn.Module):\n\n def __init__(self):\n super().__init__()\n self.conv1 = nn.Conv2d(3, 6, 3, 1)\n self.conv2 = nn.Conv2d(6, 16, 3, 1)\n self.fc1 = nn.Linear(...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for c in range(0, 7): pe1 = int(input('Digite o ano de nascimento: ')) pe1 = 2019 - pe1 if pe1 >= 21: num1 = num1 + 1 print(f'Entre as 7 pessoas, {num1} pessoas são maiores de idade.') <|reserved_special_toke...
flexible
{ "blob_id": "251d589a5815d77d2bc375d8d4a7d41e79a2a5cd", "index": 5303, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor c in range(0, 7):\n pe1 = int(input('Digite o ano de nascimento: '))\n pe1 = 2019 - pe1\n if pe1 >= 21:\n num1 = num1 + 1\nprint(f'Entre as 7 pessoas, {num1} pessoas s...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def split_page(result_obj): """ 分页模块,后台传入一个分页结果集就可以 :param result_obj: :return: """ return_str = '<nav>' return_str += "<ul class='pagination pull-right'>" if result_obj.has_previous(): return_str += '<li>' return_str += "<a href='?page=" +...
flexible
{ "blob_id": "c2c51dcd05c21e91e591de25fc2de034c88c48a1", "index": 9052, "step-1": "<mask token>\n\n\ndef split_page(result_obj):\n \"\"\"\n 分页模块,后台传入一个分页结果集就可以\n :param result_obj:\n :return:\n \"\"\"\n return_str = '<nav>'\n return_str += \"<ul class='pagination pull-right'>\"\n if resul...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 6 10:05:25 2019 @author: MCA """ import smtplib, ssl from email import encoders from email.mime.text import MIMEText from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart import os,sys import time def loadFiles(su...
normal
{ "blob_id": "b310c35b781e3221e2dacc7717ed77e20001bafa", "index": 5109, "step-1": "<mask token>\n\n\ndef loadFiles(subdir, filetype):\n \"\"\"\n example:\n dirs = [\"dir1\", \"dir2\"]\n file_type = \".dat\"\n files, keys, data = loadFiles(dirs[0], file_type)\n \n \"\"\"\n dirname = os.path...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class HTTPClient(abc.ABC): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @abc.abstractmethod def post(self, url: str, **kwargs: Dict[str, Any]) ->Any: ""...
flexible
{ "blob_id": "1a126ba7e73eb2e7811ab32146fe5aee6c6b30f9", "index": 4290, "step-1": "<mask token>\n\n\nclass HTTPClient(abc.ABC):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @abc.abstractmethod\n def post(self, url: str, **kwargs: Dict[str, Any]) ->Any:\n ...
[ 8, 10, 11, 14, 15 ]
nome = str(input('Digite um nome completo: ')).lower() silva = 'silva' in nome if silva == True: print('Existe Silva nesse nome') else: print('Não há Silva nesse nome')
normal
{ "blob_id": "faebefcadbc184fab29deb2988089223a8f09e7e", "index": 8219, "step-1": "<mask token>\n", "step-2": "<mask token>\nif silva == True:\n print('Existe Silva nesse nome')\nelse:\n print('Não há Silva nesse nome')\n", "step-3": "nome = str(input('Digite um nome completo: ')).lower()\nsilva = 'silv...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def start_thread(target): thread = threading.Thread(target=target) thread.daemon = True thread.start() <|reserved_special_token_0|> def receive_data(): while True: data = sock.recv(1024).decode() print('decoded is', data) if data == 'button': ...
flexible
{ "blob_id": "cc924892afe179e55166ea9b237b2bfe8ea900df", "index": 2120, "step-1": "<mask token>\n\n\ndef start_thread(target):\n thread = threading.Thread(target=target)\n thread.daemon = True\n thread.start()\n\n\n<mask token>\n\n\ndef receive_data():\n while True:\n data = sock.recv(1024).dec...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def getDistanceByHaversine(loc1, loc2): """Haversine formula - give coordinates as a 2D numpy array of (lat_denter link description hereecimal,lon_decimal) pairs""" lat1 = loc1[1] lon1 = loc1[0] lat2 = loc2[1] lon2 = loc2[0] lon1 = lon1 * sp.pi / 180.0 lon2...
flexible
{ "blob_id": "d2e3ac490ce5fdc20976567fa320a9e6a53cbe34", "index": 1037, "step-1": "<mask token>\n\n\ndef getDistanceByHaversine(loc1, loc2):\n \"\"\"Haversine formula - give coordinates as a 2D numpy array of\n (lat_denter link description hereecimal,lon_decimal) pairs\"\"\"\n lat1 = loc1[1]\n lon1 = ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class PraiseHistory(TimeStampedModel): class Meta: verbose_name = '칭찬 내역' verbose_name_plural = verbose_name praise = models.ForeignKey(Praise, verbose_name='칭찬') choices = JSONField(verbose_name='칭찬 대상 목록') sender_key = models.CharField(verbose_name='보낸 ...
flexible
{ "blob_id": "a4db12fee72989f983c1069839dc0a5ede4561a3", "index": 686, "step-1": "<mask token>\n\n\nclass PraiseHistory(TimeStampedModel):\n\n\n class Meta:\n verbose_name = '칭찬 내역'\n verbose_name_plural = verbose_name\n praise = models.ForeignKey(Praise, verbose_name='칭찬')\n choices = JSON...
[ 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def extract_gpx_data(gpx_file_path, attribute='elevation'): """Reads in a GPX file and returns a list of values for a specified GPX attribute. Parameters ---------- gpx_file_path : str File path to t...
flexible
{ "blob_id": "cc6d18785eff0406ff7f38f18f15476375e31b76", "index": 9254, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef extract_gpx_data(gpx_file_path, attribute='elevation'):\n \"\"\"Reads in a GPX file and returns a list of values\n for a specified GPX attribute.\n\n Parameters\n ----...
[ 0, 1, 2, 3 ]
from django import forms from django.conf import settings class SurveyFeedback(forms.Form): CHOICES = [('Very Satisfied', 'Very Satisfied'), ('Satisfied', 'Satisfied'), ('Neither', 'Neither'), ('Dissatisfied', 'Dissatisfied'), ('Very Dissatisfied', 'Very Dissatisfied')] radioFeedback = forms.C...
normal
{ "blob_id": "a9b7abaaaa811cf12a15def1f2dd21f95bac3d62", "index": 6310, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SurveyFeedback(forms.Form):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass SurveyFeedback(forms.Form):\n CHOICES = [('Very Sat...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def play(): print('playing tank games...') <|reserved_special_token_0|> <|reserved_special_token_1|> def play(): print('playing tank games...') print('runing tank now!!!') <|reserved_special_token_1|> def play(): print("playing tank game...
flexible
{ "blob_id": "8c7fe90972feec19e280d3bccd39391af666608a", "index": 9410, "step-1": "<mask token>\n", "step-2": "def play():\n print('playing tank games...')\n\n\n<mask token>\n", "step-3": "def play():\n print('playing tank games...')\n\n\nprint('runing tank now!!!')\n", "step-4": "def play():\n pri...
[ 0, 1, 2, 3 ]
from pyspark.sql import SparkSession, Row, functions, Column from pyspark.sql.types import * from pyspark.ml import Pipeline, Estimator from pyspark.ml.feature import SQLTransformer, VectorAssembler from pyspark.ml.evaluation import RegressionEvaluator from pyspark.ml.tuning import TrainValidationSplit, ParamGridBuild...
normal
{ "blob_id": "3852ff2f3f4ac889256bd5f4e36a86d483857cef", "index": 6534, "step-1": "<mask token>\n\n\ndef get_data(inputloc, tablename='data'):\n data = spark.read.csv(inputloc, schema=schema)\n data.createOrReplaceTempView(tablename)\n return data\n\n\n<mask token>\n\n\ndef resolved_max(df):\n df_max ...
[ 4, 5, 6, 7, 8 ]
import json import os from six import iteritems from ..exceptions import ColinConfigException from ..constant import CONFIG_DIRECTORY, JSON from ..loader import load_check_implementation from ..target import is_compatible class Config(object): def __init__(self, name=None): """ Load config for ...
normal
{ "blob_id": "7bb9455e6f0c15ab0be6963cff06ff41df73e6e0", "index": 2583, "step-1": "<mask token>\n\n\nclass Config(object):\n\n def __init__(self, name=None):\n \"\"\"\n Load config for colin.\n\n :param name: str (name of the config file (without .json), default is \"default\"\n \"\...
[ 6, 7, 8, 9, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def cLineGraph(j_file): data = [] with open(j_file) as f: for line in f: data.append(json.loads(line)) data = data[0] in_other = 0 in_picture = 1 in_text = 2 values = [] time =...
flexible
{ "blob_id": "319af5232c043d77a9d63ab1efa62d857da6db23", "index": 1508, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef cLineGraph(j_file):\n data = []\n with open(j_file) as f:\n for line in f:\n data.append(json.loads(line))\n data = data[0]\n in_other = 0\n in_pi...
[ 0, 1, 2, 3 ]
# leetcode 836 # determine if two rectangles overlap # input is two lists [x1,y1,x2,y2] coordinates # where x1,y1 are coordinates of bottom left corner # and x2,y2 are coordinates of top right corner def overlap_rect(rec1, rec2): """Determine if rectangles overlap.""" # true if rec2 is left of rec1 a = rec...
normal
{ "blob_id": "0ef03ed455938bd2001581986c38104bfac395ce", "index": 8078, "step-1": "<mask token>\n", "step-2": "def overlap_rect(rec1, rec2):\n \"\"\"Determine if rectangles overlap.\"\"\"\n a = rec2[2] <= rec1[0]\n b = rec1[2] <= rec2[0]\n c = rec2[3] <= rec1[1]\n d = rec1[3] <= rec2[1]\n retu...
[ 0, 1, 2 ]