code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> app_name = 'main' urlpatterns = [path('', IndexView.as_view(), name='index'), path( 'builtins/', BuiltinsView.as_view(), name='builtins'), path('custom/', CustomView.as_view(), name='custom')] <|reserved_special_token_1|...
flexible
{ "blob_id": "7b527f9ec66ddf35f3395d78c857c021975402c7", "index": 5141, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'main'\nurlpatterns = [path('', IndexView.as_view(), name='index'), path(\n 'builtins/', BuiltinsView.as_view(), name='builtins'), path('custom/',\n CustomView.as_view(),...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> try: if not os.path.isdir(dirPath): os.makedirs(os.path.join(dirPath)) except OSError as e: print('{0} Failed to create directory!!!!!'.format(dirPath)) <|reserved_special_token_0|> options.add_experimental_option(...
flexible
{ "blob_id": "5f022b7f20b8aef1e3538a6b1e69dc302752cdc7", "index": 7640, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n if not os.path.isdir(dirPath):\n os.makedirs(os.path.join(dirPath))\nexcept OSError as e:\n print('{0} Failed to create directory!!!!!'.format(dirPath))\n<mask token>\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Car: def __init__(self, speed: float=1): self.speed = speed self.forward_right_motor = Motor(forward=12, backward=16) self.backward_right_motor = Motor(forward=21, backward=20) self.forward_left_motor = Motor(forward=23, backward=18) self...
flexible
{ "blob_id": "6bf1a0fbf65895eac9baa71bc5e04e861f0a3ed5", "index": 4190, "step-1": "<mask token>\n\n\nclass Car:\n\n def __init__(self, speed: float=1):\n self.speed = speed\n self.forward_right_motor = Motor(forward=12, backward=16)\n self.backward_right_motor = Motor(forward=21, backward=...
[ 5, 6, 7, 8 ]
<|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": "b2fa6104f03dc76522a51f352101cef199ddc665", "index": 675, "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 = [('quizzapp', '...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> display.Image('./image.png') <|reserved_special_token_1|> from IPython import display display.Image('./image.png') <|reserved_special_token_1|> from IPython import display display.Image("./image.png")
flexible
{ "blob_id": "3f5096ef5677373a1e436f454109c7b7577c0205", "index": 6169, "step-1": "<mask token>\n", "step-2": "<mask token>\ndisplay.Image('./image.png')\n", "step-3": "from IPython import display\ndisplay.Image('./image.png')\n", "step-4": "from IPython import display\ndisplay.Image(\"./image.png\")", "s...
[ 0, 1, 2, 3 ]
# ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distrib...
normal
{ "blob_id": "aa4226c377368d1ece4e556db9b7fdd0134472c9", "index": 5450, "step-1": "<mask token>\n\n\nclass _RestrictData:\n __slots__ = ()\n\n\n<mask token>\n\n\nclass RestrictBlend:\n __slots__ = 'context', 'data'\n\n def __enter__(self):\n self.data = _bpy.data\n self.context = _bpy.conte...
[ 6, 9, 10, 11, 13 ]
<|reserved_special_token_0|> def annotator(): parser = argparse.ArgumentParser(description='vafator v{}'.format( vafator.VERSION), formatter_class=argparse. ArgumentDefaultsHelpFormatter, epilog=epilog) parser.add_argument('--input-vcf', dest='input_vcf', action='store', help='The VCF ...
flexible
{ "blob_id": "1651865f120ba4fe440549567a8d9903e5455788", "index": 5774, "step-1": "<mask token>\n\n\ndef annotator():\n parser = argparse.ArgumentParser(description='vafator v{}'.format(\n vafator.VERSION), formatter_class=argparse.\n ArgumentDefaultsHelpFormatter, epilog=epilog)\n parser.add_...
[ 3, 4, 5, 6, 7 ]
"""Implementation of the Brainpool standard, see https://tools.ietf.org/pdf/rfc5639.pdf#15 """ from sage.all import ZZ, GF, EllipticCurve from utils import increment_seed, embedding_degree, find_integer, SimulatedCurves, VerifiableCurve, \ class_number_check CHECK_CLASS_NUMBER = False def gen_brainpool_prime...
normal
{ "blob_id": "b717abaeecea2e97c6ec78d3e0e4c97a8de5eec3", "index": 9169, "step-1": "<mask token>\n\n\nclass Brainpool(VerifiableCurve):\n <mask token>\n\n def security(self):\n self._secure = False\n try:\n curve = EllipticCurve(GF(self._p), [self._a, self._b])\n except Arithm...
[ 8, 9, 10, 12, 17 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def BFS(graph: Graph.Graph, start, end): visited = set() parent = dict() parent[start] = None queue = [] queue.append(start) visited.add(start) while queue: current = queue.pop(0) if c...
flexible
{ "blob_id": "5c5f00084f37837b749e1fbb52a18d515e09ba06", "index": 773, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef BFS(graph: Graph.Graph, start, end):\n visited = set()\n parent = dict()\n parent[start] = None\n queue = []\n queue.append(start)\n visited.add(start)\n while...
[ 0, 1, 2 ]
# Simple read based on the py _sql context from pyspark.sql import SQLContext sqlContext = SQLContext(sc) flow_data = sc._jvm.com.tetration.apps.IO.read(sqlContext._ssql_ctx, "/tetration/flows/", "PARQUET", "LASTHOUR") flow_data.registerTempTable("flowtab") # show the unique src_address and dst_address pairs df = sq...
normal
{ "blob_id": "691075aa5c629e2d0c486ec288cd39bc142cdc7a", "index": 3448, "step-1": "<mask token>\n", "step-2": "<mask token>\nflow_data.registerTempTable('flowtab')\n<mask token>\ndf.show(1000)\n<mask token>\ndf.show(1000)\n<mask token>\nfor dstip in dstIPs:\n sql = (\n \"select src_address, dst_addres...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(len(s)): if s[i] == '\\': d_stack.append(i) elif s[i] == '/': if len(d_stack) == 0: continue left = d_stack.pop() area = i - left if len(res_stack) > 0: ...
flexible
{ "blob_id": "48e3259698788904e000eb15b5443067b0c3e791", "index": 5968, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(s)):\n if s[i] == '\\\\':\n d_stack.append(i)\n elif s[i] == '/':\n if len(d_stack) == 0:\n continue\n left = d_stack.pop()\n ...
[ 0, 1, 2, 3, 4 ]
from ..core import promise, rule _context = { '@vocab': 'https://schema.org/', 'fairsharing': 'https://fairsharing.org/', 'html': 'fairsharing:bsg-s001284', } @promise def resolve_html(url): from urllib.request import urlopen return urlopen(url).read().decode() @rule({ '@context': _context, '@type': 'W...
normal
{ "blob_id": "3272296bca0d6343540597baebef8d882a1267c0", "index": 3111, "step-1": "<mask token>\n\n\n@rule({'@context': _context, '@type': 'WebSite', '@id': {}, 'url': {}})\ndef html_resolver(ld):\n return dict(ld, **{'html': str(resolve_html(ld['url']))})\n", "step-2": "<mask token>\n\n\n@promise\ndef resol...
[ 1, 2, 3, 4, 5 ]
# https://github.com/jscancella/NYTribuneOCRExperiments/blob/master/findText_usingSums.py import os import io from pathlib import Path import sys os.environ['OPENCV_IO_ENABLE_JASPER']='True' # has to be set before importing cv2 otherwise it won't read the variable import numpy as np import cv2 import subprocess from ...
normal
{ "blob_id": "91d240b02b9d7a6c569656337521482d57918754", "index": 4333, "step-1": "<mask token>\n\n\ndef adaptative_thresholding(img, threshold):\n I = img\n gray = cv2.cvtColor(I, cv2.COLOR_BGR2GRAY)\n orignrows, origncols = gray.shape\n M = int(np.floor(orignrows / 16) + 1)\n N = int(np.floor(ori...
[ 6, 7, 8, 11, 13 ]
#!/usr/bin/python import argparse import os import pipes import sys import rospy import std_msgs.msg import actionlib import time import datetime from geometry_msgs.msg import Pose, Point, Quaternion from actionlib import * from location_provider.srv import GetLocationList from std_srvs.srv import Trigger try: i...
normal
{ "blob_id": "7a0e7ede263727ef303ba23dff1949c3a7031360", "index": 7423, "step-1": "#!/usr/bin/python\nimport argparse\nimport os\nimport pipes\nimport sys\n\nimport rospy\nimport std_msgs.msg\nimport actionlib\nimport time\n\nimport datetime\nfrom geometry_msgs.msg import Pose, Point, Quaternion\nfrom actionlib i...
[ 0 ]
import pandas as pd import os from appia.processors.core import normalizer from math import ceil class Experiment: def __init__(self, id) -> None: self.id = id self.version = 4 self._hplc = None self._fplc = None @property def hplc(self): try: return se...
normal
{ "blob_id": "754b34028780231c7eccb98cdf3e83bd615d843f", "index": 5276, "step-1": "<mask token>\n\n\nclass Experiment:\n <mask token>\n <mask token>\n\n @hplc.setter\n def hplc(self, df):\n if isinstance(df, pd.DataFrame) or df is None:\n try:\n self._hplc = df.sort_va...
[ 11, 14, 19, 20, 21 ]
#!/usr/bin/env python3 # # Copyright (C) 2011-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that...
normal
{ "blob_id": "955cf040aaf882328e31e6a943bce04cf721cb11", "index": 538, "step-1": "<mask token>\n\n\ndef get_repo_url(repo):\n url = repo.replace('upstream:', 'git://git.baserock.org/delta/')\n url = url.replace('baserock:baserock/',\n 'git://git.baserock.org/baserock/baserock/')\n url = url.replac...
[ 5, 7, 8, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(y) <|reserved_special_token_1|> v0 = 5 g = 9.81 t = 0.6 y = v0 * t - 0.5 * g * t ** 2 print(y)
flexible
{ "blob_id": "378032a8d02bc49e5ed8ebccbeddfbb281c2cbd7", "index": 6231, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(y)\n", "step-3": "v0 = 5\ng = 9.81\nt = 0.6\ny = v0 * t - 0.5 * g * t ** 2\nprint(y)\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
def execute(n,dico): """ Prend en argument n, la position de la requête dans le dictionaire et dico le nom du dictionnaire. Renvoie une liste dont chaque élément est une réponse de la requête. """ l = [] import sqlite3 conn = sqlite3.connect('imdb.db') c = conn.cursor() c.execute(dic...
normal
{ "blob_id": "7618d7fde3774a04ac2005dad104e54b9988d3e8", "index": 9487, "step-1": "<mask token>\n\n\ndef taille_plus_grande_reponse(reponses):\n \"\"\"\n Prend en argument une liste.\n Renvoie la taille du plus grand élément de la liste.\n \"\"\"\n l = reponses\n maxi = 0\n for i in range(len...
[ 8, 11, 13, 14, 21 ]
## ## Copyright (C) by Argonne National Laboratory ## See COPYRIGHT in top-level directory ## import re import os class G: pmi_vers = [] cmd_list = [] cmd_hash = {} class RE: m = None def match(pat, str, flags=0): RE.m = re.match(pat, str, flags) return RE.m def search(pat...
normal
{ "blob_id": "76382f353c47747ee730d83c2d3990049c4b0d98", "index": 6795, "step-1": "<mask token>\n\n\nclass G:\n pmi_vers = []\n cmd_list = []\n cmd_hash = {}\n\n\nclass RE:\n m = None\n\n def match(pat, str, flags=0):\n RE.m = re.match(pat, str, flags)\n return RE.m\n\n def search(...
[ 10, 13, 15, 18, 19 ]
version https://git-lfs.github.com/spec/v1 oid sha256:0c22c74b2d9d62e2162d2b121742b7f94d5b1407ca5e2c6a2733bfd7f02e3baa size 5016
normal
{ "blob_id": "c5f0b1dde320d0042a1bf4de31c308e18b53cbeb", "index": 6766, "step-1": "version https://git-lfs.github.com/spec/v1\noid sha256:0c22c74b2d9d62e2162d2b121742b7f94d5b1407ca5e2c6a2733bfd7f02e3baa\nsize 5016\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ...
[ 0 ]
from __future__ import division from __future__ import print_function import numpy import tables as PT import scipy.io import sys, math import tables.flavor from flydra_analysis.analysis.save_as_flydra_hdf5 import save_as_flydra_hdf5 tables.flavor.restrict_flavors(keep=["numpy"]) def main(): filename = sys.argv[...
normal
{ "blob_id": "b20bf203a89ed73cc65db50fdbef897667fe390f", "index": 2804, "step-1": "<mask token>\n\n\ndef main():\n filename = sys.argv[1]\n do_it(filename=filename)\n\n\ndef get_valid_userblock_size(min):\n result = 2 ** int(math.ceil(math.log(min, 2)))\n if result < 512:\n result = 512\n re...
[ 2, 3, 4, 5, 6 ]
import unittest from dispatcher.task import * from mock import * class TestTask(unittest.TestCase): def test_init(self): task_attr = ['filename=C:\\Users\\kcheng\\PycharmProjects\\first_project\\dummy_task2.py', 'frequency=1D', 'time=09:45', 'description=invalid time'] task = T...
normal
{ "blob_id": "86c053b7d4c752182965755ad5b6ba6937ce6f86", "index": 5984, "step-1": "<mask token>\n\n\nclass TestTask(unittest.TestCase):\n <mask token>\n\n def test_init_bad_invalid_filename(self):\n task_attr = [\n 'filename=C:\\\\Users\\\\kcheng\\\\PycharmProjects\\\\first_project\\\\sadf...
[ 2, 5, 6, 7, 10 ]
class mySeq: <|reserved_special_token_0|> def __len__(self): return len(self.mseq) <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class mySeq: def __init__(self): self.mseq = ['I', 'II', 'III', 'IV'] def __len__(self): return le...
flexible
{ "blob_id": "b86dedad42d092ae97eb21227034e306ca640912", "index": 5890, "step-1": "class mySeq:\n <mask token>\n\n def __len__(self):\n return len(self.mseq)\n <mask token>\n\n\n<mask token>\n", "step-2": "class mySeq:\n\n def __init__(self):\n self.mseq = ['I', 'II', 'III', 'IV']\n\n ...
[ 2, 3, 4, 5 ]
from pydispatch import dispatcher import time import serial import threading from queue import Queue PORT='/dev/ttys005' #PORT='/dev/tty.usbmodem1461' SPEED=4800.0 class GcodeSender(object): PEN_LIFT_PULSE = 1500 PEN_DROP_PULSE = 800 def __init__(self, **kwargs): super(GcodeSender, self).__init_...
normal
{ "blob_id": "10d35ba3c04d9cd09e152c575e74b0382ff60572", "index": 48, "step-1": "<mask token>\n\n\nclass GcodeSender(object):\n <mask token>\n <mask token>\n\n def __init__(self, **kwargs):\n super(GcodeSender, self).__init__(**kwargs)\n self._stop = threading.Event()\n self.parsing_...
[ 9, 14, 15, 16, 18 ]
# SymBeam examples suit # ========================================================================================== # António Carneiro <amcc@fe.up.pt> 2020 # Features: 1. Numeric length # 2. Pin # 3. Two rollers # 4. Numeric distributed...
normal
{ "blob_id": "bdbeebab70a6d69e7553807d48e3539b78b48add", "index": 2946, "step-1": "<mask token>\n", "step-2": "<mask token>\ntest_beam.add_support(0, 'roller')\ntest_beam.add_support(2, 'roller')\ntest_beam.add_support(6, 'pin')\ntest_beam.add_support(4, 'hinge')\ntest_beam.add_distributed_load(0, 4, -5)\ntest_...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def run_algo(sym, investment, start_date, end_date, bench_sym): learner = sl.StrategyLearner(bench_sym=bench_sym, verbose=verbose) learner.add_evidence(symbol=sym, start_date=start_date, end_date= end_date, investment=investment) syms = [sym] dates = date_range(sta...
flexible
{ "blob_id": "c0f9a1c39ff5d7cc99a16cf00cddcc14705937ba", "index": 3917, "step-1": "<mask token>\n\n\ndef run_algo(sym, investment, start_date, end_date, bench_sym):\n learner = sl.StrategyLearner(bench_sym=bench_sym, verbose=verbose)\n learner.add_evidence(symbol=sym, start_date=start_date, end_date=\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def upgrade(): op.create_table('views', sa.Column('id', sa.Integer(), autoincrement= True, nullable=False), sa.Column('url_id', sa.String(length=31), nullable=True), sa.ForeignKeyConstraint(['url_id'], ['urls.id']), sa.PrimaryKeyConstraint('id')) op.drop_ta...
flexible
{ "blob_id": "fd2b60de2ef540264855f04e1c5bcb9d1cf23c51", "index": 9561, "step-1": "<mask token>\n\n\ndef upgrade():\n op.create_table('views', sa.Column('id', sa.Integer(), autoincrement=\n True, nullable=False), sa.Column('url_id', sa.String(length=31),\n nullable=True), sa.ForeignKeyConstraint(...
[ 1, 2, 3, 4, 5 ]
#聚类算法: # kmeans # 密度聚类:DBSCAN # 层次聚类:AgglomerativeClustering # 谱聚类:SpectralClustering # 分批kmeans:MiniBatchKMeans # 评价指标:FMI(Fowlkes–Mallows index) # 排除:特征聚类:FeatureAgglomeration# 亲和传播聚类(AP)聚类:affinity_propagation# 偏移均值向量:MeanShift import numpy as np import sklearn.cluster as cluster import os impo...
normal
{ "blob_id": "aaebd9eba8a5c51c64baaf60224720b87a6364e1", "index": 1388, "step-1": "<mask token>\n\n\n@print_run_time\ndef dbscan(train_x, train_y):\n db = cluster.DBSCAN(eps=0.2, min_samples=3)\n db.fit(train_x)\n fmi = metrics.fowlkes_mallows_score(train_y, db.labels_)\n return fmi\n\n\n<mask token>\...
[ 1, 7, 8, 9, 10 ]
# -*- coding: utf-8-*- import random import re from datetime import datetime, time from phue import Bridge import os import glob WORDS = [] def handle(text, mic, profile): messages1 = ["Naturally Sir ","Of course Sir ","I'll get right at it"] final = random.choice(messages1) mic.say(final) command = "ssh pi@...
normal
{ "blob_id": "668a8005f2f66190d588fb9289293d73a608f767", "index": 926, "step-1": "<mask token>\n\n\ndef handle(text, mic, profile):\n messages1 = ['Naturally Sir ', 'Of course Sir ', \"I'll get right at it\"]\n final = random.choice(messages1)\n mic.say(final)\n command = 'ssh pi@'\n ip = profile['...
[ 1, 2, 3, 4, 5 ]
# Generated by Django 2.0.3 on 2018-07-05 04:16 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('application_manager', '0015_auto_20180705_0415'), ] operations = [ migrations.RemoveField( model_name='application', name='u...
normal
{ "blob_id": "7bf81954bef81004b6c9838ed00c624d24fcf0c6", "index": 3839, "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 = [('application...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class CopyGenerator(nn.Module): <|reserved_special_token_0|> def __init__(self, opt, src_dict, tgt_dict): super(CopyGenerator, self).__init__() self.linear = nn.Linear(opt.rnn_size, tgt_dict.size()) self.linear_copy = nn.Linear(opt.rnn_size, 1) sel...
flexible
{ "blob_id": "704b3c57ca080862bed7a4caa65d1c8d5a32fa0b", "index": 168, "step-1": "<mask token>\n\n\nclass CopyGenerator(nn.Module):\n <mask token>\n\n def __init__(self, opt, src_dict, tgt_dict):\n super(CopyGenerator, self).__init__()\n self.linear = nn.Linear(opt.rnn_size, tgt_dict.size())\n...
[ 4, 5, 6, 7, 8 ]
x, y = map(int, input().split()) print(max((y - x + 9) // 10, 0))
normal
{ "blob_id": "c9f3e956d4016846c8efe0382b79882559d6ce64", "index": 1488, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(max((y - x + 9) // 10, 0))\n", "step-3": "x, y = map(int, input().split())\nprint(max((y - x + 9) // 10, 0))\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def colorSpaceConvert(image): """转换到灰度空间""" res = cv.cvtColor(image, cv.COLOR_BGR2GRAY) cv.imshow('gray', res) """转换到HSV色彩空间""" res = cv.cvtColor(image, cv.COLOR_BGR2HSV) cv.imshow('hsv', res) """转换到YUV色彩空间""" res = cv.cvtColor(image, cv.COLOR_BGR2YUV) ...
flexible
{ "blob_id": "6d359d987c50fd0d5e963d467a379eb245e3eb40", "index": 3756, "step-1": "<mask token>\n\n\ndef colorSpaceConvert(image):\n \"\"\"转换到灰度空间\"\"\"\n res = cv.cvtColor(image, cv.COLOR_BGR2GRAY)\n cv.imshow('gray', res)\n \"\"\"转换到HSV色彩空间\"\"\"\n res = cv.cvtColor(image, cv.COLOR_BGR2HSV)\n ...
[ 1, 2, 3, 4, 5 ]
import re from .models import ValidatedStudent from rest_framework.authtoken.models import Token from django.contrib.auth.models import User def get_token_from_request(request): token_tuple = request.COOKIES.get('money_api_token') matches = re.search(r'(<Token: (\S*)>)', token_tuple) token = matches.group...
normal
{ "blob_id": "2187f38dc9b14ecc355e98fe15d36fdefd548f04", "index": 1159, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_token_from_request(request):\n token_tuple = request.COOKIES.get('money_api_token')\n matches = re.search('(<Token: (\\\\S*)>)', token_tuple)\n token = matches.groups...
[ 0, 1, 2, 3, 4 ]
import os import datetime from classifier import Classification class PersistableClassificationModel(Classification): """ Classification classifier with ability to persist trained classifier on the disk. """ def __init__(self, output_dir, origin): self.originModel = origin if not os...
normal
{ "blob_id": "a4697f0a0d0cc264b28a58bcc28528c221b4cb49", "index": 3807, "step-1": "<mask token>\n\n\nclass PersistableClassificationModel(Classification):\n <mask token>\n\n def __init__(self, output_dir, origin):\n self.originModel = origin\n if not os.path.isdir(output_dir):\n os....
[ 3, 6, 7, 8, 9 ]
#!/usr/bin/python # -*- coding:utf-8 -*- import epd2in7 import time from PIL import Image,ImageDraw,ImageFont import traceback try: epd = epd2in7.EPD() epd.init() epd.Clear(0xFF) time.sleep(2) epd.sleep() except: print 'traceback.format_exc():\n%s' % traceback.format_exc...
normal
{ "blob_id": "14cac4f11830511923ee1ce0d49ec579aec016fd", "index": 4720, "step-1": "#!/usr/bin/python\n# -*- coding:utf-8 -*-\n\nimport epd2in7\nimport time\nfrom PIL import Image,ImageDraw,ImageFont\nimport traceback\n\ntry:\n epd = epd2in7.EPD()\n epd.init()\n epd.Clear(0xFF)\n \n time.sleep(2)\n ...
[ 0 ]
<|reserved_special_token_0|> class Product_Object: <|reserved_special_token_0|> def get_all_text(self): """Get the text within the table""" table_text = [] row_doms = self.get_elements(self.rows_xpath) for index, row_dom in enumerate(row_doms): row_text = [] ...
flexible
{ "blob_id": "aebc8665a97ab0a71b1d8a920b5cbf2643254883", "index": 479, "step-1": "<mask token>\n\n\nclass Product_Object:\n <mask token>\n\n def get_all_text(self):\n \"\"\"Get the text within the table\"\"\"\n table_text = []\n row_doms = self.get_elements(self.rows_xpath)\n for...
[ 4, 6, 8, 11, 12 ]
import argparse import datetime import json import os import sys import hail as hl from .utils import run_all, run_pattern, run_list, RunConfig from .. import init_logging def main(args): init_logging() records = [] def handler(stats): records.append(stats) data_dir = args.data_dir or os....
normal
{ "blob_id": "d4625dd743dd6648044e40b02743ae80f4caea36", "index": 9572, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main(args):\n init_logging()\n records = []\n\n def handler(stats):\n records.append(stats)\n data_dir = args.data_dir or os.environ.get('HAIL_BENCHMARK_DIR'\n ...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ @author: longshuicui @date : 2021/2/4 @function: 32. Longest Valid Parentheses (Hard) https://leetcode.com/problems/longest-valid-parentheses/ 题目描述 在给的字符串里面找到 最大长度的 有效 括号字符串 输入输出示例 Input: s = ")()())" Output: 4 Explanation: The longest valid parentheses substring is "()()"...
normal
{ "blob_id": "0f03ff63662b82f813a18cc8ece3d377716ce678", "index": 2318, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef longestValidParentheses(s):\n stack = []\n maxLength = 0\n stack.append(-1)\n for i in range(len(s)):\n if s[i] == '(':\n stack.append(i)\n el...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import time import errno from gi.repository import GLib from ..async import (FutureSourcePair, FutureCanceled, SucceededFuture, BrokenPipeError, ConnectionError) __all__ = ('GCore',) #------------------------------------------------------------------------------# # GLib Co...
normal
{ "blob_id": "4d43e470144a6284d85902b495dc19dc150eb681", "index": 4000, "step-1": "# -*- coding: utf-8 -*-\nimport time\nimport errno\nfrom gi.repository import GLib\n\nfrom ..async import (FutureSourcePair, FutureCanceled, SucceededFuture,\n BrokenPipeError, ConnectionError)\n\n__all__ = ('GC...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def lengthOfLongestSubstring(s): max_len = 0 for i in range(len(s)): storage = set() count = 0 for j in range(i, len(s)): if not s[j] in storage: storage.append(s[j]) count += 1 ...
flexible
{ "blob_id": "7e83d11bb43229eaa199514b4be6a0acf3ab36ce", "index": 4395, "step-1": "<mask token>\n", "step-2": "def lengthOfLongestSubstring(s):\n max_len = 0\n for i in range(len(s)):\n storage = set()\n count = 0\n for j in range(i, len(s)):\n if not s[j] in storage:\n ...
[ 0, 1, 2 ]
from LAMARCK_ML.data_util import ProtoSerializable class NEADone(Exception): pass class NoSelectionMethod(Exception): pass class NoMetric(Exception): pass class NoReproductionMethod(Exception): pass class NoReplaceMethod(Exception): pass class ModelInterface(ProtoSerializable): def reset(self): ...
normal
{ "blob_id": "501b8a9307a1fd65a5f36029f4df59bbe11d881a", "index": 6591, "step-1": "<mask token>\n\n\nclass ModelInterface(ProtoSerializable):\n\n def reset(self):\n raise NotImplementedError()\n pass\n\n def run(self):\n raise NotImplementedError()\n\n def stop(self):\n raise ...
[ 9, 10, 13, 14, 16 ]
from ImageCoord import ImageCoord import os import sys from folium.features import DivIcon # Chemin du dossier ou l'on recupere les images racine = tkinter.Tk() racine.title("listPhoto") racine.directory = filedialog.askdirectory() cheminDossier = racine.directory dirImage = os.listdir(cheminDossier) listImage = [] ...
normal
{ "blob_id": "f5b8d8c291d18c6f320704a89985acbcae97ca2f", "index": 2954, "step-1": "<mask token>\n", "step-2": "<mask token>\nracine.title('listPhoto')\n<mask token>\nfor index in range(0, len(dirImage)):\n img = ImageCoord(cheminDossier + '\\\\' + dirImage[index])\n if img.has_coord():\n listImage....
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def _filtering_parsing_helper(filter_cols_key, filter_vals_key, filter_invert_key): filter_vals = os.environ[filter_vals_key].split('|') inverts = [int(y) for y in os.environ[filter_invert_key].split('|')] filter_dict = {} for xindex, x in enumerate([int(y) for y in os...
flexible
{ "blob_id": "da0076ab18531e5b8a1de909cb9178de6327d6b0", "index": 3440, "step-1": "<mask token>\n\n\ndef _filtering_parsing_helper(filter_cols_key, filter_vals_key,\n filter_invert_key):\n filter_vals = os.environ[filter_vals_key].split('|')\n inverts = [int(y) for y in os.environ[filter_invert_key].spli...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def show_raw_data(req): filename = req.GET['file'] lineno = int(req.GET['line']) from_lineno = max(0, lineno - OFFSET) to_lineno = lineno + OFFSET ctx = dict() cur_lineno = 1 lines = [] file_path = os.path.join(settings.BASE_DIR, 'parser/unzip_data/%s' % ...
flexible
{ "blob_id": "576c28bb32b5e0b2b5a82a33cee73e3080dcf3ab", "index": 1737, "step-1": "<mask token>\n\n\ndef show_raw_data(req):\n filename = req.GET['file']\n lineno = int(req.GET['line'])\n from_lineno = max(0, lineno - OFFSET)\n to_lineno = lineno + OFFSET\n ctx = dict()\n cur_lineno = 1\n lin...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class Passenger(Person): <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, p_id, p_type, p_gender, p_name, p_phonenumber, f_id, pno, f_origin, f_destination, no_of_stops, flight_type): super(Passenger, self).__init__(p_id, p_type, p_...
flexible
{ "blob_id": "95a2f5abb37642651316a8954a4289e5b04e4916", "index": 4357, "step-1": "<mask token>\n\n\nclass Passenger(Person):\n <mask token>\n <mask token>\n\n def __init__(self, p_id, p_type, p_gender, p_name, p_phonenumber, f_id,\n pno, f_origin, f_destination, no_of_stops, flight_type):\n ...
[ 5, 7, 13, 16, 17 ]
import iotsim.readers as readers import iotsim.networks as networks import iotsim.constructors as contructors import yaml _inventory = dict( assembly=dict( Flatline=contructors.Flatline, Seasaw=contructors.Seesaw, Pulser=contructors.Pulser, SimpleActuator=contructors.SimpleActuat...
normal
{ "blob_id": "1450d3b8cc4cef1c5f802e4d84e2211b7467fe12", "index": 2212, "step-1": "<mask token>\n\n\ndef inventory(component, component_type):\n try:\n component_inventory = _inventory[component]\n except KeyError:\n raise ValueError('Illegal assembly component: {}'.format(component))\n try...
[ 2, 3, 4, 5, 6 ]
# wfp, 6/6 # simple list stuff my_list = [1,'a',3.14] print("my_list consists of: ",my_list) print() print("Operations similar to strings") print("Concatenation") print("my_list + ['bill'] equals: ", my_list + ["bill"]) print() print("Repeat") print("my_list * 3 equals: ", my_list * 3) print() print("In...
normal
{ "blob_id": "1c134cba779459b57f1f3c195aed37d105b94aef", "index": 9935, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('my_list consists of: ', my_list)\nprint()\nprint('Operations similar to strings')\nprint('Concatenation')\nprint(\"my_list + ['bill'] equals: \", my_list + ['bill'])\nprint()\nprin...
[ 0, 1, 2, 3 ]
import http.client import json conn = http.client.HTTPSConnection("v3.football.api-sports.io") headers = { 'x-rapidapi-host': "v3.football.api-sports.io", 'x-rapidapi-key': "" } conn.request("GET", "/teams/statistics?season=2016&team=768&league=4", headers=headers) res = conn.getresponse() data = res.re...
normal
{ "blob_id": "a6617934c5e6527cf59225a5d159d1ce8a33db50", "index": 6681, "step-1": "<mask token>\n", "step-2": "<mask token>\nconn.request('GET', '/teams/statistics?season=2016&team=768&league=4',\n headers=headers)\n<mask token>\n", "step-3": "<mask token>\nconn = http.client.HTTPSConnection('v3.football.a...
[ 0, 1, 2, 3, 4 ]
# %load q03_skewness_log/build.py from scipy.stats import skew import pandas as pd import numpy as np data = pd.read_csv('data/train.csv') # Write code here: def skewness_log(df): df['SalePrice_New'] = np.log(df['SalePrice']) df['GrLivArea_New'] = np.log(df['GrLivArea']) skewed_slPri = skew(df['SalePrice...
normal
{ "blob_id": "f5bd41f4aaff616a332d80ec44c364ffc91c58f0", "index": 265, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef skewness_log(df):\n df['SalePrice_New'] = np.log(df['SalePrice'])\n df['GrLivArea_New'] = np.log(df['GrLivArea'])\n skewed_slPri = skew(df['SalePrice_New'])\n skewness_...
[ 0, 1, 2, 3, 4 ]
import cv2 import numpy import os import glob import ntpath from backSub import * from ConfigParser import SafeConfigParser filepath = "./tl3Pictures/" # where the input files are pathRGB = ".diff/" # where the result is saved extension = "*.jpg" # only jpg files considered batchCount = 0 backSubI...
normal
{ "blob_id": "506d33587ff6c8b2c3d9bc546307996d2f518d86", "index": 2060, "step-1": "<mask token>\n", "step-2": "<mask token>\nif not os.path.exists(filepath + pathRGB):\n os.makedirs(filepath + pathRGB)\nbackSubInstance.setConfig('sample.cfg')\nfor filename in glob.glob(filepath + extension):\n pathAndFile...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def bd_finder(qw, region, page_num): page_size = '20' bd_ak = 'wkEmrv7B1l0KPpi30F1G2VMx10xEdeol' bd_url = 'http://api.map.baidu.com/place/v2/search?' furl = (bd_url + 'q=' + qw + '&page_size=' + page_size + '&pag...
flexible
{ "blob_id": "941a93c66a5131712f337ad055bbf2a93e6ec10d", "index": 1634, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bd_finder(qw, region, page_num):\n page_size = '20'\n bd_ak = 'wkEmrv7B1l0KPpi30F1G2VMx10xEdeol'\n bd_url = 'http://api.map.baidu.com/place/v2/search?'\n furl = (bd_ur...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class TS_RLR: <|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|> <|reserved_special_token_1|> <|reserved_s...
flexible
{ "blob_id": "49df9db508637ce5914aa6591178a03c609b6bc7", "index": 659, "step-1": "<mask token>\n\n\nclass TS_RLR:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TS_RLR:\n\n def __init__(self,...
[ 1, 6, 7, 8, 10 ]
# from cis_dna import import cis_config as conf import protocol_pb2 as proto import uuid import random import math import dna_decoding import numpy as np def move(cell): pass def is_alive(cell): starvation_threshold = conf.ENERGY_THRESHOLD if cell.energy_level < starvation_threshold: return Fals...
normal
{ "blob_id": "de557c3c1455acc0a3facfca5729a010f3d123dc", "index": 4208, "step-1": "<mask token>\n\n\ndef is_alive(cell):\n starvation_threshold = conf.ENERGY_THRESHOLD\n if cell.energy_level < starvation_threshold:\n return False\n else:\n return True\n\n\n<mask token>\n\n\ndef dna_copy_or_...
[ 2, 6, 7, 8, 9 ]
from .import bp as authentication from app import db from flask import current_app as app, render_template, request, redirect, url_for, flash, session from flask_login import login_user, logout_user, current_user, login_required from .forms import Register, Login, Settings from .models import User # route for register...
normal
{ "blob_id": "74faeb1c09fe136ec4d9578173aeebe54b451e33", "index": 2406, "step-1": "<mask token>\n\n\n@authentication.route('/register', methods=['GET', 'POST'])\ndef register():\n form = Register()\n if form.validate_on_submit():\n data = {'first_name': request.form.get('first_name'), 'last_name':\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class OrderProductSerializer(serializers.ModelSerializer): class Meta: model = ShoppingCart fields = '__all__' def validate_quantity(self, value): if value <= 0: raise serializers.ValidationError( 'Please, enter a positive qua...
flexible
{ "blob_id": "9c14f024b25c5014567405535dbe5a6c787cfe28", "index": 6529, "step-1": "<mask token>\n\n\nclass OrderProductSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = ShoppingCart\n fields = '__all__'\n\n def validate_quantity(self, value):\n if value <= 0:\n ...
[ 2, 3, 5, 6, 7 ]
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using a Caesar cipher. The script should work for any printable characters. Solution: Enter a message: hello world Enter distance value: 3 khoor#zruog """ # Reque...
normal
{ "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 ]
# coding: utf-8 """ __author__: onur koc """ import numpy as np import matplotlib.pyplot as plt from mpldatacursor import datacursor #optional to annotate any clicked point # ------------ # Input values # ------------ gamma = 23 # Specific weight of the rock mass [kN/m³] H = 270 # Overburden [m] nu ...
normal
{ "blob_id": "f9cc9348d36c131aa3d34e4f78f67b008a1b565a", "index": 7121, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(p_i)):\n if p_i[i] > p_cr:\n x.append(u_ie[i])\n else:\n x.append(u_ip[i])\n<mask token>\nfor i in range(len(x_)):\n if x_[i] < 0:\n x__.a...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class MatchaMilkTea(MilkTea): <|reserved_special_token_0|> def getName(self) ->str: return self.name <|reserved_special_token_0|> <|reserved_special_token_0|> def setPrice(self, price: int) ->None: self.__price = price <|reserved_special_token_0|>...
flexible
{ "blob_id": "96b113678a3453520cd2e62eb11efd9582710409", "index": 2087, "step-1": "<mask token>\n\n\nclass MatchaMilkTea(MilkTea):\n <mask token>\n\n def getName(self) ->str:\n return self.name\n <mask token>\n <mask token>\n\n def setPrice(self, price: int) ->None:\n self.__price = p...
[ 9, 15, 20, 23, 24 ]
from keras.models import Sequential from keras.layers import Dense import numpy as np x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) y = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) x2 = np.array([11, 12, 13, 14, 15]) model = Sequential() model.add(Dense(5, input_dim=1, activation='relu')) model.add(Dense(3)) model.add(D...
normal
{ "blob_id": "43d9edd9120351ce5065eb266d482ccaa2e56177", "index": 2416, "step-1": "<mask token>\n", "step-2": "<mask token>\nmodel.add(Dense(5, input_dim=1, activation='relu'))\nmodel.add(Dense(3))\nmodel.add(Dense(1))\nmodel.summary()\n<mask token>\n", "step-3": "<mask token>\nx = np.array([1, 2, 3, 4, 5, 6,...
[ 0, 1, 2, 3, 4 ]
import splunk.admin as admin import splunk.entity as en class ConfigApp(admin.MConfigHandler): def setup(self): if self.requestedAction == admin.ACTION_EDIT: for myarg in ['api_key']: self.supportedArgs.addOptArg(myarg) def handleList(self, confInfo): confDict = self.readConf("appsetup") if None != c...
normal
{ "blob_id": "8d6c58e9ef4e14a089a7eb33a92214d081ed7692", "index": 8462, "step-1": "<mask token>\n\n\nclass ConfigApp(admin.MConfigHandler):\n <mask token>\n\n def handleList(self, confInfo):\n confDict = self.readConf('appsetup')\n if None != confDict:\n for stanza, settings in conf...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class OptionalSlashRouter(DefaultRouter): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.trailing_slash = '/?' <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class OptionalSlashRouter(DefaultR...
flexible
{ "blob_id": "991b124d365443744c946b258504c97e9076dcea", "index": 7627, "step-1": "<mask token>\n\n\nclass OptionalSlashRouter(DefaultRouter):\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self.trailing_slash = '/?'\n\n\n<mask token>\n", "step-2": "<mask token>\...
[ 2, 3, 4, 5, 6 ]
import os import logging from flask import Flask from flask_orator import Orator from flask_jwt_extended import JWTManager from dotenv import load_dotenv load_dotenv(verbose=True) app = Flask(__name__) app.secret_key = os.getenv('SECRET_KEY') app.config['JSON_SORT_KEYS'] = False app.config['ORATOR_DATABASES'] = { ...
normal
{ "blob_id": "f20e2227821c43de17c116d8c11233eda53ab631", "index": 9967, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return os.getenv('DB_HOST')\n", "step-2": "<mask token>\nload_dotenv(verbose=True)\n<mask token>\nif bool(os.getenv('IS_DEV')):\n logger = logging.getLogger('orator.connecti...
[ 1, 2, 3, 4, 5 ]
# Imports import os from flask import Flask, redirect, render_template, url_for, request, flash from flask_login import LoginManager, login_user, logout_user, login_required, current_user # Import - Database from flask_sqlalchemy import SQLAlchemy # Import - Models from werkzeug.security import generate_password_hash...
normal
{ "blob_id": "6ff4aff5811d2bd7ad150d7e8f925308d120ef74", "index": 2566, "step-1": "<mask token>\n\n\nclass User(UserMixin, db.Model):\n __tablename__ = 'users'\n id = db.Column(db.Integer, primary_key=True)\n name = db.Column(db.String(64))\n email = db.Column(db.String(64), unique=True, index=True)\n...
[ 23, 24, 26, 27, 32 ]
# -*- coding: utf-8 -*- """ Created on Mon Aug 13 14:10:15 2018 9.5 项目:将一个文件夹备份到一个 ZIP 文件 @author: NEVERGUVEIP """ #! python3 import zipfile,os def backupToZip(folder): #backup the entire contents of 'folder' into a ZIP file folder = os.path.abspath(folder) os.chdir(folder) #figure out the fil...
normal
{ "blob_id": "7af19f69e6c419649a5999f594118ad13833a537", "index": 7398, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef backupToZip(folder):\n folder = os.path.abspath(folder)\n os.chdir(folder)\n number = 1\n while True:\n zipFilename = os.path.basename(folder) + '_' + str(numbe...
[ 0, 1, 2, 3, 4 ]
# # @lc app=leetcode id=14 lang=python3 # # [14] Longest Common Prefix # # https://leetcode.com/problems/longest-common-prefix/description/ # # algorithms # Easy (34.95%) # Likes: 2372 # Dislikes: 1797 # Total Accepted: 718.5K # Total Submissions: 2M # Testcase Example: '["flower","flow","flight"]' # # Write a f...
normal
{ "blob_id": "80be5f49a179eebc4915bf734a8e362cc2f2ef7c", "index": 3213, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution:\n\n def longestCommonPrefix(self, strs: [str]) ->str:\n if not strs:\n return ''\n strs....
[ 0, 1, 2, 3, 4 ]
""" [BBC] Web Scraper """ import os from .abstract_crawler import AbstractWebCrawler class BBCCrawler(AbstractWebCrawler): """ [BBC] Web Scraper """ # Spider Properties name = "web_bbc" # Crawler Properties resource_link = 'http://www.bbc.com/news/topics/cz4pr2gd85qt/cyber-security' resourc...
normal
{ "blob_id": "3c22fbfd7d83ff3ecacabc3c88af2169fa5906b9", "index": 5190, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BBCCrawler(AbstractWebCrawler):\n <mask token>\n name = 'web_bbc'\n resource_link = (\n 'http://www.bbc.com/news/topics/cz4pr2gd85qt/cyber-security')\n resour...
[ 0, 2, 3, 4, 5 ]
#coding=utf8 """ Created on Thu Feb 20 00:53:28 2020 @author: Neal LONG """ import json import requests fake_header = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36", "Accept":"text/html,application/xhtml+xml,...
normal
{ "blob_id": "166a1dfbd3baf766230080361d98648ec0a64455", "index": 1038, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(parsed_json2)\n", "step-3": "<mask token>\nfake_header = {'user-agent':\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113...
[ 0, 1, 2, 3, 4 ]
# File Name: create_data.py from sqlalchemy.orm import sessionmaker from faker import Faker from db_orm import Base, engine, User, Course from sqlalchemy import MedaData session = sessionmaker(engine)() fake = Faker('zh-cn') # 创建表 users_table = Table('users', metadata, Column('id', Integer, primary_key = True), ...
normal
{ "blob_id": "6c94b487eaa179a70ea6528b0214d04d5148574f", "index": 4070, "step-1": "<mask token>\n\n\ndef create_users():\n for i in range(10):\n user = User(name=fake.name(), email=fake.email())\n session.add(user)\n\n\ndef create_courses():\n for user in session.query(User).all():\n fo...
[ 3, 4, 5, 6, 7 ]
from django import template register = template.Library() @register.filter(name='range') def filter_range(start, end=None): if end is None: return range(start) else: return range(start, end)
normal
{ "blob_id": "f733885eed5d1cbf6e49db0997655ad627c9d795", "index": 599, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@register.filter(name='range')\ndef filter_range(start, end=None):\n if end is None:\n return range(start)\n else:\n return range(start, end)\n", "step-3": "<mask...
[ 0, 1, 2, 3 ]
## SOLVED ## the possible way of solving this is to make a scoring of the hand ## of each player, by encoding the category of winning and the cards import csv value = ['2','3','4','5','6','7','8','9','T','J','Q','K','A'] val_order = {k:v for v,k in enumerate(value)} def compute(): poker_hand = load_data() ans...
normal
{ "blob_id": "480e595c54da7426951d750187712fecdcb6d8c7", "index": 9081, "step-1": "<mask token>\n\n\ndef compute():\n poker_hand = load_data()\n ans = sum(1 for x in poker_hand if p1_wins(x))\n return ans\n\n\ndef p1_wins(hands):\n p1 = [(a[0], a[1]) for a in hands[:5]]\n p2 = [(a[0], a[1]) for a i...
[ 6, 7, 8, 9, 11 ]
#Checks if all declared prefixes are used in the RDF File import glob import logging import sys import Utility as utility import re # set log level logging.basicConfig(level=logging.INFO) root_path = "../" rdf_file_extension = {".ttl":"turtle", ".nt":"nt", ".rdf":"application/rdf+xml"} regex_prefix = {".ttl": r'@pr...
normal
{ "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 ]
""" Physical units and dimensions """ from sympy import * from sympy.core.basic import Atom from sympy.core.methods import ArithMeths, RelMeths class Unit(Atom, RelMeths, ArithMeths): is_positive = True # make (m**2)**Rational(1,2) --> m is_commutative = True def __init__(self, name, a...
normal
{ "blob_id": "c0e1c0c4545777a669fac19900239ab9baade242", "index": 5993, "step-1": "<mask token>\n\n\nclass Unit(Atom, RelMeths, ArithMeths):\n is_positive = True\n is_commutative = True\n\n def __init__(self, name, abbrev):\n self.name = name\n self.abbrev = abbrev\n\n def tostr(self, le...
[ 5, 6, 7, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class StockListCreate(generics.ListCreateAPIView): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class StockListCreate(generics.ListCreateAPIView...
flexible
{ "blob_id": "9adf18b3a65bf58dd4c22a6fe026d0dd868533fb", "index": 5468, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass StockListCreate(generics.ListCreateAPIView):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass StockListCreate(generics.ListCreateAPIView):\n query...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class MaintenanceTestCase(RQTestCase): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class MaintenanceTestCase(RQTestCase): @unittest.skipIf(get_version(Redis()) < (6, 2, 0)...
flexible
{ "blob_id": "8dd864f1313f1e6f131ee11d4db99fbc46519126", "index": 9826, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MaintenanceTestCase(RQTestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass MaintenanceTestCase(RQTestCase):\n\n @unittest.skipIf(get_version(Redis()) < (6, 2...
[ 0, 1, 2, 3, 4 ]
import pyenttec, math, time global port MAX = 60 panels = [408, 401, 404, 16] def render(): port.render() def setColor(panel, color): if panels[panel]: port.set_channel(panels[panel] - 1, color[0]) port.set_channel(panels[panel], color[1]) port.set_channel(panels[panel] + 1, color[2]...
normal
{ "blob_id": "55252fc78c67e48c64e777e4c3a713c898312b81", "index": 7166, "step-1": "<mask token>\n\n\ndef render():\n port.render()\n\n\ndef setColor(panel, color):\n if panels[panel]:\n port.set_channel(panels[panel] - 1, color[0])\n port.set_channel(panels[panel], color[1])\n port.set_...
[ 3, 4, 5, 6 ]
#!/usr/bin/python # view_rows.py - Fetch and display the rows from a MySQL database query # import the MySQLdb and sys modules # katja seltmann April 16, 2013 to run on arthropod data in scan symbiota database import MySQLdb import sys #connection information from mysql #test database connect = MySQLdb.connect("", u...
normal
{ "blob_id": "4d066a189bf5151534e0227e67cdc2eed5cd387c", "index": 6745, "step-1": "#!/usr/bin/python\n# view_rows.py - Fetch and display the rows from a MySQL database query\n# import the MySQLdb and sys modules\n# katja seltmann April 16, 2013 to run on arthropod data in scan symbiota database\n\nimport MySQLdb\...
[ 0 ]
class TreeNode(object): <|reserved_special_token_0|> <|reserved_special_token_0|> def add_child(self, value): """ Adds a value to the list of children for this node Parameter value: the value to add to the Tree Precondition: value is not a TreeNode """ assert type(value) !...
flexible
{ "blob_id": "f7e2fc7b5420b90f733a9520b75555bd869cea98", "index": 7929, "step-1": "class TreeNode(object):\n <mask token>\n <mask token>\n\n def add_child(self, value):\n \"\"\"\n Adds a value to the list of children for this node\n\n Parameter value: the value to add to the Tree \n Preco...
[ 4, 5, 6, 7 ]
# Copyright 2023 Sony Group Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to ...
normal
{ "blob_id": "32f10c3e73a3d792416f6b2841a80f8b3c390e8c", "index": 9194, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef ref_mod2(x0, x1, fmod):\n if x0.dtype == np.float32 or fmod == True:\n return np.fmod(x0, x1)\n else:\n return np.mod(x0, x1)\n\n\n@pytest.mark.parametrize('ct...
[ 0, 2, 3, 4, 5 ]
from django import template from django.conf import settings from django.utils.html import escape from django.utils.translation import get_language from cms.models import Page from cms.conf.global_settings import LANGUAGE_NAME_OVERRIDE register = template.Library() # TODO: There's some redundancy here # TODO: {% cms...
normal
{ "blob_id": "d2acc789224d66de36b319ae457165c1438454a3", "index": 3392, "step-1": "from django import template\nfrom django.conf import settings\nfrom django.utils.html import escape\nfrom django.utils.translation import get_language\n\nfrom cms.models import Page\nfrom cms.conf.global_settings import LANGUAGE_NA...
[ 0 ]
import numpy as np import sys class NeuralNetworkClassifier(): def __init__(self, hidden_units, learning_rate, batch_size, epochs, l_1_beta_1, l_1_beta_2, l_2_alpha_1, l_2_alpha_2): self._hidden_units = hidden_units self._learning_rate = learning_rate self._batch_size = batch_size ...
normal
{ "blob_id": "6199a2ac12e80395f4a7a54877c5b639315e64aa", "index": 7702, "step-1": "<mask token>\n\n\nclass NeuralNetworkClassifier:\n <mask token>\n\n def fit(self, X_train, Y_train):\n num_input_dimensions = X_train.shape[1]\n self._num_classes = Y_train.shape[1]\n training_set_size = ...
[ 9, 15, 19, 21, 26 ]
<|reserved_special_token_0|> class MotionDetect: def __init__(self): self.static_back = None <|reserved_special_token_0|> <|reserved_special_token_0|> class InferenceModel: def __init__(self, device='MYRIAD'): self.ie = IECore() self.device = device def create_exec_inf...
flexible
{ "blob_id": "fbd7868a37a2270e5dc86843adff50a94436404d", "index": 5899, "step-1": "<mask token>\n\n\nclass MotionDetect:\n\n def __init__(self):\n self.static_back = None\n <mask token>\n <mask token>\n\n\nclass InferenceModel:\n\n def __init__(self, device='MYRIAD'):\n self.ie = IECore(...
[ 9, 10, 11, 12, 13 ]
# coding: utf-8 import sys, os sys.path.append(os.pardir) import matplotlib.pyplot as plt from dataset.mnist import load_mnist from common.util import smooth_curve from common.multi_layer_net import MultiLayerNet from common.optimizer import * # 0. MNIST 데이터 로딩 (x_train, t_train), (x_test, t_test) = load...
normal
{ "blob_id": "85d40a49341c7bd7af7a5dc62e4bce0253eb25e6", "index": 9944, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.pardir)\n<mask token>\nfor key in optimizers.keys():\n networks[key] = MultiLayerNet(input_size=784, hidden_size_list=[100, \n 100, 100, 100], output_size=10)...
[ 0, 1, 2, 3, 4 ]
from artichoke import DefaultManager, Config from artichoke.helpers import read, prompt from fabric.api import env, task, run import os chars = ''.join(chr(c) if chr(c).isupper() or chr(c).islower() else '_' for c in range(256)) class MagicDefaultManager(DefaultManager): def __init__(self, env): self.en...
normal
{ "blob_id": "09f032301fa9389f6b07687e0ee13844e0b4ddf3", "index": 249, "step-1": "from artichoke import DefaultManager, Config\nfrom artichoke.helpers import read, prompt\nfrom fabric.api import env, task, run\nimport os\n\nchars = ''.join(chr(c) if chr(c).isupper() or chr(c).islower() else '_' for c in range(256...
[ 0 ]
from airflow.plugins_manager import AirflowPlugin from flask import Blueprint, Flask from rest_api.log.views import views from rest_api.route.log_route import log from rest_api.route.mylog_route import my_log_pb from rest_api.route.native_log_route import native_log_bp class AirflowPlugin(AirflowPlugin): name = "...
normal
{ "blob_id": "39f1fc04911f8d22d07532add24cd1671a569e72", "index": 9414, "step-1": "<mask token>\n\n\nclass AirflowPlugin(AirflowPlugin):\n name = 'airflow-plugin'\n operators = []\n hooks = []\n executors = []\n macros = []\n admin_views = []\n flask_blueprints = []\n menu_links = []\n\n\n...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- import pandas as pd import matplotlib.pyplot as plt from tqdm import tqdm from scipy.io import loadmat from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt import numpy as np import copy from matplotlib import cm from matplotlib.animation import FuncAnimation import scipy.opt...
normal
{ "blob_id": "f5820824b5b7e473b79b5dfee2f203684c3755be", "index": 5154, "step-1": "<mask token>\n\n\ndef vector_to_message(vector):\n vocab_file = open('data/vocab.txt', 'r')\n vocab = vocab_file.readlines()\n message_words = []\n for vocab_record, vector_enterance in zip(vocab, vector):\n is_t...
[ 2, 3, 4, 5, 6 ]
import re def password_validation(password): return bool(re.search("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,}$", password))
normal
{ "blob_id": "d44c76ff7e94bea6e03324c45d139602c724c7be", "index": 2539, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef password_validation(password):\n return bool(re.search(\n '^(?=.*[a-z])(?=.*[A-Z])(?=.*\\\\d)[a-zA-Z\\\\d]{6,}$', password))\n", "step-3": "import re\n\n\ndef password...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Window(tk.Tk): def __init__(self): super().__init__() res = requests.get('https://flask-robert.herokuapp.com/youbike') jsonObj = res.json() areas = jsonObj['areas'] self.title('台北市行政區') topFrame = tk.Frame(self, bd=2, relief=tk.GR...
flexible
{ "blob_id": "f9becdb48583423e7bd3730d1cd74a6a016663dc", "index": 1768, "step-1": "<mask token>\n\n\nclass Window(tk.Tk):\n\n def __init__(self):\n super().__init__()\n res = requests.get('https://flask-robert.herokuapp.com/youbike')\n jsonObj = res.json()\n areas = jsonObj['areas']...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class CellState(Enum): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __str__(self): default_str = super(CellState, self).__st...
flexible
{ "blob_id": "29bee4ef11281380aa05d22ef54cb76502ecd685", "index": 466, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CellState(Enum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n default_str = super(CellState, self).__str__()\n ...
[ 0, 2, 3, 4, 5 ]
# test_LeapYear.py # By Alex Graalum import unittest import LeapYear class test_leapyear(unittest.TestCase): def test_four(self): self.assertEqual(LeapYear.leapyear(2012), True) def test_hundred(self): self.assertEqual(LeapYear.leapyear(2100), False) def test_fourhundred(self): self...
normal
{ "blob_id": "29cae66fdca65020a82212e5eabbc61eb900e543", "index": 7720, "step-1": "<mask token>\n\n\nclass test_leapyear(unittest.TestCase):\n <mask token>\n\n def test_hundred(self):\n self.assertEqual(LeapYear.leapyear(2100), False)\n\n def test_fourhundred(self):\n self.assertEqual(LeapY...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def index(request): data = parse_signed_request(request) if not data.has_key('user_id'): request_url = oauth_request_url() return HttpResponse("<script>top.location.href='%s';</script>" % requ...
flexible
{ "blob_id": "17f76c2b53b36c81cea7f7616859f5257790cd73", "index": 9298, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef index(request):\n data = parse_signed_request(request)\n if not data.has_key('user_id'):\n request_url = oauth_request_url()\n return HttpResponse(\"<script>to...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for a in range(1, 10001): pop.append(1.2 * e ** (-1.2 * x)) x = +0.0001 for k in range(100, 10100, 100): exec(f'S{k} =pop[1:k]') <|reserved_special_token_0|> for size in np.arange(100, 10100, 100): exec(f'S{size} =...
flexible
{ "blob_id": "adfdd988b7e208229f195308df8d63fd2799046f", "index": 8941, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor a in range(1, 10001):\n pop.append(1.2 * e ** (-1.2 * x))\n x = +0.0001\nfor k in range(100, 10100, 100):\n exec(f'S{k} =pop[1:k]')\n<mask token>\nfor size in np.arange(100, ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Nov 5 11:56:41 2017 @author: cgao """ from beautifultable import BeautifulTable #1. 新旧税率Bracket def tax_calculator(taxable_income, bracket, rate): bracket2 = bracket[1:] bracket2.append(float('Inf')) bracket3 = [y-x for x,y in zip(brack...
normal
{ "blob_id": "70cb5673a13967247b6da1fa5948000db39a92c8", "index": 7253, "step-1": "<mask token>\n\n\ndef old_bracket(taxable_income, joint=True):\n rate = [0.1, 0.15, 0.25, 0.28, 0.33, 0.35, 0.396]\n if not joint:\n bracket = [0, 9325, 37950, 91900, 191650, 416700, 418400]\n else:\n bracket...
[ 7, 10, 13, 15, 16 ]
import time from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from webdriver_manager.firefox import GeckoDriverManager from webdriver_manager.microsoft import EdgeChromiumDriverManager import os # caps = {'browserName': os.getenv('BROWSER', 'firefox')} # browser = webdriver.Remo...
normal
{ "blob_id": "d84641ce2854d4af26cd46abbe9557d6006cfc2e", "index": 681, "step-1": "<mask token>\n", "step-2": "<mask token>\nbrowser.get('https://www.google.com')\ntime.sleep(3)\nbrowser.maximize_window()\n<mask token>\nprint(title)\nassert 'Google' == title\nbrowser.close()\n", "step-3": "<mask token>\ncapabi...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def house_model(y_new): xs = np.array([0, 1, 2, 4, 6, 8, 10], dtype=float) ys = np.array([0.5, 0.1, 1.5, 2.5, 3.5, 4.5, 5.5], dtype=float) model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])]) model.compile(optimizer='sgd', loss='mean_squared_error') ...
flexible
{ "blob_id": "0b3f16ee9b287c6c77acde674abec9deb4053c83", "index": 946, "step-1": "<mask token>\n\n\ndef house_model(y_new):\n xs = np.array([0, 1, 2, 4, 6, 8, 10], dtype=float)\n ys = np.array([0.5, 0.1, 1.5, 2.5, 3.5, 4.5, 5.5], dtype=float)\n model = tf.keras.Sequential([keras.layers.Dense(units=1, inp...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def main(): args = sys.argv[1:] num_args = len(args) req_args = [False] * 3 num_bins = DEFAULT_NUM_BIN if num_args >= 6: i = 0 while i < num_args - 1: option = args[i] value = args[i + 1] if (option == '-ne' or option...
flexible
{ "blob_id": "86928f4358e4999a5cec8bfad1fe055c9a2778d1", "index": 6230, "step-1": "<mask token>\n\n\ndef main():\n args = sys.argv[1:]\n num_args = len(args)\n req_args = [False] * 3\n num_bins = DEFAULT_NUM_BIN\n if num_args >= 6:\n i = 0\n while i < num_args - 1:\n option...
[ 2, 3, 4, 5, 6 ]
# coding=utf-8 from lxml import etree import frontik.handler class Page(frontik.handler.PageHandler): def get_page(self): self.set_xsl(self.get_argument('template', 'simple.xsl')) self.doc.put(etree.Element('ok')) if self.get_argument('raise', 'false') == 'true': raise front...
normal
{ "blob_id": "6f331eedcdaceaded142c3ffe9400aaa817613c1", "index": 5795, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Page(frontik.handler.PageHandler):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Page(frontik.handler.PageHandler):\n\n def get_page(self):\n self.set_xsl...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> del listline[-1] <|reserved_special_token_0|> if x == n: print(sum(customers)) else: for i in range(n - x): total = 0 for j in range(i, i + x): total += customers[i] for j in range(i): ...
flexible
{ "blob_id": "24bc43c1fe035430afde05fec1330e27fb5f1d86", "index": 8809, "step-1": "<mask token>\n", "step-2": "<mask token>\ndel listline[-1]\n<mask token>\nif x == n:\n print(sum(customers))\nelse:\n for i in range(n - x):\n total = 0\n for j in range(i, i + x):\n total += custom...
[ 0, 1, 2, 3, 4 ]
from setuptools import setup setup(name='discord-ext-menus', author='TierGamerpy', url= 'https://github.com/TierGamerpy/discord-ext-menus', version=0.1, packages=['discord.ext.menus'], description= 'An extension module to make reaction based menus with discord.py', install_requires=['discord.py>=1.2.5']...
normal
{ "blob_id": "daa287eeb967d47c9a8420beccf531d9c157e925", "index": 3217, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='discord-ext-menus', author='TierGamerpy', url=\n 'https://github.com/TierGamerpy/discord-ext-menus', version=0.1,\n packages=['discord.ext.menus'], description=\n 'An...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> __author__ = 'Or'
flexible
{ "blob_id": "54c1b294d826deb43978591cad590c5e969bebd7", "index": 6655, "step-1": "<mask token>\n", "step-2": "__author__ = 'Or'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]