code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
"""Time client""" import urllib.request import json from datetime import datetime # make sure that module51-server.py service is running TIME_URL = "http://localhost:5000/" def ex51(): with urllib.request.urlopen(TIME_URL) as response: body = response.read() parsed = json.loads(body) date = datet...
normal
{ "blob_id": "e8f05a66c642ef3b570130a2996ca27efb8b0cb5", "index": 5287, "step-1": "<mask token>\n\n\ndef ex51():\n with urllib.request.urlopen(TIME_URL) as response:\n body = response.read()\n parsed = json.loads(body)\n date = datetime.fromisoformat(parsed['currentTime'])\n stamp = date.strfti...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('Su sueldo mensual sera') print(sueldo) <|reserved_special_token_1|> c_horas = int(input('Ingrese la cantidad de horas trabajadas:')) v_horas = int(input('Ingrese el valor de cada hora trabajada:')) sueldo = c_horas * v_h...
flexible
{ "blob_id": "2e4b47b8c3ac4f187b32f1013a34c3bea354b519", "index": 6817, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Su sueldo mensual sera')\nprint(sueldo)\n", "step-3": "c_horas = int(input('Ingrese la cantidad de horas trabajadas:'))\nv_horas = int(input('Ingrese el valor de cada hora trabaj...
[ 0, 1, 2, 3 ]
import platform, sys, os, ensurepip ensurepip.bootstrap() try: import pip except ImportError: print("Error: Failed to install pip, make sure you are running this script as admin.") sys.exit() arch = platform.architecture()[0] wheelUrl = "https://raw.githubusercontent.com/Starfox64/pygame-installer/master/wheels...
normal
{ "blob_id": "b44f75db652b3a40cd9475bfe44027724e845252", "index": 1146, "step-1": "<mask token>\n", "step-2": "<mask token>\nensurepip.bootstrap()\ntry:\n import pip\nexcept ImportError:\n print(\n 'Error: Failed to install pip, make sure you are running this script as admin.'\n )\n sys.e...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def draw_point(x, y): plt.scatter(x, y) plt.title('点分布图') plt.xlabel('x轴') plt.ylabel('y轴') plt.grid(True) plt.show() def draw_route(route_list, x, y): plt.scatter(x, y) for route in route_list: route = np.array(route) plt.plot(route[:, 0]...
flexible
{ "blob_id": "1c60620814a4aea2573caf99cee87590a8d57c18", "index": 5483, "step-1": "<mask token>\n\n\ndef draw_point(x, y):\n plt.scatter(x, y)\n plt.title('点分布图')\n plt.xlabel('x轴')\n plt.ylabel('y轴')\n plt.grid(True)\n plt.show()\n\n\ndef draw_route(route_list, x, y):\n plt.scatter(x, y)\n ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('Login to weibo.com') <|reserved_special_token_0|> req.add_header('Host', 'chenshuaijun.com') req.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safar...
flexible
{ "blob_id": "9bd63181de024c2f4517defa9ed51bdbc8d610d2", "index": 6025, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Login to weibo.com')\n<mask token>\nreq.add_header('Host', 'chenshuaijun.com')\nreq.add_header('User-Agent',\n 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like G...
[ 0, 1, 2, 3, 4 ]
import random import sys import numpy from gensim import corpora from coherence.wn import WordNetEvaluator from topic.topic import Topic from nltk.corpus import wordnet as wn from nltk.corpus import reuters from nltk.corpus import brown # python random_tc.py <dname> <word_count> <sample_times> <output> # <word_count>...
normal
{ "blob_id": "2d7e3a70f1c25bbc7ad5eafa006ab12c978eaec4", "index": 1115, "step-1": "import random\nimport sys\n\nimport numpy\nfrom gensim import corpora\n\nfrom coherence.wn import WordNetEvaluator\nfrom topic.topic import Topic\nfrom nltk.corpus import wordnet as wn\nfrom nltk.corpus import reuters\nfrom nltk.co...
[ 0 ]
<|reserved_special_token_0|> class ScheduleAdmin(admin.ModelAdmin): """model admin for schedules""" list_display = ('id', 'name', 'func', 'schedule_type', 'repeats', 'cluster', 'next_run', 'last_run', 'success') if not croniter: readonly_fields = 'cron', list_filter = 'next_run', 'sche...
flexible
{ "blob_id": "5aebebb7f22e094a1a897b3266ff07d59400b76c", "index": 2209, "step-1": "<mask token>\n\n\nclass ScheduleAdmin(admin.ModelAdmin):\n \"\"\"model admin for schedules\"\"\"\n list_display = ('id', 'name', 'func', 'schedule_type', 'repeats',\n 'cluster', 'next_run', 'last_run', 'success')\n ...
[ 10, 21, 22, 23, 26 ]
from django import template import ast register = template.Library() @register.simple_tag() def multiplication(value, arg, *args, **kwargs): return value * arg @register.filter def in_category(things, category): return things.filter(category=category) @register.simple_tag() def division(value, arg, *args,...
normal
{ "blob_id": "9339d3bc0c3005880b1c8d1c9914d6e28d39dbbd", "index": 7285, "step-1": "<mask token>\n\n\n@register.simple_tag()\ndef multiplication(value, arg, *args, **kwargs):\n return value * arg\n\n\n@register.filter\ndef in_category(things, category):\n return things.filter(category=category)\n\n\n@registe...
[ 3, 4, 5, 6 ]
import os from typing import List from pypinyin import pinyin, lazy_pinyin # map vowel-number combination to unicode toneMap = { "d": ['ā', 'ē', 'ī', 'ō', 'ū', 'ǜ'], "f": ['á', 'é', 'í', 'ó', 'ú', 'ǘ'], "j": ['ǎ', 'ě', 'ǐ', 'ǒ', 'ǔ', 'ǚ'], "k": ['à', 'è', 'ì', 'ò', 'ù', 'ǜ'], } weightMap = {} def g...
normal
{ "blob_id": "e50c1ef7368aabf53bc0cfd45e19101fa1519a1f", "index": 6245, "step-1": "<mask token>\n\n\ndef getWeightMap():\n with open(os.path.join(os.path.dirname(__file__),\n '../cells/cubor-base.dict.yaml'), 'r', encoding='utf8') as base:\n _lines = base.readlines()\n for wunit in _lines:...
[ 4, 5, 7, 8, 9 ]
""" DB models. """ from sqlalchemy import Column, Integer, String, ForeignKey, DateTime from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship from db.session import map_engine, replay_engine MapBase = declarative_base(bind=map_engine) ReplayBase = declarative_base(bind=replay...
normal
{ "blob_id": "6b3cb7a42c8bc665e35206b135f6aefea3439758", "index": 7381, "step-1": "<mask token>\n\n\nclass Line(MapBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __repr__(self):\n return (\"<Line(id='{}', len='{}', p0='{}', p1='...
[ 14, 16, 17, 18, 21 ]
class Solution(object): def checkSubarraySum(self, nums, k): if not nums or len(nums) == 1: return False sum_array = [0] * (len(nums) + 1) for i, num in enumerate(nums): sum_array[i + 1] = sum_array[i] + num if k == 0: if sum_array[-1] == 0: ...
normal
{ "blob_id": "033973ddc81a5fdf0e40009c4f321215fe3f4217", "index": 6779, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def checkSubarraySum(self, nums, k):\n if not nums or len(nums) == 1:\n return False\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(args): openstack.enable_logging(debug=False) api = openstack.connect(cloud=args.cloud) snapshot_id = args.snapshot server = args.volume try: snapshot = Snapshot(api=api, snapshot=api.volume.g...
flexible
{ "blob_id": "aebe749a20482636d7ed508f9cbd9cde56656b73", "index": 6236, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main(args):\n openstack.enable_logging(debug=False)\n api = openstack.connect(cloud=args.cloud)\n snapshot_id = args.snapshot\n server = args.volume\n try:\n ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python # -*- coding:utf-8 -*- import importlib def import_string(path): """ 根据字符串的形式去导入路径中的对象 :param path: 'src.engine.agent.AgentHandler' :return: """ module_path,cls_name = path.rsplit('.',maxsplit=1) module = importlib.import_module(module_path) return getattr(module,cls...
normal
{ "blob_id": "8502ebdb13c68a9a56a1a4ba51370d8458ca81dc", "index": 7944, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef import_string(path):\n \"\"\"\n 根据字符串的形式去导入路径中的对象\n :param path: 'src.engine.agent.AgentHandler'\n :return:\n \"\"\"\n module_path, cls_name = path.rsplit('.', ...
[ 0, 1, 2, 3 ]
# Dependencies import pandas as pd # Load in data file from resources bank_data = "Resources/budget_data.csv" # Read and display with pandas bank_df = pd.read_csv(bank_data) # Find the total number of months included in the dataset total_months = bank_df["Date"].count() # Find the total net amount of "Profit/Losses...
normal
{ "blob_id": "1ad694c68ef264c6fbba4f4b9c069f22818d2816", "index": 9973, "step-1": "<mask token>\n", "step-2": "<mask token>\noutput.write(\"\"\"{}\n{}\n{}\n{}\n{}\n{}\n{}\n\"\"\".format(line1, line2, line3, line4,\n line5, line6, line7))\n", "step-3": "<mask token>\nbank_data = 'Resources/budget_data.csv'\...
[ 0, 1, 2, 3, 4 ]
import array def swap(arr, first, second): """ Swaps the first index with the second. arr: an input array first: an index in the array second: an index in the array This function has the side effect mentioned above. """ arr[first], arr[second] = arr[second], arr[first] def parent(i...
normal
{ "blob_id": "1262d41be3bf873d003464cb23998dde20fde318", "index": 8115, "step-1": "<mask token>\n\n\ndef swap(arr, first, second):\n \"\"\"\n Swaps the first index with the second.\n\n arr: an input array\n first: an index in the array\n second: an index in the array\n\n This function has the si...
[ 5, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> np.set_printoptions(precision=3) <|reserved_special_token_0|> sp.init_printing() <|reserved_special_token_0|> I.extend([(v ** 2 - 1) for v in vs]) print('Generating') <|reserved_special_token_0|> print('Done') print('=== Generator...
flexible
{ "blob_id": "88af8b4eeb40ecf19622ecde1a5dea9a078bb66c", "index": 8817, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.set_printoptions(precision=3)\n<mask token>\nsp.init_printing()\n<mask token>\nI.extend([(v ** 2 - 1) for v in vs])\nprint('Generating')\n<mask token>\nprint('Done')\nprint('=== Genera...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> obj = NistschemaSvIvListNmtokensMinLength5(value=['f', 'D', 'T', 'a', 'b', 'C', 'o', 't', 't', 'w']) <|reserved_special_token_1|> from output.models.nist_data.list_pkg.nmtokens.schema_instance.nistschema_sv_iv_list_nmtokens...
flexible
{ "blob_id": "3941f283893c259033d7fb3be83c8071433064ba", "index": 7170, "step-1": "<mask token>\n", "step-2": "<mask token>\nobj = NistschemaSvIvListNmtokensMinLength5(value=['f', 'D', 'T', 'a', 'b',\n 'C', 'o', 't', 't', 'w'])\n", "step-3": "from output.models.nist_data.list_pkg.nmtokens.schema_instance.n...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # coding: utf-8 # Time complexity: O() # Space complexity: O() import math # 最大公约数 Greatest common divisor def get_gcd(a, b): if b == 0: return a print(a, b) return get_gcd(b, a % b) get_gcd(48, 30) # 计算约数个数 # 时间复杂度 O(n) def divisor1(num): count = 0 for i in ran...
normal
{ "blob_id": "32066db8b43bc70c564cce5a33f50921285b3627", "index": 6477, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\nclass Solution:\n\n def isPowerOfTwo(self, n: int) ->bool:\n return n > 0 and n & n - 1 == 0\n\n\nclass Solution:\n\n def isPowerOfTwo(self, n: int) ->bool:\n ...
[ 11, 17, 19, 21, 22 ]
import twitter def twitter_authenticate(): return; def identify_dupes(): return; def remove_dupes(): return; def get_tweets(): return;
normal
{ "blob_id": "d4683d055ca70f31b050f0d84cb93c030feb4593", "index": 2179, "step-1": "<mask token>\n\n\ndef twitter_authenticate():\n return\n\n\n<mask token>\n\n\ndef get_tweets():\n return\n", "step-2": "<mask token>\n\n\ndef twitter_authenticate():\n return\n\n\n<mask token>\n\n\ndef remove_dupes():\n ...
[ 2, 3, 4, 5, 6 ]
from sklearn.datasets import make_regression from sklearn.model_selection import train_test_split import random def sim_data(): # Parameters n_samples = random.randint(500, 5000) n_features = random.randint(5, 25) n_informative = random.randint(5, n_features) noise = random.uniform(0.5, 2) # ...
normal
{ "blob_id": "c4aa5869d5f916f13aa924c19dc9792337619b31", "index": 4011, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sim_data():\n n_samples = random.randint(500, 5000)\n n_features = random.randint(5, 25)\n n_informative = random.randint(5, n_features)\n noise = random.uniform(0.5, ...
[ 0, 1, 2, 3 ]
IEX_CLOUD_API_TOKEN = 'Tpk_5d9dc536610243cda2c8ef4787d729b6'
normal
{ "blob_id": "86849d0e63cdb93a16497ca56ff9c64c15a60fa7", "index": 4891, "step-1": "<mask token>\n", "step-2": "IEX_CLOUD_API_TOKEN = 'Tpk_5d9dc536610243cda2c8ef4787d729b6'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> model.load_state_dict(ckpt['model_state_dict']) model.eval() model.to(device) <|reserved_special_token_0|> model_face.eval() <|reserved_special_token_0|> for img in tqdm(video): if img is not None: annotation = model_f...
flexible
{ "blob_id": "1cc14836808d70c1e53a9ca948a52776ebc89f4a", "index": 4624, "step-1": "<mask token>\n", "step-2": "<mask token>\nmodel.load_state_dict(ckpt['model_state_dict'])\nmodel.eval()\nmodel.to(device)\n<mask token>\nmodel_face.eval()\n<mask token>\nfor img in tqdm(video):\n if img is not None:\n a...
[ 0, 1, 2, 3, 4 ]
# written by Mohammad Shahrad @UBC RECENT_NEWS_COUNT = 5 import json with open("./all-news.json") as f: allNews = json.load(f) recent_news_counter = 0 with open("./recent-news.js", "w") as f: f.write("document.write('\\\n") f.write("<ul>\\\n") for value in allNews.values(): f.write("<li>\\\n...
normal
{ "blob_id": "6097840cdf4b42efaca3e197f88703d927abe889", "index": 2548, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('./all-news.json') as f:\n allNews = json.load(f)\n<mask token>\nwith open('./recent-news.js', 'w') as f:\n f.write(\"document.write('\\\\\\n\")\n f.write('<ul>\\\\\\n'...
[ 0, 1, 2, 3, 4 ]
from django.contrib import admin from calc.models import CalcResult class MyAdmin(admin.ModelAdmin): def has_add_permission(self, request, obj=None): return False def has_delete_permission(self, request, obj=None): return False class CalcResultAdmin(MyAdmin): list_display = ('result', ...
normal
{ "blob_id": "e2573a5dc507e9aeb811fbc254129aeb6e54cc0b", "index": 2483, "step-1": "<mask token>\n\n\nclass MyAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n\n\nclass CalcResultAdmin(MyAdmin):\n list_display = 'result', 'message', 'time'\n search_fields = 'result', 'message', 'time'\n\n\n<mask...
[ 3, 4, 5, 6, 8 ]
<|reserved_special_token_0|> class graphingwidget(QtGui.QWidget): <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, reactor, configpath): super(graphingwidget, self).__init__() self.reactor = reactor self.configpath = configpath self.initialize()...
flexible
{ "blob_id": "8173afbd82b8da04db4625ac686c0d052e65a21c", "index": 9470, "step-1": "<mask token>\n\n\nclass graphingwidget(QtGui.QWidget):\n <mask token>\n <mask token>\n\n def __init__(self, reactor, configpath):\n super(graphingwidget, self).__init__()\n self.reactor = reactor\n sel...
[ 7, 8, 9, 10, 11 ]
<|reserved_special_token_0|> class LanguageAdmin(admin.ModelAdmin): <|reserved_special_token_0|> list_display = 'language_name', 'description', 'environment' filter_horizontal = () list_filter = () fieldsets = () class LessonAdmin(admin.ModelAdmin): """ Model for the Admin page """ list_...
flexible
{ "blob_id": "2500c3562819e4e85ce3cbc30e0ddf1b8437e0a2", "index": 6448, "step-1": "<mask token>\n\n\nclass LanguageAdmin(admin.ModelAdmin):\n <mask token>\n list_display = 'language_name', 'description', 'environment'\n filter_horizontal = ()\n list_filter = ()\n fieldsets = ()\n\n\nclass LessonAdm...
[ 8, 9, 12, 14, 15 ]
<|reserved_special_token_0|> def getDirList(p): p = p.replace('/', '\\') if p[-1] != '\\': p = p + '\\' a = os.listdir(p) for x in a: if os.path.isfile(p + x): a, b = os.path.splitext(p + x) if 0 < b.find('bak'): print(p + x) os.r...
flexible
{ "blob_id": "e553da92b1bb5dfaa0fb7c702f5be4f66201c75b", "index": 8843, "step-1": "<mask token>\n\n\ndef getDirList(p):\n p = p.replace('/', '\\\\')\n if p[-1] != '\\\\':\n p = p + '\\\\'\n a = os.listdir(p)\n for x in a:\n if os.path.isfile(p + x):\n a, b = os.path.splitext(p...
[ 2, 3, 4, 5, 6 ]
import os import redis class Carteiro(): if os.environ.get("REDIS_URL") != None: redis_pool = redis.ConnectionPool.from_url(os.environ.get("REDIS_URL")) else: redis_pool = '' def __init__(self, id, pacote): if os.environ.get("REDIS_URL") != None: self.redis_bd ...
normal
{ "blob_id": "dd95d14f35b6a92b3363d99a616678da18733a61", "index": 7839, "step-1": "<mask token>\n\n\nclass Carteiro:\n if os.environ.get('REDIS_URL') != None:\n redis_pool = redis.ConnectionPool.from_url(os.environ.get('REDIS_URL'))\n else:\n redis_pool = ''\n\n def __init__(self, id, pacot...
[ 4, 5, 6, 7, 8 ]
from socket import * from multiprocessing import Process import sys ADDR = ("127.0.0.1", 8888) udp_socket = socket(AF_INET, SOCK_DGRAM) # udp_socket.bind(("0.0.0.0",6955)) # udp套接字在一段时间不链接后,会自动重新分配端口,所以需要绑定 def login(): while True: name = input("请输入昵称(不能重复)") msg = "LOGIN" + "##" + name u...
normal
{ "blob_id": "fd6cf903490ff4352e4721282354a68437ecb1e0", "index": 8314, "step-1": "<mask token>\n\n\ndef login():\n while True:\n name = input('请输入昵称(不能重复)')\n msg = 'LOGIN' + '##' + name\n udp_socket.sendto(msg.encode(), ADDR)\n data, addr = udp_socket.recvfrom(1024)\n if da...
[ 4, 5, 7, 8, 9 ]
class Config: DEBUG = False TESTING = False # mysql+pymysql://user:password@host:port/database # SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://gjp:976431@49.235.194.73:3306/test' SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@127.0.0.1:3306/mydb' SQLALCHEMY_TRACK_MODIFICATIONS = True SECR...
normal
{ "blob_id": "d89f0ef24d8e8d23a77cbbb0ae8723c7dec8c00a", "index": 4954, "step-1": "<mask token>\n\n\nclass DevelopmentConfig(Config):\n <mask token>\n <mask token>\n\n\nclass ProductionConfig(Config):\n DATABASE_URI = ''\n\n\nclass TestingConfig(Config):\n TESTING = True\n", "step-2": "<mask token>\...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def iou_score(target, prediction): intersection = np.logical_and(target, prediction) union = np.logical_or(target, prediction) iou_score = np.sum(intersection) / (np.sum(union) + 1e-06) return iou_score def dice_score(actual, predicted): actual = np.asarray(actual).a...
flexible
{ "blob_id": "c599a75788e3548c52ebb3b29e7a2398ff1b28a2", "index": 1808, "step-1": "<mask token>\n\n\ndef iou_score(target, prediction):\n intersection = np.logical_and(target, prediction)\n union = np.logical_or(target, prediction)\n iou_score = np.sum(intersection) / (np.sum(union) + 1e-06)\n return ...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class TestCase(TestCase): <|reserved_special_token_0|> def setUp(self): Document.objects.create(name='First').save() <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestCase(TestCase): <|reserved_special_token_0|> ...
flexible
{ "blob_id": "0d28ab54f08301d9788ca9a5e46d522e043e9507", "index": 4474, "step-1": "<mask token>\n\n\nclass TestCase(TestCase):\n <mask token>\n\n def setUp(self):\n Document.objects.create(name='First').save()\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TestCase(TestCase):\n <mask t...
[ 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> dl = DataLoader(phase='Train', shuffle=True) X_data, y_data = dl.shuffle_and_get() X_data = np.reshape(X_data, [-1, cf.Height, cf.Width]) config = tf.ConfigProto() config.gpu_options.allow_growth = True config.gpu_options.visible_...
flexible
{ "blob_id": "a5559ff22776dee133f5398bae573f515efb8484", "index": 3820, "step-1": "<mask token>\n", "step-2": "<mask token>\ndl = DataLoader(phase='Train', shuffle=True)\nX_data, y_data = dl.shuffle_and_get()\nX_data = np.reshape(X_data, [-1, cf.Height, cf.Width])\nconfig = tf.ConfigProto()\nconfig.gpu_options....
[ 0, 1, 2, 3 ]
from django.shortcuts import render from .models import Recipe, Author def index(request): recipes_list = Recipe.objects.all() return render(request, "index.html", {"data": recipes_list, "title": "Recipe Box"}) def recipeDetail(request, recipe_id): recipe_detail = Recipe.objects.filter...
normal
{ "blob_id": "f0f8ad7b65707bcf691847ccb387e4d026b405b5", "index": 6395, "step-1": "<mask token>\n\n\ndef authorDetail(request, author_id):\n author = Author.objects.filter(id=author_id).first()\n recipes = Recipe.objects.filter(author=author_id)\n return render(request, 'author_detail.html', {'recipes': ...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python from distutils.core import setup setup( name='RBM', version='0.0.1', description='Restricted Boltzmann Machines', long_description='README', install_requires=['numpy','pandas'], )
normal
{ "blob_id": "fab7ee8a7336ba2c044adce4cc8483af78b775ba", "index": 1827, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='RBM', version='0.0.1', description=\n 'Restricted Boltzmann Machines', long_description='README',\n install_requires=['numpy', 'pandas'])\n", "step-3": "from distutils...
[ 0, 1, 2, 3 ]
""" Pattern matching problem Boyer Moore algorithm First is my attempt, below is the code provided in the book Idea: Optimize brute force approach using 2 heuristics: - Looking-Glass: start searches from last character of the pattern and work backwards - Character-Jump: During testing of a pattern P, a mismatch in T[i...
normal
{ "blob_id": "c418b9b6903ebdad204a3a55f2384a94a3be0d09", "index": 5561, "step-1": "<mask token>\n\n\ndef find_boyer_moore2(T, P):\n \"\"\" return lowest index of T at which the substring P begins or -1\"\"\"\n n, m = len(T), len(P)\n if m == 0:\n return 0\n last = {}\n for k in range(m):\n ...
[ 1, 2, 3, 4, 5 ]
""" Given a sentence as `txt`, return `True` if any two adjacent words have this property: One word ends with a vowel, while the word immediately after begins with a vowel (a e i o u). ### Examples vowel_links("a very large appliance") ➞ True vowel_links("go to edabit") ➞ True vowel_links("an...
normal
{ "blob_id": "eefd94e7c04896cd6265bbacd624bf7e670be445", "index": 4347, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef vowel_links(txt):\n import re\n lst = txt.split(' ')\n for i in range(len(lst) - 1):\n if re.search('[aeiou]', lst[i][-1]) and re.search('[aeiou]', lst[i +\n ...
[ 0, 1, 2 ]
import io import socket import ssl from ..exceptions import ProxySchemeUnsupported from ..packages import six SSL_BLOCKSIZE = 16384 class SSLTransport: """ The SSLTransport wraps an existing socket and establishes an SSL connection. Contrary to Python's implementation of SSLSocket, it allows you to cha...
normal
{ "blob_id": "78d59e903fecd211aa975ae4c8dc01b17c8fad44", "index": 8471, "step-1": "<mask token>\n\n\nclass SSLTransport:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __exit__(self, *_):\n self.close()\n\n def fileno(self):\n return self.socket.fileno()\n\n ...
[ 19, 23, 27, 28, 30 ]
<|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": "6e56c7792d88385cc28c48a7d6dd32b9d6917c64", "index": 2913, "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 = [('adminsite',...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def GetDatetimeFromMyFormat(l): l_words = l.split() l_days = l_words[0].split('-') l_times = l_words[1].split(':') out = datetime.datetime(int(l_days[0]), int(l_days[1]), int(l_days[2]), int(l_times[0]), ...
flexible
{ "blob_id": "6767302869d73d041e2d7061722e05484d19f3e0", "index": 4752, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef GetDatetimeFromMyFormat(l):\n l_words = l.split()\n l_days = l_words[0].split('-')\n l_times = l_words[1].split(':')\n out = datetime.datetime(int(l_days[0]), int(l_da...
[ 0, 1, 2, 3 ]
class SurveyRepository: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class SurveyRepository: def __init__(self): self._surveys = {} <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_to...
flexible
{ "blob_id": "961643e93582bd92e148d00efebbfe38f99100fc", "index": 2866, "step-1": "class SurveyRepository:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class SurveyRepository:\n\n def __init__(self):\n self._surveys = {}\n <mask token>\n <mask token>\n", "step-3": "clas...
[ 1, 2, 3, 4 ]
from tkinter import * global P,M,G,en P=0 M=0 G=0 en=1 def inicio(): global P,M,G,en B1=Button(ventana,text="CAJAS PEQUEÑAS",command=A,state="normal",bg="yellow").grid(column=1,row=1) B2=Button(ventana,text="CAJAS MEDIANAS",command=B,state="normal",bg="orange").grid(column=2,row=1) B3=Bu...
normal
{ "blob_id": "393af07fa7a5c265dbdd3047ef33a77130edf259", "index": 1915, "step-1": "<mask token>\n\n\ndef inicio():\n global P, M, G, en\n B1 = Button(ventana, text='CAJAS PEQUEÑAS', command=A, state='normal',\n bg='yellow').grid(column=1, row=1)\n B2 = Button(ventana, text='CAJAS MEDIANAS', comman...
[ 5, 6, 7, 8, 9 ]
import tkinter as tk import random import numpy as np import copy import time ################################################################################# # # Données de partie NbSimulation = 20000 Data = [ [1,1,1,1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,0,0...
normal
{ "blob_id": "86177dfa9b8bed5916703edcc16ea4d01cbabf84", "index": 3278, "step-1": "<mask token>\n\n\nclass Game:\n\n def __init__(self, Grille, PlayerX, PlayerY, Score=0):\n self.PlayerX = PlayerX\n self.PlayerY = PlayerY\n self.Score = Score\n self.Grille = Grille\n\n def copy(s...
[ 8, 11, 14, 15, 17 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(reader.categories()) print(reader.fileids()) <|reserved_special_token_0|> print(fileP) print(fileN) for w in reader.words(fileP): print(w + ' ', end='') if w is '.': print() for w in reader.words(fileN): ...
flexible
{ "blob_id": "81cec5c1f28e92bf8e4adc2e2c632e072ed1f901", "index": 5765, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(reader.categories())\nprint(reader.fileids())\n<mask token>\nprint(fileP)\nprint(fileN)\nfor w in reader.words(fileP):\n print(w + ' ', end='')\n if w is '.':\n print()...
[ 0, 1, 2, 3, 4 ]
#-*- coding: utf-8 -*- from __future__ import unicode_literals from django.core.files import File as DjangoFile from django.core.management.base import BaseCommand, NoArgsCommand from filer.models.filemodels import File from leonardo.module.media.models import * from filer.settings import FILER_IS_PUBLIC_DEFAULT from ...
normal
{ "blob_id": "864e9063ec1ed80cd1da3128a38633cbeb2f8bba", "index": 3775, "step-1": "<mask token>\n\n\nclass Command(NoArgsCommand):\n \"\"\"\n Import directory structure into the filer ::\n\n manage.py --path=/tmp/assets/images\n manage.py --path=/tmp/assets/news --folder=images\n \"\"\"\n ...
[ 4, 6, 9, 11, 12 ]
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
normal
{ "blob_id": "edc7c74a19a272bdd6da81b3ce2d214a2b613984", "index": 5835, "step-1": "<mask token>\n\n\nclass PipelineTest(unittest.TestCase):\n <mask token>\n\n\n class CustomTransform(PTransform):\n\n def expand(self, pcoll):\n return pcoll | '+1' >> FlatMap(lambda x: [x + 1])\n\n\n clas...
[ 37, 60, 63, 68, 85 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(12): aux = [] for j in range(12): aux.append(float(input())) m.append(aux) aux = [] <|reserved_special_token_0|> for i in range(12): soma += m[i][c] <|reserved_special_token_0|> print('%....
flexible
{ "blob_id": "6edb1f99ca9af01f28322cbaf13f278e79b94e92", "index": 5882, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(12):\n aux = []\n for j in range(12):\n aux.append(float(input()))\n m.append(aux)\n aux = []\n<mask token>\nfor i in range(12):\n soma += m[i][c]\n<m...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def sample_items(num_items, shape, random_state=None): """ Randomly sample a number of items. Parameters ---------- num_items: int Total number of items from which we should sample: the maxi...
flexible
{ "blob_id": "d414e4497bae23e4273526c0bbdecd23ed665cac", "index": 4857, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sample_items(num_items, shape, random_state=None):\n \"\"\"\n Randomly sample a number of items.\n\n Parameters\n ----------\n\n num_items: int\n Total numbe...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from job_description import JobDescription from resume import Resume from resume_manager import ResumeManager
flexible
{ "blob_id": "a998433e45c1d5135749c5164e8ec1f2eb0e572a", "index": 1693, "step-1": "<mask token>\n", "step-2": "from job_description import JobDescription\nfrom resume import Resume\nfrom resume_manager import ResumeManager\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while len(card) > 1: topCard = card.pop(0) trash.append(topCard) card.append(card.pop(0)) <|reserved_special_token_0|> for i in range(len(trash)): outputStr += str(trash[i]) + ' ' outputStr += str(card[0]) print(ou...
flexible
{ "blob_id": "90e475dfd128689dd4e1a5375ced6e4cbfb73c07", "index": 7860, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile len(card) > 1:\n topCard = card.pop(0)\n trash.append(topCard)\n card.append(card.pop(0))\n<mask token>\nfor i in range(len(trash)):\n outputStr += str(trash[i]) + ' '\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> pd.set_option('display.max_columns', None) <|reserved_special_token_0|> file_open.close() <|reserved_special_token_0|> for i in range(len(df)): count = [] count = df2['Newappend1'][(df2['Newappend1'] > Newtaxiout_time[i]) ...
flexible
{ "blob_id": "f5a474cdc8aa22322b252b980c0334a9db21bd5c", "index": 9300, "step-1": "<mask token>\n", "step-2": "<mask token>\npd.set_option('display.max_columns', None)\n<mask token>\nfile_open.close()\n<mask token>\nfor i in range(len(df)):\n count = []\n count = df2['Newappend1'][(df2['Newappend1'] > New...
[ 0, 1, 2, 3, 4 ]
from SMP.motion_planner.node import PriorityNode import numpy as np from heapq import nsmallest import sys from SMP.motion_planner.plot_config import DefaultPlotConfig from SMP.motion_planner.search_algorithms.best_first_search import GreedyBestFirstSearch # imports for route planner: class StudentMotionPlanner(Greedy...
normal
{ "blob_id": "6ecbe119c8a14776373d165dc05e81f91084893c", "index": 4229, "step-1": "<mask token>\n\n\nclass StudentMotionPlanner(GreedyBestFirstSearch):\n <mask token>\n\n def __init__(self, scenario, planningProblem, automata, plot_config=\n DefaultPlotConfig):\n super().__init__(scenario=scen...
[ 9, 11, 12, 13, 17 ]
str = 'Hello world' print ("字符串长度 : %d" %(len(str))) print("字符串的长度 444:",len(str)) print (str) print (str[0]) print (str[1:5]) print (str[:len(str)]) print (str[1:]*3) print (str[1:]*5) print ('字符串拼接') print ("Hello" + "world") #print ("python : str.join Test") str1 = "-" print (str1.join(str)) list = [1,2,3...
normal
{ "blob_id": "77b7a0ae115aa063512ea7d6e91811470a4cf9d0", "index": 2187, "step-1": "\nstr = 'Hello world'\n\nprint (\"字符串长度 : %d\" %(len(str)))\nprint(\"字符串的长度 444:\",len(str))\nprint (str)\nprint (str[0])\nprint (str[1:5])\nprint (str[:len(str)])\nprint (str[1:]*3)\nprint (str[1:]*5)\n\nprint ('字符串拼接')\n\nprint (...
[ 0 ]
# Copyright 2022 Huawei Technologies Co., Ltd # # 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 agree...
normal
{ "blob_id": "443ed24ab396e83dbf12558207376258124bca8b", "index": 4094, "step-1": "<mask token>\n\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument('--src_path', default='', type=str)\n parser.add_argument('--save_path', default='', type=str)\n parser.add_argument('--interpolat...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from fgpio import GPIO import boards
flexible
{ "blob_id": "f66f79cd4132b23c082149a3a1d887f661fd7ee5", "index": 7247, "step-1": "<mask token>\n", "step-2": "from fgpio import GPIO\nimport boards\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> CustomLogger.init_log() <|reserved_special_token_0|> CustomLogger.info('[main]', log_str) <|reserved_special_token_1|> <|reserved_special_token_0|> CustomLogger.init_log() log_str = '%s/%s/%s\n' % ('demo1', 'demo2', 'demo3') Cu...
flexible
{ "blob_id": "ed5653455062cb3468c232cf0fa3f1d18793626a", "index": 591, "step-1": "<mask token>\n", "step-2": "<mask token>\nCustomLogger.init_log()\n<mask token>\nCustomLogger.info('[main]', log_str)\n", "step-3": "<mask token>\nCustomLogger.init_log()\nlog_str = '%s/%s/%s\\n' % ('demo1', 'demo2', 'demo3')\nC...
[ 0, 1, 2, 3, 4 ]
import json import requests import boto3 import uuid import time profile_name = 'mine' region = 'us-west-2' session = boto3.Session(profile_name=profile_name) api = session.client('apigateway', region_name=region) cf = session.client('cloudformation', region_name=region) def get_key(name_of_key): print('Discover...
normal
{ "blob_id": "10fda09f47c292cb3dc901f42d38ead7757460f5", "index": 3699, "step-1": "<mask token>\n\n\ndef get_key(name_of_key):\n print('Discovering API Key')\n response = api.get_api_keys(includeValues=True)\n items = response['items']\n for item in items:\n if name_of_key in item['name']:\n ...
[ 3, 4, 5, 6, 7 ]
from distutils.core import setup setup( name="zuknuft", version="0.1", author="riotbib", author_email="riotbib@github", scripts=["zukunft.py"], install_requires=[ 'bottle', ], )
normal
{ "blob_id": "638842cda666100ce197437cb354f66de77eb328", "index": 8065, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='zuknuft', version='0.1', author='riotbib', author_email=\n 'riotbib@github', scripts=['zukunft.py'], install_requires=['bottle'])\n", "step-3": "from distutils.core impor...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def sequential_search(my_list, search_elt): found = False start_time = time.time() for elt in my_list: if search_elt == elt: found = True break return time.time() - start_time, found def ordered_sequential_search(my_list, search_elt): ...
flexible
{ "blob_id": "f3a34d1c37165490c77ccd21f428718c8c90f866", "index": 4057, "step-1": "<mask token>\n\n\ndef sequential_search(my_list, search_elt):\n found = False\n start_time = time.time()\n for elt in my_list:\n if search_elt == elt:\n found = True\n break\n return time.ti...
[ 6, 7, 9, 10, 11 ]
<|reserved_special_token_0|> class Helper(object): <|reserved_special_token_0|> def base_dir(self, filePath, folder='data'): """ 返回公共路径 :parameter folder:文件夹 :parameter filePath:文件名称 """ return os.path.join(os.path.dirname(os.path.dirname(__file__)), folder...
flexible
{ "blob_id": "7c2349810fc757848eeb5bddef4640d87d5f9ab9", "index": 2439, "step-1": "<mask token>\n\n\nclass Helper(object):\n <mask token>\n\n def base_dir(self, filePath, folder='data'):\n \"\"\"\n 返回公共路径\n :parameter folder:文件夹\n :parameter filePath:文件名称\n \"\"\"\n return ...
[ 3, 4, 6, 7, 8 ]
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. # Copyright (c) 2008 JAILLET Simon - CrysaLEAD - www.crysalead.fr from . import models from . import wizards from odoo import api, SUPERUSER_ID from odoo.addons.account.models.chart_template import preserve_existing_tag...
normal
{ "blob_id": "74b38599dd793282612a468a760f6301b9f039d6", "index": 9878, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef _preserve_tag_on_taxes(cr, registry):\n preserve_existing_tags_on_taxes(cr, registry, 'l10n_lb')\n env = api.Environment(cr, SUPERUSER_ID, {})\n accounts = env['account.a...
[ 0, 1, 2, 3 ]
from rest_framework import serializers from films.models import * from django.contrib.auth.models import User class UserSerializer(serializers.ModelSerializer): films = serializers.PrimaryKeyRelatedField(many=True, queryset=Film.objects.all()) theaters = serializers.PrimaryKeyRelatedField(many=True, queryset=F...
normal
{ "blob_id": "e6aa28ae312ea5d7f0f818b7e86b0e76e2e57b48", "index": 4652, "step-1": "<mask token>\n\n\nclass FilmSerializer(serializers.ModelSerializer):\n owner = serializers.ReadOnlyField(source='owner.username')\n\n\n class Meta:\n model = Film\n fields = 'id', 'title', 'year_prod', 'genre', ...
[ 7, 9, 10, 11, 13 ]
<|reserved_special_token_0|> class RandomIterator(TransitionIterator): _n_steps_per_epoch: int <|reserved_special_token_0|> def _reset(self) ->None: pass <|reserved_special_token_0|> def _has_finished(self) ->bool: return self._count >= self._n_steps_per_epoch def __len__(se...
flexible
{ "blob_id": "3b9193fcd69b0387222feab96c50bf3617606cdd", "index": 7329, "step-1": "<mask token>\n\n\nclass RandomIterator(TransitionIterator):\n _n_steps_per_epoch: int\n <mask token>\n\n def _reset(self) ->None:\n pass\n <mask token>\n\n def _has_finished(self) ->bool:\n return self....
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': setup(**config) <|reserved_special_token_1|> <|reserved_special_token_0|> config = {'name': 'beziers', 'author': 'Simon Cozens', 'author_email': 'simon@simon-cozens.org', 'url': 'https://g...
flexible
{ "blob_id": "98ddf0be2c38cd9b10dfa9cc09f53907b34c1287", "index": 7728, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n setup(**config)\n", "step-3": "<mask token>\nconfig = {'name': 'beziers', 'author': 'Simon Cozens', 'author_email':\n 'simon@simon-cozens.org', 'url':...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> setup(name='json_config', version='0.0.01', packages=['', 'test'], url='', license='', author='craig.ferguson', author_email='', description= 'Simple Functional Config For Changing Environments') <|reserved_special_token...
flexible
{ "blob_id": "ee57e6a1ccbec93f3def8966f5621ea459f3d228", "index": 6538, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='json_config', version='0.0.01', packages=['', 'test'], url='',\n license='', author='craig.ferguson', author_email='', description=\n 'Simple Functional Config For Chang...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def LevelToIntensity(NoiseLevelIndB): I0 = 10.0 ** -12 NoiseLevel = float(NoiseLevelIndB) Intensity = I0 * 10 ** (NoiseLevel / 10) return Intensity def IntensityToLevel(Intensity): I0 = 10.0 ** -12 Intensity = Intensity NoiseLevelIndB = 10 * np.log10(Intensit...
flexible
{ "blob_id": "68a1d5a77abd19aece04bd560df121ceddccea42", "index": 3179, "step-1": "<mask token>\n\n\ndef LevelToIntensity(NoiseLevelIndB):\n I0 = 10.0 ** -12\n NoiseLevel = float(NoiseLevelIndB)\n Intensity = I0 * 10 ** (NoiseLevel / 10)\n return Intensity\n\n\ndef IntensityToLevel(Intensity):\n I0...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> scaler.fit(np.array([v for v in ISOELECTRIC_POINTS.values()]).reshape(-1, 1)) <|reserved_special_token_0|> for k, v in ISOELECTRIC_POINTS.items(): ISOELECTRIC_POINTS_STD[k] = scaler.transform(np.array([v]).reshape(-1, 1)) <|re...
flexible
{ "blob_id": "330df4f194deec521f7db0389f88171d9e2aac40", "index": 2384, "step-1": "<mask token>\n", "step-2": "<mask token>\nscaler.fit(np.array([v for v in ISOELECTRIC_POINTS.values()]).reshape(-1, 1))\n<mask token>\nfor k, v in ISOELECTRIC_POINTS.items():\n ISOELECTRIC_POINTS_STD[k] = scaler.transform(np.a...
[ 0, 1, 2, 3, 4 ]
import os import subprocess import re # import fcntl # path_ffmpeg = path_ffmpeg = r'C:\work\ffmpeg\ffmpeg-3.4.2-win64-static\bin\ffmpeg.exe' dir_ts_files = r'E:\ts' dir_output = r'E:\hb' path_lock = r'C:\work\ffmpeg\encode.lock' def get_work_base(f_base): re_num = re.compile(r'(\d+)\-.+') r = re_num.searc...
normal
{ "blob_id": "502e2d2222863236a42512ffc98c2cc9deaf454f", "index": 7058, "step-1": "<mask token>\n\n\ndef chk_tmp_file(f_tmp):\n pass\n\n\ndef get_file_base(path):\n fname = os.path.basename(path)\n return fname.split('.ts')[0]\n\n\ndef _exec_transcode(path):\n f_base = get_file_base(path)\n work_ba...
[ 6, 7, 8, 9, 11 ]
#!/usr/bin/env python #coding:utf-8 ''' Created on 2016年8月29日 @author: lichen ''' def custom_proc(request): """ 自定义context_processors """ return { "context_test":"test" }
normal
{ "blob_id": "43ecb173e3d306284f2122410b5b74945572f683", "index": 8104, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef custom_proc(request):\n \"\"\"\n 自定义context_processors\n \"\"\"\n return {'context_test': 'test'}\n", "step-3": "#!/usr/bin/env python\n#coding:utf-8\n\n'''\nCreated...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def main(): piso = largura * comprimento volume_sala = largura * comprimento * altura area = 2 * altura * largura + 2 * altura * comprimento print(piso) print(volume_sala) print(area) <|reserved_special_token_0|> <|reserved_special...
flexible
{ "blob_id": "d78fd8ebf9ef55700a25a9ce96d9094f1bfa564e", "index": 6455, "step-1": "<mask token>\n", "step-2": "def main():\n piso = largura * comprimento\n volume_sala = largura * comprimento * altura\n area = 2 * altura * largura + 2 * altura * comprimento\n print(piso)\n print(volume_sala)\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class LSTMCallback(Callback): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class LSTMCallback(Callback): def on_test_end(self, trainer, pl_module): f = open('/evalu...
flexible
{ "blob_id": "42743ee2a812d8fe6fc036ba97daaff5be35564d", "index": 4618, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LSTMCallback(Callback):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LSTMCallback(Callback):\n\n def on_test_end(self, trainer, pl_module):\n f = open('/...
[ 0, 1, 2, 3 ]
import hashlib import json import logging import os import urllib.parse import uuid from datetime import datetime import pytz from celery import states as celery_states from django.conf import settings from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.base_user import BaseUserManager ...
normal
{ "blob_id": "32e904a39d03d3166369420b49db0b9b118110a3", "index": 4179, "step-1": "<mask token>\n\n\nclass ContentKind(models.Model):\n <mask token>\n\n def __str__(self):\n return self.kind\n\n\nclass FileFormat(models.Model):\n extension = models.CharField(primary_key=True, max_length=40, choice...
[ 65, 102, 158, 169, 216 ]
# coding=utf-8 # *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** from .. import _utilities import typing # Export this package's modules as members: from .authority import * from .ca_pool import * fro...
normal
{ "blob_id": "4ca4d4bd684802b056417be4ee3d7d10e8f5dc85", "index": 8842, "step-1": "<mask token>\n", "step-2": "from .. import _utilities\nimport typing\nfrom .authority import *\nfrom .ca_pool import *\nfrom .ca_pool_iam_binding import *\nfrom .ca_pool_iam_member import *\nfrom .ca_pool_iam_policy import *\nfro...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def get_bios_boot_order(self): result = {} boot_device_list = [] boot_device_details = [] key = 'Bios' bootsources = 'BootSources' response = self.get_request(self.root_uri + self.systems_uri) if response['ret'] is False: r...
flexible
{ "blob_id": "bbe7df31a44ccf51c305cd620dc7c4155b7e1a97", "index": 2668, "step-1": "<mask token>\n", "step-2": "def get_bios_boot_order(self):\n result = {}\n boot_device_list = []\n boot_device_details = []\n key = 'Bios'\n bootsources = 'BootSources'\n response = self.get_request(self.root_ur...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- """ Created on Mon Nov 11 18:50:46 2019 @author: kanfar """ import numpy as np import timeit import matplotlib.pyplot as plt from numpy import expand_dims, zeros, ones from numpy.random import randn, randint from keras.models import load_model from keras.optimizers import Adam from keras.model...
normal
{ "blob_id": "fc6c220f8a3a0e9dd1d6e6e1ca131136db8f8a58", "index": 9155, "step-1": "<mask token>\n\n\nclass cGAN:\n\n def __init__(self, input_dim1, input_dim2, input_dim3, latent_size):\n self.input_dim1 = input_dim1\n self.input_dim2 = input_dim2\n self.input_dim3 = input_dim3\n se...
[ 10, 11, 12, 13, 14 ]
import logging from datetime import datetime import boto3 from pytz import timezone from mliyweb.api.v1.api_session_limiter import session_is_okay from mliyweb.api.v1.json_view import JsonView from mliyweb.dns import deleteDnsEntry from mliyweb.models import Cluster from mliyweb.resources.clusters import ClusterServi...
normal
{ "blob_id": "f882b73645c6a280a17f40b27c01ecad7e4d85ae", "index": 5860, "step-1": "<mask token>\n\n\nclass UserClusters(JsonView):\n logger = logging.getLogger('mliyweb.views.UserClusters')\n cluster_service = ClusterService()\n\n @log_enter_exit(logger)\n def get_data(self, context):\n usernam...
[ 9, 11, 12, 13, 15 ]
<|reserved_special_token_0|> def plotTensorflowConfmat(confmat, classes): plt.imshow(confmat, interpolation='nearest', cmap=plt.cm.Blues) plt.title('Confusion Matrix') plt.colorbar() tick_marks = np.arange(len(classes)) plt.xticks(tick_marks, classes, rotation=45) plt.yticks(tick_marks, classe...
flexible
{ "blob_id": "3923aed29006b4290437f2b0e11667c702da3241", "index": 4605, "step-1": "<mask token>\n\n\ndef plotTensorflowConfmat(confmat, classes):\n plt.imshow(confmat, interpolation='nearest', cmap=plt.cm.Blues)\n plt.title('Confusion Matrix')\n plt.colorbar()\n tick_marks = np.arange(len(classes))\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def create_meme(word): return f'this is your meme NEW VERSION {word}'
flexible
{ "blob_id": "32b3e65add5fb44320898b682e8f94f1460a32e7", "index": 628, "step-1": "<mask token>\n", "step-2": "def create_meme(word):\n return f'this is your meme NEW VERSION {word}'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open(sys.argv[1], 'r') as blastOut: geneHits = [] orgHits = [] hits = 0.0 for line in blastOut: hits += 1.0 currHit = line.split()[1] currGene = currHit.split('_')[-1] currOrg =...
flexible
{ "blob_id": "a8659ca7d7a5870fc6f62b3dfee1779e33373e7b", "index": 8388, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(sys.argv[1], 'r') as blastOut:\n geneHits = []\n orgHits = []\n hits = 0.0\n for line in blastOut:\n hits += 1.0\n currHit = line.split()[1]\n c...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def sigmoid(X): """ Applies the logistic function to x, element-wise. """ return 1 / (1 + np.exp(-X)) def x_strich(X): return np.column_stack((np.ones(len(X)), X)) <|reserved_special_token_0|> def rescale_model(thetas, mean, std): thetas_rescaled = np.zeros(thetas.sh...
flexible
{ "blob_id": "36e7398f576aa1d298a20b4d4a27a7b93e3bd992", "index": 5482, "step-1": "<mask token>\n\n\ndef sigmoid(X):\n \"\"\" Applies the logistic function to x, element-wise. \"\"\"\n return 1 / (1 + np.exp(-X))\n\n\ndef x_strich(X):\n return np.column_stack((np.ones(len(X)), X))\n\n\n<mask token>\n\n\n...
[ 7, 9, 10, 11, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(4, N + 1): two_per = 10 ** 6 three_per = 10 ** 6 if i % 3 == 0: three_per = dp_table[i // 3] + 1 if i % 2 == 0: two_per = dp_table[i // 2] + 1 minus = dp_table[i - 1] + 1 dp_t...
flexible
{ "blob_id": "34a8fc38ed875e1c564f535348dc0d5d88c76ab1", "index": 7281, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(4, N + 1):\n two_per = 10 ** 6\n three_per = 10 ** 6\n if i % 3 == 0:\n three_per = dp_table[i // 3] + 1\n if i % 2 == 0:\n two_per = dp_table[i /...
[ 0, 1, 2, 3, 4 ]
from bs4 import BeautifulSoup import re class Rules: def __init__(self): self.ruleCollection = { "1" : self.rule1, "2" : self.rule2, "3" : self.rule3, "4" : self.rule4, "5" : self.rule5, "6" : self.rule6, "7" : self.rule7, "8" : self.r...
normal
{ "blob_id": "7747cbb1a1ed191b616b0d1bcfd51cdea05067f5", "index": 5954, "step-1": "<mask token>\n\n\nclass Rules:\n\n def __init__(self):\n self.ruleCollection = {'1': self.rule1, '2': self.rule2, '3': self.\n rule3, '4': self.rule4, '5': self.rule5, '6': self.rule6, '7':\n self.ru...
[ 8, 11, 13, 14, 17 ]
import numpy as np class Adaline: def __init__(self, eta = 0.0001, n_iter = 2000): self.eta = eta self.n_iter = n_iter self.error = [] def fit(self, X, Y): X = np.hstack((np.ones((X.shape[0],1)), X)) self.w = np.random.uniform(-1, 1, (X.shape[1], 1)) for n in ...
normal
{ "blob_id": "02e711dfc122007c74949cd9f86e2aeb9d334871", "index": 329, "step-1": "<mask token>\n\n\nclass Adaline:\n <mask token>\n\n def fit(self, X, Y):\n X = np.hstack((np.ones((X.shape[0], 1)), X))\n self.w = np.random.uniform(-1, 1, (X.shape[1], 1))\n for n in range(self.n_iter):\n...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python def get_attachment_station_coords(station): if (station == "gripper1"): coords = [0.48, 0.05, 0.161] elif (station == "gripper2"): coords = [0.28, 0.05, 0.13] elif (station == "syringe"): coords = [0.405, 0.745, 0.213] else: coords = [0.0, 0.0, 0.0]...
normal
{ "blob_id": "86c03fa85ac405a148be13325efeaaf691d9ec26", "index": 5223, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_station_coords(station):\n if station == 'steaks':\n coords = [0.4625, 0.375, 0.14]\n elif station == 'griddle':\n coords = [0.73, 0.375, 0.05]\n elif s...
[ 0, 1, 2, 3 ]
''' #조건문 예제 #fdragon50 #2016 ''' # 주석 : 도움말/덧글 / 미사용(추후 사용가능한) 코드 기록 # 여러줄의 문자열 표현은 ''' ''' 사이에 표현 가능하나 사용은 권장않음 # #으로 시작하는것은 문자열 자체가 아닌.. 무시되는 구간 # 주석은 누가봐도 이해할수있게 / 간결하게 # 더 좋은것은 누가봐도 이해할수 있는 코드임 # 가독성이 좋은 코드를 만들수 있도록.. #조건문 예제 #fdragon50 #2016 input = 11 real_fdragon50 = 11 #real_k8805 = "ab" if real_fdr...
normal
{ "blob_id": "2da6debb1f9ae2c966a17fdfb3b668160a3ef8d7", "index": 1384, "step-1": "<mask token>\n", "step-2": "<mask token>\nif real_fdragon50 == input:\n print('Hello!')\nelse:\n print('Who are you')\n", "step-3": "<mask token>\ninput = 11\nreal_fdragon50 = 11\nif real_fdragon50 == input:\n print('H...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def merge_bitplane_to_image(bitplane, arr, color): arr = bp.to_image(arr) img = np.zeros(arr.shape) img[:, :, color] = bitplane return img <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if len(sys.argv) < 4: print('USAGE: {0...
flexible
{ "blob_id": "95ea811d38c314f5f19294500e16bae3d00d4fff", "index": 1328, "step-1": "<mask token>\n\n\ndef merge_bitplane_to_image(bitplane, arr, color):\n arr = bp.to_image(arr)\n img = np.zeros(arr.shape)\n img[:, :, color] = bitplane\n return img\n\n\n<mask token>\n", "step-2": "<mask token>\nif le...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Elasticsearch(object): <|reserved_special_token_0|> <|reserved_special_token_0|> class UnitTest(unittest.TestCase): """Class: UnitTest Description: Class which is a representation of a unit testing. Methods: setUp test_not_created_repo ...
flexible
{ "blob_id": "5c01b83634b7ae9bc691341d7432a4e59617444c", "index": 5182, "step-1": "<mask token>\n\n\nclass Elasticsearch(object):\n <mask token>\n <mask token>\n\n\nclass UnitTest(unittest.TestCase):\n \"\"\"Class: UnitTest\n\n Description: Class which is a representation of a unit testing.\n\n M...
[ 10, 12, 13, 14, 16 ]
import math import pygame import numpy as np from main import Snake, SCREEN_WIDTH, SCREEN_HEIGHT, drawGrid, GRIDSIZE from random import randint FOOD_REWARD = 5 DEATH_PENALTY = 10 MOVE_PENALTY = 0.1 LIVES = 5 SQUARE_COLOR = (80,80,80) SNAKE_HEAD_COLOR = ((0,51,0), (0,0,153), (102,0,102)) SNAKE_COLOR = ((154,205,50), ...
normal
{ "blob_id": "3bb408f2b2ac63a2555258c05844881ccdfc5057", "index": 5428, "step-1": "<mask token>\n\n\nclass SnakeGame:\n\n def __init__(self, board_width=10, board_height=10, gui=False,\n enemy_epsilon=0.1):\n self.score = 0\n self.board = {'width': board_width, 'height': board_height}\n ...
[ 12, 14, 18, 22, 24 ]
import pymysql db= pymysql.connect(host = 'localhost', port = 3306, user = 'root', password = 'Wubaba950823', database = 'mydb', charset = 'utf8mb4' ) # 使用cursor()方法获取操作游标 curso...
normal
{ "blob_id": "8566e30a6450a72a0e441155321bd03363944b5a", "index": 8236, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(sql)\ntry:\n cursor.execute(sql)\n db.commit()\nexcept:\n db.rollback()\ndb.close()\n", "step-3": "<mask token>\ndb = pymysql.connect(host='localhost', port=3306, user='r...
[ 0, 1, 2, 3, 4 ]
import socket import sys from datetime import datetime from threading import Thread import logging class RRConnection(): def __init__(self): self._listenerSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self._inSock = None self._inThread = Thread(target=self.inLoop) self...
normal
{ "blob_id": "2ccc5e01a3b47a77abcb32160dee74a6a74fcfbb", "index": 5808, "step-1": "<mask token>\n\n\nclass RRConnection:\n <mask token>\n <mask token>\n\n def stop(self):\n self._isRunning = False\n self._listenerSocket.close()\n self._inSock.close()\n <mask token>\n <mask toke...
[ 7, 12, 13, 16, 19 ]
# -*- coding: utf-8 -*- import abc import datetime import importlib import inspect import os import re import six from .library import HalLibrary @six.add_metaclass(abc.ABCMeta) class Hal(): def __init__(self, configpath): self.configpath = configpath # Find libraries inside the lib directory ...
normal
{ "blob_id": "81dec10686b521dc9400a209caabc1601efd2a88", "index": 540, "step-1": "<mask token>\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass Hal:\n\n def __init__(self, configpath):\n self.configpath = configpath\n dir_path = os.path.join(os.path.dirname(__file__), 'libraries')\n lib_files =...
[ 3, 5, 6, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_problem_7_1_8(): assert check_linalg() assert abs(problem_7_1_8(5000) - 84.8) < 1 <|reserved_special_token_1|> import pytest from a3 import * from test_utils import * from numpy import allclose def test_pro...
flexible
{ "blob_id": "c7553cadb49c9c7e80a7800b9bff4d5f64796494", "index": 7568, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_problem_7_1_8():\n assert check_linalg()\n assert abs(problem_7_1_8(5000) - 84.8) < 1\n", "step-3": "import pytest\nfrom a3 import *\nfrom test_utils import *\nfrom n...
[ 0, 1, 2, 3 ]
import sqlite3 conn = sqlite3.connect("blog.db") c = conn.cursor() q = "CREATE TABLE users(Username text, Password text, UserID integer)" c.execute(q) q = "CREATE TABLE blogs(Title text, Content text, BlogID integer, UserID integer)" c.execute(q) q = "CREATE TABLE comments(Content text, CommentID integer, BlogID i...
normal
{ "blob_id": "8afaa69d3a20c5e39e6321869f25dbd9020a5b3a", "index": 2460, "step-1": "<mask token>\n", "step-2": "<mask token>\nc.execute(q)\n<mask token>\nc.execute(q)\n<mask token>\nc.execute(q)\nconn.commit()\n", "step-3": "<mask token>\nconn = sqlite3.connect('blog.db')\nc = conn.cursor()\nq = 'CREATE TABLE ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class test_leapyear(unittest.TestCase): <|reserved_special_token_0|> def test_hundred(self): self.assertEqual(LeapYear.leapyear(2100), False) def test_fourhundred(self): self.assertEqual(LeapYear.leapyear(2000), True) def test_normal(self): self....
flexible
{ "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|> class Solution(object): <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): def checkSubarraySum(self, nums, k): if not nums or len(nums) == 1: return False sum_array = [0] * (len(nums) + 1...
flexible
{ "blob_id": "033973ddc81a5fdf0e40009c4f321215fe3f4217", "index": 6779, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def checkSubarraySum(self, nums, k):\n if not nums or len(nums) == 1:\n return False\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class UDP_packet: def __init__(self, board_info, board_add, state): self.board_type = int('{0:08b}'.format(board_info)[:4], 2) self.board_num = int('{0:08b}'.format(board_info)[4:], 2) self.board_add = board_add self.state = state def __str__(self...
flexible
{ "blob_id": "7c2a59f698b75d0de89a16310d97a01506c99cb3", "index": 9840, "step-1": "<mask token>\n\n\nclass UDP_packet:\n\n def __init__(self, board_info, board_add, state):\n self.board_type = int('{0:08b}'.format(board_info)[:4], 2)\n self.board_num = int('{0:08b}'.format(board_info)[4:], 2)\n ...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> class NP_Net_MirrorSym: <|reserved_special_token_0|> def load_from_file(self, fname): params = joblib.load(fname) pol_scope = list(params.keys())[0][0:list(params.keys())[0].find('/')] obrms_runningsumsq = params[pol_scope + '/obfilter/runningsumsq:0'] ...
flexible
{ "blob_id": "97c5b75323bb143c87972b389e2f27e443c1e00c", "index": 9945, "step-1": "<mask token>\n\n\nclass NP_Net_MirrorSym:\n <mask token>\n\n def load_from_file(self, fname):\n params = joblib.load(fname)\n pol_scope = list(params.keys())[0][0:list(params.keys())[0].find('/')]\n obrms...
[ 8, 12, 14, 16, 17 ]
import os from typing import List, Optional, Sequence import boto3 from google.cloud import storage from ..globals import GLOBALS, LOGGER def set_gcs_credentials(): if os.path.exists(GLOBALS.google_application_credentials): return secrets_client = boto3.client( "secretsmanager", reg...
normal
{ "blob_id": "a5eeafef694db04770833a4063358e8f32f467b0", "index": 8310, "step-1": "<mask token>\n\n\ndef set_gcs_credentials():\n if os.path.exists(GLOBALS.google_application_credentials):\n return\n secrets_client = boto3.client('secretsmanager', region_name=GLOBALS.\n aws_region, endpoint_ur...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class DGMSOLVER: def __init__(self, G, fname, fm, cm, mm, nPin, norm=None, mapping=None, vacuum=False, k=None, phi=None, psi=None): """ Inputs: G - Number of energy groups fname - Name of the cross section file fm - F...
flexible
{ "blob_id": "1358adc3b2b3ffe72c0ed87fb0024f1079ca7d04", "index": 1710, "step-1": "<mask token>\n\n\nclass DGMSOLVER:\n\n def __init__(self, G, fname, fm, cm, mm, nPin, norm=None, mapping=None,\n vacuum=False, k=None, phi=None, psi=None):\n \"\"\"\n Inputs:\n G - Number of e...
[ 6, 8, 9, 11, 13 ]
from wagtail.tests.utils import WagtailPageTests from setup_guide.models import SetupGuideLandingPage, SetupGuidePage from home.models import HomePage class SetupGuideLandingPageTests(WagtailPageTests): def test_can_create_under_homepage(self): self.assertCanCreateAt(HomePage, SetupGuideLandingPage) ...
normal
{ "blob_id": "5fdcbccb99880da79eb0efbdecd328ca1cf73d7f", "index": 1415, "step-1": "<mask token>\n\n\nclass SetupGuideLandingPageTests(WagtailPageTests):\n <mask token>\n <mask token>\n\n\nclass SetupGuidePageTests(WagtailPageTests):\n\n def test_can_create_under_landing_page(self):\n self.assertCa...
[ 3, 4, 5, 6, 7 ]