code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
# strspn(str1,str2) str1 = '12345678' str2 = '456' # str1 and chars both in str1 and str2 print(str1 and str2) str1 = 'cekjgdklab' str2 = 'gka' nPos = -1 for c in str1: if c in str2: nPos = str1.index(c) break print(nPos)
normal
{ "blob_id": "5c30b0e952ddf2e05a7ad5f8d9bbd4f5e22f887d", "index": 62, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(str1 and str2)\n<mask token>\nfor c in str1:\n if c in str2:\n nPos = str1.index(c)\n break\nprint(nPos)\n", "step-3": "str1 = '12345678'\nstr2 = '456'\nprint(str1 ...
[ 0, 1, 2, 3 ]
import datetime import subprocess from time import sleep from flask import render_template, redirect, request, url_for, flash, abort from dirkules import app, db, scheduler, app_version import dirkules.manager.serviceManager as servMan import dirkules.manager.driveManager as driveMan import dirkules.manager.cleaning as...
normal
{ "blob_id": "ab27780b19db6854855af51eea063f07d9eb7302", "index": 3553, "step-1": "<mask token>\n\n\n@app.errorhandler(500)\ndef internal_server_error(e):\n return render_template('500.html', error=str(e))\n\n\n<mask token>\n\n\n@app.route('/pools', methods=['GET'])\ndef pools():\n return render_template('p...
[ 5, 8, 9, 11, 13 ]
<|reserved_special_token_0|> def prepare_dataset(dataset_path, json_path, n_mfcc=13, hop_length=512, n_fft=2048): data = {'mappings': [], 'labels': [], 'MFCCs': [], 'files': []} for i, (dir_path, dir_names, filenames) in enumerate(os.walk(dataset_path) ): if dir_path is not dataset_path: ...
flexible
{ "blob_id": "ba808d23f6a8226f40e1c214012a1535ee1e9e98", "index": 2947, "step-1": "<mask token>\n\n\ndef prepare_dataset(dataset_path, json_path, n_mfcc=13, hop_length=512,\n n_fft=2048):\n data = {'mappings': [], 'labels': [], 'MFCCs': [], 'files': []}\n for i, (dir_path, dir_names, filenames) in enumer...
[ 1, 2, 3, 4, 5 ]
from setuptools import setup import imp def get_version(): ver_file = None try: ver_file, pathname, description = imp.find_module('__version__', ['cmakelint']) vermod = imp.load_module('__version__', ver_file, pathname, description) version = vermod.VERSION return version ...
normal
{ "blob_id": "b3d9013ab6facb8dd9361e2a0715a8ed0cdfeaba", "index": 342, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_version():\n ver_file = None\n try:\n ver_file, pathname, description = imp.find_module('__version__', [\n 'cmakelint'])\n vermod = imp.load_modu...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def sigmoid(x): return expit(x) def LRcost(t, pred): pred[pred == 0.0] = 10 ** -10 cost_per_sample = -t * np.log(pred) - (1 - t) * np.log(1 - pred) avg_cost = np.mean(cost_per_sample) return avg_cost def LRgradient_batch(X, y, pred): m = X.shape[0] grad = n...
flexible
{ "blob_id": "3accf1c066547c4939c104c36247370b4a260635", "index": 8959, "step-1": "<mask token>\n\n\ndef sigmoid(x):\n return expit(x)\n\n\ndef LRcost(t, pred):\n pred[pred == 0.0] = 10 ** -10\n cost_per_sample = -t * np.log(pred) - (1 - t) * np.log(1 - pred)\n avg_cost = np.mean(cost_per_sample)\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def hello(): print(_conf['greeting']) print(_pkg_data) print(_sys_data) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> try: _sys_data = open(sys.prefix + '/data/data1.dat').read() except Exception as exc: print(exc) _sys...
flexible
{ "blob_id": "4689ee7f7178cef16ac1f5375481a9ee8a48f924", "index": 3780, "step-1": "<mask token>\n\n\ndef hello():\n print(_conf['greeting'])\n print(_pkg_data)\n print(_sys_data)\n\n\n<mask token>\n", "step-2": "<mask token>\ntry:\n _sys_data = open(sys.prefix + '/data/data1.dat').read()\nexcept Exc...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding:utf-8 -*- school = "Old boy" def chang_name(name): global school #声明全局变量 school = "Mage Linux" print("Before change:", name, school) name = 'Stack Cong' age = 33 print("After change:", name) print("School:", school) name = "Stack" chang_name(name) print(na...
normal
{ "blob_id": "a9531fb020428e573d189c377652692e301ea4d3", "index": 3026, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef chang_name(name):\n global school\n school = 'Mage Linux'\n print('Before change:', name, school)\n name = 'Stack Cong'\n age = 33\n print('After change:', name)...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def GetRadius(Ri, DV, mu): def f(Rf): return sqrt(mu / Ri) * (sqrt(2 * Rf / (Rf + Ri)) - 1) + sqrt(mu / Rf ) * (1 - sqrt(2 * Ri / (Rf + Ri))) - DV return newton(f, Ri) <|reserved_special_token_0|> ...
flexible
{ "blob_id": "20722cf82371d176942e068e91b8fb38b4db61fd", "index": 6951, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef GetRadius(Ri, DV, mu):\n\n def f(Rf):\n return sqrt(mu / Ri) * (sqrt(2 * Rf / (Rf + Ri)) - 1) + sqrt(mu / Rf\n ) * (1 - sqrt(2 * Ri / (Rf + Ri))) - DV\n re...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class SNS(email_service_interface.EmailService): <|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 M...
flexible
{ "blob_id": "16dd73f2c85eff8d62cf0e605489d0db1616e36e", "index": 8650, "step-1": "<mask token>\n\n\nclass SNS(email_service_interface.EmailService):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass MockSNS(SNS):\n \"\"\"\n...
[ 6, 12, 14, 15, 16 ]
<|reserved_special_token_0|> class AsyncConsumer(AsyncWebsocketConsumer): <|reserved_special_token_0|> async def connect(self): self.room_name = self.scope['url_route']['kwargs']['room_name'] self.room_group_name = 'chat_%s' % self.room_name await self.channel_layer.group_add(self.roo...
flexible
{ "blob_id": "7955479c70de679cfb7575c8bd9208d00a4893df", "index": 4979, "step-1": "<mask token>\n\n\nclass AsyncConsumer(AsyncWebsocketConsumer):\n <mask token>\n\n async def connect(self):\n self.room_name = self.scope['url_route']['kwargs']['room_name']\n self.room_group_name = 'chat_%s' % s...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def main(): global device args = parse_args() cfg = Config.from_file(args.config) out = cfg.train.out if not os.path.exists(out): os.makedirs(out) cuda = torch.cuda.is_available() if cuda and args.gpu >= 0: print('# cuda available! #') d...
flexible
{ "blob_id": "d6c06a465c36430e4f2d355450dc495061913d77", "index": 5357, "step-1": "<mask token>\n\n\ndef main():\n global device\n args = parse_args()\n cfg = Config.from_file(args.config)\n out = cfg.train.out\n if not os.path.exists(out):\n os.makedirs(out)\n cuda = torch.cuda.is_availa...
[ 4, 6, 7, 8, 9 ]
#Exercício Python 055: Faça um programa que leia o peso de cinco pessoas. No final, mostre qual foi o maior e o menor peso lidos. pessoas = int(input('Informe a quantidade de pessoas que deseja analisar: ')) peso = 0 maior = 0 menor = 0 for c in range(0, pessoas): peso = float(input('Informe o peso: ')) if c ==...
normal
{ "blob_id": "78c71a4f3c4e8f24f0ae90555a3caf15f35332f6", "index": 1774, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor c in range(0, pessoas):\n peso = float(input('Informe o peso: '))\n if c == 1:\n maior = peso\n menor = peso\n else:\n if peso > maior:\n maio...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Movie: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Movie: def __init__(self, movieid, moviename, score, poster): self.movieid = movieid self.moviename = moviename sel...
flexible
{ "blob_id": "856e62cf4cd443c7b3397e926f8fc4fece145f5b", "index": 3447, "step-1": "<mask token>\n", "step-2": "class Movie:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Movie:\n\n def __init__(self, movieid, moviename, score, poster):\n self.movieid = movieid\n self.moviename = mo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('Retrieving: ', url) <|reserved_special_token_0|> print('Retrieved', len(data), 'characters') <|reserved_special_token_0|> print('User count:', len(info['comments'])) <|reserved_special_token_0|> for items in x: y = item...
flexible
{ "blob_id": "cd175c236dd1d1c7387a21a491e80d6723f161dc", "index": 7762, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Retrieving: ', url)\n<mask token>\nprint('Retrieved', len(data), 'characters')\n<mask token>\nprint('User count:', len(info['comments']))\n<mask token>\nfor items in x:\n y = it...
[ 0, 1, 2, 3, 4 ]
from boxsdk import Client, OAuth2 import os import sys def ConfigObject(config_path): "read a configuration file to retrieve access token" configDict = {} with open(config_path,'r') as config: for line in config.readlines(): try: configDict[line.split("=")[0]] = line.sp...
normal
{ "blob_id": "e76ebbe8dab2e5169ef40b559f783c49ba4de825", "index": 1750, "step-1": "<mask token>\n\n\ndef ConfigObject(config_path):\n \"\"\"read a configuration file to retrieve access token\"\"\"\n configDict = {}\n with open(config_path, 'r') as config:\n for line in config.readlines():\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_tensortuple(): a = torch.randn(3, 3), torch.randn(3, 3) t = TensorTuple(a) assert t[0].dtype == torch.float32 assert t.to(torch.int32)[0].dtype == torch.int32 <|reserved_special_token_1|> <|reserved_s...
flexible
{ "blob_id": "c70b4ff26abe3d85e41bfc7a32cf6e1ce4c48d07", "index": 6291, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_tensortuple():\n a = torch.randn(3, 3), torch.randn(3, 3)\n t = TensorTuple(a)\n assert t[0].dtype == torch.float32\n assert t.to(torch.int32)[0].dtype == torch.i...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class TimeUtils(object): <|reserved_special_token_0|> class StringUtils(object): @staticmethod def remove_emoji_from_string(text): co = re.compile(u'[𐀀-\U0010ffff]') return co.sub(u'', text) <|reserved_special_token_1|> <|reserved_special_token_0|> cla...
flexible
{ "blob_id": "933f74e4fda0b30bdf70ff3f3dbde2383b10c694", "index": 8773, "step-1": "<mask token>\n\n\nclass TimeUtils(object):\n <mask token>\n\n\nclass StringUtils(object):\n\n @staticmethod\n def remove_emoji_from_string(text):\n co = re.compile(u'[𐀀-\\U0010ffff]')\n return co.sub(u'', te...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python from setuptools import setup, find_packages #if sys.argv[-1] == 'publish': # os.system('python setup.py sdist upload') # sys.exit() with open('bace/__init__.py') as fid: for line in fid: if line.startswith('__version__'): VERSION = line.strip().split()[-1][1:-1] ...
normal
{ "blob_id": "d28571214805df766c2cc2f45a6b5bea88d7ac18", "index": 9371, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('bace/__init__.py') as fid:\n for line in fid:\n if line.startswith('__version__'):\n VERSION = line.strip().split()[-1][1:-1]\n break\nwith open...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def plotImage(f): folder = 'C:/temp/' im = imread(os.path.join(folder, f)).astype(np.float32) / 255 plt.imshow(im) a = plt.gca() a.get_xaxis().set_visible(False) a.get_yaxis().set_visible(False) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reser...
flexible
{ "blob_id": "146db68fb84569b914fa741457c595108088dc63", "index": 7199, "step-1": "<mask token>\n\n\ndef plotImage(f):\n folder = 'C:/temp/'\n im = imread(os.path.join(folder, f)).astype(np.float32) / 255\n plt.imshow(im)\n a = plt.gca()\n a.get_xaxis().set_visible(False)\n a.get_yaxis().set_vis...
[ 1, 2, 3, 4, 5 ]
import p01 as p stu = p.Student() stu.say() p.sayHello()
normal
{ "blob_id": "8be3a3d32da208e2f45aad61813bc6f5ea513f01", "index": 9803, "step-1": "<mask token>\n", "step-2": "<mask token>\nstu.say()\np.sayHello()\n", "step-3": "<mask token>\nstu = p.Student()\nstu.say()\np.sayHello()\n", "step-4": "import p01 as p\nstu = p.Student()\nstu.say()\np.sayHello()\n", "step-...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def lambda_handler(event, context): body = event videoPath = str(body['videoPath']) templatePath = str(body['templatePath']) facePath = str(body['facePath']) targetPeople = str(body['targetPeople']) FACES...
flexible
{ "blob_id": "8c96c38a67c2eb97e30b325e4917ba4888731118", "index": 7349, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lambda_handler(event, context):\n body = event\n videoPath = str(body['videoPath'])\n templatePath = str(body['templatePath'])\n facePath = str(body['facePath'])\n ...
[ 0, 1, 2, 3, 4 ]
""""""""""""""" Write Data """"""""""""""" import json from city import City def load_json(file_name='data.json'): with open(file_name, 'r') as json_fp: json_data = json_fp.read() data_arr = json.loads(json_data) return data_arr if __name__ == '__main__': json_file = 'data.json' ...
normal
{ "blob_id": "63068a15d750abb29398d687495d6001ba17ab8a", "index": 9435, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef load_json(file_name='data.json'):\n with open(file_name, 'r') as json_fp:\n json_data = json_fp.read()\n data_arr = json.loads(json_data)\n return data_arr...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('Praktikum Programa Komputer ') print('Exercise 7.21') print('') print('===========================') print('Nama : Ivanindra Rizky P') print('NIM : I0320054') print('') print('===========================') print('') <|reserved_special_token_0|> print('...
flexible
{ "blob_id": "6b731e329eec3947a17ef8ee8280f2ddf980c81c", "index": 7154, "step-1": "<mask token>\n", "step-2": "print('Praktikum Programa Komputer ')\nprint('Exercise 7.21')\nprint('')\nprint('===========================')\nprint('Nama : Ivanindra Rizky P')\nprint('NIM : I0320054')\nprint('')\nprint('===========...
[ 0, 1, 2, 3, 4 ]
"""Class for better periodic call handling""" import tornado import tornado.gen import logging class YieldPeriodicCallback(object): """Class for better periodic call""" def __init__(self, callback, callback_time, io_loop=None, faststart=False): """Init method it can be used like tornado periodic callb...
normal
{ "blob_id": "7726f8cc9adf15823cccdaa4ba316800bb134460", "index": 1920, "step-1": "<mask token>\n\n\nclass YieldPeriodicCallback(object):\n <mask token>\n\n def __init__(self, callback, callback_time, io_loop=None, faststart=False):\n \"\"\"Init method it can be used like tornado periodic callback, b...
[ 5, 6, 7, 8, 9 ]
import argparse from figure import Figure from figure.Circle import Circle from figure.Square import Square class FCreator(object): __types = ['square', 'circle'] def createParser(self, line: str): parser = argparse.ArgumentParser() parser.add_argument('-t', '--type', required=True, choices=...
normal
{ "blob_id": "086ee4de1d74654ef85bd0a169fdf49c8f52bef2", "index": 3792, "step-1": "<mask token>\n\n\nclass FCreator(object):\n <mask token>\n <mask token>\n\n def editParser(self, line: str):\n parser = argparse.ArgumentParser()\n parser.add_argument('-n', '--name', required=True)\n ...
[ 5, 7, 8, 9, 12 ]
# Generated by Django 3.2 on 2021-04-20 13:08 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('excursions', '0003_auto_20210420_1608'), ] operations = [ migrations.AlterField( model_name='exscursion', name='type',...
normal
{ "blob_id": "a048396019aa7603a20535a3ce4bc9770509097d", "index": 2291, "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 = [('excursions'...
[ 0, 1, 2, 3, 4 ]
from .isearch import ISearcher __all__ = ['ISearcher']
normal
{ "blob_id": "13e2f474294edb7c78bd81456097d1389e6a0f1b", "index": 5003, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['ISearcher']\n", "step-3": "from .isearch import ISearcher\n__all__ = ['ISearcher']\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def dado(n): i = 1 dos = 0 tres = 0 cuatro = 0 cinco = 0 seis = 0 siete = 0 ocho = 0 nueve = 0 diez = 0 once = 0 doce = 0 cont = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] while i <...
flexible
{ "blob_id": "2d0d73c0ea20d6736c10d5201abcfa9d561ef216", "index": 7474, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef dado(n):\n i = 1\n dos = 0\n tres = 0\n cuatro = 0\n cinco = 0\n seis = 0\n siete = 0\n ocho = 0\n nueve = 0\n diez = 0\n once = 0\n doce = 0\n...
[ 0, 1, 2, 3, 4 ]
from unittest import mock import pytest from lms.models import GroupInfo from lms.services.group_info import GroupInfoService from tests import factories class TestGroupInfoService: AUTHORITY = "TEST_AUTHORITY_PROVIDED_ID" def test_upsert_group_info_adds_a_new_if_none_exists(self, db_session, svc, params):...
normal
{ "blob_id": "07452795a677836b89eef85b6fb25b33eb464d91", "index": 1919, "step-1": "<mask token>\n\n\nclass TestGroupInfoService:\n <mask token>\n\n def test_upsert_group_info_adds_a_new_if_none_exists(self, db_session,\n svc, params):\n course = factories.Course(authority_provided_id=self.AUTH...
[ 7, 11, 13, 14, 15 ]
<|reserved_special_token_0|> class WaypointUpdater(object): def __init__(self): rospy.init_node('waypoint_updater') rospy.Subscriber('/current_pose', PoseStamped, self.pose_cb) rospy.Subscriber('/base_waypoints', Lane, self.waypoints_cb) rospy.Subscriber('/traffic_waypoint', Int32...
flexible
{ "blob_id": "9ad92b23b8a02204a86af599e507eb889e5bcec7", "index": 7565, "step-1": "<mask token>\n\n\nclass WaypointUpdater(object):\n\n def __init__(self):\n rospy.init_node('waypoint_updater')\n rospy.Subscriber('/current_pose', PoseStamped, self.pose_cb)\n rospy.Subscriber('/base_waypoin...
[ 10, 15, 16, 17, 19 ]
from bs4 import BeautifulSoup from bs4 import BeautifulSoup import requests,pymysql,random,time import http.cookiejar from multiprocessing import Pool,Lock def get_proxies_ip(): db = pymysql.connect("localhost","root","xxx","xxx",charset='utf8') cursor = db.cursor() sql = "SELECT * FROM proxies_info;" ...
normal
{ "blob_id": "d49aa03cd6b8ba94d68a1bc1e064f77fded65000", "index": 8870, "step-1": "<mask token>\n\n\ndef get_headers():\n USER_AGENTS = [\n 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)'\n ,\n 'Mozilla/4.0 (compatible; MSIE 7.0...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class ThermalSpectrum(Spectrum): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @staticmethod def units_string(): return '1/erg/cm^3' def integrate(self, units=True, e_weight=0): ...
flexible
{ "blob_id": "8560c0068eff894e5aa1d0788bd9e5ad05c14997", "index": 2262, "step-1": "<mask token>\n\n\nclass ThermalSpectrum(Spectrum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def units_string():\n return '1/erg/cm^3'\n\n def integrate(self, units=...
[ 9, 12, 13, 14, 16 ]
<|reserved_special_token_0|> class RegressionFitness(evo.Fitness): <|reserved_special_token_0|> def __init__(self, train_inputs, train_output, error_fitness, handled_errors, stats: evo.utils.stats.Stats=None, store_bsfs: bool =True, fitness_measure: evo.sr.ErrorMeasure=evo.sr.ErrorMeasure.R2)...
flexible
{ "blob_id": "e53d4bb853eb54e4dfedf7126480e2c3e1af1378", "index": 2825, "step-1": "<mask token>\n\n\nclass RegressionFitness(evo.Fitness):\n <mask token>\n\n def __init__(self, train_inputs, train_output, error_fitness,\n handled_errors, stats: evo.utils.stats.Stats=None, store_bsfs: bool\n =T...
[ 5, 6, 7, 9, 11 ]
<|reserved_special_token_0|> @celery_app.task(bind=True) def debug_task(self): print('Request: {0!r}'.format(self.request)) <|reserved_special_token_1|> <|reserved_special_token_0|> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'nightcrawler.settings') <|reserved_special_token_0|> celery_app.config_from_obje...
flexible
{ "blob_id": "d4bc6bfe6bef730273db38f3c99352bbc3f48a5f", "index": 7604, "step-1": "<mask token>\n\n\n@celery_app.task(bind=True)\ndef debug_task(self):\n print('Request: {0!r}'.format(self.request))\n", "step-2": "<mask token>\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'nightcrawler.settings')\n<mask t...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class ChatMessage(models.Model): context = models.CharField(max_length=1000) user = models.ForeignKey(User, on_delete=models.CASCADE) chat = models.ForeignKey(Chat, on_delete=models.CASCADE) timestamp = models.DateTimeField(auto_now_add=True) def __str__(self): ...
flexible
{ "blob_id": "61179dc734069017adaabd53804ed0102d9416e3", "index": 8865, "step-1": "<mask token>\n\n\nclass ChatMessage(models.Model):\n context = models.CharField(max_length=1000)\n user = models.ForeignKey(User, on_delete=models.CASCADE)\n chat = models.ForeignKey(Chat, on_delete=models.CASCADE)\n ti...
[ 3, 4, 5, 6, 7 ]
<|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": "99154212d8d5fdb92cd972c727791158d09e3e2c", "index": 3789, "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 = [('civictechpr...
[ 0, 1, 2, 3, 4 ]
from collections import defaultdict class Graph: def __init__(self): self._graph = defaultdict(list) self._odd_vertices = [] def add_vertex(self, v): if not v in self._graph: self._graph[v] = list() def add_edge(self, v1, v2): self._graph[v1].append(v2) ...
normal
{ "blob_id": "b4d412e8b45722a855a16dd64b7bce9b303d0ffe", "index": 964, "step-1": "<mask token>\n\n\nclass Graph:\n\n def __init__(self):\n self._graph = defaultdict(list)\n self._odd_vertices = []\n\n def add_vertex(self, v):\n if not v in self._graph:\n self._graph[v] = list...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): c1 = Print('HLT_HT550_HLT_HT250.pdf') c1.open() diffList = [] cumuList = [] histList = 'HT_Nom', 'HT_Denom' dirs = ['HLT_HT550_v11_HLT_HT250_v11', 'HLT_HT550_v2_HLT_HT250_v2', 'HLT_HT5...
flexible
{ "blob_id": "e748420dfdb77fa8661111a92fc48b79f64bff10", "index": 4128, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n c1 = Print('HLT_HT550_HLT_HT250.pdf')\n c1.open()\n diffList = []\n cumuList = []\n histList = 'HT_Nom', 'HT_Denom'\n dirs = ['HLT_HT550_v11_HLT_HT250_...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def guguPrint(n): print('*' * 30) for i in range(1, 10): print('{} X {} = {}'.format(n, i, n * i)) <|reserved_special_token_0|> <|reserved_special_token_1|> def guguPrint(n): print('*' * 30) for i in range(1, 10): print('{...
flexible
{ "blob_id": "aa2e24d80789f2a6ebd63ec42a17499f1e79ca49", "index": 5237, "step-1": "<mask token>\n", "step-2": "def guguPrint(n):\n print('*' * 30)\n for i in range(1, 10):\n print('{} X {} = {}'.format(n, i, n * i))\n\n\n<mask token>\n", "step-3": "def guguPrint(n):\n print('*' * 30)\n for ...
[ 0, 1, 2, 3 ]
#!/usr/bin/python # -*- coding: utf-8 -*- import os # Describes where to search for the config file if no location is specified DEFAULT_CONFIG_LOCATION = "config.json" DEFAULT_CONFIG = { "project": None, "fixed_model_name": None, "config": DEFAULT_CONFIG_LOCATION, "data": None, "emulate": None...
normal
{ "blob_id": "5c4c893caa19e58491e641420261bb70e7202cf0", "index": 3566, "step-1": "<mask token>\n\n\nclass AnnotatorConfig(object):\n <mask token>\n\n def __init__(self, filename=None):\n pass\n <mask token>\n\n def get(self, key, default=None):\n return self.__dict__.get(key, default)\n...
[ 11, 13, 15, 16, 19 ]
import tensorflow as tf from model import CabbageModel import numpy as np from krx import KrxCrawler from naver_stock import StockModel as sm from scattertest import scattertest as st class CabbageController: def __init__(self): #def __init__(self, avg_temp, min_temp, max_temp, rain_fall): #self._a...
normal
{ "blob_id": "90a220775efcc8ff9e83f1a1f011f424ddc3476d", "index": 4487, "step-1": "<mask token>\n\n\nclass CabbageController:\n <mask token>\n\n def service(self):\n X = tf.placeholder(tf.float32, shape=[None, 4])\n W = tf.Variable(tf.random_normal([4, 1]), name='weight')\n b = tf.Varia...
[ 2, 3, 4, 5, 6 ]
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from pants.backend.scala.goals.tailor import classify_source_files from pants.backend.scala.target_types import ( ScalaJunitTestsGeneratorTarget, ScalaSourcesGeneratorTarget, ...
normal
{ "blob_id": "42d2d8717ec2c25a99302e8de3090d600f8e80ff", "index": 674, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_classify_source_files() ->None:\n scalatest_files = {'foo/bar/BazSpec.scala'}\n junit_files = {'foo/bar/BazTest.scala'}\n lib_files = {'foo/bar/Baz.scala'}\n asser...
[ 0, 1, 2, 3 ]
import pymongo myclient = pymongo.MongoClient('mongodb://localhost:27017/') #We create the database object mydb = myclient['mydatabase'] #Create a database mycol = mydb['customers'] #Create a collection into my mydatabase mydict = [{"name": "Eric", "address": "Highway 37"}, {"name": "Albert", "address": "Highway 37...
normal
{ "blob_id": "6c6026a7ff0345c37e62de7c0aac0ee3bcde2c82", "index": 5879, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(mydoc)\n", "step-3": "<mask token>\nmyclient = pymongo.MongoClient('mongodb://localhost:27017/')\nmydb = myclient['mydatabase']\nmycol = mydb['customers']\nmydict = [{'name': 'Eri...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_pilatus_timestamp(timestamp_string): if '.' in timestamp_string: timestamp, milliseconds = timestamp_string.split('.') else: timestamp = timestamp_string milliseconds = '000' for forma...
flexible
{ "blob_id": "21526dabe8456c599e4409228fa69ffd0d672c5b", "index": 4689, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_pilatus_timestamp(timestamp_string):\n if '.' in timestamp_string:\n timestamp, milliseconds = timestamp_string.split('.')\n else:\n timestamp = timestamp_...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def storeInorder(root, inorder): if root is None: return storeInorder(root.left, inorder) inorder.append(root.data) storeInorder(root.right, inorder) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def storeInorder(root...
flexible
{ "blob_id": "d2af2b25a1ba2db93c977a13fe0273919bc2e6e0", "index": 7768, "step-1": "<mask token>\n\n\ndef storeInorder(root, inorder):\n if root is None:\n return\n storeInorder(root.left, inorder)\n inorder.append(root.data)\n storeInorder(root.right, inorder)\n\n\n<mask token>\n", "step-2": ...
[ 1, 3, 4, 5, 6 ]
# 5.2 Training a convnet from scratch on a "small dataset" (p.131) # Preprocessing (p.133) # Copying images to train, validation and test directories import os, shutil # The path to the directory where the original dataset was uncompressed original_dataset_dir = 'E:/train/' # The directory where we will store our sma...
normal
{ "blob_id": "8340872f03c1bf7c1aee0c437258ac8e44e08bb8", "index": 7313, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.mkdir(base_dir)\n<mask token>\nos.mkdir(train_dir)\n<mask token>\nos.mkdir(validation_dir)\n<mask token>\nos.mkdir(test_dir)\n<mask token>\nos.mkdir(train_cats_dir)\n<mask token>\nos.m...
[ 0, 1, 2, 3, 4 ]
<|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": "a4c4a5cc63c345d1fa8cbf426f7857a0f3d4357f", "index": 8360, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('FAQ', '0004...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> mat_tissue.add_element('O', 0.079013) mat_tissue.add_element('C', 0.32948) mat_tissue.add_element('H', 0.546359) mat_tissue.add_element('N', 0.008619) mat_tissue.add_element('Mg', 0.036358) mat_tissue.add_element('Cl', 0.000172) m...
flexible
{ "blob_id": "28bf11cb4205dd186b84cc7b7c8b9009f35fe408", "index": 7415, "step-1": "<mask token>\n", "step-2": "<mask token>\nmat_tissue.add_element('O', 0.079013)\nmat_tissue.add_element('C', 0.32948)\nmat_tissue.add_element('H', 0.546359)\nmat_tissue.add_element('N', 0.008619)\nmat_tissue.add_element('Mg', 0.0...
[ 0, 1, 2, 3, 4 ]
from channels.generic.websocket import WebsocketConsumer, AsyncWebsocketConsumer from asgiref.sync import async_to_sync from channels.layers import get_channel_layer import json class AsyncConsumer(AsyncWebsocketConsumer): chats = dict() async def connect(self): # 连接时触发 self.room_name = self.scope...
normal
{ "blob_id": "7955479c70de679cfb7575c8bd9208d00a4893df", "index": 4979, "step-1": "<mask token>\n\n\nclass AsyncConsumer(AsyncWebsocketConsumer):\n <mask token>\n\n async def connect(self):\n self.room_name = self.scope['url_route']['kwargs']['room_name']\n self.room_group_name = 'chat_%s' % s...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def execute_file(input_fp, output_fp): oie = OIE() oie.extract_file(input_fp, output_fp) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def execute_file(input_fp, output_fp): oie = OIE() oie.extract_file(input_fp, output_fp) ...
flexible
{ "blob_id": "bc5e928305d82c92c10106fe1f69f5979d57e3d2", "index": 5446, "step-1": "<mask token>\n\n\ndef execute_file(input_fp, output_fp):\n oie = OIE()\n oie.extract_file(input_fp, output_fp)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef execute_file(input_fp, output_fp):\n oie = OIE()\n ...
[ 1, 3, 4, 5, 6 ]
class Step: def __init__(self, action): self.action = action def __str__(self) ->str: return f'Step: {{action: {self.action.__str__()}}}' def __repr__(self) ->str: return f'Step: {{action: {self.action.__str__()}}}'
normal
{ "blob_id": "9adff5da4e26088def9f0e32aa712a1f2b0336ba", "index": 925, "step-1": "class Step:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Step:\n <mask token>\n <mask token>\n\n def __repr__(self) ->str:\n return f'Step: {{action: {self.action.__str__()}}}'\n", "...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> def combinacaoDeEmbralhamento(qtdeLinhas): while True: a = randint(0, qtdeLinhas) b = randint(0, qtdeLinhas) if a == b: continue else: break resp = [[a, b]] return resp def embaralhaMatriz(x): for i in range(qtdeLin...
flexible
{ "blob_id": "28ed494939d0928bf3ad4f07f58186374e925426", "index": 7024, "step-1": "<mask token>\n\n\ndef combinacaoDeEmbralhamento(qtdeLinhas):\n while True:\n a = randint(0, qtdeLinhas)\n b = randint(0, qtdeLinhas)\n if a == b:\n continue\n else:\n break\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for ch in plainText: ordvalue = ord(ch) cipherValue = ordvalue + distance if cipherValue > 127: cipherValue = distance - (127 - ordvalue + 1) code += chr(cipherValue) print(code) <|reserved_special_token_...
flexible
{ "blob_id": "bf98e81c160d13b79ebe9d6f0487b57ad64d1322", "index": 7827, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor ch in plainText:\n ordvalue = ord(ch)\n cipherValue = ordvalue + distance\n if cipherValue > 127:\n cipherValue = distance - (127 - ordvalue + 1)\n code += chr(ciph...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class MipsVisitor: <|reserved_special_token_0|> def __init__(self, inherit_graph, output_file='mips_code.mips'): self.inherit_graph, _ = inherit_graph self.offset = dict() self.type_index = [] self.dispatchtable_code = [] self.prototypes_co...
flexible
{ "blob_id": "63bc191a81a200d3c257de429c082cc8d13c98f4", "index": 9952, "step-1": "<mask token>\n\n\nclass MipsVisitor:\n <mask token>\n\n def __init__(self, inherit_graph, output_file='mips_code.mips'):\n self.inherit_graph, _ = inherit_graph\n self.offset = dict()\n self.type_index = ...
[ 25, 31, 32, 48, 50 ]
x=input("Do you really want to run this program? (y/n) : ") x=x.upper() if x=="Y" or x=="N" or x=="Q": while x=="Y" or x=="N" or x=="Q": if x=="Q": print("Exiting the Program") import sys sys.exit() elif x=="N": print("You decided to leave. See you ag...
normal
{ "blob_id": "7dff15a16ecc3ce3952f4b47290393ea3183807f", "index": 4414, "step-1": "<mask token>\n", "step-2": "<mask token>\nif x == 'Y' or x == 'N' or x == 'Q':\n while x == 'Y' or x == 'N' or x == 'Q':\n if x == 'Q':\n print('Exiting the Program')\n import sys\n sys....
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def readInputModel(txt, equivalentAxisFit, Settings): psfwing_02pxscale_datatab = None psfwing_logscale_datatab = None componentslist = [] params = Parameters() data = open(txt) for line in data: ...
flexible
{ "blob_id": "219b22b6ad685fc316b1df02cc924a1cfec89f5b", "index": 650, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef readInputModel(txt, equivalentAxisFit, Settings):\n psfwing_02pxscale_datatab = None\n psfwing_logscale_datatab = None\n componentslist = []\n params = Parameters()\n ...
[ 0, 1, 2, 3 ]
""" Implements Single Instance Learning SVM From https://github.com/garydoranjr/misvm/blob/master/misvm/sil.py Modified by Nicolas """ from __future__ import print_function, division import numpy as np import inspect from sklearn.svm import LinearSVC as SVM from milsvm.util import slices class SIL(SVM): """ S...
normal
{ "blob_id": "f125269d5b52da41734ce94683139c44f0c4a66a", "index": 3402, "step-1": "<mask token>\n\n\nclass SIL(SVM):\n <mask token>\n <mask token>\n\n def fit(self, bags, y):\n \"\"\"\n @param bags : a sequence of n bags; each bag is an m-by-k array-like\n object contai...
[ 3, 4, 7, 8, 10 ]
<|reserved_special_token_0|> class OrderSuccessView(LoginRequiredMixin, View): """订单成功页面""" def get(self, request): """提供订单成功页面""" order_id = request.GET.get('order_id') payment_amount = request.GET.get('payment_amount') pay_method = request.GET.get('pay_method') conte...
flexible
{ "blob_id": "0402096f215ae600318d17bc70e5e3067b0a176b", "index": 3864, "step-1": "<mask token>\n\n\nclass OrderSuccessView(LoginRequiredMixin, View):\n \"\"\"订单成功页面\"\"\"\n\n def get(self, request):\n \"\"\"提供订单成功页面\"\"\"\n order_id = request.GET.get('order_id')\n payment_amount = requ...
[ 9, 16, 17, 19, 22 ]
<|reserved_special_token_0|> def cumprod(arr, MOD): L = len(arr) Lsq = int(L ** 0.5 + 1) arr = np.resize(arr, Lsq ** 2).reshape(Lsq, Lsq) for n in range(1, Lsq): arr[:, n] *= arr[:, n - 1] arr[:, n] %= MOD for n in range(1, Lsq): arr[n] *= arr[n - 1, -1] arr[n] %= M...
flexible
{ "blob_id": "43d5bf79f16e8530797cdd13cdfcc91f0d3aef5e", "index": 8208, "step-1": "<mask token>\n\n\ndef cumprod(arr, MOD):\n L = len(arr)\n Lsq = int(L ** 0.5 + 1)\n arr = np.resize(arr, Lsq ** 2).reshape(Lsq, Lsq)\n for n in range(1, Lsq):\n arr[:, n] *= arr[:, n - 1]\n arr[:, n] %= MO...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: def isToeplitzMatrix(self, matrix: List[List[int]]) ->bool: h = len(matrix) w = len(matrix[0]) for curRow in range(h): va...
flexible
{ "blob_id": "774f5d01cd274755626989c2b58bde68df349d8e", "index": 5845, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def isToeplitzMatrix(self, matrix: List[List[int]]) ->bool:\n h = len(matrix)\n w = len(matrix[0])\n for c...
[ 0, 1, 2, 3 ]
from django.db import models from accounts.models import User from cmdb.models.base import IDC from cmdb.models.asset import Server, NetDevice class CPU(models.Model): # Intel(R) Xeon(R) Gold 5118 CPU @ 2.30GHz version = models.CharField('型号版本', max_length=100, unique=True) speed = models.PositiveSmallInt...
normal
{ "blob_id": "6bd423223e1ec2bb3a213158ac6da3a6483b531f", "index": 4914, "step-1": "<mask token>\n\n\nclass NetworkAdapter(models.Model):\n <mask token>\n <mask token>\n\n\n class Meta:\n db_table = 'cmdb_acc_network_adapter'\n verbose_name = u'配件网卡表'\n verbose_name_plural = u'配件网卡表'\...
[ 15, 17, 18, 19, 27 ]
import subprocess from dissamblerAbstract import disassemblerAbstract #lib/ZydisDisasm -64 /home/nislab2/Desktop/DissamblerEffect/metamorphic/00fe0c08024f7db771d6711787d890a3.exe class ZydisDisassembler(disassemblerAbstract): def diassemble(self,filename, bits='32bit'): """ Disassembly executa...
normal
{ "blob_id": "fedec397ac0346bad1790315b4f85fbb1a662a4e", "index": 9466, "step-1": "<mask token>\n\n\nclass ZydisDisassembler(disassemblerAbstract):\n\n def diassemble(self, filename, bits='32bit'):\n \"\"\"\n Disassembly executable file return iterable instruction set.\n\n :param f...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class FaceRecognitionLib(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self): sub_dirs = glob(FaceRecognitionLib.__data_set_dir + '/*/'...
flexible
{ "blob_id": "2d69a39be3931aa4c62cadff4cdfad76f6b32c59", "index": 6473, "step-1": "<mask token>\n\n\nclass FaceRecognitionLib(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self):\n sub_dirs = glob(FaceRecognitionLib.__data_set_dir + '...
[ 3, 4, 5, 8, 9 ]
<|reserved_special_token_0|> @test(depends_on_classes=[AfterConfigurationsCreation], groups=[tests. DBAAS_API_CONFIGURATIONS]) class ListConfigurations(ConfigurationsTestBase): @test def test_configurations_list(self): result = instance_info.dbaas.configurations.list() for conf in result:...
flexible
{ "blob_id": "120021e44f6df9745db35ea2f38f25acecca9252", "index": 3201, "step-1": "<mask token>\n\n\n@test(depends_on_classes=[AfterConfigurationsCreation], groups=[tests.\n DBAAS_API_CONFIGURATIONS])\nclass ListConfigurations(ConfigurationsTestBase):\n\n @test\n def test_configurations_list(self):\n ...
[ 29, 40, 43, 52, 53 ]
#classes that store values related to levels from mg_cus_struct import * from mg_movement import * import copy class BulletTemplate(object) : def __init__(self, animationName, initialVelocity, hitbox) : self._spawningCycle = 0 self._animationName = animationName self._initialVelocity = init...
normal
{ "blob_id": "519746450826d02230a492a99e0b518602d53fcb", "index": 9932, "step-1": "<mask token>\n\n\nclass BulletSpawnerTemplate(object):\n <mask token>\n <mask token>\n\n def setRounds(self, rounds):\n self._rounds = rounds\n <mask token>\n\n def setInBetweenTimer(self, delay):\n sel...
[ 16, 19, 22, 25, 26 ]
# -*- coding:utf-8 -*- # Copyright 2015 NEC Corporation. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License...
normal
{ "blob_id": "b220189d506737bf8cff9e600d1cfd4d7bc8435d", "index": 1434, "step-1": "# -*- coding:utf-8 -*-\n\n# Copyright 2015 NEC Corporation. #\n# #\n# Licensed under the Apache License, Version 2.0 ...
[ 0 ]
# -*- coding: utf-8 -*- from django.http import Http404 from django.shortcuts import render,render_to_response, get_object_or_404, redirect, HttpResponse from django.core.context_processors import csrf from django.views.decorators.csrf import csrf_protect, csrf_exempt from django.template import RequestContext,Context...
normal
{ "blob_id": "fb16009985ee7fe4a467a94160f593723b5aaf03", "index": 7964, "step-1": "# -*- coding: utf-8 -*- \nfrom django.http import Http404\nfrom django.shortcuts import render,render_to_response, get_object_or_404, redirect, HttpResponse\nfrom django.core.context_processors import csrf\nfrom django.views.decora...
[ 0 ]
<|reserved_special_token_0|> def jsons_to_table(dir_jsons, dir_out, name, format='html'): """ Extracts the informations stored in the JSON files and stores creates an HTML-table for them. :param dir_jsons: directory of JSON files :param dir_out: output directory of the HTML-table :param name: na...
flexible
{ "blob_id": "d6e836140b1f9c955711402111dc07e74b4a23b1", "index": 1621, "step-1": "<mask token>\n\n\ndef jsons_to_table(dir_jsons, dir_out, name, format='html'):\n \"\"\"\n Extracts the informations stored in the JSON files and stores creates an HTML-table for them.\n\n :param dir_jsons: directory of JS...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import calendar as cal import random import pytz from datetime import datetime, timedelta, time from dateutil import rrule from dateutil.relativedelta import relativedelta from babel.dates import format_datetime from od...
normal
{ "blob_id": "e03dfa0e02313c5478d4e97dcaf3bc27915bd878", "index": 1421, "step-1": "<mask token>\n\n\nclass CalendarAppointmentSlot(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 @api.constrains('hour')\n def ch...
[ 7, 10, 12, 18, 19 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @login_required(login_url='/accounts/login/') def postpoject(request): if request.method == 'POST': postform = PostForm(request.POST, request.FILES) if postform.is_valid: pro = postform.save(commi...
flexible
{ "blob_id": "67de51e2a176907fd89793bd3ec52f898130e104", "index": 3713, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@login_required(login_url='/accounts/login/')\ndef postpoject(request):\n if request.method == 'POST':\n postform = PostForm(request.POST, request.FILES)\n if postfor...
[ 0, 3, 4, 5, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_current_user(s: str=None, required=True): """ get current user by request auth header :param s: :return: {'code': 'SUCCESS', 'nickName': 'gs1', 'appName': '__base__', 'tenantId': '650', 't...
flexible
{ "blob_id": "342063b37038c804c2afa78091b1f1c2facbc560", "index": 3102, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_current_user(s: str=None, required=True):\n \"\"\"\n get current user by request auth header\n :param s:\n :return:\n {'code': 'SUCCESS', 'nickName': 'gs1',...
[ 0, 1, 2, 3, 4 ]
import json from logger import logger def parse_json(text): start = text.find("{") end = text.find("}") + 1 try: data = json.loads(text[start:end]) return data except Exception: logger.error("json解析失败:%s" % text)
normal
{ "blob_id": "9f8fbfb8a9c849ca0e8881c479800c8e190e4a1c", "index": 6485, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_json(text):\n start = text.find('{')\n end = text.find('}') + 1\n try:\n data = json.loads(text[start:end])\n return data\n except Exception:\n ...
[ 0, 1, 2, 3 ]
#!c:\Python\python.exe # Fig 35.16: fig35_16.py # Program to display CGI environment variables import os import cgi print "Content-type: text/html" print print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">""" print """ <html xmlns = "http://www...
normal
{ "blob_id": "61b28088e4344d8a94006e5c04c189a44bbb6ff3", "index": 3334, "step-1": "#!c:\\Python\\python.exe\r\n# Fig 35.16: fig35_16.py\r\n# Program to display CGI environment variables\r\n\r\nimport os\r\nimport cgi\r\n\r\nprint \"Content-type: text/html\"\r\nprint\r\n\r\nprint \"\"\"<!DOCTYPE html PUBLIC\r\n ...
[ 0 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright 2020-2021 by Murray Altheim. All rights reserved. This file is part # of the Robot Operating System project, released under the MIT License. Please # see the LICENSE file included as part of this package. # # author: Murray Altheim # created: 2020-04-15 # ...
normal
{ "blob_id": "3a6038cb80548b98fc7e4a328092f1dc1ffd6dfd", "index": 1154, "step-1": "<mask token>\n\n\nclass ConfigLoader:\n <mask token>\n\n def __init__(self, level):\n self._log = Logger('configloader', level)\n self._log.info('ready.')\n\n def configure(self, filename='config.yaml'):\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class Board: <|reserved_special_token_0|> def draw_squares(self, win): win.fill(GREY) for row in range(ROWS): for col in range(row % 2, COLS, 2): pygame.draw.rect(win, WHITE, (row * SQUARE_SIZE, col * SQUARE_SIZE, SQ...
flexible
{ "blob_id": "b80b997f802c7ed4f0a838030703a314f2383c9d", "index": 5226, "step-1": "<mask token>\n\n\nclass Board:\n <mask token>\n\n def draw_squares(self, win):\n win.fill(GREY)\n for row in range(ROWS):\n for col in range(row % 2, COLS, 2):\n pygame.draw.rect(win, W...
[ 8, 9, 11, 13, 14 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> """Файл, который запускается при python qtester """
flexible
{ "blob_id": "90fc6590dab51141124ca73082b8d937008ae782", "index": 7400, "step-1": "<mask token>\n", "step-2": "\"\"\"Файл, который запускается при python qtester\n\"\"\"", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#!/usr/bin/python """ Starter code for exploring the Enron dataset (emails + finances); loads up the dataset (pickled dict of dicts). The dataset has the form: enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict } {features_dict} is a dictionary of features associated with that pers...
normal
{ "blob_id": "c5d224a3d63d0d67bc7a48fecec156cca41cdcf7", "index": 5129, "step-1": "#!/usr/bin/python\n\n\"\"\" \n Starter code for exploring the Enron dataset (emails + finances);\n loads up the dataset (pickled dict of dicts).\n\n The dataset has the form:\n enron_data[\"LASTNAME FIRSTNAME MIDDLEINIT...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if len(s) < 26: for i in range(26): c = chr(ord('a') + i) if c not in s: print(s + c) exit() else: for i in reversed(range(1, 26)): if s[i - 1] < s[i]: s1 = s[0:i...
flexible
{ "blob_id": "9931fc25118981bcce80cffd3fda9dc99d951bf5", "index": 180, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(s) < 26:\n for i in range(26):\n c = chr(ord('a') + i)\n if c not in s:\n print(s + c)\n exit()\nelse:\n for i in reversed(range(1, 26)):\n...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('admin/', admin.site.urls), path('api/', include( 'api.urls')), path('api/adv/', include('adventure.urls'))] <|reserved_special_token_1|> from django.contrib import admin from django.urls import path, in...
flexible
{ "blob_id": "a14114f9bb677601e6d75a72b84ec128fc9bbe61", "index": 71, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('admin/', admin.site.urls), path('api/', include(\n 'api.urls')), path('api/adv/', include('adventure.urls'))]\n", "step-3": "from django.contrib import admin\nfrom...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def saveDatadic(file_path, name, dataset): np.save(file_path + name + '_x', dataset['x']) np.save(file_path + name + '_t', dataset['t']) np.save(file_path + name + '_e', dataset['e']) <|reserved_special_token_0|> def encoder_z(mu_logvar, epsilon=None): mu, logvar = tf....
flexible
{ "blob_id": "ebebdb0e79e9d78b818dab3f93d130ccddd2914e", "index": 1185, "step-1": "<mask token>\n\n\ndef saveDatadic(file_path, name, dataset):\n np.save(file_path + name + '_x', dataset['x'])\n np.save(file_path + name + '_t', dataset['t'])\n np.save(file_path + name + '_e', dataset['e'])\n\n\n<mask tok...
[ 7, 10, 14, 17, 18 ]
class Solution: def validIPAddress(self, IP): """ :type IP: str :rtype: str """ def validateIPv4(IP): digits = IP.split('.') if len(digits) != 4: return False for digitstr in digits: if len(digitstr)...
normal
{ "blob_id": "6216a5e45fee8ade5ec9072c42c1b08f3b0f4c65", "index": 2433, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def validIPAddress(self, IP):\n \"\"\"\n :type IP: str\n :rtype: str\n \"\"\"\n\n def valida...
[ 0, 1, 2, 3 ]
from collections import deque def safeInsert(graph,left,right): if left not in graph: graph[left] = {} graph[left][right] = True if right not in graph: graph[right] = {} graph[right][left] = True def trace(graph,start,end): queue = deque([start]) pred = {start:None} while len(queue)>0: cur = queue.poplef...
normal
{ "blob_id": "3f655a12ac45c152215949d3d8bdb71147eeb849", "index": 3651, "step-1": "from collections import deque\n\ndef safeInsert(graph,left,right):\n\tif left not in graph:\n\t\tgraph[left] = {}\n\tgraph[left][right] = True\n\tif right not in graph:\n\t\tgraph[right] = {}\n\tgraph[right][left] = True\n\ndef tra...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def check_is_with_singleton(physical_line, line_number): match_obj = IS_WITH_SINGLETON_REGEX.search(physical_line) if match_obj is not None: offset = match_obj.span()[0] return 0, 12, (line_number, offset...
flexible
{ "blob_id": "cf6d3a0fbf2a2daf8432622f780e138784ec505d", "index": 8300, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef check_is_with_singleton(physical_line, line_number):\n match_obj = IS_WITH_SINGLETON_REGEX.search(physical_line)\n if match_obj is not None:\n offset = match_obj.span...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python3 import sys import math class parameter : opt = 0 xp = 0 yp = 0 zp = 0 xv = 0 yv = 0 zv = 0 p = 0 def check_args() : try : int(sys.argv[1]) int(sys.argv[2]) int(sys.argv[3]) int(sys.argv[4]) int(sys.argv[5]) int(sys...
normal
{ "blob_id": "d1af148bc6b27d38052f2e57f1c610c86eccebef", "index": 7757, "step-1": "<mask token>\n\n\nclass parameter:\n opt = 0\n xp = 0\n yp = 0\n zp = 0\n xv = 0\n yv = 0\n zv = 0\n p = 0\n\n\n<mask token>\n\n\ndef help():\n if len(sys.argv) == 2 and sys.argv[1] == '-h':\n prin...
[ 5, 7, 8, 11, 12 ]
""" @version: author:yunnaidan @time: 2019/07/22 @file: download_mseed.py @function: """ from obspy.clients.fdsn import Client from obspy.core import UTCDateTime import numpy as np import obspy import os import re import time import glob import shutil import platform import subprocess import multiprocessing def load_...
normal
{ "blob_id": "34db3c9998e1d7647dd954e82e18147504cc74fc", "index": 6736, "step-1": "<mask token>\n\n\ndef load_stations(filename):\n with open(filename, 'r') as f:\n sta_data = f.readlines()\n sta_list = []\n for l in range(1, len(sta_data)):\n sta_info = sta_data[l]\n net_name = re.s...
[ 3, 5, 6, 7, 9 ]
from tracking.centroidtracker import CentroidTracker from tracking.trackableobject import TrackableObject import tensornets as nets import cv2 import numpy as np import time import dlib import tensorflow.compat.v1 as tf import os # For 'disable_v2_behavior' see https://github.com/theislab/scgen/issues/14 tf.disable_v2...
normal
{ "blob_id": "7b01e81c3e31e0a315ee01f36bf1b1f7384a9d10", "index": 3597, "step-1": "<mask token>\n", "step-2": "<mask token>\ntf.disable_v2_behavior()\n<mask token>\nprint('Loading video {video_path}...'.format(video_path=video_path))\nif not os.path.exists(video_path):\n print('File does not exist. Exited.')...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns.append(path('sub/', include( 'sandbox.staticpages_testapp.sub_urls'))) <|reserved_special_token_1|> <|reserved_special_token_0|> staticpages_loader = StaticpagesLoader() urlpatterns = [path('admin/', admin.site....
flexible
{ "blob_id": "333914f99face050376e4713ca118f2347e50018", "index": 989, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns.append(path('sub/', include(\n 'sandbox.staticpages_testapp.sub_urls')))\n", "step-3": "<mask token>\nstaticpages_loader = StaticpagesLoader()\nurlpatterns = [path('admin/...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while num <= 100: if num % 4 == 0 and num % 6 == 0: print(num) break num += 1 <|reserved_special_token_1|> num = 1 while num <= 100: if num % 4 == 0 and num % 6 == 0: print(num) break...
flexible
{ "blob_id": "d04506e67071abf36d43a828d90fbe0f14230103", "index": 3208, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile num <= 100:\n if num % 4 == 0 and num % 6 == 0:\n print(num)\n break\n num += 1\n", "step-3": "num = 1\nwhile num <= 100:\n if num % 4 == 0 and num % 6 == 0...
[ 0, 1, 2, 3 ]
import packaging.requirements import pydantic import pytest from prefect.software.pip import PipRequirement, current_environment_requirements class TestPipRequirement: def is_packaging_subclass(self): r = PipRequirement("prefect") assert isinstance(r, packaging.requirements.Requirement) def ...
normal
{ "blob_id": "64366e8532ffe05db7e7b7313e1d573c78a4e030", "index": 796, "step-1": "<mask token>\n\n\nclass TestPipRequirement:\n\n def is_packaging_subclass(self):\n r = PipRequirement('prefect')\n assert isinstance(r, packaging.requirements.Requirement)\n\n def test_can_be_used_in_pydantic_mod...
[ 6, 7, 8, 10, 11 ]
# Error using ncdump - NetCDF4 Python ncdump -h filename
normal
{ "blob_id": "12f0eeeb81fe611d88e33fd2e8df407e289fb582", "index": 1255, "step-1": "# Error using ncdump - NetCDF4 Python\nncdump -h filename\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
from models.bearing_registry import BearingRegistry from models.faction import Faction from models.maneuver import Maneuver import time class Activation: """ This class represents the Activation phase of a turn """ def __init__(self, game): """ Constructor game: Th...
normal
{ "blob_id": "0774bad4082e0eb04ae3f7aa898c0376147e9779", "index": 2645, "step-1": "<mask token>\n\n\nclass Activation:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Activation:\n <mask token>\n\n def __init__(self, game):\n \"\"\"\n Constructor\...
[ 1, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- """ Created on Fri Nov 14 22:09:56 2014 @author: duhan """ #arrayMapPath = r'/usr/local/lib/python2.7/dist-packages/ticketpitcher/data/3' arrayMapPath = r'C:\Python27\Lib\site-packages\ticketpitcher\data' #tempPath = r'/tmp/' tempPath = 'd:\\temp\\'
normal
{ "blob_id": "9627e8a468d3a75787c5a9e01856913fc8beb3c4", "index": 1868, "step-1": "<mask token>\n", "step-2": "<mask token>\narrayMapPath = 'C:\\\\Python27\\\\Lib\\\\site-packages\\\\ticketpitcher\\\\data'\ntempPath = 'd:\\\\temp\\\\'\n", "step-3": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Nov 14 22:09...
[ 0, 1, 2 ]
lista = [x for x in range(11)] ##todo: wazne kwadraty = [i**2 for i in lista] kwadraty = [(i, i**2, i**3) for i in range(-10, 11)] zbior_wyr = {'aa', '1233', '111111'} slownik = {i : len(i)for i in zbior_wyr} print(kwadraty, slownik, sep='\n')
normal
{ "blob_id": "248b9b9d613f71e0130353f0792083b7d3f6ccd6", "index": 7000, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(kwadraty, slownik, sep='\\n')\n", "step-3": "lista = [x for x in range(11)]\nkwadraty = [(i ** 2) for i in lista]\nkwadraty = [(i, i ** 2, i ** 3) for i in range(-10, 11)]\nzbior_...
[ 0, 1, 2, 3 ]
from pythonforandroid.recipe import CompiledComponentsPythonRecipe from multiprocessing import cpu_count from os.path import join class NumpyRecipe(CompiledComponentsPythonRecipe): version = '1.18.1' url = 'https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip' site_packages_name = 'numpy' ...
normal
{ "blob_id": "610610e7e49fc98927a4894efe62686e26e0cb83", "index": 3502, "step-1": "<mask token>\n\n\nclass NumpyRecipe(CompiledComponentsPythonRecipe):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def build_compiled_components(self, arch):\n ...
[ 3, 4, 5, 6, 7 ]
import os.path import numpy as np import matplotlib.pyplot as plt import util import collections def learn_distributions(file_lists_by_category): """ Estimate the parameters p_d, and q_d from the training set Input ----- file_lists_by_category: A two-element list. The first element is a list of ...
normal
{ "blob_id": "7ed84706ace2cbf523021887df1e13d113f9ce4c", "index": 4172, "step-1": "<mask token>\n\n\ndef learn_distributions(file_lists_by_category):\n \"\"\"\n Estimate the parameters p_d, and q_d from the training set\n\n Input\n -----\n file_lists_by_category: A two-element list. The first eleme...
[ 1, 2, 3, 4, 5 ]
class Rectangulo: <|reserved_special_token_0|> def calcular_area(self): return self.base * self.altura <|reserved_special_token_0|> <|reserved_special_token_1|> class Rectangulo: def __init__(self, base, altura): self.base = base self.altura = altura def calcular_area(sel...
flexible
{ "blob_id": "2e60781da004fb86d3a33deae970c1faf2a5037d", "index": 5793, "step-1": "class Rectangulo:\n <mask token>\n\n def calcular_area(self):\n return self.base * self.altura\n\n\n<mask token>\n", "step-2": "class Rectangulo:\n\n def __init__(self, base, altura):\n self.base = base\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class QuestionVectorTask(luigi.Task): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def output(self): return luigi.LocalTarget('./cache/question_distance/%s.npy' % self. dataset) <|reserved_special_token_0|>...
flexible
{ "blob_id": "ae6a6f7622bf98c094879efb1b9362a915a051b8", "index": 1175, "step-1": "<mask token>\n\n\nclass QuestionVectorTask(luigi.Task):\n <mask token>\n <mask token>\n <mask token>\n\n def output(self):\n return luigi.LocalTarget('./cache/question_distance/%s.npy' % self.\n datase...
[ 7, 8, 11, 12, 13 ]
import sys import time from PyQt5.QtGui import * from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5 import * class PromptMessage(QWidget): def __init__(self, parent = None): super(PromptMessage,self).__init__(parent) self.m_show_tm = QTimer() self.m_stay_tm = QTimer() ...
normal
{ "blob_id": "18a49d46b39fe6e00e2ad137984cceab82f1e94b", "index": 2422, "step-1": "<mask token>\n\n\nclass PromptMessage(QWidget):\n <mask token>\n <mask token>\n <mask token>\n\n def on_move(self):\n self.m_desktop_height = self.m_desktop_height - 10\n self.move(self.m_point.x(), self.m...
[ 2, 4, 6, 7, 10 ]
############################################## # Binary Tree # # by Vishal Nirmal # # # # A Binary Tree ADT implementation. # ############################################## class BinaryTree: def __init_...
normal
{ "blob_id": "3eaced9609c7adfa5457d7dcad8b2dfaeb697b16", "index": 3220, "step-1": "class BinaryTree:\n\n def __init__(self, data=None):\n self.data = data\n self.left = None\n self.right = None\n\n def insert(self, data):\n if self.data != None:\n arr = [self]\n ...
[ 12, 15, 18, 19, 22 ]
import simple_map import pickle import os import argparse import cv2 argparser = argparse.ArgumentParser() argparser.add_argument("--src", type=str, required=True, help="source directory") argparser.add_argument("--dst", type=str, required=True, help="destination directory") ar...
normal
{ "blob_id": "a8c59f97501b3f9db30c98e334dbfcffffe7accd", "index": 6557, "step-1": "<mask token>\n\n\ndef get_reference():\n json = sorted([os.path.join(args.ref, file) for file in os.listdir(args\n .ref) if file.endswith('.json')])[0]\n smap = simple_map.SimpleMap(json)\n return smap.northing, sma...
[ 2, 3, 5, 6, 7 ]