code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
import warnings from re import * from pattern import collection warnings.filterwarnings("ignore") def test(): raw_text = "通化辉南县经济适用房_通化辉南县经适房_通化辉南县经济适用房转让_通化去114网通化切换城市var googlequerykey ='二手经适房 二手房买卖 二手房地产公司' ; var AdKeyWords = 'j...
normal
{ "blob_id": "488d20a86c5bddbca2db09b26fb8df4b6f87a1dc", "index": 2354, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test():\n raw_text = (\n \"通化辉南县经济适用房_通化辉南县经适房_通化辉南县经济适用房转让_通化去114网通化切换城市var googlequerykey ='二手经适房 二手房买卖 二手房地产公司' ; ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): dependencies = [(...
flexible
{ "blob_id": "3e305cee2f814698729c008320e326c4bd42640d", "index": 6629, "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 = [('grid2', '00...
[ 0, 1, 2, 3, 4 ]
n, x = input().split() n = int(n) x = int(x) m = [int(i) for i in input().split()] m.sort(reverse=True) i = 0 res = 0 while x > 0: res += max(0, m[i]) m[i] -= 1 x -= 1 if m[i % n] < m[(i + 1) % n]: i = (i + 1) % n print(res)
normal
{ "blob_id": "9d3439a2be1f22c8ec59923b88ac22877a4f13e8", "index": 663, "step-1": "<mask token>\n", "step-2": "<mask token>\nm.sort(reverse=True)\n<mask token>\nwhile x > 0:\n res += max(0, m[i])\n m[i] -= 1\n x -= 1\n if m[i % n] < m[(i + 1) % n]:\n i = (i + 1) % n\nprint(res)\n", "step-3":...
[ 0, 1, 2 ]
from lib.appData import driver_queue from lib.pyapp import Pyapp import threading from appium.webdriver.common.touch_action import TouchAction from lib.logger import logger import time local = threading.local() class BasePage(object): def __init__(self, driver=None): if driver is None: local.d...
normal
{ "blob_id": "aa51c8f736461f147704c1ec0669c265348fcb80", "index": 6869, "step-1": "<mask token>\n\n\nclass QQ_Login_Page(BasePage):\n\n def login(self):\n local.pyapp.click('android=>new UiSelector().text(\"登 录\")')\n\n def username(self):\n local.pyapp.type('content=>请输入QQ号码或手机或邮箱', 340846750...
[ 15, 16, 18, 20, 24 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = patterns('', url('^$', home.HomeView.as_view(), name='home'), url('^cluster/status/$', cluster.ClusterStatusView.as_view(), name= 'cluster_status'), url('^node/list/$', node.NodeListView.as_view(), name='...
flexible
{ "blob_id": "484d104a8481a707a187d0bcb30898c3459a88be", "index": 389, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', url('^$', home.HomeView.as_view(), name='home'),\n url('^cluster/status/$', cluster.ClusterStatusView.as_view(), name=\n 'cluster_status'), url('^node/list...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- def merge_sort(mlist): if len(mlist) <= 1: return mlist mid = int(len(mlist) / 2) # 使用递归将数组二分分解 left = merge_sort(mlist[:mid]) right = merge_sort(mlist[mid:]) return merge(left, right) # 将每次分解出来的数组各自排序,合并成一个大数组 def merge(left, right): """ ...
normal
{ "blob_id": "a6192e39d86005882d0bde040a99f364bf701c3b", "index": 1266, "step-1": "<mask token>\n", "step-2": "def merge_sort(mlist):\n if len(mlist) <= 1:\n return mlist\n mid = int(len(mlist) / 2)\n left = merge_sort(mlist[:mid])\n right = merge_sort(mlist[mid:])\n return merge(left, rig...
[ 0, 1, 2, 3, 4 ]
import time import click from contextlib import contextmanager from pathlib import Path from model.data import CellsDataset from model.model import build_model, train_transform, test_transform from model.vis import plot_cells @contextmanager def timer(name): t0 = time.time() yield print("{color}[{name}] d...
normal
{ "blob_id": "5cc325758d5bd99ebe49c40af4d2e339bbf64044", "index": 7508, "step-1": "<mask token>\n\n\n@contextmanager\ndef timer(name):\n t0 = time.time()\n yield\n print('{color}[{name}] done in {et:.0f} s{nocolor}'.format(name=name,\n et=time.time() - t0, color='\\x1b[1;33m', nocolor='\\x1b[0m'))...
[ 2, 4, 5, 6, 7 ]
import socket import time import sys def main(): if len(sys.argv) != 2: print("usage : %s port") sys.exit() port = int(sys.argv[1]) count = 0 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setsockopt(socke...
normal
{ "blob_id": "68b9f7317f7c6dcda791338ee642dffb653ac694", "index": 4804, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n if len(sys.argv) != 2:\n print('usage : %s port')\n sys.exit()\n port = int(sys.argv[1])\n count = 0\n sock = socket.socket(socket.AF_INET, soc...
[ 0, 1, 2, 3, 4 ]
def minvalue(weight,Day): maximum = 0 res = 0 for x in range(0, len(weight)): if weight[x] > maximum: maximum = weight[x] res += weight[x] Capitivity = max(res // Day, maximum) while True: sum=0 day=1 for t in range(0, len(weight)): if ...
normal
{ "blob_id": "a0ffb793650b0e911dd9bcbec0b7ba76f7829c12", "index": 1539, "step-1": "<mask token>\n", "step-2": "def minvalue(weight, Day):\n maximum = 0\n res = 0\n for x in range(0, len(weight)):\n if weight[x] > maximum:\n maximum = weight[x]\n res += weight[x]\n Capitivity...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class PromptMessage(QWidget): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def on_move(self): self.m_desktop_height = self.m_desktop_height - 10 self.move(self.m_point.x(), self.m_desktop_height) if self.m_...
flexible
{ "blob_id": "18a49d46b39fe6e00e2ad137984cceab82f1e94b", "index": 2422, "step-1": "<mask token>\n\n\nclass PromptMessage(QWidget):\n <mask token>\n <mask token>\n <mask token>\n\n def on_move(self):\n self.m_desktop_height = self.m_desktop_height - 10\n self.move(self.m_point.x(), self.m...
[ 2, 4, 6, 7, 10 ]
<|reserved_special_token_0|> class MobileNetV3(MobileNetV2): <|reserved_special_token_0|> def forward(self, x): return self.dropout(self.classifier(torch.flatten(self.avg_pool( self.features(x)), 1))) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_...
flexible
{ "blob_id": "4a5185fac7d6c09daa76b5d0d5aee863028a6bce", "index": 5328, "step-1": "<mask token>\n\n\nclass MobileNetV3(MobileNetV2):\n <mask token>\n\n def forward(self, x):\n return self.dropout(self.classifier(torch.flatten(self.avg_pool(\n self.features(x)), 1)))\n\n\n<mask token>\n", ...
[ 2, 3, 4, 5, 6 ]
import pandas as pd from scipy.stats import shapiro import scipy.stats as stats df_test = pd.read_excel("datasets/ab_testing_data.xlsx", sheet_name="Test Group") df_control = pd.read_excel("datasets/ab_testing_data.xlsx", sheet_name="Control Group") df_test.head() df_control.head() df_control.info() df_te...
normal
{ "blob_id": "9e01ba8c489791ec35b86dffe12d0cedb5f09004", "index": 3919, "step-1": "<mask token>\n\n\ndef outlier_thresholds(dataframe, variable, low_quantile=0.05, up_quantile=0.95\n ):\n quantile_one = dataframe[variable].quantile(low_quantile)\n quantile_three = dataframe[variable].quantile(up_quantile...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- import itertools as itt import random import unittest from collections import Counter from uuid import uuid4 import numpy as np from pybel import BELGraph from pybel.constants import INCREASES, PROTEIN from pybel.dsl import protein from pybel_tools.selection import get_random_subgraph from py...
normal
{ "blob_id": "3a88ff479e3b01518d79e9930c29514863f96f9b", "index": 1568, "step-1": "<mask token>\n\n\nclass TestRandomSelectNode(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass TestRandomSample(unittest.TestCase):\n\n def setUp(self):\n ...
[ 5, 8, 9, 10, 13 ]
<|reserved_special_token_0|> class GPDataset(Dataset): <|reserved_special_token_0|> <|reserved_special_token_0|> def __len__(self): return self.n_samples def __getitem__(self, index): self.counter += 1 if self.counter == self.n_samples: self.data, self.targets = s...
flexible
{ "blob_id": "870de8888c00bbf9290bcc847e2a4fbb823cd4b7", "index": 6305, "step-1": "<mask token>\n\n\nclass GPDataset(Dataset):\n <mask token>\n <mask token>\n\n def __len__(self):\n return self.n_samples\n\n def __getitem__(self, index):\n self.counter += 1\n if self.counter == se...
[ 10, 11, 13, 14, 17 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> ii = [('CoolWHM2.py', 73), ('MarrFDI3.py', 2), ('IrviWVD.py', 2), ( 'CoolWHM3.py', 8), ('LewiMJW.py', 1), ('JacoWHI2.py', 4), ('EvarJSP.py', 1) ]
flexible
{ "blob_id": "379c666f19537b513169c6b30e0c669dda6e372c", "index": 9165, "step-1": "<mask token>\n", "step-2": "ii = [('CoolWHM2.py', 73), ('MarrFDI3.py', 2), ('IrviWVD.py', 2), (\n 'CoolWHM3.py', 8), ('LewiMJW.py', 1), ('JacoWHI2.py', 4), ('EvarJSP.py', 1)\n ]\n", "step-3": null, "step-4": null, "st...
[ 0, 1 ]
# coding=utf-8 import tensorflow as tf import numpy as np state = [[1.0000037e+00, 1.0000037e+00, 1.0000000e+00, 4.5852923e-01], [1.0000000e+00, 1.0000000e+00, 1.0000000e+00, 8.3596563e-01], [1.0000478e+00, 1.0000000e+00, 1.0000478e+00, 1.4663711e+00], [1.0000037e+00, 1.0000478e+00, 1.00000...
normal
{ "blob_id": "5a3b88f899cfb71ffbfac3a78d38b748bffb2e43", "index": 6295, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith tf.Session() as sess:\n sess.run(tf.initialize_all_variables())\n result = sess.run(fetches=s_t, feed_dict={s_t: [state]})\n print(result)\n result = sess.run(fetches=con...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> answer.append('A') answer.append('C') print(chose_from_two) print(answer) <|reserved_special_token_1|> chose_from_two = 'A', 'B', 'C' answer = [] answer.append('A') answer.append('C') print(chose_from_two) print(answer) <|res...
flexible
{ "blob_id": "70b26052d9516fd067ff71074a6dc4c58ace7d80", "index": 5513, "step-1": "<mask token>\n", "step-2": "<mask token>\nanswer.append('A')\nanswer.append('C')\nprint(chose_from_two)\nprint(answer)\n", "step-3": "chose_from_two = 'A', 'B', 'C'\nanswer = []\nanswer.append('A')\nanswer.append('C')\nprint(ch...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Extractor: def __init__(self, prefix=''): self.variables = {} self.prefix = os.path.basename(prefix) <|reserved_special_token_0|> def find_variable_name(self, value): for var, val in self.variables.items(): if value == val: ...
flexible
{ "blob_id": "dffcaf47ec8e0daa940e7047f11681ef3eabc772", "index": 8591, "step-1": "<mask token>\n\n\nclass Extractor:\n\n def __init__(self, prefix=''):\n self.variables = {}\n self.prefix = os.path.basename(prefix)\n <mask token>\n\n def find_variable_name(self, value):\n for var, v...
[ 4, 6, 7, 8, 9 ]
import numpy as np import copy ''' 本脚本主要用来实现决策树的相关内容。 constrcut_tree:该函数是构建决策树的主要函数 其输入:数据集X:n*p n:样本数,p-1维特征,p为样本类别, 以及属性信息label:属性名称,p-1一维数组,label表示的是此时X每一列对应的属性名称 决策结构用字典来表示,例如{attribution1:{0:{attribution2:{}},1:{attribution3:{}}} ''' def construct_tree(X,label): classList = [sample[-1] for sample in X] ...
normal
{ "blob_id": "ff66b33a133b627ba2329434d6c1649c94b6ec78", "index": 8188, "step-1": "<mask token>\n\n\ndef return_major(Y):\n label_count = {}\n for i in Y:\n label_count[i] = label_count.get(i, 0) + 1\n sorted_class = sorted(label_count.items(), key=operator.itemgetter(1),\n reverse=True)\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class Settings: SINGLETON = None def __init__(self): self.url_pattern = ( 'href="((http[s]?://|/)(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)"' ) self.crawl_content_type_whitelist_pattern = 'text/html' self...
flexible
{ "blob_id": "e92a738d3233450b255605619dafadd4d829604b", "index": 9067, "step-1": "<mask token>\n\n\nclass Settings:\n SINGLETON = None\n\n def __init__(self):\n self.url_pattern = (\n 'href=\"((http[s]?://|/)(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\\\(\\\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)\"'\n ...
[ 14, 19, 20, 21, 25 ]
<|reserved_special_token_0|> class Config(object): <|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_0|> ...
flexible
{ "blob_id": "a649139a600cb506056a20e00089a07ec9244394", "index": 858, "step-1": "<mask token>\n\n\nclass Config(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask t...
[ 13, 15, 16, 18, 22 ]
import pymongo import time client = pymongo.MongoClient('localhost', 27017); db = client['zhihu']; # 类似dict,若不存在,则新建; # client.drop_database('zhihu') # 删除db collection = db['zhihu']; # 若不存在,则新建; # db.drop_collection('zhihu') # 删除collection document_test = {'name': 'test', 'time': time.strftime('%Y-%m-%d %H:%M:%...
normal
{ "blob_id": "d1d293a5d2c394e69d93488605f27b5468220286", "index": 6627, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(test_id)\n", "step-3": "<mask token>\nclient = pymongo.MongoClient('localhost', 27017)\ndb = client['zhihu']\ncollection = db['zhihu']\ndocument_test = {'name': 'test', 'time': ti...
[ 0, 1, 2, 3, 4 ]
from selenium.webdriver import Chrome path=("/Users/karimovrustam/PycharmProjects/01.23.2020_SeleniumAutomation/drivers/chromedriver") driver=Chrome(executable_path=path) driver.maximize_window() driver.get("http://www.toolsqa.com/iframe-practice-page/") # driver.switch_to.frame("iframe2") # When working with few wi...
normal
{ "blob_id": "53eb1dcd54ce43d9844c48eb1d79f122a87dca39", "index": 3831, "step-1": "<mask token>\n", "step-2": "<mask token>\ndriver.maximize_window()\ndriver.get('http://www.toolsqa.com/iframe-practice-page/')\ndriver.switch_to.default_content()\ndriver.find_element_by_xpath(\"//span[text()='VIDEOS']\").click()...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def ncomb(n, r): return reduce(lambda a, b: a * b % MOD, (Fraction(n - i, i + 1) for i in range(r)), 1) <|reserved_special_token_0|> def comball(a): r = [] for l in range(0, len(a) + 1): r.extend(comb(a, l)) return r <|reserved_special_token_1|> <|re...
flexible
{ "blob_id": "2bc0d76e17f2f52fce9cc1925a3a0e0f53f5b81d", "index": 7953, "step-1": "<mask token>\n\n\ndef ncomb(n, r):\n return reduce(lambda a, b: a * b % MOD, (Fraction(n - i, i + 1) for i in\n range(r)), 1)\n\n\n<mask token>\n\n\ndef comball(a):\n r = []\n for l in range(0, len(a) + 1):\n ...
[ 2, 3, 4, 5, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> http1.post('http://' + ip + '/music_download/api/login', 'username=admin&password=123456') http1.upload('http://' + ip + '/music_download/api/song/upload', 'speed=0&styleId=c0a4bd86-a09b-43ac-8169-14bb69630ac0&file=G:\\mus...
flexible
{ "blob_id": "68e09f72e8338efbef108ffd0c93eff067bf7b07", "index": 135, "step-1": "<mask token>\n", "step-2": "<mask token>\nhttp1.post('http://' + ip + '/music_download/api/login',\n 'username=admin&password=123456')\nhttp1.upload('http://' + ip + '/music_download/api/song/upload',\n 'speed=0&styleId=c0a4...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class AgentInstallerLocalTest(BaseDaemonLiveTestCase): <|reserved_special_token_0|> @classmethod def setUpClass(cls): cls.logger = setup_logger(cls.__name__) cls.source_url = get_source_uri() cls.requirements_file = get_requirements_uri() def setU...
flexible
{ "blob_id": "eed3ec2897d4da20b576cb4e2ce95331ae223f76", "index": 7938, "step-1": "<mask token>\n\n\nclass AgentInstallerLocalTest(BaseDaemonLiveTestCase):\n <mask token>\n\n @classmethod\n def setUpClass(cls):\n cls.logger = setup_logger(cls.__name__)\n cls.source_url = get_source_uri()\n ...
[ 4, 6, 8, 10, 11 ]
""" You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices. Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the stri...
normal
{ "blob_id": "5efb8151375d705f3591921654f847e45b6927c9", "index": 3614, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def areAlmostEqual(self, s1, s2):\n if not len(s1) == len(s2):\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class ProxySwift(object): <|reserved_special_token_0|> def requerst_get(self, url, data, *p, **kwargs): SecretKey = '3JCx8fAF7Bpq5Aj4t9wS7cfVB7hpXZ7j' PartnerID = '2017061217350058' TimeStamp = int(time.time()) source_data = {'partner_id': PartnerI...
flexible
{ "blob_id": "0ff96b2314927d7b3e763242e554fd561f3c9343", "index": 5872, "step-1": "<mask token>\n\n\nclass ProxySwift(object):\n <mask token>\n\n def requerst_get(self, url, data, *p, **kwargs):\n SecretKey = '3JCx8fAF7Bpq5Aj4t9wS7cfVB7hpXZ7j'\n PartnerID = '2017061217350058'\n TimeStam...
[ 9, 10, 13, 14, 16 ]
<|reserved_special_token_0|> @app.on_message(filters.command('start')) def start(client, message): kb = [[InlineKeyboardButton('🍿 Channel', url= 'https://telegram.me/MyTestBotZ'), InlineKeyboardButton( '🍿 BotsList', url='https://t.me/mybotzlist')]] reply_markup = InlineKeyboardMarkup(kb) ...
flexible
{ "blob_id": "ecbb64223b0d5aa478cf91e1fcafe45572eac1af", "index": 6197, "step-1": "<mask token>\n\n\n@app.on_message(filters.command('start'))\ndef start(client, message):\n kb = [[InlineKeyboardButton('🍿 Channel', url=\n 'https://telegram.me/MyTestBotZ'), InlineKeyboardButton(\n '🍿 BotsList', ...
[ 12, 13, 14, 15, 16 ]
import pytest from eth_utils import encode_hex, remove_0x_prefix from ethereum.tester import keys import os import json from microraiden.client.client import CHANNEL_MANAGER_ABI_NAME, TOKEN_ABI_NAME from microraiden.crypto import privkey_to_addr @pytest.fixture def contracts_relative_path(): return 'data/contrac...
normal
{ "blob_id": "438fe1ccf265706e202d7cc6044e57590f29801f", "index": 9375, "step-1": "<mask token>\n\n\n@pytest.fixture\ndef contracts_relative_path():\n return 'data/contracts.json'\n\n\n@pytest.fixture\ndef compiled_contracts_path(test_dir, contracts_relative_path):\n return os.path.join(test_dir, contracts_...
[ 10, 11, 17, 18, 21 ]
<|reserved_special_token_0|> class GridWalker: def __init__(self): self._current_pos = [0, 0] self._heading = math.pi / 2 @property def position(self): return self._current_pos @property def distance_from_home(self): return int(abs(self._current_pos[0]) + abs(sel...
flexible
{ "blob_id": "907f0564d574f197c25b05a79569a8b6f260a8cd", "index": 7817, "step-1": "<mask token>\n\n\nclass GridWalker:\n\n def __init__(self):\n self._current_pos = [0, 0]\n self._heading = math.pi / 2\n\n @property\n def position(self):\n return self._current_pos\n\n @property\n ...
[ 8, 9, 11, 13, 14 ]
import sys, getopt sys.path.append('.') import RTIMU import os.path import time import math import encoders import motors #right is master, left is slave master_power = .6 slave_power = -.6 right_num_revs = 0 left_num_revs = 0 kp = .5 encoders.init() motors.init() en_left, en_right = encoders.read() SETTINGS_FILE ...
normal
{ "blob_id": "00f8a56b160cab22bf73c0d2397eb2c411e8c966", "index": 7714, "step-1": "<mask token>\n\n\ndef adjustMotorPowers():\n global slave_power\n global en_left\n global en_right\n global kp\n error = en_right + en_left\n slave_power -= error / kp\n encoders.clear()\n time.sleep(0.1)\n\...
[ 2, 3, 4, 5, 6 ]
import numpy as np x = np.zeros(10) idx = [1, 4, 5, 9] np.put(x, ind=idx, v=1) print(x)
normal
{ "blob_id": "9e2485554a5a8de07dd3df39cc255f2a1ea2f164", "index": 4769, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.put(x, ind=idx, v=1)\nprint(x)\n", "step-3": "<mask token>\nx = np.zeros(10)\nidx = [1, 4, 5, 9]\nnp.put(x, ind=idx, v=1)\nprint(x)\n", "step-4": "import numpy as np\nx = np.zeros(...
[ 0, 1, 2, 3 ]
from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import Context from books.models import book,Author def index(request): book_list=book.objects.all() c=Context({"book_list":book_list}) return render_to_response("index.html",c)
normal
{ "blob_id": "441d224c37e0eae531c17db0e903b3344c570516", "index": 9867, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef index(request):\n book_list = book.objects.all()\n c = Context({'book_list': book_list})\n return render_to_response('index.html', c)\n", "step-3": "from django.http im...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def find_webs(query): urls = [] rrss = ['facebook', 'twitter', 'linkedin', 'instagram', 'youtube', 'pinterest', 'angel'] sites = [] red_social = False for s in search(query, tld='com', num=30, stop=30, pause=3, lang='en'): if len(urls) < 10: ...
flexible
{ "blob_id": "9c7ecd3c878d43633606439aa63f840176f20dee", "index": 7941, "step-1": "<mask token>\n\n\ndef find_webs(query):\n urls = []\n rrss = ['facebook', 'twitter', 'linkedin', 'instagram', 'youtube',\n 'pinterest', 'angel']\n sites = []\n red_social = False\n for s in search(query, tld='...
[ 14, 15, 16, 20, 22 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def fib(n): if n == 1 or n == 2: return 1 return fib(n - 1) + fib(n - 2) <|reserved_special_token_0|> <|reserved_special_token_1|> def fib(n): if n == 1 or n == 2: return 1 return fib(n - 1) + fib(n - 2) print(fib(10)) ...
flexible
{ "blob_id": "59376f6565cd72e20087609253a41c04c6327a27", "index": 6324, "step-1": "<mask token>\n", "step-2": "def fib(n):\n if n == 1 or n == 2:\n return 1\n return fib(n - 1) + fib(n - 2)\n\n\n<mask token>\n", "step-3": "def fib(n):\n if n == 1 or n == 2:\n return 1\n return fib(n ...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ Created on Fri Oct 5 17:05:12 2018 @author: Shane """ import math import scipy.integrate as integrate import random import numpy as np import sympy as sym ''' Question 1 plug and play into formula for VC generalization ''' print('Question 1') error = 0.05 for N in [400000,420000,4400...
normal
{ "blob_id": "abe53120a485f608431142c6b9452666fcd72dbf", "index": 7464, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Question 1')\n<mask token>\nfor N in [400000, 420000, 440000, 460000, 480000]:\n print(4 * (2 * N) ** 10 * math.exp(-(1 / 8) * error ** 2 * N))\n<mask token>\nprint('Question 2'...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python import rospy from geometry_msgs.msg import PoseStamped from styx_msgs.msg import Lane, Waypoint from scipy.spatial import KDTree import numpy as np from std_msgs.msg import Int32 import math ''' This node will publish waypoints from the car's current position to some `x` distance ahead. As men...
normal
{ "blob_id": "9ad92b23b8a02204a86af599e507eb889e5bcec7", "index": 7565, "step-1": "<mask token>\n\n\nclass WaypointUpdater(object):\n\n def __init__(self):\n rospy.init_node('waypoint_updater')\n rospy.Subscriber('/current_pose', PoseStamped, self.pose_cb)\n rospy.Subscriber('/base_waypoin...
[ 10, 15, 16, 17, 19 ]
import os import json import pytest from datetime import datetime from collections import OrderedDict import numpy as np import pandas as pd from sqlalchemy.exc import ProgrammingError import pawprint def test_create_table_with_default_options(pawprint_default_tracker_db): """Ensure the table is correctly crea...
normal
{ "blob_id": "89a75ae980b7b48d33d0e8aa53ec92296dbfbc8e", "index": 2843, "step-1": "<mask token>\n\n\ndef test_create_table_with_default_options(pawprint_default_tracker_db):\n \"\"\"Ensure the table is correctly created with the default schema.\"\"\"\n tracker = pawprint_default_tracker_db\n assert track...
[ 8, 15, 18, 20, 21 ]
<|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": "b90fb1e657d4c7e186a7b889eee586527bec4413", "index": 2040, "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 = [('crm', '0003...
[ 0, 1, 2, 3, 4 ]
import Utility import copy class Ratio_Execution_Time: utility = None def __init__(self): self.utility = Utility.Utility() print("Successfully Found Ration Corrssponding to Execution Time") def calculatePercentage(self,B,total,strr): E = {} for i in B: ...
normal
{ "blob_id": "150603004a4b194a7c08f1f23e37c613aa3b883a", "index": 6431, "step-1": "<mask token>\n\n\nclass Ratio_Execution_Time:\n <mask token>\n <mask token>\n\n def calculatePercentage(self, B, total, strr):\n E = {}\n for i in B:\n s = ''\n for j in range(i[0], i[1]...
[ 3, 5, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for m in mentions: if m.has_attr('representative') == False: print('before: =>\n{}'.format(m)) m['representative'] = 'false' print('after: =>\n{}'.format(m)) <|reserved_special_token_1|> <|reserved_s...
flexible
{ "blob_id": "04938e14f22c44437188469b53dfb05d2ecd4a5c", "index": 4481, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor m in mentions:\n if m.has_attr('representative') == False:\n print('before: =>\\n{}'.format(m))\n m['representative'] = 'false'\n print('after: =>\\n{}'.format...
[ 0, 1, 2, 3, 4 ]
import pandas import numpy as np train_set = pandas.read_csv("./dataset/train.csv") test_set = pandas.read_csv("./dataset/test.csv") print(train_set) train_set = train_set.drop('id',axis=1) print(train_set.describe()) train_set['type'], categories = train_set['type'].factorize() import matplotlib.pyplot as plt print...
normal
{ "blob_id": "ccedca543fc4dee284a9243317d028ffdeac229d", "index": 2923, "step-1": "<mask token>\n\n\nclass CreateExtraFeatures(BaseEstimator, TransformerMixin):\n <mask token>\n <mask token>\n\n def transform(self, X, y=None):\n X['hair_soul'] = X['hair_length'] * X['has_soul']\n X['flesh_s...
[ 6, 8, 9, 10, 12 ]
from api import db from api.models.author import AuthorModel class QuoteModel(db.Model): id = db.Column(db.Integer, primary_key=True) author_id = db.Column(db.Integer, db.ForeignKey(AuthorModel.id)) quote = db.Column(db.String(255), unique=False) rate = db.Column(db.Integer) def __init__(self, au...
normal
{ "blob_id": "38f41fa87230ddc0b3a8c411b4c569f59f0ea065", "index": 2509, "step-1": "<mask token>\n\n\nclass QuoteModel(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, author, quote, rating=1):\n self.author = author\n self.quote = quote\n ...
[ 3, 4, 5, 7, 8 ]
from __future__ import absolute_import import numpy as np import matplotlib.pyplot as pl import seaborn as sb sb.set_color_codes('muted') import scipy.optimize as op from scipy import stats def errorbar(t, f, s, fp=None, **kwargs): with sb.axes_style('white'): fig, ax = pl.subplots(1, 1, figsize=(10,3)) ...
normal
{ "blob_id": "1e929bc3c97de859a16a4ac8d5ac2ebadefd0516", "index": 6624, "step-1": "<mask token>\n\n\ndef errorbar(t, f, s, fp=None, **kwargs):\n with sb.axes_style('white'):\n fig, ax = pl.subplots(1, 1, figsize=(10, 3))\n ax.errorbar(t, f, s, marker='o', color='b', linestyle='none', **kwargs)\n ...
[ 4, 5, 6, 7, 8 ]
# Celery配置文件 # 指定消息队列为Redis broker_url = "redis://120.78.168.67/10" CELERY_RESULT_BACKEND = "redis://120.78.168.67/0" CELERY_TIMEZONE = 'Asia/Shanghai'
normal
{ "blob_id": "095374aa7613f163fedbd7d253219478108d4f42", "index": 992, "step-1": "<mask token>\n", "step-2": "broker_url = 'redis://120.78.168.67/10'\nCELERY_RESULT_BACKEND = 'redis://120.78.168.67/0'\nCELERY_TIMEZONE = 'Asia/Shanghai'\n", "step-3": "# Celery配置文件\n\n# 指定消息队列为Redis\nbroker_url = \"redis://120....
[ 0, 1, 2 ]
<|reserved_special_token_0|> class AXCadvisorClient(object): def __init__(self, ip): self._wait_interval = 60 self._url_prefix = 'http://{ip}:{port}/api/v2.0/'.format(ip=ip, port=4194) self.wait_for_cadvisor_up() def wait_for_cadvisor_up(self): """ Poll ca...
flexible
{ "blob_id": "87f672919f6019e549508b239c798301d5f549bd", "index": 7667, "step-1": "<mask token>\n\n\nclass AXCadvisorClient(object):\n\n def __init__(self, ip):\n self._wait_interval = 60\n self._url_prefix = 'http://{ip}:{port}/api/v2.0/'.format(ip=ip,\n port=4194)\n self.wait_...
[ 5, 6, 7, 8, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('From fahrenheit to celcius', celcius) <|reserved_special_token_1|> fahrenheit = float(input('Enter a fahrenheit degree: ')) celcius = (fahrenheit - 32) * 5 / 9 print('From fahrenheit to celcius', celcius) <|reserved_sp...
flexible
{ "blob_id": "2f2030107f3a23c0d2f404a838eaccc8b35ac410", "index": 1086, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('From fahrenheit to celcius', celcius)\n", "step-3": "fahrenheit = float(input('Enter a fahrenheit degree: '))\ncelcius = (fahrenheit - 32) * 5 / 9\nprint('From fahrenheit to celc...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class MotorControl(object): <|reserved_special_token_0|> <|reserved_special_token_0|> def forward(self, speed=1.0, t=None): self.pwm_r1.ChangeDutyCycle(self.r_level * speed) self.pwm_r2.ChangeDutyCycle(0) self.pwm_l1.ChangeDutyCycle(self.l_level * spee...
flexible
{ "blob_id": "2985360c1e2d03c619ea2994c609fdf8c033bebd", "index": 9177, "step-1": "<mask token>\n\n\nclass MotorControl(object):\n <mask token>\n <mask token>\n\n def forward(self, speed=1.0, t=None):\n self.pwm_r1.ChangeDutyCycle(self.r_level * speed)\n self.pwm_r2.ChangeDutyCycle(0)\n ...
[ 5, 11, 13, 15, 18 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @admin.register(OrderModel) class OrderAdmin(admin.ModelAdmin): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @admin.register(OrderModel) class OrderAdmin(admin.ModelAdmin): ...
flexible
{ "blob_id": "a238175c94764137bfc8fac1ce67436016b1591a", "index": 1519, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@admin.register(OrderModel)\nclass OrderAdmin(admin.ModelAdmin):\n <mask token>\n", "step-3": "<mask token>\n\n\n@admin.register(OrderModel)\nclass OrderAdmin(admin.ModelAdmin):\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Point: def __init__(self, x, y): self.x = x self.y = y <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Point: def __init__(self, x, y): self.x = x self.y = y def callback(ref): print(...
flexible
{ "blob_id": "2542998c3a7decd6329856a31d8e9de56f82bae1", "index": 3922, "step-1": "<mask token>\n\n\nclass Point:\n\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Point:\n\n def __init__(self, x, y):\n self.x = x\n ...
[ 2, 3, 5, 6, 7 ]
<|reserved_special_token_0|> class PrepareData: def __init__(self): return def sparse_tuple_from_label(self, sequences, dtype=np.int32): """Create a sparse representention of x. Args: sequences: a list of lists of type dtype where each element is a sequence Return...
flexible
{ "blob_id": "315fe68f4adf39ded46fa9ad059fd2e962e46437", "index": 8533, "step-1": "<mask token>\n\n\nclass PrepareData:\n\n def __init__(self):\n return\n\n def sparse_tuple_from_label(self, sequences, dtype=np.int32):\n \"\"\"Create a sparse representention of x.\n Args:\n s...
[ 7, 8, 9, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open(fn, 'w') as file_Obj: file_Obj.write(x) <|reserved_special_token_1|> fn = 'out14_26.txt' x = 100 with open(fn, 'w') as file_Obj: file_Obj.write(x) <|reserved_special_token_1|> # ch14_26.py fn = 'out14_26.t...
flexible
{ "blob_id": "e4f07355300003943d2fc09f80746a1201de7e37", "index": 1678, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(fn, 'w') as file_Obj:\n file_Obj.write(x)\n", "step-3": "fn = 'out14_26.txt'\nx = 100\nwith open(fn, 'w') as file_Obj:\n file_Obj.write(x)\n", "step-4": "# ch14_26.py\...
[ 0, 1, 2, 3 ]
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter from math import sqrt from sys import exit from subprocess import Popen, DEVNULL from resmon import LineSegment, reorder_step def write_head(file): with open("head.tex", "r") as head: for line in head: f.write(line) def writ...
normal
{ "blob_id": "5c0ee6e8a0d80dbb77a7a376c411b85bf1405272", "index": 1880, "step-1": "<mask token>\n\n\ndef write_head(file):\n with open('head.tex', 'r') as head:\n for line in head:\n f.write(line)\n\n\ndef write_foot(file):\n with open('foot.tex', 'r') as head:\n for line in head:\n...
[ 2, 3, 4, 5, 6 ]
from common.utils import create_brokers from Bot import DataGatherBot, ArbitrageBot import api_config as config ### PAPER 이라고 정의한 # brokers = create_brokers('PAPER', config.CURRENCIES, config.EXCHANGES) # bot = ArbitrageBot(config, brokers) # brokers = create_brokers('BACKTEST', config.CURRENCIES, config.EXCHANGES) #...
normal
{ "blob_id": "4436fa36ec21edb3be467f74d8b9705780535f22", "index": 6786, "step-1": "<mask token>\n", "step-2": "<mask token>\ntrade_bot.start(sleep=1)\nprint('Done!')\n", "step-3": "<mask token>\nbrokers = create_brokers('LIVE', config.CURRENCIES, config.EXCHANGES)\ngp = brokers[2]\ntrade_bot = ArbitrageBot(co...
[ 0, 1, 2, 3, 4 ]
from peewee import * db = PostgresqlDatabase('contacts', user='postgres', password='', host='localhost', port=5432) intro_question = input("What would you like to do with Contacts? Create? Read? Find? Delete? Update? ") def read_contact(): contacts = Contact.select() for contact in c...
normal
{ "blob_id": "07544d1eb039da0081716aa489fc1a0a5a200145", "index": 1072, "step-1": "<mask token>\n\n\ndef read_contact():\n contacts = Contact.select()\n for contact in contacts:\n print(contact)\n print(contact.firstname + ' ' + contact.lastname + ' ' + contact.\n phone + ' ' + cont...
[ 7, 9, 10, 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...
normal
{ "blob_id": "e6010ec05ec24dcd2a44e54ce1b1f11000e775ce", "index": 8399, "step-1": "<mask token>\n\n\nclass INDENT_STACK:\n <mask token>\n\n def __init__(self):\n self.my_stack = [{'physical': 0, 'logical': 0, 'type': 'none'}]\n\n def init_indent(self):\n del self.my_stack\n self.my_s...
[ 7, 10, 11, 17, 19 ]
# Register all decoders import ludwig.schema.decoders.base import ludwig.schema.decoders.sequence_decoders # noqa
normal
{ "blob_id": "53509d826b82211bac02ea5f545802007b06781c", "index": 1630, "step-1": "<mask token>\n", "step-2": "import ludwig.schema.decoders.base\nimport ludwig.schema.decoders.sequence_decoders\n", "step-3": "# Register all decoders\nimport ludwig.schema.decoders.base\nimport ludwig.schema.decoders.sequence_...
[ 0, 1, 2 ]
import os def mini100(videopath, minipath,mod='train'): with open(videopath, 'r') as video_f: all_videos = video_f.readlines() #if mod=='train': # count = [400 for _ in range(0,100)] #else: # count = [25 for _ in range(0,100)] count = [0 for _ in range(0,100)] ...
normal
{ "blob_id": "f6d4208afee7aacd96ea5ae6c9e38d2876466703", "index": 7417, "step-1": "<mask token>\n\n\ndef mini200(videopath, minipath, mod='train'):\n with open(videopath, 'r') as video_f:\n all_videos = video_f.readlines()\n count = [(0) for _ in range(0, 200)]\n with open(minipath, 'w') a...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = patterns('', url('^$', Index.as_view(), name='core_index'), url('^configuracoes/', Configuracoes.as_view(), name= 'core.core_configurations'), url('^parametros/data/$', ParametrosData. as_view(), name='co...
flexible
{ "blob_id": "74c60c9e37e4e13ed4c61f631c3426b685b5d38f", "index": 8875, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', url('^$', Index.as_view(), name='core_index'),\n url('^configuracoes/', Configuracoes.as_view(), name=\n 'core.core_configurations'), url('^parametros/dat...
[ 0, 1, 2, 3 ]
print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh?", weight = raw_input() print "So, you're %r old, %r tall, and %r heavy." % (age, height, weight) #raw_input does not exist in Python 3.x while input() does. raw_input() returns a string, and inp...
normal
{ "blob_id": "4df747b3ff254e0ccc4483acd7be12f3441bbcd8", "index": 5531, "step-1": "\nprint \"How old are you?\",\nage = raw_input()\nprint \"How tall are you?\",\nheight = raw_input()\nprint \"How much do you weigh?\",\nweight = raw_input()\n\nprint \"So, you're %r old, %r tall, and %r heavy.\" % (age, height, we...
[ 0 ]
<|reserved_special_token_0|> class DatasetType(enum.Enum): """ Represents the type of dataset """ TRAIN = 0 VAL = 1 TEST = 2 class Language(enum.Enum): """ Represents the dataset language """ GERMAN = 0 ENGLISH = 1 CHINESE = 2 def load_text(path): """ Given ...
flexible
{ "blob_id": "0150e1db3ef2f6c07280f21971b43ac71fc4cada", "index": 8984, "step-1": "<mask token>\n\n\nclass DatasetType(enum.Enum):\n \"\"\"\n Represents the type of dataset\n \"\"\"\n TRAIN = 0\n VAL = 1\n TEST = 2\n\n\nclass Language(enum.Enum):\n \"\"\"\n Represents the dataset language\...
[ 7, 8, 11, 12, 13 ]
<|reserved_special_token_0|> class Graph(ndb.Model): name = ndb.StringProperty(required=True) graphID = ndb.IntegerProperty(required=True) owner_id = ndb.IntegerProperty(required=True) machines = ndb.StructuredProperty(Machine, repeated=True) services = ndb.StructuredProperty(Service, repeated=Tru...
flexible
{ "blob_id": "ac60fd79d7fb15624cf79adc7e456960e7523e2e", "index": 9131, "step-1": "<mask token>\n\n\nclass Graph(ndb.Model):\n name = ndb.StringProperty(required=True)\n graphID = ndb.IntegerProperty(required=True)\n owner_id = ndb.IntegerProperty(required=True)\n machines = ndb.StructuredProperty(Mac...
[ 38, 45, 49, 52, 53 ]
import sys sys.path.append("..") # Adds higher directory to python modules path. from utils import npm_decorator # num_node = 3 @ npm_decorator(3) def scenario(): """ 1. Check each peer's genesis block 2. Generate new blocks on each peer 2.1. 2 blocks on peer #1 2.2. 4 blocks on peer #2 ...
normal
{ "blob_id": "91cf1f4cf34ac9723be4863e81149c703adca27a", "index": 3583, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@npm_decorator(3)\ndef scenario():\n \"\"\"\n 1. Check each peer's genesis block\n 2. Generate new blocks on each peer\n 2.1. 2 blocks on peer #1\n 2.2. 4 block...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class WriteToCsv(object): <|reserved_special_token_0|> def process_item(self, item, spider): write_to_csv(item) return item <|reserved_special_token_1|> <|reserved_special_token_0|> class WriteToCsv(object): item_counter = 0 def process_item(self, it...
flexible
{ "blob_id": "f0c621583caf6eea6f790649862a03a464f6574b", "index": 3727, "step-1": "<mask token>\n\n\nclass WriteToCsv(object):\n <mask token>\n\n def process_item(self, item, spider):\n write_to_csv(item)\n return item\n", "step-2": "<mask token>\n\n\nclass WriteToCsv(object):\n item_coun...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(len(cha)): for j in dial: if cha[i] in j: num = num + dial.index(j) + 3 print(num) <|reserved_special_token_1|> dial = ['ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQRS', 'TUV', 'WXYZ'] cha = inpu...
flexible
{ "blob_id": "774e607c693fa2d5199582302e466674f65b6449", "index": 6213, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(cha)):\n for j in dial:\n if cha[i] in j:\n num = num + dial.index(j) + 3\nprint(num)\n", "step-3": "dial = ['ABC', 'DEF', 'GHI', 'JKL', 'MNO', '...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def get_max_sum(arr): max_sum = -math.inf for i in range(1, 5): for j in range(1, 5): temp = arr[i][j] + arr[i - 1][j - 1] + arr[i - 1][j] + arr[i - 1][ j + 1] + arr[i + 1][j + 1] + arr[i + 1][j] + arr[i + 1][j - 1] max_sum = max(max...
flexible
{ "blob_id": "c99f1333c5ca3221e9932d9a9ba1d95a77924f0d", "index": 351, "step-1": "<mask token>\n\n\ndef get_max_sum(arr):\n max_sum = -math.inf\n for i in range(1, 5):\n for j in range(1, 5):\n temp = arr[i][j] + arr[i - 1][j - 1] + arr[i - 1][j] + arr[i - 1][\n j + 1] + arr...
[ 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ 项目:爬取思否网站首页推荐文章 作者:cho 时间:2019.9.23 """ import json import parsel import scrapy from scrapy import Request from SF.items import SfItem class SfCrawlSpider(scrapy.Spider): name = 'sf_crawl' allowed_domains = ['segmentfault.com'] header = { 'user-agent': 'Mozilla/5.0 (W...
normal
{ "blob_id": "7ed6d475bfe36fdd0b6cd2f0902a0bccb22f7f60", "index": 6082, "step-1": "<mask token>\n\n\nclass SfCrawlSpider(scrapy.Spider):\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 SfCrawlSpider(scrapy.Spider)...
[ 1, 4, 5, 6, 7 ]
from setuptools import setup, find_packages __version__ = '2.0' setup( name='sgcharts-pointer-generator', version=__version__, python_requires='>=3.5.0', install_requires=[ 'tensorflow==1.10.0', 'pyrouge==0.1.3', 'spacy==2.0.12', 'en_core_web_sm==2.0.0', 'sgchar...
normal
{ "blob_id": "e52b01cc7363943f5f99b1fa74720c6447b1cfae", "index": 6266, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='sgcharts-pointer-generator', version=__version__,\n python_requires='>=3.5.0', install_requires=['tensorflow==1.10.0',\n 'pyrouge==0.1.3', 'spacy==2.0.12', 'en_core_web_...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): dependencies = [(...
flexible
{ "blob_id": "c7558486fc50623f6e64b58668153b75bb6149b9", "index": 6613, "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 = [('planner', '...
[ 0, 1, 2, 3, 4 ]
#容器序列 #list tuple collections.deque dict #扁平序列 #str #可变序列 #list collections.deque dict #不变序列 # tuple str
normal
{ "blob_id": "1f45bdbfdd29a0b832ebac7e4ff91df1203ae158", "index": 7712, "step-1": "#容器序列\n#list tuple collections.deque dict\n#扁平序列\n#str \n#可变序列\n#list collections.deque dict\n#不变序列\n# tuple str", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 1 ] }
[ 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def log_func(handler): if handler.get_status() < 400: log_method = logging.info elif handler.get_status() < 500: log_method = logging.warning else: log_method = logging.error request_time ...
flexible
{ "blob_id": "e403be68894ba283d71a0b71bb0bfd0adfab8c41", "index": 8684, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef log_func(handler):\n if handler.get_status() < 400:\n log_method = logging.info\n elif handler.get_status() < 500:\n log_method = logging.warning\n else:\n ...
[ 0, 1, 2, 3, 4 ]
from __future__ import division import random as rnd import math from collections import Counter from matplotlib import pyplot as plt import ds_library import ds_algebra import ds_probability import ds_gradient_descent def normal_pdfs_visualization(): xs = [x/10.0 for x in range(-50, 50)] plt.plot(xs...
normal
{ "blob_id": "c0adc0032a2647a19d3540c057fa9762906e5f62", "index": 4439, "step-1": "<mask token>\n\n\ndef normal_pdfs_visualization():\n xs = [(x / 10.0) for x in range(-50, 50)]\n plt.plot(xs, [ds_probability.normal_pdf(x, sigma=1) for x in xs], '-',\n label='mu=0-sigma=1')\n plt.plot(xs, [ds_prob...
[ 3, 4, 6, 7, 8 ]
from functools import partial import torch from torch import nn from src.backbone.layers.conv_block import ConvBNAct, MBConvConfig, MBConvSE, mobilenet_v2_init from src.backbone.mobilenet_v2 import MobileNetV2 from src.backbone.utils import load_from_zoo class MobileNetV3(MobileNetV2): def __init__(self, residu...
normal
{ "blob_id": "4a5185fac7d6c09daa76b5d0d5aee863028a6bce", "index": 5328, "step-1": "<mask token>\n\n\nclass MobileNetV3(MobileNetV2):\n <mask token>\n\n def forward(self, x):\n return self.dropout(self.classifier(torch.flatten(self.avg_pool(\n self.features(x)), 1)))\n\n\n<mask token>\n", ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class PlayerRecord: <|reserved_special_token_0|> character: str <|reserved_special_token_0|> @property def team(self) ->ba.SessionTeam: """The ba.SessionTeam the last associated player was last on. This can still return a valid result even if the play...
flexible
{ "blob_id": "7c63abacce07ee9d4c2b3941d05f951b75c8d0ff", "index": 1157, "step-1": "<mask token>\n\n\nclass PlayerRecord:\n <mask token>\n character: str\n <mask token>\n\n @property\n def team(self) ->ba.SessionTeam:\n \"\"\"The ba.SessionTeam the last associated player was last on.\n\n ...
[ 17, 23, 28, 29, 30 ]
#!/usr/bin/python # -*- coding: utf-8 -*- import asyncio from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from myshell.environment import Environment from myshell.job import Job, JobState class JobManager: """事务管理器,用以调度前台和后台事务""" def __init__(self, environment: "Environment"): self...
normal
{ "blob_id": "e09f914f00e59124ef7d8a8f183bff3f7f74b826", "index": 5869, "step-1": "<mask token>\n\n\nclass JobManager:\n <mask token>\n\n def __init__(self, environment: 'Environment'):\n self.foreground_job: Optional[Job] = None\n self.background_jobs: list[Optional[Job]] = [None]\n se...
[ 11, 12, 14, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: def canJump(self, nums): best_index = 0 for i in range(len(nums)): if i > best_index: ...
flexible
{ "blob_id": "f6974c0e5908710031bc3c3bb75c277be426632c", "index": 2789, "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 canJump(self, nums):\n best_index = 0\n for i in range(len(nums)):\n if i > best...
[ 0, 1, 2, 3, 4 ]
import json import requests import config class RequestAnnotation: def schedule(self, command: str, **kwargs): response = requests.post(url=f"http://localhost:{config.annotation_port}/{command}", json=kwargs) # not 'text' for annotating, but...
normal
{ "blob_id": "6782761bcbf53ea5076b6dfb7de66d0e68a9f45d", "index": 3123, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass RequestAnnotation:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass RequestAnnotation:\n\n def schedule(self, command: str, **kwargs):\n response = requests....
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- from nose.tools import * # noqa import mock import httpretty from tests.base import OsfTestCase from tests.factories import AuthUserFactory, ProjectFactory import urlparse from framework.auth import Auth from website.addons.mendeley.tests.factories import ( MendeleyAccountFactory, ...
normal
{ "blob_id": "f69351474fb3eb48eeb65eaf1aa46d2f4a390471", "index": 1887, "step-1": "<mask token>\n\n\nclass MendeleyViewsTestCase(OsfTestCase):\n\n def setUp(self):\n super(MendeleyViewsTestCase, self).setUp()\n self.account = MendeleyAccountFactory()\n self.user = AuthUserFactory(external_...
[ 11, 14, 16, 20, 25 ]
class MyMath: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class Calsi: def add(num1, num2): return num1 + num2 def sub(num1, num2): return num1 - num2 def mul(num1, num2): return num1 * num2 <|reserved_special_token_1|> c...
flexible
{ "blob_id": "20d363f5d02cc0b1069aa8951999c0cb22b85613", "index": 7578, "step-1": "class MyMath:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Calsi:\n\n def add(num1, num2):\n return num1 + num2\n\n def sub(num1, num2):\n return num1 - num2\n\n def mul(num1, num2):\n ...
[ 5, 6, 7, 8, 9 ]
import sys import os import tensorflow as tf import keras from cv2 import * from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten from PIL import Image import numpy as np import pickle from sklearn.model_selection import train_test_split from keras.utils import np_utils from keras.layers ...
normal
{ "blob_id": "0681ab83843187701ac72018b6078f5141bf22e0", "index": 3663, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.random.seed(7)\n<mask token>\ntf.keras.backend.set_session(tf.Session(config=config))\nnp.set_printoptions(threshold=np.nan)\n<mask token>\nwith open('gei.txt', 'rb') as fr:\n x_tra...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def n_over_phi(n): top = 1 bot = 1 pfactors = prime_factors(n) for p, count in pfactors.items(): top *= p bot *= p - 1 return top / bot def maximise_n_over_phi(upto): max_value = 0 max_n = 0 for n in range(2, upto + 1): n_over_phi_...
flexible
{ "blob_id": "2d248ac1df1845bc5a2ee62a7171c1c47ca6d0ca", "index": 3665, "step-1": "<mask token>\n\n\ndef n_over_phi(n):\n top = 1\n bot = 1\n pfactors = prime_factors(n)\n for p, count in pfactors.items():\n top *= p\n bot *= p - 1\n return top / bot\n\n\ndef maximise_n_over_phi(upto)...
[ 2, 3, 4, 5, 6 ]
'''Instantiate data parsers for all cities. If additional city parsers are added, the `bikerrawdata` instance in this file should be updated. Written by: Anders Ohrn 2020 ''' from dataset_creators.cities import parse_taipei_file, taipei_system, \ parse_london_file, london_system, ...
normal
{ "blob_id": "53bf97d66d0b26c6b5639acd0261604082474e7b", "index": 8163, "step-1": "<mask token>\n\n\ndef compile_data(city_labels=None):\n \"\"\"Compile all data into common structure\n\n \"\"\"\n pass\n\n\ndef compile_and_save_data(f_out, city_labels=None):\n \"\"\"Compile and save all data\n\n \"...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> @event_class() class FunctionCallEvent(EventBase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @event_class() class PacketEvent(EventBase): """ L7 packet message """ deferred = True @classmethod def from_mes...
flexible
{ "blob_id": "9a665d126d7b48adbd876b48c3d8806eabea1108", "index": 3716, "step-1": "<mask token>\n\n\n@event_class()\nclass FunctionCallEvent(EventBase):\n <mask token>\n <mask token>\n <mask token>\n\n\n@event_class()\nclass PacketEvent(EventBase):\n \"\"\"\n L7 packet message\n \"\"\"\n defe...
[ 11, 12, 13, 15, 17 ]
''' Copyright Jelen forráskód a Budapesti Műszaki és Gazdaságtudományi Egyetemen tartott "Deep Learning a gyakorlatban Python és LUA alapon" tantárgy segédanyagaként készült. A tantárgy honlapja: http://smartlab.tmit.bme.hu/oktatas-deep-learning Deep Learning kutatás: http://smartlab.tmit.bme.hu/deep-learning A forr...
normal
{ "blob_id": "cc097b4d2a5a521a0adb83ca1b58470b4ce84f39", "index": 7143, "step-1": "<mask token>\n\n\ndef data():\n (x_train, y_train), (x_test, y_test) = cifar10.load_data()\n num_classes = 10\n y_train = keras.utils.to_categorical(y_train, num_classes)\n y_test = keras.utils.to_categorical(y_test, nu...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- """ Created on Tue Jan 23 20:44:38 2018 @author: user """ import fitbit import gather_keys_oauth2 as Oauth2 import pandas as pd import datetime as dt from config import CLIENT_ID, CLIENT_SECRET #Establish connection to Fitbit API server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET) server...
normal
{ "blob_id": "9f1cbc655a5d8f14fa45cf977bb2dcee4874b188", "index": 5809, "step-1": "<mask token>\n\n\ndef get_heart_rate(auth2_client, date, granularity='1sec'):\n \"\"\"\n Query intraday time series given date\n granularity: 1sec or 1min\n \"\"\"\n heart_rate_raw = auth2_client.intraday_time_series...
[ 1, 2, 3, 4, 5 ]
from django.shortcuts import render,redirect from django.http import HttpResponseRedirect from . import forms,models from django.contrib.auth.models import Group from django.contrib import auth from django.contrib.auth.decorators import login_required,user_passes_test from datetime import datetime,timedelta,date from d...
normal
{ "blob_id": "ce9e1ac0f1596ba4db904289f91f5ab95c2de4b8", "index": 7642, "step-1": "<mask token>\n\n\ndef home_view(request):\n if request.user.is_authenticated:\n return HttpResponseRedirect('afterlogin')\n return render(request, 'library/index.html')\n\n\n<mask token>\n\n\ndef studentsignup_view(req...
[ 8, 11, 15, 18, 19 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for test_case in range(1, T + 1): N = int(input()) l = list(map(int, input().split())) min_v = 1000001 max_v = 0 i = 0 while i < N: if l[i] < min_v: min_v = l[i] if l[i] > max_v:...
flexible
{ "blob_id": "2b5df70c75f2df174991f6b9af148bdcf8751b61", "index": 4275, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor test_case in range(1, T + 1):\n N = int(input())\n l = list(map(int, input().split()))\n min_v = 1000001\n max_v = 0\n i = 0\n while i < N:\n if l[i] < min_v:...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # -*- coding: UTF-8 -*- import os import platform import subprocess # try to import json module, if got an error use simplejson instead of json. try: import json except ImportError: import simplejson as json # if your server uses fqdn, you can suppress the domain, just change the bellow...
normal
{ "blob_id": "de819a72ab659b50620fad2296027cb9f4d3e4c0", "index": 5048, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n import json\nexcept ImportError:\n import simplejson as json\n<mask token>\nif platform.system() == 'Linux':\n\n def SubprocessPopen(k):\n devnull = open(os.devnull...
[ 0, 1, 2, 3, 4 ]
from PyInstaller.utils.hooks import collect_data_files hiddenimports = ['sklearn.utils.sparsetools._graph_validation', 'sklearn.utils.sparsetools._graph_tools', 'sklearn.utils.lgamma', 'sklearn.utils.weight_vector'] datas = collect_data_files('sklearn')
normal
{ "blob_id": "12396130dc52866cc54d6dc701cf0f9a41a168b6", "index": 8351, "step-1": "<mask token>\n", "step-2": "<mask token>\nhiddenimports = ['sklearn.utils.sparsetools._graph_validation',\n 'sklearn.utils.sparsetools._graph_tools', 'sklearn.utils.lgamma',\n 'sklearn.utils.weight_vector']\ndatas = collect...
[ 0, 1, 2 ]
class Rectangle: <|reserved_special_token_0|> <|reserved_special_token_0|> def perimeter(self): return 2 * (self.length + self.breadth) <|reserved_special_token_0|> <|reserved_special_token_1|> class Rectangle: def __init__(self, length, breadth): self.length = length self...
flexible
{ "blob_id": "d5691403812cd3742f8e8b74d4ca613eca784ffd", "index": 9677, "step-1": "class Rectangle:\n <mask token>\n <mask token>\n\n def perimeter(self):\n return 2 * (self.length + self.breadth)\n\n\n<mask token>\n", "step-2": "class Rectangle:\n\n def __init__(self, length, breadth):\n ...
[ 2, 3, 4, 6, 7 ]
<|reserved_special_token_0|> class Blogsaljazeera2Spider(Spider): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @staticmethod def cleanhtml(raw_html): cleanr = re.compile('<.*?>') cleantext = re.sub(cleanr, '', raw_html) return clea...
flexible
{ "blob_id": "17058b323c0a0974dfa8f124ccd6cb5bf29dd849", "index": 2065, "step-1": "<mask token>\n\n\nclass Blogsaljazeera2Spider(Spider):\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def cleanhtml(raw_html):\n cleanr = re.compile('<.*?>')\n cleantext = re.sub(clean...
[ 6, 7, 8, 9, 10 ]
import numpy from sklearn.ensemble import RandomForestClassifier from sklearn.ensemble import GradientBoostingClassifier from sklearn.cross_validation import cross_val_score lag = 10 print "Loading train_data..." train_data = numpy.loadtxt("../KddJavaToolChain/train_timelines_final.csv", delimiter=",") print...
normal
{ "blob_id": "68d37421b71d595510a1439c06cc31d00c23c277", "index": 1125, "step-1": "import numpy\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.ensemble import GradientBoostingClassifier\nfrom sklearn.cross_validation import cross_val_score\n\nlag = 10\n\nprint \"Loading train_data...\"\ntrain_...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> quotes = [ 'Today you are you! That is truer than true! There is no one alive who is you-er than you!' , "Don't cry because it's over. Smile because it happened.", "You have brains in your head. You have feet in your shoes. You can steer yourself ...
flexible
{ "blob_id": "f9ba944724b262afb39f2859b5726b961536cdf0", "index": 2092, "step-1": "<mask token>\n", "step-2": "quotes = [\n 'Today you are you! That is truer than true! There is no one alive who is you-er than you!'\n , \"Don't cry because it's over. Smile because it happened.\",\n \"You have brains in...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class Solution: <|reserved_special_token_0|> def leaf_nodes_util(self, curr, result): if not curr: return self.leaf_nodes_util(self, curr.left, result) if not curr.left and not curr.right: result.append(curr.val) self.leaf_n...
flexible
{ "blob_id": "a49ee1e3f600d83486d0cf2396ed261c61fdf926", "index": 1711, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n def leaf_nodes_util(self, curr, result):\n if not curr:\n return\n self.leaf_nodes_util(self, curr.left, result)\n if not curr.left and not ...
[ 3, 6, 7, 8, 9 ]
import math import time def calculate_time(func): def inner_fn(*args, **kwargs): start = time.time() func(*args, **kwargs) end = time.time() print("Time taken to execute \'{}\' function is: {} seconds".format(func.__name__, round(end - start, 2))) return i...
normal
{ "blob_id": "7c9c13974e1deeb55f08c9e251e8c876cedcad6b", "index": 2484, "step-1": "<mask token>\n\n\n@calculate_time\ndef factorial(num):\n time.sleep(2)\n print(math.factorial(num))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef calculate_time(func):\n\n def inner_fn(*args, **kwargs):\n ...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- from Clases import Lugar from Clases import Evento import Dialogos import Funciones puntuacion_necesaria = 10 hp_inicial = 5 eventos = [ Evento("dormir", 2, False, -3, 4, Dialogos.descripciones_eventos[0], Dialogos.descripciones_triunfos[0], Dialogos.descripciones...
normal
{ "blob_id": "fe45fc6cd16be37b320844c5a8b43a964c016dd1", "index": 5018, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(Dialogos.saludo[0])\n<mask token>\nprint('\\nHola', nombre, 'tienes,', edad, 'años.')\nif edad >= 18:\n print('¡Tienes edad suficiente para jugar!')\n quiere_jugar = input('¿Q...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class CSV_conc(object): <|reserved_special_token_0|> <|reserved_special_token_0|> class CSV_conc_set(object): def __init__(self, rootname, stim_time=0, features=[]): self.stim_time = stim_time * msec_per_sec self.features = features if os.path.isdir(...
flexible
{ "blob_id": "20649decd3ff21b1aa814d0a04180195cac3629b", "index": 498, "step-1": "<mask token>\n\n\nclass CSV_conc(object):\n <mask token>\n <mask token>\n\n\nclass CSV_conc_set(object):\n\n def __init__(self, rootname, stim_time=0, features=[]):\n self.stim_time = stim_time * msec_per_sec\n ...
[ 3, 7, 8, 9, 10 ]
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2018 Cesar Sinchiguano <cesarsinchiguano@hotmail.es> # # Distributed under terms of the BSD license. """ """ import numpy as np from open3d import * def main(): print("Load a ply point cloud, print it, and render it") pcd = read_...
normal
{ "blob_id": "30e8e269cf6500ab804566a85c9b96b3ef9bda36", "index": 4143, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n print('Load a ply point cloud, print it, and render it')\n pcd = read_point_cloud('11.ply')\n \"\"\" read_point_cloud reads a point cloud from a file.\n ...
[ 0, 1, 2, 3, 4 ]
# fabric이 실행할 대상을 제어. from fabric.api import * AWS_EC2_01 = 'ec2-52-78-143-155.ap-northeast-2.compute.amazonaws.com' # Running PROJECT_DIR = '/var/www/kamper' APP_DIR = '%s/app' % PROJECT_DIR """ # the user to use for the remote commands env.user = 'appuser' # the servers where the commands are executed env.ho...
normal
{ "blob_id": "98db990f406cc6815480cca33011c8b0b2ad67c7", "index": 2343, "step-1": "<mask token>\n\n\ndef deploy():\n print('deploying')\n pass\n", "step-2": "<mask token>\n\n\ndef pack():\n local('git checkout')\n local('git commit -a -s -m \"Fabric Pack Commit\"')\n\n\ndef deploy():\n print('dep...
[ 1, 2, 3, 4, 5 ]