code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> class Station(Named): <|reserved_special_token_0|> def __init__(self, name, long_name, time_zone_name, latitude=None, longitude=None, elevation=None): super().__init__(name) self._long_name = long_name self._time_zone = ZoneInfo(time_zone_name) ...
flexible
{ "blob_id": "ad09880b9e06a129b9623be2a086ebcc8dc55c2c", "index": 9079, "step-1": "<mask token>\n\n\nclass Station(Named):\n <mask token>\n\n def __init__(self, name, long_name, time_zone_name, latitude=None,\n longitude=None, elevation=None):\n super().__init__(name)\n self._long_name ...
[ 6, 7, 9, 10, 11 ]
<|reserved_special_token_0|> def autorotate(angle): v.set_rotation_angle([0.0, -angle, 0.0]) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def autorotate(angle): v.set_rotation_angle([0.0, -angle, 0.0]) <|reserved_special_token_0|> v.animate(0, 360, autorotate...
flexible
{ "blob_id": "00be3d813ce4335ff9ea02ed9f1884d3210f3d5a", "index": 3101, "step-1": "<mask token>\n\n\ndef autorotate(angle):\n v.set_rotation_angle([0.0, -angle, 0.0])\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef autorotate(angle):\n v.set_rotation_angle([0.0, -angle, 0.0])\n\n\n<mask token>\nv.a...
[ 1, 2, 3, 4, 5 ]
# zip(),可以压缩 N 个列表成为一个zip对象(可迭代对象)。 a =['a', 'b', 'c'] b =[1, 2, 3] [x for x in zip(a, b)] # [('a', 1), ('b', 2), ('c', 3)] # 列表长度不等时,以短的为准 c =['x','y'] [x for x in zip(a, c)] # [('a', 'x'), ('b', 'y')] # 例子 books =['简爱','小王子','瓦尔登湖'] prices =[56, 78, 66] for book, price in zip(books, prices): print("%s的价格是:%3....
normal
{ "blob_id": "0eab23f4271f724da587707599eb0cbf2144efa1", "index": 8178, "step-1": "<mask token>\n", "step-2": "<mask token>\n[x for x in zip(a, b)]\n<mask token>\n[x for x in zip(a, c)]\n<mask token>\nfor book, price in zip(books, prices):\n print('%s的价格是:%3.1f' % (book, price))\n[y for y in reversed(b)]\nfo...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- from ..general.utils import log_errors from googleapiclient import discovery from oauth2client.client import SignedJwtAssertionCredentials from django.conf import settings from celery import shared_task from logging import getLogger import httplib2 _logger = getLogger(__name__) def create_ev...
normal
{ "blob_id": "36fb0d936be5c5d305c4076fd1c497664c9b770a", "index": 8374, "step-1": "<mask token>\n\n\ndef create_events_calendar():\n \"\"\" Create an events calendar if none already exists. This function mostly exists for\n creating calendars for dev environments, not used in prod.\n \"\"\"\n service ...
[ 4, 6, 7, 8, 9 ]
ghj=input("enter your first name:") print("Welcome to my Quiz:\nIf you go wrong once you lose but if you give all the answers correct then you win but no CHEATING.") print("Q1:-Who is the president of India?") winlist=("ramnath govind","multiple choice question","multiple choice questions","mumbai") enter=input("en...
normal
{ "blob_id": "351421ef6a40e3a4bd4549a1851fbf4bed9ddf30", "index": 5024, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\n \"\"\"Welcome to my Quiz:\nIf you go wrong once you lose but if you give all the answers correct then you win but no CHEATING.\"\"\"\n )\nprint('Q1:-Who is the president of...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ Created on Sat Nov 2 08:04:11 2019 @author: yocoy """ import serial, time arduino = serial.Serial('COM7', 9600) time.sleep(4) lectura = [] for i in range(100): lectura.append(arduino.readline()) arduino.close() print(lectura)
normal
{ "blob_id": "d514413c303dd174d8f56685158780a1681e1aba", "index": 7925, "step-1": "<mask token>\n", "step-2": "<mask token>\ntime.sleep(4)\n<mask token>\nfor i in range(100):\n lectura.append(arduino.readline())\narduino.close()\nprint(lectura)\n", "step-3": "<mask token>\narduino = serial.Serial('COM7', 9...
[ 0, 1, 2, 3, 4 ]
from enum import unique from django.db import models import secrets import string CARD_PACK_CHOICES = ( ('1', 'Traditional Cards'), ('2', 'Special Cards'), ('3', 'Other Themed Cards') ) MARKER_CHOICES = ( ('1', 'Plastic Dots'), ('2', 'Quarters'), ('3', 'Beans') ) def generate_game_code() -> ...
normal
{ "blob_id": "2fd33439d4403ec72f890a1d1b4f35f2b38d033b", "index": 9268, "step-1": "<mask token>\n\n\nclass Game(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Player(models.Model):\n \"\"\" Model that descr...
[ 4, 7, 9, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def cnt(): s1 = input('enter a string :').strip() count = 0 countu = 0 for i in s1: if i.islower(): count += 1 elif i.isupper(): countu += 1 else: pass print('THE NUMBER OF UPPER ...
flexible
{ "blob_id": "6cfda09f360aaa560011b91db8316e5e3889eea1", "index": 2017, "step-1": "<mask token>\n", "step-2": "def cnt():\n s1 = input('enter a string :').strip()\n count = 0\n countu = 0\n for i in s1:\n if i.islower():\n count += 1\n elif i.isupper():\n countu +...
[ 0, 1, 2 ]
import unittest import A1 import part_manager import security class test_A1(unittest.TestCase): # ----------------------------------- set up the mock data for test cases ----------------------------------- def setUp(self): self.security1 = security.Security("XXX-1234-ABCD-1234", None) self...
normal
{ "blob_id": "2ba5cb1265090b42b9a4838b792a3e81b209ba1a", "index": 3822, "step-1": "<mask token>\n\n\nclass test_A1(unittest.TestCase):\n\n def setUp(self):\n self.security1 = security.Security('XXX-1234-ABCD-1234', None)\n self.security2 = security.Security(None, 'kkklas8882kk23nllfjj88290')\n ...
[ 6, 7, 8, 9, 11 ]
"""Exercise 9c""" import time import numpy as np import matplotlib.pyplot as plt from plot_results import plot_2d from run_simulation import run_simulation from simulation_parameters import SimulationParameters def exercise_9c(world, timestep, reset): """Exercise 9c""" n_joints = 10 Rhead = 0.44 ...
normal
{ "blob_id": "a0284eba1a0e6c498f240068c586e7f8b79cd86c", "index": 5782, "step-1": "<mask token>\n\n\ndef main():\n n_joints = 10\n parameter_set = [SimulationParameters(simulation_duration=15, drive=4.0,\n amplitudes=None, phase_lag=None, turn=None, amplitude_gradient=[\n Rhead, Rtail], backwa...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def train(token2id, train_data, lr, batch_size, epochs, model): dataset = DataGenerator(token2id, train_data) dataloader = DataLoader(dataset, batch_size=batch_size, collate_fn= my_collate) model = to_device(...
flexible
{ "blob_id": "d0364b7cad29c639af9df5c78e810144ffd6ce2e", "index": 2415, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef train(token2id, train_data, lr, batch_size, epochs, model):\n dataset = DataGenerator(token2id, train_data)\n dataloader = DataLoader(dataset, batch_size=batch_size, collate...
[ 0, 1, 2, 3, 4 ]
# coding: utf-8 # In[5]: import os import numpy as np import pandas as pd from PIL import Image import argparse import time import shutil from sklearn.metrics import accuracy_score, mean_squared_error import torch import torch.optim from torch.utils.data import Dataset, DataLoader from torch.autograd import Variab...
normal
{ "blob_id": "f3a3746c48617754aad5ae8d0d7a0b8908c34562", "index": 7852, "step-1": "<mask token>\n\n\nclass ProtestDataset(Dataset):\n <mask token>\n <mask token>\n\n def __len__(self):\n return len(self.label_frame)\n <mask token>\n\n\nclass ProtestDatasetEval(Dataset):\n \"\"\"\n dataset...
[ 20, 21, 22, 25, 35 ]
import sys from Decks.Virtual_World.vw_sets import * from tools import * hand_3playable_hts = ["Nibiru, the Primal Being", "Effect Veiler", "Fantastical Dragon Phantazmay", "Dragon Buster Destruction Sword", "Dragon Buster Destruction Sword"] hand_2playable_hts = ["Nibiru, the Primal Being", "Nibiru, the Primal Being"...
normal
{ "blob_id": "43179b8b096836758271a791b4aacb7bbe398ea9", "index": 1807, "step-1": "<mask token>\n\n\ndef test_playable_hts_in_hand():\n assert playable_hts_in_hand(hand_3playable_hts) == 3\n assert playable_hts_in_hand(hand_2playable_hts) == 2\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef test_pl...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def generate_colour_data(width, height, imagiry_data, pixel2coord): """Extract color data from the .tiff file """ for i in range(1, height): for j in range(1, width): colour_data.append([pixel2coord(j, i)[0], pixel2coord(j, i)[1], imagiry_data.r...
flexible
{ "blob_id": "7e8b192e77e857f1907d5272d03c1138a10c61f4", "index": 4803, "step-1": "<mask token>\n\n\ndef generate_colour_data(width, height, imagiry_data, pixel2coord):\n \"\"\"Extract color data from the .tiff file \"\"\"\n for i in range(1, height):\n for j in range(1, width):\n colour_d...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class TestTTT(unittest.TestCase): def test_mcts(self): if 0 in skip: print('Skipping ai self-play') return ttt = TTT() for i in range(1000): mcts = MCTS(ttt) state = mcts.root.state while not mcts.boa...
flexible
{ "blob_id": "d0a3f332e04627eb275168972bd92cd1ea9b9447", "index": 227, "step-1": "<mask token>\n\n\nclass TestTTT(unittest.TestCase):\n\n def test_mcts(self):\n if 0 in skip:\n print('Skipping ai self-play')\n return\n ttt = TTT()\n for i in range(1000):\n ...
[ 4, 6, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in NICList: os.system('sudo ifconfig ' + i + ' promisc') os.system('sudo python ./src/top.py') <|reserved_special_token_1|> <|reserved_special_token_0|> NICList = [i for i in netifaces.interfaces() if i != 'lo'] for i...
flexible
{ "blob_id": "b38d23a7de3c805ddde4ed2d236e3c6e7bb5e2d0", "index": 118, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in NICList:\n os.system('sudo ifconfig ' + i + ' promisc')\nos.system('sudo python ./src/top.py')\n", "step-3": "<mask token>\nNICList = [i for i in netifaces.interfaces() if i ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for instance in instances['instances']: inst_names.append(instance['name']) inst_dict[instance['name']] = [] print(inst_names) <|reserved_special_token_0|> for snapshot in snapshots['instanceSnapshots']: inst_dict[snap...
flexible
{ "blob_id": "2023e0b749338488e63cbbb475b7a915bccccce0", "index": 7531, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor instance in instances['instances']:\n inst_names.append(instance['name'])\n inst_dict[instance['name']] = []\nprint(inst_names)\n<mask token>\nfor snapshot in snapshots['instanc...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class TestStudent(unittest.TestCase): def setUp(self): desired_caps = {} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '7.0' desired_caps['automationName'] = 'UIAutomator2' desired_caps['deviceName'] = 'PRA-AL00' ...
flexible
{ "blob_id": "8d7697a0e49dc9e966b9657171c66ccda57279d6", "index": 1930, "step-1": "<mask token>\n\n\nclass TestStudent(unittest.TestCase):\n\n def setUp(self):\n desired_caps = {}\n desired_caps['platformName'] = 'Android'\n desired_caps['platformVersion'] = '7.0'\n desired_caps['au...
[ 5, 6, 7, 8, 9 ]
class BruteForceSolution: <|reserved_special_token_0|> class Solution: def smallerNumbersThanCurrent(self, nums): answer = [] sortedNums = sorted(nums) for num in nums: answer.append(sortedNums.index(num)) return answer <|reserved_special_token_0|> <|reserved_s...
flexible
{ "blob_id": "58e023c3c453d1e190fdb5bc457358f42d1bd93f", "index": 397, "step-1": "class BruteForceSolution:\n <mask token>\n\n\nclass Solution:\n\n def smallerNumbersThanCurrent(self, nums):\n answer = []\n sortedNums = sorted(nums)\n for num in nums:\n answer.append(sortedNu...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('loading data...') with open('movienumbers.pickle', 'rb') as input_file: movienumbers = pickle.load(input_file) with open('ratings.pickle', 'rb') as input_file: ratings = pickle.load(input_file) with open('userrating...
flexible
{ "blob_id": "1f69cf5f6d15048e6ead37b5da836c9e2f783f74", "index": 803, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('loading data...')\nwith open('movienumbers.pickle', 'rb') as input_file:\n movienumbers = pickle.load(input_file)\nwith open('ratings.pickle', 'rb') as input_file:\n ratings =...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append('../..') <|reserved_special_token_0|> for epoch in range(60): batch_count = 0 for i in range(len(X)): feature = np.mat(X.values[i]).reshape(img_shape) label = np.mat(one_hot_label[i]).T ...
flexible
{ "blob_id": "63f155f7da958e9b6865007c701f7cf986b0cbac", "index": 7800, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('../..')\n<mask token>\nfor epoch in range(60):\n batch_count = 0\n for i in range(len(X)):\n feature = np.mat(X.values[i]).reshape(img_shape)\n label ...
[ 0, 1, 2, 3, 4 ]
# coding: utf-8 from mrcnn import utils import numpy as np import os import skimage class SlicesDataset(utils.Dataset): """ Extension of maskrcnn dataset class to be used with our provided data. """ def load_slices(self, dataset_dir, n_images, n_patches, channels = ["base"]): """Load a ...
normal
{ "blob_id": "8675deb69eae04a722073432eaf69ce3d24a11ad", "index": 9041, "step-1": "<mask token>\n\n\nclass SlicesDataset(utils.Dataset):\n <mask token>\n <mask token>\n\n def load_image(self, image_id):\n \"\"\"Returns an image with a given id.\"\"\"\n info = self.image_info[image_id]\n ...
[ 2, 4, 5, 6, 7 ]
import sys from PyQt5 import QtWidgets from PyQt5.QtWidgets import QMainWindow, QApplication #---Import that will load the UI file---# from PyQt5.uic import loadUi import detechRs_rc #---THIS IMPORT WILL DISPLAY THE IMAGES STORED IN THE QRC FILE AND _rc.py FILE--# #--CLASS CREATED THAT WILL LOAD THE UI FILE...
normal
{ "blob_id": "a9b1cc9b928b8999450b6c95656b863c476b273b", "index": 7355, "step-1": "<mask token>\n\n\nclass Login(QMainWindow):\n\n def __init__(self):\n super(Login, self).__init__()\n loadUi('login_UI.ui', self)\n self.loginButton.clicked.connect(self.loginFunction)\n\n def loginFuncti...
[ 3, 4, 5, 6, 7 ]
import asyncio import multiprocessing from concurrent.futures import ProcessPoolExecutor from apscheduler.schedulers.asyncio import AsyncIOScheduler from datetime import datetime import time from apscheduler.schedulers.blocking import BlockingScheduler from apscheduler.triggers.combining import OrTrigger from apschedu...
normal
{ "blob_id": "f5a953d91e95d82e84e3e6d18ee89d28ba1b1515", "index": 6022, "step-1": "import asyncio\nimport multiprocessing\nfrom concurrent.futures import ProcessPoolExecutor\nfrom apscheduler.schedulers.asyncio import AsyncIOScheduler\nfrom datetime import datetime\nimport time\n\nfrom apscheduler.schedulers.bloc...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> x += 3 print('x : ', x) print('-' * 30) <|reserved_special_token_0|> total += 1 total <|reserved_special_token_1|> x = 5 x += 3 print('x : ', x) print('-' * 30) total = 0 total += 1 total <|reserved_special_token_1|> # opera...
flexible
{ "blob_id": "4f8bc19bb113c9eac7c2ac774ac7b16f569d9704", "index": 3083, "step-1": "<mask token>\n", "step-2": "<mask token>\nx += 3\nprint('x : ', x)\nprint('-' * 30)\n<mask token>\ntotal += 1\ntotal\n", "step-3": "x = 5\nx += 3\nprint('x : ', x)\nprint('-' * 30)\ntotal = 0\ntotal += 1\ntotal\n", "step-4": ...
[ 0, 1, 2, 3 ]
import numpy as np import faiss from util import vecs_io, vecs_util from time import time import os ''' 提取vecs, 输出numpy文件 ''' def vecs2numpy(fname, new_file_name, file_type, file_len=None): if file_type == 'bvecs': vectors, dim = vecs_io.bvecs_read_mmap(fname) elif file_type == 'ivecs':...
normal
{ "blob_id": "5f84c8654c976bca2fa33e8f9ba5e28e3249253d", "index": 7312, "step-1": "<mask token>\n\n\ndef vecs2numpy(fname, new_file_name, file_type, file_len=None):\n if file_type == 'bvecs':\n vectors, dim = vecs_io.bvecs_read_mmap(fname)\n elif file_type == 'ivecs':\n vectors, dim = vecs_io....
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class StockPagination(PageNumberPagination): page_size = 20 page_size_query_param = 'page_size' max_page_size = 500 class StockView(APIView): def get(self, request, *args, **kwargs): if request.GET.get('ticker'): qs = Stock.objects.filter(ticker=requ...
flexible
{ "blob_id": "34536e3112c8791c8f8d48bb6ffd059c1af38e2f", "index": 8978, "step-1": "<mask token>\n\n\nclass StockPagination(PageNumberPagination):\n page_size = 20\n page_size_query_param = 'page_size'\n max_page_size = 500\n\n\nclass StockView(APIView):\n\n def get(self, request, *args, **kwargs):\n ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def _camel_to_snake(s): """ Convert CamelCase to snake_case. """ return '_'.join([i.lower() for i in _camel_words.split(s)[1::2]]) <|reserved_special_token_1|> <|reserved_special_token_0|> _camel_words = re.compil...
flexible
{ "blob_id": "6c9f9363a95ea7dc97ccb45d0922f0531c5cfec9", "index": 6572, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef _camel_to_snake(s):\n \"\"\" Convert CamelCase to snake_case.\n \"\"\"\n return '_'.join([i.lower() for i in _camel_words.split(s)[1::2]])\n", "step-3": "<mask token>\n...
[ 0, 1, 2, 3, 4 ]
class Solution: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_0|> def backtracing(self, arr, start): if start == len(arr): self.resu...
flexible
{ "blob_id": "632c690261b31c7ac0e1d90c814e3b9a7a0dcb29", "index": 7663, "step-1": "class Solution:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Solution:\n <mask token>\n <mask token>\n\n def backtracing(self, arr, start):\n if start == len(arr):\n self.r...
[ 1, 2, 3, 4, 5 ]
water = 400 milk = 540 coffee = 120 cups = 9 money = 550 def buying(): global water global coffee global cups global milk global money choice_coffee = input("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:") if choice_coffee == "1": ...
normal
{ "blob_id": "4e98ebd040297cb9472368478452bc484e0aaa04", "index": 3255, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef stats_print():\n print('The coffee machine has:')\n print(str(water) + ' of water')\n print(str(milk) + ' of milk')\n print(str(coffee) + ' of coffee beans')\n prin...
[ 0, 2, 6, 7, 8 ]
<|reserved_special_token_0|> def code_pre_block(func): """ formats a code block according to rst format """ @functools.wraps(func) def wrapper(*args, **kwargs): block = func(*args, **kwargs) new_block = '\n.. code-block::\n\n' for line in block.split('\n'): new...
flexible
{ "blob_id": "d1b2420778e788d78be2a12a27c80f5fa1b15a0f", "index": 465, "step-1": "<mask token>\n\n\ndef code_pre_block(func):\n \"\"\"\n formats a code block according to rst format\n \"\"\"\n\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n block = func(*args, **kwargs)\n n...
[ 7, 8, 9, 10, 11 ]
from python_logging.Demo_CustomLogger import CustomLogger CustomLogger.init_log() # CustomLogger.info() log_str = '%s/%s/%s\n' % ("demo1", "demo2", "demo3") CustomLogger.info('[main]', log_str)
normal
{ "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 ]
""" Массив размером 2m + 1, где m — натуральное число, заполнен случайным образом. Найдите в массиве медиану. Медианой называется элемент ряда, делящий его на две равные части: в одной находятся элементы, которые не меньше медианы, в другой — не больше медианы. Примечание: задачу можно решить без сортировки исходного м...
normal
{ "blob_id": "fbcbad9f64c0f9b68e29afde01f3a4fdba012e10", "index": 4868, "step-1": "<mask token>\n\n\ndef heapify(array, size, ind):\n largest = ind\n left = 2 * ind + 1\n right = 2 * ind + 2\n if left < size and array[left] > array[largest]:\n largest = left\n if right < size and array[right...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def china_lunar(): today = str(date.today()) today_list = today.split('-') lunar_day = lunar.getDayBySolar(int(datetime.datetime.now().year), int( datetime.datetime.now().month), int(datetime.datetime.now().day)) if lunar_day.Lleap: china_day = '农历:{0}月{1}'...
flexible
{ "blob_id": "e1d0648825695584d3ea518db961a9178ea0c66a", "index": 50, "step-1": "<mask token>\n\n\ndef china_lunar():\n today = str(date.today())\n today_list = today.split('-')\n lunar_day = lunar.getDayBySolar(int(datetime.datetime.now().year), int(\n datetime.datetime.now().month), int(datetime...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def gridsearchcv(X, y): accuracy = [] stdlist = [] classifier = RandomForestClassifier(verbose=2, n_jobs=1, oob_score=1) param_grid = {'n_estimators': np.arange(1, 100, 10)} grid = GridSearchCV(classifier, param_grid=param_grid) grid.fit(X, y) fig = plt.figure(...
flexible
{ "blob_id": "08f0b261b5a9b0f5133c468b3f92dc00285eda6a", "index": 4477, "step-1": "<mask token>\n\n\ndef gridsearchcv(X, y):\n accuracy = []\n stdlist = []\n classifier = RandomForestClassifier(verbose=2, n_jobs=1, oob_score=1)\n param_grid = {'n_estimators': np.arange(1, 100, 10)}\n grid = GridSea...
[ 1, 2, 3, 4, 5 ]
import numpy as np import math import activations class FC_layer(): def __init__(self, input_size, output_size, weight_init_range, activation, debug): self.type = "FC" self.activation_name = activation self.shape = (input_size, output_size) self.activation = activations.get_activati...
normal
{ "blob_id": "ff99b5fd168d7987e488d7f6d0455619e988f15a", "index": 3574, "step-1": "<mask token>\n\n\nclass conv2D:\n <mask token>\n <mask token>\n\n def forward(self, input_feature_maps):\n output = np.zeros(self.output_shape)\n input_feature_maps = self.apply_zero_padding(input_feature_map...
[ 24, 25, 28, 33, 39 ]
# Python 3.6. Written by Alex Clarke # Breakup a large fits image into smaller ones, with overlap, and save to disk. # Sourecfinding is run on each cutout, and catalogues are sifted to remove duplicates from the overlap. import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import multiprocessing...
normal
{ "blob_id": "a22aa66bd65033750f23f47481ee84449fa80dbc", "index": 8995, "step-1": "# Python 3.6. Written by Alex Clarke\n# Breakup a large fits image into smaller ones, with overlap, and save to disk.\n# Sourecfinding is run on each cutout, and catalogues are sifted to remove duplicates from the overlap.\n\nimpor...
[ 0 ]
import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 'go-', label='line 1', linewidth=2) plt.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25], 'rs--', label='line 2', linewidth=4) plt.axis([0, 6, 0, 26]) plt.legend(loc="upper right") plt.show()
normal
{ "blob_id": "7eeba06e78bd1e7139b1706574c4d040465d4566", "index": 4178, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.plot([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 'go-', label='line 1', linewidth=2)\nplt.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25], 'rs--', label='line 2',\n linewidth=4)\nplt.axis([0, 6, 0, ...
[ 0, 1, 2, 3 ]
import sys def digit_sum(x): sum = 0 while x != 0: sum = sum + x % 10 x = x // 10 return sum for i in sys.stdin: test_num = int(i) if test_num == 0: break count = 11 while digit_sum(test_num) != digit_sum(count * test_num): count = count + 1 print('{}'...
normal
{ "blob_id": "0d37b6f0ea8854f9d4d4cd2ff235fa39bab7cc12", "index": 6549, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef digit_sum(x):\n sum = 0\n while x != 0:\n sum = sum + x % 10\n x = x // 10\n return sum\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef digit_sum(x...
[ 0, 1, 2, 3 ]
import sqlite3 connection = sqlite3.connect('database.db') cursor = connection.cursor() # cursor.execute('CREATE TABLE users (id int, username text, password text)') cursor.execute('INSERT INTO users VALUES(?,?,?)',(1,'ilia','qwerty')) users = [(2,'nika','asdf'),(3,'nino','sdfg')] cursor.executemany('INSERT INTO ...
normal
{ "blob_id": "d6b49533573dfefba6286ac2bffc2bd7a4075063", "index": 1731, "step-1": "<mask token>\n", "step-2": "<mask token>\ncursor.execute('INSERT INTO users VALUES(?,?,?)', (1, 'ilia', 'qwerty'))\n<mask token>\ncursor.executemany('INSERT INTO users VALUES(?,?,?)', users)\nfor row in cursor.execute('SELECT * F...
[ 0, 1, 2, 3, 4 ]
import queue from enum import IntEnum from time import sleep import keyboard # I know, I copy pasted this horrobly written class # again... # and again.. I should really write a proper intcode computer class IntCodeComputer: def __init__(self, code): self.defaultCode = code self.runningCode = self...
normal
{ "blob_id": "6eac04bc10ef712ab4e2cde4730950ddcbe42585", "index": 8983, "step-1": "<mask token>\n\n\nclass IntCodeComputer:\n\n def __init__(self, code):\n self.defaultCode = code\n self.runningCode = self.defaultCode.copy()\n self.instructionPointer = 0\n self.outputQueue = queue.Q...
[ 5, 8, 9, 10, 12 ]
class Handlers(): change_store = "/change_store" change_status = "/change_status" mail = "/mail" get_status = "/get_status" create_order = "/create_order" ask_store = "/ask_store" check = "/check" test = "/test"
normal
{ "blob_id": "32e3eed2e279706bca2925d3d9d897a928243b4c", "index": 4518, "step-1": "<mask token>\n", "step-2": "class Handlers:\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", "step-3": "class Handlers:\n cha...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @pytest.mark.parametrize('n, result', ASSERTIONS) def test_flatten_me(n, result): """Test flatten_me() for proper output in test cases.""" from flatten_me import flatten_me assert flatten_me(n) == result <|reserved...
flexible
{ "blob_id": "c233ce4e14e9a59a9fb0f29589ced947efeb73a9", "index": 3120, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.mark.parametrize('n, result', ASSERTIONS)\ndef test_flatten_me(n, result):\n \"\"\"Test flatten_me() for proper output in test cases.\"\"\"\n from flatten_me import flat...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def rotate_pdf_pages(filename, rotation, output_name): pdf_reader = PdfFileReader('{}.pdf'.format(filename)) pdf_writer = PdfFileWriter() for page in range(pdf_reader.getNumPages()): if rotation == '1': ...
flexible
{ "blob_id": "624027373f53f62ededc40bfc859f28b5a83ca04", "index": 3266, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef rotate_pdf_pages(filename, rotation, output_name):\n pdf_reader = PdfFileReader('{}.pdf'.format(filename))\n pdf_writer = PdfFileWriter()\n for page in range(pdf_reader.g...
[ 0, 1, 2, 3, 4 ]
from django.conf import settings from django.db import migrations, models import django_otp.plugins.otp_totp.models class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( nam...
normal
{ "blob_id": "2e448176a755828e5c7c90e4224102a285098460", "index": 4852, "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 = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(wikipedia.summary(input_)) <|reserved_special_token_1|> <|reserved_special_token_0|> input_ = input('Type in your question ') print(wikipedia.summary(input_)) <|reserved_special_token_1|> import wikipedia input_ = inpu...
flexible
{ "blob_id": "5eb5388ffe7a7c880d8fcfaa137c2c9a133a0636", "index": 713, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(wikipedia.summary(input_))\n", "step-3": "<mask token>\ninput_ = input('Type in your question ')\nprint(wikipedia.summary(input_))\n", "step-4": "import wikipedia\ninput_ = input...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while True: n = input('Right or left? ') if n == 'right': right(60) forward(100) elif n == 'left': left(60) forward(100) <|reserved_special_token_1|> from turtle import * while True: ...
flexible
{ "blob_id": "6f698196e9391d73bd99cda0a098a5bf7a3832ff", "index": 963, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n n = input('Right or left? ')\n if n == 'right':\n right(60)\n forward(100)\n elif n == 'left':\n left(60)\n forward(100)\n", "step-3": ...
[ 0, 1, 2, 3 ]
# Fuck you Disyer. Stealing my fucking paypal. GET FUCKED: toontown.shtiker.CogPageGlobals COG_QUOTAS = ((30, 25, 20, 15, 10, 5, 2, 1), (45, 40, 35, 30, 25, 20, 15, 10)) COG_UNSEEN = 1 COG_BATTLED = 2 COG_DEFEATED = 3 COG_COMPLETE1 = 4 COG_COMPLETE2 = 5
normal
{ "blob_id": "fdb680f12dfb4b29f25cfe4f7af80469dc4294cf", "index": 2437, "step-1": "<mask token>\n", "step-2": "COG_QUOTAS = (30, 25, 20, 15, 10, 5, 2, 1), (45, 40, 35, 30, 25, 20, 15, 10)\nCOG_UNSEEN = 1\nCOG_BATTLED = 2\nCOG_DEFEATED = 3\nCOG_COMPLETE1 = 4\nCOG_COMPLETE2 = 5\n", "step-3": "# Fuck you Disyer....
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class First(BaseGame): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> de...
flexible
{ "blob_id": "81fa3129d971fe8296a89a7b772d61ff50a8b9f7", "index": 9284, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass First(BaseGame):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def has_won(self, draws):\n return dra...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Piece(Source, PageNumbersMixin): """A piece (e.g., essay).""" type = models.CharField(verbose_name=_('piece type'), max_length= TYPE_MAX_LENGTH, choices=PIECE_TYPES, default=PIECE_TYPES[0][0]) def __html__(self) ->str: """Return the piece's citation HTML...
flexible
{ "blob_id": "30c24b9a4738c1952fc5d36a4bc36d8d3576ed3b", "index": 7201, "step-1": "<mask token>\n\n\nclass Piece(Source, PageNumbersMixin):\n \"\"\"A piece (e.g., essay).\"\"\"\n type = models.CharField(verbose_name=_('piece type'), max_length=\n TYPE_MAX_LENGTH, choices=PIECE_TYPES, default=PIECE_TY...
[ 4, 5, 6, 7, 8 ]
import os import random import cv2 import numpy as np from keras.preprocessing.image import img_to_array import numpy as np import keras from scipy import ndimage, misc def preprocess_image(img): img = img.astype(np.uint8) (channel_b, channel_g, channel_r) = cv2.split(img) result = ndimage.maximum_filter(...
normal
{ "blob_id": "586d39556d2922a288a2bef3bcffbc6f9e3dc39d", "index": 6707, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef preprocess_image(img):\n img = img.astype(np.uint8)\n channel_b, channel_g, channel_r = cv2.split(img)\n result = ndimage.maximum_filter(channel_g, size=5)\n ret, resu...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> warnings.filterwarnings('ignore', 'Your application has authenticated using end user credentials') <|reserved_special_token_0|> for exam in exams: print('checking', exam) exam_json = json.dumps(get_exam(exam=exam)) ...
flexible
{ "blob_id": "b74c759b51fb6591477757e2ff54b545f225991c", "index": 7470, "step-1": "<mask token>\n", "step-2": "<mask token>\nwarnings.filterwarnings('ignore',\n 'Your application has authenticated using end user credentials')\n<mask token>\nfor exam in exams:\n print('checking', exam)\n exam_json = jso...
[ 0, 1, 2, 3, 4 ]
import cv2 import numpy as np import time from dronekit import connect, VehicleMode connection_string = "/dev/ttyACM0" baud_rate = 115200 print(">>>> Connecting with the UAV <<<<") vehicle = connect(connection_string, baud=baud_rate, wait_ready=True) vehicle.wait_ready('autopilot_version') print('ready') cap = cv2.V...
normal
{ "blob_id": "8c11463e35fb32949abbb163a89f874040a33ad0", "index": 5415, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('>>>> Connecting with the UAV <<<<')\n<mask token>\nvehicle.wait_ready('autopilot_version')\nprint('ready')\n<mask token>\nif cap.isOpened() == False:\n print('Unable to read cam...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def build_statements_features(df, vectorizer, train=True, tokenizer= tokenizer_nltk): filtered_statements_dic = {} for index, row in df.iterrows(): filtered_statement = [] tokenized_statement = tokenizer(row['statement'].lower().decode( 'utf-8')) ...
flexible
{ "blob_id": "0356b408624988100c10b20facecef14f1552203", "index": 4537, "step-1": "<mask token>\n\n\ndef build_statements_features(df, vectorizer, train=True, tokenizer=\n tokenizer_nltk):\n filtered_statements_dic = {}\n for index, row in df.iterrows():\n filtered_statement = []\n tokenize...
[ 3, 5, 7, 9, 10 ]
<|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": "d0dfea27128ca6966c85da6529ead5c95c86c4cf", "index": 1183, "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 = [('blog', '003...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 import pandas from matplotlib import pyplot as plt from sklearn.tree import DecisionTreeRegressor from sklearn.ensemble import AdaBoostRegressor import numpy as np from sklearn.metrics import mean_absolute_error, mean_squared_error from math import sqrt def main(): df = pandas.read_csv("201...
normal
{ "blob_id": "e35dbcdef8779ffabc34b5e5c543e35b29523971", "index": 7989, "step-1": "<mask token>\n\n\ndef make_scatter(df):\n plt.figure(figsize=(8, 6))\n plt.plot(df['Start station number'], df['Counts'], 'o')\n plt.xlabel('Station')\n plt.ylabel('Counts')\n plt.show()\n return\n\n\ndef train_pr...
[ 3, 4, 5, 6, 7 ]
class User(): def __init__(self, first, last, gender, age): self.first_name = first self.last_name = last self.gender = gender self.age = age self.full_name = self.first_name + " " + self.last_name def describe_user(self): print("The name of the user is " + self....
normal
{ "blob_id": "93b712c60ba4bfa81d967ec59035b6fb7793ce87", "index": 1974, "step-1": "class User:\n <mask token>\n <mask token>\n\n def greet_user(self):\n if self.gender.lower() == 'male':\n print('Greetings, Mr. ' + self.last_name.title() + '!')\n elif self.gender.lower() == 'fema...
[ 2, 3, 4, 6, 7 ]
import torch import torch.nn as nn import torch.nn.init as init import torch.nn.functional as F # add DenseNet structure class Net(nn.Module): def __init__(self): super(Net, self).__init__() # self.x = x self.block0 = nn.Sequential( # input image 96x96 nn.ReLU(), ...
normal
{ "blob_id": "49cdeb59e75ed93122b3a62fbdc508b7d66166d6", "index": 2337, "step-1": "<mask token>\n\n\nclass Net(nn.Module):\n <mask token>\n <mask token>\n\n def _initialize_weights(self):\n pass\n", "step-2": "<mask token>\n\n\nclass Net(nn.Module):\n\n def __init__(self):\n super(Net,...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if len(sys.argv) < 2: raise NameError( 'Please add subject number (ex:1) as 1st argument in the command line!' ) elif len(sys.argv) < 3: raise NameError( 'Please select server being used (ex: aeneas...
flexible
{ "blob_id": "d9156e240d49e0a6570a5bc2315f95a7a670fd4f", "index": 6327, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv) < 2:\n raise NameError(\n 'Please add subject number (ex:1) as 1st argument in the command line!'\n )\nelif len(sys.argv) < 3:\n raise NameError(\n ...
[ 0, 1, 2, 3, 4 ]
''' selection review very similar to quicksort in terms of set up. no need to sort to find kth element in a list but instead can be done in o(n) quick sort can be o(nlogn) if we choose median instead of pivot tips: raise value error for bad index not in between 0 <= k < n basecase of n <=1 --> return arr[0] use L, E, ...
normal
{ "blob_id": "69d3a39dc024929eaf6fb77e38a7a818d2886cf7", "index": 8512, "step-1": "<mask token>\n\n\ndef select(arr, k):\n n = len(arr)\n if not 0 <= k < n:\n raise ValueError('not valid index in array')\n if n <= 1:\n return arr[0]\n pivot = random.choice(arr)\n L, E, G = [], [], []\...
[ 1, 2, 3, 4, 5 ]
"""Command generator for running a script against a BigQuery cluster. Contains the method to compile the BigQuery specific script execution command based on generic arguments (sql script, output destination) and BigQuery specific arguments (flag values). """ __author__ = 'p3rf@google.com' from absl import flags fla...
normal
{ "blob_id": "5e14eeaa3c79bfdd564f3bfd1575c9bbf1a3773d", "index": 7881, "step-1": "<mask token>\n\n\ndef generate_provider_specific_cmd_list(script, driver, output, error):\n \"\"\"Method to compile the BigQuery specific script execution command.\n\n Arguments:\n script: SQL script which contains the query...
[ 1, 2, 3, 4, 5 ]
import io import os import sys import whwn from setuptools import setup, find_packages from setuptools.command.test import test as TestCommand here = os.path.abspath(os.path.dirname(__file__)) with open('README.md') as readme: long_description = readme.read() with open('requirements.txt') as reqs: install_re...
normal
{ "blob_id": "bd2a5c2dd3eef5979c87a488fb584dce740ccb05", "index": 3870, "step-1": "<mask token>\n\n\nclass PyTest(TestCommand):\n\n def finalize_options(self):\n TestCommand.finalize_options(self)\n self.test_args = []\n self.test_suite = True\n\n def run_tests(self):\n import py...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def solution(clothes): answer = 1 hash_map = defaultdict(lambda : 0) for value, key in clothes: hash_map[key] += 1 for v in hash_map.values(): answer *= v + 1 return answer - 1 <|reserved_sp...
flexible
{ "blob_id": "601089c2555e6fc75803087ee1d8af7f8180f651", "index": 4199, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solution(clothes):\n answer = 1\n hash_map = defaultdict(lambda : 0)\n for value, key in clothes:\n hash_map[key] += 1\n for v in hash_map.values():\n an...
[ 0, 1, 2 ]
<|reserved_special_token_0|> @app.route('/') def index(): return "<h1>Congratulations, it's a web app!</h1>" <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.route('/') def index(): return "<h1>Congratulations, it's a web app!</h1>" if __name__ == '__main__'...
flexible
{ "blob_id": "612535d95e655f2e2d2c58f41b2aa99afa7fbcbc", "index": 874, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return \"<h1>Congratulations, it's a web app!</h1>\"\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef index():\n return \"<h1>Congratulations, it's a w...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Session: <|reserved_special_token_0|> class APIStatisticsCollection: API_ACTION = 'x-stats-api-action' DICT_PARAMS = 'x-stats-param-dict' DICT_RESPONSE = 'x-stats-resp-dict' SUCCESS = 'x-stats-success' COLLECT = 'x-stats-collect' c...
flexible
{ "blob_id": "d0e5a3a6db0e27ecf157294850a48a19750a5ac2", "index": 1667, "step-1": "<mask token>\n\n\nclass Session:\n <mask token>\n\n\n class APIStatisticsCollection:\n API_ACTION = 'x-stats-api-action'\n DICT_PARAMS = 'x-stats-param-dict'\n DICT_RESPONSE = 'x-stats-resp-dict'\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "e72962b644fab148741eb1c528d48ada45a43e51", "index": 3978, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class TestEosLacpInterfacesModule(TestEosModule): <|reserved_special_token_0|> def setUp(self): super(TestEosLacpInterfacesModule, self).setUp() self.mock_get_config = patch( 'ansible_collections.ansible.netcommon.plugins.module_utils.network.common.ne...
flexible
{ "blob_id": "6efe3975f4d5d9f431391b3560c37a3e89e27f3d", "index": 9172, "step-1": "<mask token>\n\n\nclass TestEosLacpInterfacesModule(TestEosModule):\n <mask token>\n\n def setUp(self):\n super(TestEosLacpInterfacesModule, self).setUp()\n self.mock_get_config = patch(\n 'ansible_co...
[ 4, 8, 11, 15, 16 ]
#!/usr/bin/env python import sys import struct import Queue import logging import redis logging.getLogger("scapy.runtime").setLevel(logging.ERROR) from threading import Thread from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr from scapy.all import Packet, IPOption from scapy.all import PacketList...
normal
{ "blob_id": "e4ecc1746e907f11936683384e1edb34dd637de7", "index": 8171, "step-1": "#!/usr/bin/env python\nimport sys\nimport struct\nimport Queue\nimport logging\nimport redis\nlogging.getLogger(\"scapy.runtime\").setLevel(logging.ERROR)\n\nfrom threading import Thread\nfrom scapy.all import sniff, sendp, hexdump...
[ 0 ]
# Copyright (c) "Neo4j" # Neo4j Sweden AB [https://neo4j.com] # # This file is part of Neo4j. # # 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 # # https://www.apache.org/licenses/LICENSE-2...
normal
{ "blob_id": "5b33615e1890631bac68801310e4b606ac41cb13", "index": 1340, "step-1": "<mask token>\n\n\nclass TestTimeDehydration(_TestTemporalDehydrationV1):\n\n @pytest.fixture\n def hydration_handler(self):\n return HydrationHandler()\n <mask token>\n <mask token>\n\n def test_pandas_date_ti...
[ 6, 7, 8, 11, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TextPageContentModelTest(TestCase): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TextPageContentModelTest(TestCase): def test_instance(self): file = Ima...
flexible
{ "blob_id": "5287bd1847848aa527df8ce57e896bc30c70b43c", "index": 4432, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TextPageContentModelTest(TestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TextPageContentModelTest(TestCase):\n\n def test_instance(self):\n file ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def test(): webbrowser.open_new_tab('Test.html') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> ventana.geometry('1920x1080') def test(): webbrowser.open_new_tab('Test.html') <|reserved_special_token_0|> boton1.grid(row=3, column=0)...
flexible
{ "blob_id": "8bf330dc7bee65ac9478722233477ebe5d0286c2", "index": 1102, "step-1": "<mask token>\n\n\ndef test():\n webbrowser.open_new_tab('Test.html')\n\n\n<mask token>\n", "step-2": "<mask token>\nventana.geometry('1920x1080')\n\n\ndef test():\n webbrowser.open_new_tab('Test.html')\n\n\n<mask token>\nbo...
[ 1, 2, 3, 4, 5 ]
"""Utilities for AnalysisModules.""" import inspect from mongoengine import QuerySet from numpy import percentile from .modules import AnalysisModule def get_primary_module(package): """Extract AnalysisModule primary module from package.""" def test_submodule(submodule): """Test a submodule to see ...
normal
{ "blob_id": "3472dc0c9d00c10ab0690c052e70fbf6a4bdb13d", "index": 7889, "step-1": "<mask token>\n\n\ndef boxplot(values):\n \"\"\"Calculate percentiles needed for a boxplot.\"\"\"\n percentiles = percentile(values, [0, 25, 50, 75, 100])\n result = {'min_val': percentiles[0], 'q1_val': percentiles[1],\n ...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def main(): subs = subdir_maker(os.path.dirname(os.path.realpath(__file__))) for i in range(len(subs)): daily_github_upload(subs[i]) print('_' * 40 + '\n\n' + 'Uploaded {0} to Github. '.format(i) + '\n' + '_' * 40) time.sleep(86400) <|reserved...
flexible
{ "blob_id": "bcc3d4e9be0de575c97bb3bf11eeb379ab5be458", "index": 5380, "step-1": "<mask token>\n\n\ndef main():\n subs = subdir_maker(os.path.dirname(os.path.realpath(__file__)))\n for i in range(len(subs)):\n daily_github_upload(subs[i])\n print('_' * 40 + '\\n\\n' + 'Uploaded {0} to Github....
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def partial_correlation_loop(solver, x, y, ensemble=None): e_hat = np.zeros(y.shape[1]) for i in range(y.shape[1]): y_i = y[:, i].reshape(-1, 1) y_not_i = np.delete(y, i, axis=1) r = partial_correlation_bagging(solver, x, y_i, y_not_i, ensemble) e_h...
flexible
{ "blob_id": "dfd2b515e08f285345c750bf00f6a55f43d60039", "index": 8379, "step-1": "<mask token>\n\n\ndef partial_correlation_loop(solver, x, y, ensemble=None):\n e_hat = np.zeros(y.shape[1])\n for i in range(y.shape[1]):\n y_i = y[:, i].reshape(-1, 1)\n y_not_i = np.delete(y, i, axis=1)\n ...
[ 4, 5, 6, 7, 9 ]
<|reserved_special_token_0|> def workingDate(start, end): cal = UnitedKingdom() res = [] delta = end - start for i in range(delta.days + 1): day = start + timedelta(days=i) if cal.is_working_day(day) or day.weekday() < 5: res.append(day) else: pass r...
flexible
{ "blob_id": "feed412278d9e711e49ef209ece0876c1de4a873", "index": 886, "step-1": "<mask token>\n\n\ndef workingDate(start, end):\n cal = UnitedKingdom()\n res = []\n delta = end - start\n for i in range(delta.days + 1):\n day = start + timedelta(days=i)\n if cal.is_working_day(day) or da...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # Copyright (c) 2018-2020 Christiaan Frans Rademan <chris@fwiw.co.za>. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the ...
normal
{ "blob_id": "cdbf9427d48f0a5c53b6efe0de7dfea65a8afd83", "index": 87, "step-1": "<mask token>\n\n\ndef request_id():\n global req_c, pid\n if req_c is None:\n req_c = random.randint(1000 * 1000, 1000 * 1000 * 1000)\n if pid is None:\n pid = str(os.getpid())\n req_id = req_c = req_c + 1\n...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 # # compare-sorts.py # Copyright (c) 2017 Dylan Brown. All rights reserved. # # Use Python 3. Run from within the scripts/ directory. import os import sys import re import subprocess # Ensure we don't silently fail by running Python 2. assert sys.version_info[0] >= 3, "This script requires P...
normal
{ "blob_id": "501d50fa933f55c178b4b2eba6cfc5b85592beaa", "index": 8473, "step-1": "<mask token>\n\n\ndef main():\n sorts = ['selection-sort', 'insertion-sort', 'shell-sort']\n for sort in sorts:\n exe_path = './build/{}'.format(sort.rstrip())\n if not os.path.isfile(exe_path):\n rai...
[ 1, 2, 3, 4, 5 ]
import numpy as np from math import ceil, log2 def avg(list): return np.mean(list) def dispersion(list): res = 0 for i in list: res += (i - np.mean(list)) ** 2 return res / len(list) def variation_coefficient(list): return (dispersion(list) ** (1/2) / np.mean(list)) * 100 def chi_squ...
normal
{ "blob_id": "f2b978b9a4c00469cdd2f5e1e9275df73c7379b8", "index": 3904, "step-1": "<mask token>\n\n\ndef dispersion(list):\n res = 0\n for i in list:\n res += (i - np.mean(list)) ** 2\n return res / len(list)\n\n\n<mask token>\n\n\ndef chi_square(list):\n b = sorted(list)\n k = ceil(log2(len...
[ 2, 3, 4, 5, 6 ]
# Generated by Django 3.1.6 on 2021-04-03 20:16 import django.contrib.postgres.fields from django.db import migrations, models import enrolments.validators class Migration(migrations.Migration): dependencies = [ ("enrolments", "0007_merge_20210320_1853"), ] operations = [ migrations.Add...
normal
{ "blob_id": "dbea2b1555368460b7d14369d2dfe4f0a01f9e4f", "index": 8423, "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 = [('enrolments'...
[ 0, 1, 2, 3, 4 ]
g#https://www.acmicpc.net/problem/9461 ''' 1. Divide 2 case △ and ▽ d[0] is △ sequence d[1] is ▽ sequence 2. find a role between d[0] and d[1] ''' import math t = int(input()) n = [] for _ in range(t): n.append(int(input())) index = math.ceil(max(n)/2) d = [[0 for _ in range(52)] for _ in range(2)] d[0][1],d[0][2],...
normal
{ "blob_id": "524b6ebd0be4c2285fac540627bb48baca71452e", "index": 2989, "step-1": "<mask token>\n", "step-2": "g\n<mask token>\nfor _ in range(t):\n n.append(int(input()))\n<mask token>\nfor i in range(3, index + 1):\n d[0][i] = d[1][i - 1] + d[1][i - 3]\n d[1][i] = d[0][i] + d[0][i - 2]\nfor k in n:\n...
[ 0, 1, 2, 3, 4 ]
# name: Ali # date: 7/12/2016 # description: uses openweathermap.org's api to get weather data about # the city that is inputted # unbreakable? = idk import json import urllib2 from collections import OrderedDict from pprint import pprint api_key = "&APPID=507e30d896f751513350c41899382d89" city_name_url = "http://api....
normal
{ "blob_id": "94540561ba29d2fc1766dac7b199e0cbbbeecdfc", "index": 8046, "step-1": "# name: Ali\n# date: 7/12/2016\n# description: uses openweathermap.org's api to get weather data about\n# the city that is inputted\n\n# unbreakable? = idk\nimport json\nimport urllib2\nfrom collections import OrderedDict\nfrom ppr...
[ 0 ]
#from __future__ import absolute_import #import os from celery import Celery #from django.conf import settings #os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'learning.settings') app = Celery('tasks', broker="redis://localhost") #app.config_from_object('django.conf:settings') #app.autodiscover_tasks(lambda: setti...
normal
{ "blob_id": "3ef114dd35ef3995ae73bf85bbe38db4fb7045d8", "index": 7315, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.task\ndef add(x, y):\n return x + y\n", "step-3": "<mask token>\napp = Celery('tasks', broker='redis://localhost')\n\n\n@app.task\ndef add(x, y):\n return x + y\n", "st...
[ 0, 1, 2, 3, 4 ]
import cgi from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.ext import db from models.nutrient import * class SoilRecord(db.Model): year=db.DateProperty(auto_now_add=True) stats=NutrientProfile() amendmen...
normal
{ "blob_id": "01a6283d2331590082cdf1d409ecdb6f93459882", "index": 4861, "step-1": "<mask token>\n\n\nclass CropRecord(db.Model):\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 CropRecord(db.Model):\n year = db...
[ 1, 5, 9, 10, 11 ]
#https://www.hackerrank.com/challenges/caesar-cipher-1/problem n=int(input()) stringy=input() k=int(input()) s="" for i in stringy: if ord(i)>=65 and ord(i)<=90: temp=(ord(i)+k-65)%26 s+=chr(temp+65) elif ord(i)>=97 and ord(i)<=122: temp=(ord(i)+k-97)%26 s+=chr(temp+97) else...
normal
{ "blob_id": "acf787885834961a71fb2655b9d8a1eb026942c7", "index": 4089, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in stringy:\n if ord(i) >= 65 and ord(i) <= 90:\n temp = (ord(i) + k - 65) % 26\n s += chr(temp + 65)\n elif ord(i) >= 97 and ord(i) <= 122:\n temp = (ord...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import json import requests from requests.auth import HTTPBasicAuth if __name__ == "__main__": auth = HTTPBasicAuth('cisco', 'cisco') headers = { 'Accept': 'application/json', 'Content-Type': 'application/json' } url = "https://asav/api/interfaces/physical/Gigab...
normal
{ "blob_id": "6801d68ebcc6ff52d9be92efeeb8727997a14bbd", "index": 523, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n auth = HTTPBasicAuth('cisco', 'cisco')\n headers = {'Accept': 'application/json', 'Content-Type': 'application/json'\n }\n url = 'https://asav/...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> TABLE_NAME = 'active_module'
flexible
{ "blob_id": "ff3962d875da8e3f9e6c3178b1a8191ebb8a7b60", "index": 3639, "step-1": "<mask token>\n", "step-2": "TABLE_NAME = 'active_module'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
import json import argparse import sys import os if __name__ == '__main__': ap = argparse.ArgumentParser() ap.add_argument("-sd","--startdate", help="Date to start scheduling trials, format is MM/DD.", required=True) ap.add_argument("-r", "--round",help="A number.", required=True) ap.add_argument("-hs...
normal
{ "blob_id": "e4767d8a4991a1180cc185c4c2d77104d63f9c7a", "index": 6858, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n ap = argparse.ArgumentParser()\n ap.add_argument('-sd', '--startdate', help=\n 'Date to start scheduling trials, format is MM/DD.', required=True...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Link(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Link(models.Model): <|reserved...
flexible
{ "blob_id": "61a58b934c6663e87824e4f9f9ffd92c3236947c", "index": 7930, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Link(models.Model):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Link(models.Model):\n <mask token>\n <mask token>\n\n ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from setuptools import setup, find_packages config = { 'name': 'beziers', 'author': 'Simon Cozens', 'author_email': 'simon@simon-cozens.org', 'url': 'https://github.com/simoncozens/beziers.py', 'description': 'Bezier curve manipulation library', 'lo...
normal
{ "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|> def emphasize(sentence): words = sentence.split(' ') for i, word in enumerate(words): words[i] = word[0].upper() + word[1:].lower() return ' '.join(words) <|reserved_special_token_0|> <|reserved_special_token_1|> def emphasize(sentenc...
flexible
{ "blob_id": "518dcdca8f5e6b42624083e4327143dfba59b2ba", "index": 9785, "step-1": "<mask token>\n", "step-2": "def emphasize(sentence):\n words = sentence.split(' ')\n for i, word in enumerate(words):\n words[i] = word[0].upper() + word[1:].lower()\n return ' '.join(words)\n\n\n<mask token>\n", ...
[ 0, 1, 2, 3, 4 ]
import torch import argparse from DialogGenerator import DialogGenerator from DialogDataset import DialogDataset from DialogDiscriminator import DialogDiscriminator from transformers import GPT2Tokenizer import os def prep_folder(args): """ Append to slash to filepath if needed, and generate folder if it doesn't e...
normal
{ "blob_id": "18be97061c65185fcebf10c628e0e51bb08522cf", "index": 3609, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef prep_folder(args):\n \"\"\" Append to slash to filepath if needed, and generate folder if it doesn't exist\"\"\"\n if args.save_folder[-1] != '/':\n args.save_folder ...
[ 0, 1, 2, 3, 4 ]
""" sed_thermal.py Author: Joshua Lande <joshualande@gmail.com> """ import numpy as np from scipy import integrate from . sed_integrate import logsimps from . sed_spectrum import Spectrum from . import sed_config from . import units as u class ThermalSpectrum(Spectrum): vectorized = True def __init__(s...
normal
{ "blob_id": "8560c0068eff894e5aa1d0788bd9e5ad05c14997", "index": 2262, "step-1": "<mask token>\n\n\nclass ThermalSpectrum(Spectrum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def units_string():\n return '1/erg/cm^3'\n\n def integrate(self, units=...
[ 9, 12, 13, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_word_score(word_1, n_1): """string""" sum_1 = 0 dictionary_ = {'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, '...
flexible
{ "blob_id": "325708d5e8b71bad4806b59f3f86a737c1baef8d", "index": 3976, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_word_score(word_1, n_1):\n \"\"\"string\"\"\"\n sum_1 = 0\n dictionary_ = {'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2,\n 'h': 4, 'i': 1, 'j': 8, 'k...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Bookings(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Airlines(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "e57b30a7a1cf987918abfb3cb7d612bdead2ddcd", "index": 406, "step-1": "<mask token>\n\n\nclass Bookings(models.Model):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Airlines(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask ...
[ 1, 6, 7, 9, 10 ]
Relevance Thus, designing an automatic MWP solver, with semantic understanding and inference capability, has been considered as a crucial step towards general AI. Solving a math problem manually involves too many steps. So MWP will reduc Attachment final.pdf added.Conversation opened. 1 read message. Skip ...
normal
{ "blob_id": "eb6a4170e5427f10eda4d650996c2cbd8a34ca21", "index": 2667, "step-1": "Relevance\r\n\r\nThus, designing an automatic MWP solver, with semantic understanding and\r\n inference capability, has been considered as a crucial step towards general AI. \r\n Solving a math problem manually involves too many s...
[ 0 ]
<|reserved_special_token_0|> class Model: <|reserved_special_token_0|> <|reserved_special_token_0|> @property def form(self): """Contains the data send from the client.""" return security.get_field_storage() @property def cookie(self): """The client cookie""" ...
flexible
{ "blob_id": "7f21ab8d332d169226ef17276abbdd373e3a62c2", "index": 8544, "step-1": "<mask token>\n\n\nclass Model:\n <mask token>\n <mask token>\n\n @property\n def form(self):\n \"\"\"Contains the data send from the client.\"\"\"\n return security.get_field_storage()\n\n @property\n ...
[ 7, 8, 9, 10, 11 ]
<|reserved_special_token_0|> class Datafunction(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": "7611a57705939ce456e34d5ae379d6ca748b13c3", "index": 1884, "step-1": "<mask token>\n\n\nclass Datafunction(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\n ...
[ 3, 11, 12, 16, 18 ]
from flask import Flask from flask_bcrypt import Bcrypt from flask_jwt_extended import JWTManager from flask_migrate import Migrate from flask_restful import Api from flask_apispec.extension import FlaskApiSpec from server.admin import add_admin from server.config import Config from server.db import db from server.cli ...
normal
{ "blob_id": "f1d813ccaf49c8941bf594e22d8683c0ab422a22", "index": 7632, "step-1": "<mask token>\n\n\n@jwt.user_lookup_loader\ndef user_loader_callback(_jwt_header, jwt_data):\n return user_service.first(id=jwt_data['sub'])\n\n\n@jwt.user_identity_loader\ndef user_identity_lookup(email):\n return user_servic...
[ 4, 5, 6, 7 ]
i = 0 while i < 10: print("Hello", 2 * i + 5) i = i + 1
normal
{ "blob_id": "e22574b5c458c23c48915274656f95a375cdc0e6", "index": 6181, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile i < 10:\n print('Hello', 2 * i + 5)\n<mask token>\n", "step-3": "i = 0\nwhile i < 10:\n print('Hello', 2 * i + 5)\ni = i + 1\n", "step-4": "\r\ni = 0\r\nwhile i < 10:\r\n ...
[ 0, 1, 2, 3 ]
def coroutine(func): def start_coroutine(*args, **kwargs): cr = func(*args, **kwargs) next(cr) return cr return start_coroutine <|reserved_special_token_0|> <|reserved_special_token_1|> def coroutine(func): def start_coroutine(*args, **kwargs): cr = func(*args, **kwarg...
flexible
{ "blob_id": "bebe098c5abb579eb155a1dc325347d100ddfa8f", "index": 1805, "step-1": "def coroutine(func):\n\n def start_coroutine(*args, **kwargs):\n cr = func(*args, **kwargs)\n next(cr)\n return cr\n return start_coroutine\n\n\n<mask token>\n", "step-2": "def coroutine(func):\n\n d...
[ 1, 2, 3, 4, 6 ]