code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> def euler(): h = 0.1 x = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] y_eval = [0.0] delta_y = [0.0] y_real = [0.0] eps = [0.0] for i in range(1, len(x)): y_eval.append(y_eval[i - 1] + h * fun(x[i - 1], y_eval[i - 1])) delta_y.append(h * fun(y_eval[i], x[i]))...
flexible
{ "blob_id": "20f0480ee7e0782b23ec8ade150cdd8d8ad718bb", "index": 783, "step-1": "<mask token>\n\n\ndef euler():\n h = 0.1\n x = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]\n y_eval = [0.0]\n delta_y = [0.0]\n y_real = [0.0]\n eps = [0.0]\n for i in range(1, len(x)):\n y_eval.append(y_eval[i - 1] +...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(set(fruits)) print(fruits.count('orange')) <|reserved_special_token_1|> fruits = ['orange', 'apple', 'mango', 'grapes', 'banana', 'apple', 'litchi'] print(set(fruits)) print(fruits.count('orange')) <|reserved_special_to...
flexible
{ "blob_id": "158b39a64d725bdbfc78acc346ed8335613ae099", "index": 8367, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(set(fruits))\nprint(fruits.count('orange'))\n", "step-3": "fruits = ['orange', 'apple', 'mango', 'grapes', 'banana', 'apple', 'litchi']\nprint(set(fruits))\nprint(fruits.count('or...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': log.initialize_logs() run_server() <|reserved_special_token_1|> from warehouse.server import run_server from warehouse.server.config import log if __name__ == '__main__': log.initialize_lo...
flexible
{ "blob_id": "8c8b5c1ff749a8563788b8d5be5332e273275be3", "index": 6450, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n log.initialize_logs()\n run_server()\n", "step-3": "from warehouse.server import run_server\nfrom warehouse.server.config import log\nif __name__ == '...
[ 0, 1, 2, 3 ]
import pandas as pd import subprocess import statsmodels.api as sm import numpy as np import math ''' This function prcesses the gene file Output is a one-row file for a gene Each individual is in a column Input file must have rowname gene: gene ENSG ID of interest start_col: column number which the gene exp value st...
normal
{ "blob_id": "2f64aac7032ac099870269659a84b8c7c38b2bf0", "index": 8385, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lm_res(snps, gene, cov):\n res = pd.DataFrame(np.zeros([snps.shape[0], 2], dtype=np.float32))\n res.index = snps.index\n res.columns = ['beta', 'pval']\n for i in rang...
[ 0, 1, 2, 3, 4 ]
import matplotlib import matplotlib.pyplot as plt from matplotlib.transforms import Bbox from matplotlib.path import Path import json def cLineGraph(j_file): data = [] with open(j_file) as f: for line in f: data.append(json.loads(line)) data = data[0] in_other = 0 in_picture =...
normal
{ "blob_id": "319af5232c043d77a9d63ab1efa62d857da6db23", "index": 1508, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef cLineGraph(j_file):\n data = []\n with open(j_file) as f:\n for line in f:\n data.append(json.loads(line))\n data = data[0]\n in_other = 0\n in_pi...
[ 0, 1, 2, 3 ]
""" time: X * Y space: worst case X * Y """ class Solution: def numIslands(self, grid: List[List[str]]) -> int: if not grid: return 0 Y = len(grid) X = len(grid[0]) def dfs(y, x): if y < 0 or x < 0 or y > Y-1 or x > X-1: ...
normal
{ "blob_id": "58bd14d240242ed58dcff35fe91cebeae4899478", "index": 9087, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def numIslands(self, grid: List[List[str]]) ->int:\n if not grid:\...
[ 0, 1, 2, 3, 4 ]
from scheme import * from tests.util import * class TestDateTime(FieldTestCase): def test_instantiation(self): with self.assertRaises(TypeError): DateTime(minimum=True) with self.assertRaises(TypeError): DateTime(maximum=True) def test_processing(self): field ...
normal
{ "blob_id": "92b22ea23ad0cf4e16c7d19d055b7ec152ca433a", "index": 5191, "step-1": "<mask token>\n\n\nclass TestDateTime(FieldTestCase):\n <mask token>\n <mask token>\n\n def test_utc_processing(self):\n field = DateTime(utc=True)\n self.assert_processed(field, None)\n self.assert_not...
[ 3, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def most_expensive_item(products): return max(products.items(), key=lambda p: p[1])[0]
flexible
{ "blob_id": "f1e335d0187aeb78d857bc523eb33221fd2e7e6d", "index": 7148, "step-1": "<mask token>\n", "step-2": "def most_expensive_item(products):\n return max(products.items(), key=lambda p: p[1])[0]\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
''' tk_image_view_url_io.py display an image from a URL using Tkinter, PIL and data_stream tested with Python27 and Python33 by vegaseat 01mar2013 ''' import io # allows for image formats other than gif from PIL import Image, ImageTk try: # Python2 import Tkinter as tk from urllib2 import urlopen except...
normal
{ "blob_id": "7764effac0b95ad8f62b91dd470c1d0e40704a7d", "index": 9705, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n import Tkinter as tk\n from urllib2 import urlopen\nexcept ImportError:\n import tkinter as tk\n from urllib.request import urlopen\n<mask token>\nroot.title(sf)\n<mask...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Solution(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Solution(object): def nextGreaterElement(self, findNums, nums): """ :type findNums: List[int] :type num...
flexible
{ "blob_id": "3abeac4fb80244d2da14e14a6048c09b0c0c1393", "index": 6047, "step-1": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution(object):\n\n def nextGreaterElement(self, findNums, nums):\n \"\"\"\n :type findNums: ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def long_alpha(str1): list1 = [] list2 = '' maxi = 0 j = 0 for i in range(len(str1)): if i == 0: list2 += str1[i] elif ord(str1[i - 1]) <= ord(str1[i]): list2 += str1[i] else: lis...
flexible
{ "blob_id": "e7c18fa99c801fd959c868954f020d8c55babe0d", "index": 7543, "step-1": "<mask token>\n", "step-2": "def long_alpha(str1):\n list1 = []\n list2 = ''\n maxi = 0\n j = 0\n for i in range(len(str1)):\n if i == 0:\n list2 += str1[i]\n elif ord(str1[i - 1]) <= ord(st...
[ 0, 1, 2, 3, 4 ]
naam = raw_input("Wat is je naam?") getal = raw_input("Geef me een getal?") if naam == "Barrie": print "Welkom " * int(getal) else: print "Helaas, tot ziens"
normal
{ "blob_id": "c48d5d9e088acfed0c59e99d3227c25689d205c6", "index": 7848, "step-1": "naam = raw_input(\"Wat is je naam?\")\ngetal = raw_input(\"Geef me een getal?\")\nif naam == \"Barrie\":\n\tprint \"Welkom \" * int(getal)\nelse:\n\tprint \"Helaas, tot ziens\"", "step-2": null, "step-3": null, "step-4": null...
[ 0 ]
import requests import os from bs4 import BeautifulSoup from urllib.parse import urljoin CURRENT_DIR = os.getcwd() DOWNLOAD_DIR = os.path.join(CURRENT_DIR, 'malware_album') os.makedirs(DOWNLOAD_DIR, exist_ok=True) url = 'http://old.vision.ece.ucsb.edu/~lakshman/malware_images/album/' class Extractor(object): "...
normal
{ "blob_id": "a53d7b4c93fa49fb0162138d4a262fe7a5546148", "index": 5215, "step-1": "<mask token>\n\n\nclass Extractor(object):\n \"\"\"docstring for Parser\"\"\"\n\n def __init__(self, html, base_url):\n self.soup = BeautifulSoup(html, 'html5lib')\n self.base_url = base_url\n\n def get_album...
[ 9, 10, 11, 13, 14 ]
# -*- coding: utf-8 -*- import scrapy from scrapy.linkextractors import LinkExtractor from scrapy.spiders import CrawlSpider, Rule class ItemCrawlSpider(CrawlSpider): name = 'auction_crwal' allowed_domains = ['itempage3.auction.co.kr'] def __init__(self, keyword=None, *args, **kwargs): super(Item...
normal
{ "blob_id": "cba12d076ed8cba84501983fda9bdce8312f2618", "index": 6337, "step-1": "<mask token>\n\n\nclass ItemCrawlSpider(CrawlSpider):\n <mask token>\n <mask token>\n\n def __init__(self, keyword=None, *args, **kwargs):\n super(ItemCrawlSpider, self).__init__(*args, **kwargs)\n keyword.re...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def matches(needle, haystack): for straw in haystack: if needle == straw: return True return False def appendSection(section): if len(section) < 2: return if not section[0].endswith('-'): print('warning: section name does not end with ...
flexible
{ "blob_id": "c712875273f988a3aa6dab61f79e99a077823060", "index": 807, "step-1": "<mask token>\n\n\ndef matches(needle, haystack):\n for straw in haystack:\n if needle == straw:\n return True\n return False\n\n\ndef appendSection(section):\n if len(section) < 2:\n return\n if ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def runall(path): print('==========================') """get the current path """ abs_file_path = os.path.abspath(__file__) parent_dir = os.path.dirname(abs_file_path) parent_dir = os.path.dirname(parent_dir)...
flexible
{ "blob_id": "1158ab95ac67d62459284267a8cc9f587daf89b1", "index": 9329, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef runall(path):\n print('==========================')\n \"\"\"get the current path \"\"\"\n abs_file_path = os.path.abspath(__file__)\n parent_dir = os.path.dirname(abs_...
[ 0, 1, 2, 3, 4 ]
from django.shortcuts import render from django.shortcuts import redirect from django.http import HttpResponse from .models import * from django.contrib.auth import logout, authenticate, login from django.contrib.auth.decorators import login_required from django.template.loader import get_template from django.template ...
normal
{ "blob_id": "e982fd5bed540b836fd4e2caaec033d8cbfb0e4f", "index": 9854, "step-1": "<mask token>\n\n\n@csrf_exempt\ndef login_form(request):\n formulario = '<form action=\"login\" method=\"POST\">'\n formulario += 'Nombre<br><input type=\"text\" name=\"Usuario\"><br>'\n formulario += 'Contraseña<br><input...
[ 8, 12, 13, 14, 17 ]
<|reserved_special_token_0|> def is_top_left_occupied(data, i, j): found = False occupied = 0 while i >= 0 and j >= 0 and not found: occupied, found = check_seat(data, i, j) i -= 1 j -= 1 return occupied def is_top_occupied(data, i, j): found = False occupied = 0 ...
flexible
{ "blob_id": "246ec0d6833c9292487cb4d381d2ae82b220677e", "index": 3969, "step-1": "<mask token>\n\n\ndef is_top_left_occupied(data, i, j):\n found = False\n occupied = 0\n while i >= 0 and j >= 0 and not found:\n occupied, found = check_seat(data, i, j)\n i -= 1\n j -= 1\n return ...
[ 5, 10, 11, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def tock(t0, dat=None): if dat is not None: try: _ = dat.block_until_ready() except AttributeError: _ = jnp.array(dat).block_until_ready() return time.perf_counter() - t0 <|reser...
flexible
{ "blob_id": "e58dbb4f67c93abf3564dc0f38df8852313338f0", "index": 5520, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef tock(t0, dat=None):\n if dat is not None:\n try:\n _ = dat.block_until_ready()\n except AttributeError:\n _ = jnp.array(dat).block_until_rea...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if len(links) > 0: for i, l in enumerate(links): article = {'link': l, 'title': titles[i], 'source': mail_ru_link} news.append(article) else: print('Error') <|reserved_special_token_0|> if len(links) > 0: ...
flexible
{ "blob_id": "00d2a29774a4278b1b022571b3f16c88224f08fc", "index": 5207, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(links) > 0:\n for i, l in enumerate(links):\n article = {'link': l, 'title': titles[i], 'source': mail_ru_link}\n news.append(article)\nelse:\n print('Error')\n...
[ 0, 1, 2, 3, 4 ]
# Generic function for updating Weblogic system resources def update_system_resources(clusterName): print "Cluster name is " + clusterName startTransaction() create_JMSSystemResource("/", "DummyJMSModule") delete_JMSModule("/JMSSystemResources", "DummyJMSModule") endTransaction() print "update_s...
normal
{ "blob_id": "99ddc00bf1d0141118748aa98bcc3e7b8a0ff29e", "index": 1503, "step-1": "# Generic function for updating Weblogic system resources\ndef update_system_resources(clusterName):\n print \"Cluster name is \" + clusterName\n startTransaction()\n create_JMSSystemResource(\"/\", \"DummyJMSModule\")\n...
[ 0 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- import enhancedyaml import vector def roots_of_n_poly_eq(n, x, var_upper_bounds=tuple()): '''find the all possible non-negative interger roots of a `n`-term polynomial equals `x`.''' countdown = lambda: xrange(x if not var_upper_bounds else var_upper_bounds[0], -...
normal
{ "blob_id": "c6b80a7dfce501bfe91f818ac7ab45238a0a126b", "index": 3367, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport enhancedyaml\nimport vector\n\ndef roots_of_n_poly_eq(n, x, var_upper_bounds=tuple()):\n '''find the all possible non-negative interger roots of a `n`-term polynomial equa...
[ 0 ]
from StringIO import StringIO import gzip import urllib2 import urllib url="http://api.syosetu.com/novelapi/api/" get={} get["gzip"]=5 get["out"]="json" get["of"]="t-s-w" get["lim"]=500 get["type"]="er" url_values = urllib.urlencode(get) request = urllib2.Request(url+"?"+url_values) response = urllib2.urlopen(reque...
normal
{ "blob_id": "4b622c7f9b5caa7f88367dd1fdb0bb9e4a81477b", "index": 2338, "step-1": "<mask token>\n", "step-2": "<mask token>\nif response.info().get('Content-Type') == 'application/x-gzip':\n buf = StringIO(response.read())\n f = gzip.GzipFile(fileobj=buf)\n data = f.read()\nelse:\n data = response.r...
[ 0, 1, 2, 3, 4 ]
#!/bin/usr/python2.7.x import os, re, urllib2 def main(): ip = raw_input(" Target IP : ") check(ip) def check(ip): try: print "Loading Check File Uploader...." print 58*"-" page = 1 while page <= 21: bing = "http://www.bing.com/search?q=ip%3A" + \ ip + "+upload&count=50&first=" + str(...
normal
{ "blob_id": "21af630bf383ee1bdd0f644283f0ddadde71620a", "index": 236, "step-1": "#!/bin/usr/python2.7.x\r\n\r\nimport os, re, urllib2\r\n\r\ndef main():\r\n\tip = raw_input(\" Target IP : \")\r\n\tcheck(ip)\r\n\r\ndef check(ip):\r\n\ttry:\r\n\t\tprint \"Loading Check File Uploader....\"\r\n\t\tprint 58*\"-\"\r\n...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> with open('Book1.txt', 'r') as file1: with open('20k.txt', 'r') as file2: same = set(file1).intersection(file2) same.discard('\n') with open('notin20kforBook1.txt', 'w') as file_out: for line in same: file_out.write(line) with open('Bo...
flexible
{ "blob_id": "21a41356fcedb36223498db0fe783e4a9e8e1ba6", "index": 210, "step-1": "<mask token>\n", "step-2": "with open('Book1.txt', 'r') as file1:\n with open('20k.txt', 'r') as file2:\n same = set(file1).intersection(file2)\nsame.discard('\\n')\nwith open('notin20kforBook1.txt', 'w') as file_out:\n ...
[ 0, 1, 2 ]
#!/usr/bin/env python x *= 2 """run = 0 while(run < 10): [TAB]x = (first number in sequence) [TAB](your code here) [TAB]run += 1"""
normal
{ "blob_id": "3e84265b7c88fc45bc89868c4339fe37dcc7d738", "index": 1112, "step-1": "<mask token>\n", "step-2": "x *= 2\n<mask token>\n", "step-3": "#!/usr/bin/env python\r\n\r\nx *= 2\r\n\r\n\"\"\"run = 0\r\nwhile(run < 10):\r\n[TAB]x = (first number in sequence)\r\n[TAB](your code here)\r\n[TAB]run += 1\"\"\"...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def test_convert_wrong_char(): txt = convert('@!*', ':icon:', ':nbsp') assert txt == """:icon::icon::icon::nbsp:nbsp:icon::icon::icon::nbsp:nbsp:icon::icon::icon: :nbsp:nbsp:icon::nbsp:nbsp:nbsp:nbsp:icon::nbsp:nbsp:nbsp:nbsp:icon: :nbsp:icon::nbsp:nbsp:nbsp:nbsp:icon::nbsp:nbsp:n...
flexible
{ "blob_id": "c3bfcb971a6b08cdf98200bd2b2a8fe6ac2dd083", "index": 6969, "step-1": "<mask token>\n\n\ndef test_convert_wrong_char():\n txt = convert('@!*', ':icon:', ':nbsp')\n assert txt == \"\"\":icon::icon::icon::nbsp:nbsp:icon::icon::icon::nbsp:nbsp:icon::icon::icon:\n:nbsp:nbsp:icon::nbsp:nbsp:nbsp:nbsp...
[ 1, 2, 3, 4, 5 ]
import math,random,numpy as np def myt(): x=[0]*10 y=[] for i in range(100000): tmp = int(random.random()*10) x[tmp] = x[tmp]+1 tmpy=[0]*10 tmpy[tmp] = 1 for j in range(10): tmpy[j] = tmpy[j] + np.random.laplace(0,2,None) y.append(tmpy) result...
normal
{ "blob_id": "7b7705cdaa8483f6abbc3f4fb3fa1ca506742da8", "index": 6042, "step-1": "import math,random,numpy as np\n\ndef myt():\n x=[0]*10\n y=[]\n for i in range(100000):\n tmp = int(random.random()*10)\n x[tmp] = x[tmp]+1\n tmpy=[0]*10\n tmpy[tmp] = 1\n for j in range...
[ 0 ]
import tensorflow as tf import numpy as np from datetime import datetime import os from CNN import CNN from LSTM import LSTM from BiLSTM import BiLSTM from SLAN import Attention from HAN2 import HierarchicalAttention import sklearn.metrics as metrics import DataProcessor as dp import matplotlib.pyplot as plt import num...
normal
{ "blob_id": "3aff6bdfd7c2ffd57af7bb5d0079a8a428e02331", "index": 1284, "step-1": "<mask token>\n\n\ndef evaluate(sess, data, embds, model, logdir):\n checkpoint_dir = '{}checkpoints'.format(logdir)\n saver = tf.train.Saver()\n sess.run(tf.global_variables_initializer())\n sess.run(model.embedding_ini...
[ 5, 6, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def interseccao_chaves(lis_dic): lista = [] for dic1 in lis_dic[0]: for cahves in dic1: lista.append(dic1) for dic2 in lis_dic[1]: for cahves in dic2: lista.append(dic2) return lista
flexible
{ "blob_id": "f3ff453655d7938cb417ce212f3836fabafaea43", "index": 1696, "step-1": "<mask token>\n", "step-2": "def interseccao_chaves(lis_dic):\n lista = []\n for dic1 in lis_dic[0]:\n for cahves in dic1:\n lista.append(dic1)\n for dic2 in lis_dic[1]:\n for cahves in dic2:\n ...
[ 0, 1 ]
<|reserved_special_token_0|> class Node(object): """ Defines a Node Class for storing characteristics and CPT of each node """ def __init__(self, name): self.parents = [] self.children = [] self.name = name self.cpt = [] self.limit = 3 def addParent(self, ...
flexible
{ "blob_id": "eb4bc008b7e68f8a6e80e837fa970d77a5ed3547", "index": 8218, "step-1": "<mask token>\n\n\nclass Node(object):\n \"\"\"\n Defines a Node Class for storing characteristics and CPT of each node\n \"\"\"\n\n def __init__(self, name):\n self.parents = []\n self.children = []\n ...
[ 12, 13, 15, 17, 20 ]
new_tuple = (11,12,13,14,15,16,17) new_list = ['one' ,12,'three' ,14,'five'] print("Tuple: ",new_tuple) print("List: ", new_list) tuple_2= tuple (new_list) print("Converted tuple from the list : ", tuple_2)
normal
{ "blob_id": "889fdca3f92f218e6d6fd3d02d49483f16a64899", "index": 9117, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Tuple: ', new_tuple)\nprint('List: ', new_list)\n<mask token>\nprint('Converted tuple from the list : ', tuple_2)\n", "step-3": "new_tuple = 11, 12, 13, 14, 15, 16, 17\nnew_list ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def CheckNumber(userInput): """ This function returns True if userInput can be converted to a number and returns False if it cannot. """ try: float(userInput) return True except ValueError: return False def DateInput(message): """ This functio...
flexible
{ "blob_id": "77e985d94d3b47539f046a3a46cb1a197cef86f4", "index": 3409, "step-1": "<mask token>\n\n\ndef CheckNumber(userInput):\n \"\"\" This function returns True if userInput can be converted to a number and\n returns False if it cannot. \"\"\"\n try:\n float(userInput)\n return True\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class BitfinexMMTrader: <|reserved_special_token_0|> def get_fees(self): account_info = self.trade_client.account_info() return float(account_info[0]['maker_fees']) def get_pnl(self): pos = max(self.buy_position, self.sell_position) if pos == ...
flexible
{ "blob_id": "6abfd6c0a644356ae0bc75d62472b5c495118a8e", "index": 4466, "step-1": "<mask token>\n\n\nclass BitfinexMMTrader:\n <mask token>\n\n def get_fees(self):\n account_info = self.trade_client.account_info()\n return float(account_info[0]['maker_fees'])\n\n def get_pnl(self):\n ...
[ 11, 16, 20, 21, 22 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def func(n): return n * 2 def my_map(f, seq): return [f(item) for item in seq] <|reserved_special_token_0|> <|reserved_special_token_1|> def func(n): return n * 2 def my_map(f, seq): return [f(item) for item in seq] def main(): ...
flexible
{ "blob_id": "55acae8129ddaba9a860d5d356e91f40607ac95a", "index": 8614, "step-1": "<mask token>\n", "step-2": "def func(n):\n return n * 2\n\n\ndef my_map(f, seq):\n return [f(item) for item in seq]\n\n\n<mask token>\n", "step-3": "def func(n):\n return n * 2\n\n\ndef my_map(f, seq):\n return [f(i...
[ 0, 2, 3, 4 ]
<|reserved_special_token_0|> def main(): service_account_json = path.join(path.dirname(path.abspath(__file__)), 'service_account.json') credentials = service_account.Credentials.from_service_account_file( service_account_json, scopes=SCOPES) service = build('sheets', 'v4', credentials=cred...
flexible
{ "blob_id": "f9261c1844cc629c91043d1221d0b76f6e22fef6", "index": 6157, "step-1": "<mask token>\n\n\ndef main():\n service_account_json = path.join(path.dirname(path.abspath(__file__)),\n 'service_account.json')\n credentials = service_account.Credentials.from_service_account_file(\n service_a...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def calcLuckyNumber(x): resultSet = set() for i in range(30): for j in range(30): for k in range(30): number = pow(3, i) * pow(5, j) * pow(7, k) if number > 1 and number <= x: res...
flexible
{ "blob_id": "49a9fb43f3651d28d3ffac5e33d10c428afd08fd", "index": 6072, "step-1": "<mask token>\n", "step-2": "def calcLuckyNumber(x):\n resultSet = set()\n for i in range(30):\n for j in range(30):\n for k in range(30):\n number = pow(3, i) * pow(5, j) * pow(7, k)\n ...
[ 0, 1, 2, 3, 4 ]
from django.urls import path, include from .views import StatusAPIView, StateAPIView, LogAPIView urlpatterns = [ path('status/', StatusAPIView.as_view(), name='status'), path('log/', LogAPIView.as_view(), name='log'), path('state/', StateAPIView.as_view(), name='state'), ]
normal
{ "blob_id": "1ae8d78c6581d35cd82194e2565e7a11edda1487", "index": 7265, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('status/', StatusAPIView.as_view(), name='status'),\n path('log/', LogAPIView.as_view(), name='log'), path('state/',\n StateAPIView.as_view(), name='state')]\n",...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import socket import os def http_header_parser(request): headers = {} lines = request.split('\n')[1:] for string in lines: first_pos = string.find(":") headers[string[:first_pos]] = string[first_pos + 2:] return headers def create_response(http_code, http_co...
normal
{ "blob_id": "41350714ce13e3627b9bd56eb934846a99f8e1b3", "index": 7047, "step-1": "# -*- coding: utf-8 -*-\nimport socket\nimport os\n\n\ndef http_header_parser(request):\n headers = {}\n\n lines = request.split('\\n')[1:]\n for string in lines:\n first_pos = string.find(\":\")\n headers[st...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def n_grams(unigramsFile, bigramsFile, parameterization, sentences): words = [] param = [] unigrams = [] bigrams = [] with open(parameterization) as p: data = p.read().split() word = data[0] ...
flexible
{ "blob_id": "87c200796e1fac508a43e899c0ed53878b8c1d88", "index": 5244, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef n_grams(unigramsFile, bigramsFile, parameterization, sentences):\n words = []\n param = []\n unigrams = []\n bigrams = []\n with open(parameterization) as p:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @typ.typ(items=[int]) def gnome_sort(items): """ >>> gnome_sort([]) [] >>> gnome_sort([1]) [1] >>> gnome_sort([2,1]) [1, 2] >>> gnome_sort([1,2]) [1, 2] >>> gnome_sort([1,2,2]) [1, 2, 2] """ i = 0 ...
flexible
{ "blob_id": "70aba6c94b7050113adf7ae48bd4e13aa9a34587", "index": 1023, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@typ.typ(items=[int])\ndef gnome_sort(items):\n \"\"\"\n >>> gnome_sort([])\n []\n >>> gnome_sort([1])\n [1]\n >>> gnome_sort([2,1])\n [1, 2]\n >>> gnome_sort([1,2])\n [1, ...
[ 0, 1, 2 ]
import re class CoordinatesDataParser: def __init__(self): return def get_coords(self, response): html = response.xpath('.//body').extract_first() longitude = re.search(r'-\d+\.\d{5,}', html) longitude = longitude.group() if longitude else None if longitude: ...
normal
{ "blob_id": "7d5f41cfa2d5423c6db2678f1eb8160638b50c02", "index": 1835, "step-1": "<mask token>\n\n\nclass CoordinatesDataParser:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass CoordinatesDataParser:\n\n def __init__(self):\n return\n <mask token>\n", "step-3": "<mask ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Copyright: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def _c_cpp_formater(self): return '/* ' + self.declaration + ' */' for ft in _file_type['c/c++']: _formaters[ft] = ...
flexible
{ "blob_id": "dc05a441c21a67fbb3a1975b3fccb865a32731c8", "index": 4642, "step-1": "<mask token>\n\n\nclass Copyright:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def _c_cpp_formater(self):\n return '/* ' + self.declaration + ' */'\n for ft in _file_type['c/c++']:\n ...
[ 5, 7, 11, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(a) <|reserved_special_token_0|> print('The result is:', a[b]) print(a[8]) print(a[-1]) print(a[0:3]) print(a[0:]) <|reserved_special_token_0|> print(a + b) print(b * 3) print(a[2]) <|reserved_special_token_0|> print(a) print...
flexible
{ "blob_id": "f7d29dd1d990b3e07a7c07a559cf5658b6390e41", "index": 4601, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a)\n<mask token>\nprint('The result is:', a[b])\nprint(a[8])\nprint(a[-1])\nprint(a[0:3])\nprint(a[0:])\n<mask token>\nprint(a + b)\nprint(b * 3)\nprint(a[2])\n<mask token>\nprint(a...
[ 0, 1, 2, 3 ]
import os import requests from pprint import pprint as pp from lxml import html from bs4 import BeautifulSoup from dotenv import load_dotenv import datetime load_dotenv() class PrometeoAPI: def __init__(self, user, pwd): self.base_url = 'https://prometeoapi.com' self.session = requests.Session()...
normal
{ "blob_id": "f3e654a589cc1c16b36203dd358671d0426556e6", "index": 2676, "step-1": "<mask token>\n\n\nclass PrometeoAPI:\n\n def __init__(self, user, pwd):\n self.base_url = 'https://prometeoapi.com'\n self.session = requests.Session()\n self.__user = user\n self.__pwd = pwd\n ...
[ 5, 6, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> name = socket.gethostname() <|reserved_special_token_1|> import socket name = socket.gethostname() <|reserved_special_token_1|> #!/usr/bin/env python import socket name = socket.gethostname()
flexible
{ "blob_id": "79c043fc862e77bea5adc3f1c6bb9a6272f19c75", "index": 78, "step-1": "<mask token>\n", "step-2": "<mask token>\nname = socket.gethostname()\n", "step-3": "import socket\nname = socket.gethostname()\n", "step-4": "#!/usr/bin/env python\n\nimport socket\n\nname = socket.gethostname()\n", "step-5"...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def is_palindrome(n): """ What comes in: An non-negative integer n. What goes out: Returns True if the given integer is a palindrome, that is, if it reads the same backwards and forwards. Returns False ...
flexible
{ "blob_id": "ca6a9656efe439c9e90f2724e38e652a09e46dae", "index": 7686, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef is_palindrome(n):\n \"\"\"\n What comes in: An non-negative integer n.\n What goes out: Returns True if the given integer is a palindrome,\n that is, if it reads t...
[ 0, 5, 9, 10, 11 ]
''' Write the necessary code calculate the volume and surface area of a cylinder with a radius of 3.14 and a height of 5. Print out the result. ''' pi = 3.14159 r = 3.14 h = 5 volume = pi*r**2*h surface_area = 2*pi*r**2+r*h print(volume,surface_area)
normal
{ "blob_id": "d04e69c234f2887f5301e4348b4c4ec2ad3af7a2", "index": 2623, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(volume, surface_area)\n", "step-3": "<mask token>\npi = 3.14159\nr = 3.14\nh = 5\nvolume = pi * r ** 2 * h\nsurface_area = 2 * pi * r ** 2 + r * h\nprint(volume, surface_area)\n",...
[ 0, 1, 2, 3 ]
import matplotlib.pyplot as plt def visualize_data(positive_images, negative_images): # INPUTS # positive_images - Images where the label = 1 (True) # negative_images - Images where the label = 0 (False) figure = plt.figure() count = 0 for i in range(positive_images.shape[0]): ...
normal
{ "blob_id": "ebe79cf1b54870055ce8502430f5fae833f3d96d", "index": 3121, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef visualize_data(positive_images, negative_images):\n figure = plt.figure()\n count = 0\n for i in range(positive_images.shape[0]):\n count += 1\n figure.add_...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class UserProfile(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> def __unicode__(self): return '%s : %s' % (self.user, self.tiers) @property def list_name(self): t = EntiteClass.objects.get(id=self.tiers) u = User.obj...
flexible
{ "blob_id": "a094207b2cd9a5a4bd409ac8a644268f3808e346", "index": 7023, "step-1": "<mask token>\n\n\nclass UserProfile(models.Model):\n <mask token>\n <mask token>\n\n def __unicode__(self):\n return '%s : %s' % (self.user, self.tiers)\n\n @property\n def list_name(self):\n t = Entite...
[ 3, 4, 6, 9, 10 ]
<|reserved_special_token_0|> class Studies(db.Model): <|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": "06b07045fcfafd174bb78ff5c3a36bed11e36e54", "index": 9616, "step-1": "<mask token>\n\n\nclass Studies(db.Model):\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 d...
[ 42, 44, 53, 54, 60 ]
<|reserved_special_token_0|> class NConv2d(_ConvNd): <|reserved_special_token_0|> <|reserved_special_token_0|> def init_parameters(self): if self.init_method == 'x': torch.nn.init.xavier_uniform_(self.weight) elif self.init_method == 'k': torch.nn.init.kaiming_unif...
flexible
{ "blob_id": "64b4deaad548a38ba646423d33fc6a985483a042", "index": 3592, "step-1": "<mask token>\n\n\nclass NConv2d(_ConvNd):\n <mask token>\n <mask token>\n\n def init_parameters(self):\n if self.init_method == 'x':\n torch.nn.init.xavier_uniform_(self.weight)\n elif self.init_me...
[ 15, 17, 18, 19, 21 ]
disk = bytearray (1024*1024); def config_complete(): pass def open(readonly): return 1 def get_size(h): global disk return len (disk) def can_write(h): return True def can_flush(h): return True def is_rotational(h): return False def can_trim(h): return True def pread(h, count, of...
normal
{ "blob_id": "2e3c1bf0a4c88bda35a48008cace8c21e071384e", "index": 8378, "step-1": "<mask token>\n\n\ndef config_complete():\n pass\n\n\n<mask token>\n\n\ndef get_size(h):\n global disk\n return len(disk)\n\n\n<mask token>\n\n\ndef is_rotational(h):\n return False\n\n\ndef can_trim(h):\n return True...
[ 7, 8, 11, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('', views.index, name='index'), path('login', views. login_view, name='login'), path('logout', views.logout_view, name= 'logout'), path('menu', views.menu, name='menu'), path('add_item', views.add_i...
flexible
{ "blob_id": "9be6940fc6f405db652d478f9a74fcf56d8a0ad7", "index": 3470, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.index, name='index'), path('login', views.\n login_view, name='login'), path('logout', views.logout_view, name=\n 'logout'), path('menu', views.menu, n...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def make_noises(bs): return mx.nd.random_normal(0, 1, shape=(bs, 512), ctx=CTX, dtype='float32' ).reshape((bs, 512, 1, 1)) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> mx.random.seed(5) logger.basicConfig(level=logger.INFO, filena...
flexible
{ "blob_id": "c14d76493cd3dacc55c993f588dec555b7a4a13c", "index": 4192, "step-1": "<mask token>\n\n\ndef make_noises(bs):\n return mx.nd.random_normal(0, 1, shape=(bs, 512), ctx=CTX, dtype='float32'\n ).reshape((bs, 512, 1, 1))\n\n\n<mask token>\n", "step-2": "<mask token>\nmx.random.seed(5)\nlogger.b...
[ 1, 3, 4, 5, 6 ]
''' A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Given two integers A and B, print the number of primes between them, inclusively. ''' a = int(input()) b = int(input()) count = 0 for i in range(a, b+1): true_prime = True for num in range(2, i): ...
normal
{ "blob_id": "ed4c97913a9dba5cf6be56050a8d2ce24dbd6033", "index": 1870, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(a, b + 1):\n true_prime = True\n for num in range(2, i):\n if i % num == 0:\n true_prime = False\n if true_prime:\n count += 1\nprint(coun...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> ok_(is_inf_rigid(fw_2d, 2)) ok_(not is_inf_rigid(fw_3d, 3)) ok_(is_inf_rigid(fw_1d, 1)) <|reserved_special_token_0|> print(len(rand_fw.nodes)) draw_framework(rand_fw) <|reserved_special_token_0|> print(R) print(f) print(R.dot(f)) ...
flexible
{ "blob_id": "4e31619efcaf6eeab3b32116b21e71de8202aee2", "index": 8646, "step-1": "<mask token>\n", "step-2": "<mask token>\nok_(is_inf_rigid(fw_2d, 2))\nok_(not is_inf_rigid(fw_3d, 3))\nok_(is_inf_rigid(fw_1d, 1))\n<mask token>\nprint(len(rand_fw.nodes))\ndraw_framework(rand_fw)\n<mask token>\nprint(R)\nprint(...
[ 0, 1, 2, 3, 4 ]
# Copyright 2019 PerfKitBenchmarker Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
normal
{ "blob_id": "9cebce7f97a1848885883692cd0f494cce6bae7f", "index": 5263, "step-1": "<mask token>\n\n\nclass RedshiftClusterSubnetGroup(resource.BaseResource):\n <mask token>\n\n def __init__(self, cmd_prefix):\n super(RedshiftClusterSubnetGroup, self).__init__(user_managed=False)\n self.cmd_pre...
[ 4, 5, 6, 7, 8 ]
from .. import dataclass # trigger the register in the dataclass package
normal
{ "blob_id": "681750dbf489a6a32e9ef1d6f64d493cc252b272", "index": 6386, "step-1": "<mask token>\n", "step-2": "from .. import dataclass\n", "step-3": "from .. import dataclass # trigger the register in the dataclass package\r\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
forbidden = ['Key.esc', 'Key.cmd', 'Key.cmd_r', 'Key.menu', 'Key.pause', 'Key.scroll_lock', 'Key.print_screen', 'Key.enter', 'Key.space', 'Key.backspace', 'Key.ctrl_l', 'Key.ctrl_r', 'Key.alt_l', 'Key.alt_gr', 'Key.caps_lock', 'Key.num_lock', 'Key.tab', 'Key.shift', 'Key.shift_r', 'Key.insert', 'Key.del...
normal
{ "blob_id": "995dc34ea32de4566e2804b6797d9b551b733ff3", "index": 3406, "step-1": "<mask token>\n", "step-2": "forbidden = ['Key.esc', 'Key.cmd', 'Key.cmd_r', 'Key.menu', 'Key.pause',\n 'Key.scroll_lock', 'Key.print_screen', 'Key.enter', 'Key.space',\n 'Key.backspace', 'Key.ctrl_l', 'Key.ctrl_r', 'Key.alt...
[ 0, 1 ]
import sys; input = sys.stdin.readline from collections import deque from itertools import combinations from copy import deepcopy n, m = map(int, input().split()) graph = [list(map(int,input().split())) for i in range(n)] virus_lst = [] for i in range(n): for j in range(n): if graph[i][j]==2: g...
normal
{ "blob_id": "0e3bf0ddd654b92b2cd962a2f3935c639eeb0695", "index": 2155, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bfs(start_nodes, g):\n dq = deque()\n dq.extend(start_nodes)\n for i, j in start_nodes:\n g[i][j] = -1\n while dq:\n y, x = dq.popleft()\n for k i...
[ 0, 1, 2, 3, 5 ]
#!/usr/bin/python3 """ This module add a better setattr function """ def add_attribute(obj, name, value): """ add an attribute to a class if possible""" if hasattr(obj, "__dict__"): setattr(obj, name, value) else: raise TypeError("can't add new attribute")
normal
{ "blob_id": "bee7f3acdb103f3c20b6149407854c83ad367a6b", "index": 2621, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef add_attribute(obj, name, value):\n \"\"\" add an attribute to a class if possible\"\"\"\n if hasattr(obj, '__dict__'):\n setattr(obj, name, value)\n else:\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def log(text, level=2, outFile='log.txt'): text = str(text) if level == 0: return True if level == 3: with open(outFile, 'a') as logger: logger.write(text) logger.close() ...
flexible
{ "blob_id": "015b06d7f08f9de60a46d8428820333621732c53", "index": 6425, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef log(text, level=2, outFile='log.txt'):\n text = str(text)\n if level == 0:\n return True\n if level == 3:\n with open(outFile, 'a') as logger:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def objective(params): train = create_set(base_path=BASE_PATH + SET, conf=CONF, key=DSKEY, redo=False) test = train.query('train == 0') train.query('train == 1', inplace=True) X = train[FEATURES + ['session_id']] y = train['label'] del train gc.collect(...
flexible
{ "blob_id": "daf070291bbf59a7a06b129bbde5fd79b5cd46ad", "index": 6715, "step-1": "<mask token>\n\n\ndef objective(params):\n train = create_set(base_path=BASE_PATH + SET, conf=CONF, key=DSKEY,\n redo=False)\n test = train.query('train == 0')\n train.query('train == 1', inplace=True)\n X = trai...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class _VL53L1: <|reserved_special_token_0|> def set_range(self, rng): if rng < 4 and rng >= 0: self.tof.set_range() else: raise Exception('Invalid range: 1 - short, 2 - med, 3 - long') <|reserved_special_token_0|> def read(self): ...
flexible
{ "blob_id": "c6d9b971ab6919846807b740313d450d086ecc23", "index": 7643, "step-1": "<mask token>\n\n\nclass _VL53L1:\n <mask token>\n\n def set_range(self, rng):\n if rng < 4 and rng >= 0:\n self.tof.set_range()\n else:\n raise Exception('Invalid range: 1 - short, 2 - med,...
[ 3, 4, 5, 6, 7 ]
def add_route_distance(routes, cities, source): c = source.split() citykey = c[0] + ':' + c[2] cities.add(c[0]) routes[citykey] = c[4] def get_route_distance(routes, source, dest): if (source+":"+dest in routes): return routes[source+":"+dest] else: return routes[dest+":"+sourc...
normal
{ "blob_id": "810e9e4b18ff8cb388f9e16607b8ab3389a9831d", "index": 7402, "step-1": "<mask token>\n\n\ndef get_route_distance(routes, source, dest):\n if source + ':' + dest in routes:\n return routes[source + ':' + dest]\n else:\n return routes[dest + ':' + source]\n\n\n<mask token>\n", "step...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def getIntersection(a, b): intersection = [0, 0, 0, 0] if b[0] <= a[0] and a[0] <= b[2]: intersection[0] = a[0] elif a[0] <= b[0] and b[0] <= a[2]: intersection[0] = b[0] else: return 0 if b[1] <= a[1] and a[1] <= b[3]: intersection[1] =...
flexible
{ "blob_id": "f8a31cdf5f55b5aed33a407d2c008ba9b969d655", "index": 9493, "step-1": "<mask token>\n\n\ndef getIntersection(a, b):\n intersection = [0, 0, 0, 0]\n if b[0] <= a[0] and a[0] <= b[2]:\n intersection[0] = a[0]\n elif a[0] <= b[0] and b[0] <= a[2]:\n intersection[0] = b[0]\n else...
[ 3, 5, 6, 7, 8 ]
#!/usr/bin/env python # coding: utf-8 # Predicting Surviving the Sinking of the Titanic # ----------------------------------------------- # # # This represents my first attempt at training up some classifiers for the titanic dataset. # In[ ]: # data analysis and wrangling import pandas as pd import numpy as np i...
normal
{ "blob_id": "05f143e28ff9c7397376ad598529c1dfb7528ee3", "index": 7269, "step-1": "<mask token>\n\n\ndef get_na(dataset):\n na_males = dataset[dataset.Sex == 'male'].loc[:, 'AgeGroup'].isnull().sum()\n na_females = dataset[dataset.Sex == 'female'].loc[:, 'AgeGroup'].isnull(\n ).sum()\n return {'ma...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Context(Base): def __init__(self, dataset='', capsys=None): super(Context, self).__init__(capsys=capsys) self.dataset = '' self.dataset = dataset def get_dataset(self): return self...
flexible
{ "blob_id": "0e6e84a31b626639e2aa149fd1ef89f3ef251cd7", "index": 207, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Context(Base):\n\n def __init__(self, dataset='', capsys=None):\n super(Context, self).__init__(capsys=capsys)\n self.dataset = ''\n self.dataset = datase...
[ 0, 4, 5, 6, 7 ]
# DISCLAIMER # The "Math" code was taken from http://depado.markdownblog.com/2015-09-29-mistune-parser-syntax-highlighter-mathjax-support-and-centered-images # The HighlightRenderer code was taken from https://github.com/rupeshk/MarkdownHighlighter # MarkdownHighlighter is a simple syntax highlighter for Markdown syn...
normal
{ "blob_id": "a6c45ab3df0a692cd625d8203e1152e942a4cd6c", "index": 5908, "step-1": "<mask token>\n\n\nclass MathBlockLexer(mistune.BlockLexer):\n <mask token>\n\n def __init__(self, rules=None, **kwargs):\n if rules is None:\n rules = MathBlockGrammar()\n super(MathBlockLexer, self)....
[ 15, 17, 19, 24, 25 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> const.API_PROFILE_URL = 'https://api.line.me/v2/profile' const.API_NOTIFICATIONTOKEN_URL = ( 'https://api.line.me/message/v3/notifier/token') const.API_ACCESSTOKEN_URL = 'https://api.line.me/v2/oauth/accessToken' const.API_SEN...
flexible
{ "blob_id": "25fcf162306b3d6d6307e703a7d829754cba2778", "index": 2347, "step-1": "<mask token>\n", "step-2": "<mask token>\nconst.API_PROFILE_URL = 'https://api.line.me/v2/profile'\nconst.API_NOTIFICATIONTOKEN_URL = (\n 'https://api.line.me/message/v3/notifier/token')\nconst.API_ACCESSTOKEN_URL = 'https://a...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> with open('vocabulary.txt', 'r') as f: for line in f: information = line.strip().split(': ') question = information[1] answer = information[0] my_answer = input(f'{question}:') if my_answer == answer: pr...
flexible
{ "blob_id": "34009d1aa145f4f5c55d0c5f5945c3793fbc6429", "index": 7823, "step-1": "<mask token>\n", "step-2": "with open('vocabulary.txt', 'r') as f:\n for line in f:\n information = line.strip().split(': ')\n question = information[1]\n answer = information[0]\n my_answer = input...
[ 0, 1, 2 ]
from app import db from datetime import datetime from sqlalchemy.orm import validates class Posts(db.Model): id = db.Column(db.BigInteger, primary_key=True, autoincrement=True) title = db.Column(db.String(200)) content = db.Column(db.Text) category = db.Column(db.String(100)) created_date = db.Column(db.Date...
normal
{ "blob_id": "29298ee7ddb4e524a23000abf86854d72f49954c", "index": 1850, "step-1": "<mask token>\n\n\nclass Posts(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __repr__(self):\n return '<Posts {}>'.format(s...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> pygame.init() pygame.camera.init() <|reserved_special_token_0|> print(camlist) <|reserved_special_token_1|> <|reserved_special_token_0|> pygame.init() pygame.camera.init() camlist = pygame.camera.list_cameras() print(camlist) ...
flexible
{ "blob_id": "aae280e049c00e70e2214662a07eee8bfa29227e", "index": 6632, "step-1": "<mask token>\n", "step-2": "<mask token>\npygame.init()\npygame.camera.init()\n<mask token>\nprint(camlist)\n", "step-3": "<mask token>\npygame.init()\npygame.camera.init()\ncamlist = pygame.camera.list_cameras()\nprint(camlist...
[ 0, 1, 2, 3, 4 ]
# orm/relationships.py # Copyright (C) 2005-2023 the SQLAlchemy authors and contributors # <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: https://www.opensource.org/licenses/mit-license.php """Heuristics related to join conditions as used in :func:`_orm.relationship`....
normal
{ "blob_id": "5f8303ce91c5de779bbddbaafb3fb828596babe5", "index": 8669, "step-1": "<mask token>\n\n\nclass JoinCondition:\n primaryjoin_initial: Optional[ColumnElement[bool]]\n primaryjoin: ColumnElement[bool]\n secondaryjoin: Optional[ColumnElement[bool]]\n secondary: Optional[FromClause]\n prop: ...
[ 44, 79, 88, 99, 100 ]
#This program is a nice example of a core algorithm #Remove Individual Digits # To remove individual digits you use two operations # 1 MOD: # mod return the remainder after division. 5%2 = 1. # If we mod by 10 we get the units digit. 723%10 = 3 # 2 Integer Division: # Integer division is when we divide and remove de...
normal
{ "blob_id": "2a95a68d8570a314b2b6e5731d7a695e5d7e7b30", "index": 6261, "step-1": "<mask token>\n\n\ndef isHarshad(n):\n if n % findSum(n) == 0:\n return True\n return False\n\n\ndef findHarshad(low, high):\n low = 500\n high = 525\n streak = 0\n maxStreak = 0\n for i in range(low, hig...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def LinuxSysInfo(): return sysinfo.collect() <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def LinuxSysInfo(): return sysinfo.collect() def WindowsSysInfo(): from windows import sysinfo as win_sysinfo return win_sysinfo.col...
flexible
{ "blob_id": "30a2e4aa88b286179e2870205e90fab4a7474e12", "index": 2969, "step-1": "<mask token>\n\n\ndef LinuxSysInfo():\n return sysinfo.collect()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef LinuxSysInfo():\n return sysinfo.collect()\n\n\ndef WindowsSysInfo():\n from windows import sysinfo ...
[ 1, 2, 3, 4, 5 ]
<|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": "ae82ecadb61fd87afbc83926b9dc9d5f7e8c35a0", "index": 4194, "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 = [('product', '...
[ 0, 1, 2, 3, 4 ]
from .queue_worker import QueueWorker import threading class WorkersOrchestrator: @classmethod def worker_func(cls, worker): worker.start_consumption() def run_orchestrator(self, num_of_workers): worker_list = [] for i in range(num_of_workers): worker_list.append(Queu...
normal
{ "blob_id": "6a4a5eac1b736ee4f8587adba298571f90df1cf9", "index": 8864, "step-1": "<mask token>\n\n\nclass WorkersOrchestrator:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass WorkersOrchestrator:\n\n @classmethod\n def worker_func(cls, worker):\n worker.start_consumption...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def search4vowels(word): """ Return sny vowels founded in a supplied word.""" vowels = set('aeiou') found = vowels.intersection(set(word)) for vowels in found: print(vowels) <|reserved_special_token_1|> def search4vowels(word): ...
flexible
{ "blob_id": "8a21a7005fb17cc82759079022b540cf4fd062c5", "index": 3458, "step-1": "<mask token>\n", "step-2": "def search4vowels(word):\n \"\"\" Return sny vowels founded in a supplied word.\"\"\"\n vowels = set('aeiou')\n found = vowels.intersection(set(word))\n for vowels in found:\n print...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(x * y) <|reserved_special_token_1|> x, y = [float(x) for x in raw_input().split(' ')] print(x * y) <|reserved_special_token_1|> x, y = [float(x) for x in raw_input().split(" ")] print(x*y)
flexible
{ "blob_id": "1ed7fb0dd5f0fa5e60c855eceaaf3259092918ef", "index": 1240, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(x * y)\n", "step-3": "x, y = [float(x) for x in raw_input().split(' ')]\nprint(x * y)\n", "step-4": "x, y = [float(x) for x in raw_input().split(\" \")]\nprint(x*y)", "step-5"...
[ 0, 1, 2, 3 ]
#import os import queue as q #Считываем ввод file = open('input.txt', 'r') inp = '' for i in file: for j in i: if (j != '\n'): inp += j else: inp += ' ' inp += ' ' #print(inp) file.close() #Записываем все пути в двумерный массив tmp = '' #Переменная для хранения текущего ...
normal
{ "blob_id": "bb847480e7e4508fbfb5e7873c4ed390943e2fcf", "index": 3589, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in file:\n for j in i:\n if j != '\\n':\n inp += j\n else:\n inp += ' '\ninp += ' '\nfile.close()\n<mask token>\nfor i in inp:\n if i != ' ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('', admin.site.urls), path('upload/', include( 'links.urls'))] <|reserved_special_token_1|> from django.contrib import admin from django.urls import include, path urlpatterns = [path('', admin.site.urls)...
flexible
{ "blob_id": "45e8bdacad4ed293f7267d96abc9cbe8c8e192ae", "index": 4148, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', admin.site.urls), path('upload/', include(\n 'links.urls'))]\n", "step-3": "from django.contrib import admin\nfrom django.urls import include, path\nurlpatter...
[ 0, 1, 2, 3 ]
<|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": "c0cabf2b6f7190aefbaefa197a9008de3a344147", "index": 2082, "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 = [('core', '005...
[ 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_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "8cec6778f530cb06e4f6cb2e6e9b6cb192d20f97", "index": 3280, "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 FeedOnlyAutonomousMode(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def OnEnable(self): """ This function is called when Autonomous mode is enabled. You should initialize things neede...
flexible
{ "blob_id": "3596ef12ce407a8d84319daa38a27a99ed0de763", "index": 5208, "step-1": "<mask token>\n\n\nclass FeedOnlyAutonomousMode(object):\n <mask token>\n <mask token>\n <mask token>\n\n def OnEnable(self):\n \"\"\"\n This function is called when Autonomous mode is enabled. You shou...
[ 3, 4, 5, 6, 7 ]
import os import unittest from mock import Mock from tfsnippet.utils import * class HumanizeDurationTestCase(unittest.TestCase): cases = [ (0.0, '0 sec'), (1e-8, '1e-08 sec'), (0.1, '0.1 sec'), (1.0, '1 sec'), (1, '1 sec'), (1.1, '1.1 secs'), (59, '59 secs...
normal
{ "blob_id": "9189c1dd21b0858df3138bcf4fc7568b378e6271", "index": 885, "step-1": "<mask token>\n\n\nclass NotSetTestCase(unittest.TestCase):\n <mask token>\n\n\nclass _CachedPropertyHelper(object):\n\n def __init__(self, value):\n self.value = value\n\n @cached_property('_cached_value')\n def c...
[ 11, 12, 13, 18, 22 ]
import sys sys.stdin = open('4828.txt', 'r') sys.stdout = open('4828_out.txt', 'w') T = int(input()) 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[...
normal
{ "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 ]
def SimpleSymbols(str): if str[0].isalpha() and str[-1].isalpha(): return "false" for i in range(0, len(str)): if str[i].isalpha(): if str[i-1] == '+' and str[i+1] == '+': return "true" return "false" # keep this function call here # to see how to enter arguments in Python scrol...
normal
{ "blob_id": "d3a22cad850e895950ce322aac393b31758a2237", "index": 7157, "step-1": "def SimpleSymbols(str): \n if str[0].isalpha() and str[-1].isalpha():\n return \"false\"\n for i in range(0, len(str)):\n if str[i].isalpha():\n if str[i-1] == '+' and str[i+1] == '+':\n return \"true\"\n retur...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open('/Users/neeraj.joshi/Downloads/index.html') as html_file: soup = BeautifulSoup(html_file, 'lxml') <|reserved_special_token_0|> for tree in soup.find_all('tr'): data = [] for todd in tree.find_all('td'): ...
flexible
{ "blob_id": "47be41bd5838b828acdc90c3ef5abdeec9da1e85", "index": 1579, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('/Users/neeraj.joshi/Downloads/index.html') as html_file:\n soup = BeautifulSoup(html_file, 'lxml')\n<mask token>\nfor tree in soup.find_all('tr'):\n data = []\n for to...
[ 0, 1, 2, 3, 4 ]
import torch import torch.nn as nn class ReconstructionLoss(nn.Module): def __init__(self, config): super(ReconstructionLoss, self).__init__() self.velocity_dim = config.velocity_dim def forward(self, pre_seq, gt_seq): MSE_loss = nn.MSELoss() rec_loss = MSE_loss(pre_seq[:, 1:-...
normal
{ "blob_id": "edc66bdc365f9c40ee33249bd2d02c0c5f28256a", "index": 8386, "step-1": "<mask token>\n\n\nclass VelocityLoss(nn.Module):\n\n def __init__(self, _mean, _std, config):\n super(VelocityLoss, self).__init__()\n self._mean = _mean\n self._std = _std\n self.device = config.devi...
[ 14, 18, 19, 23, 24 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created for COMP5121 Lab on 2017 JUN 24 @author: King """ import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.svm import SVC import sklearn.metrics as metrics from sklearn.metrics import accuracy_score data = [[...
normal
{ "blob_id": "33365d5ce5d2a7d28b76a7897de25e1f35d28855", "index": 6269, "step-1": "<mask token>\n", "step-2": "<mask token>\nmodel.fit(data_train, label_train)\n<mask token>\nprint(model.score(data_test, label_test))\nprint(accuracy_score(label_test, predictions))\nprint(accuracy_score(label_test, predictions, ...
[ 0, 1, 2, 3, 4 ]
from django.conf.urls import patterns, include, url from django.contrib import admin from metainfo.views import DomainListView urlpatterns = patterns('', # Examples: # url(r'^$', 'metapull.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url(r'^$', DomainListView.as_view()), url(...
normal
{ "blob_id": "1599f5e49ec645b6d448e74719e240343077aedd", "index": 5464, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', url('^$', DomainListView.as_view()), url(\n '^admin/', include(admin.site.urls)), url('^domains/', include(\n 'metainfo.urls', namespace='domains')))\n", ...
[ 0, 1, 2, 3 ]
# # purpose: setup file to install the compiled-language python libraries # usage: python setup.py config_fc --f90flags="-O2 -fopenmp" install --prefix=$PWD # from numpy.distutils.core import Extension c_array_sqrt = Extension (name = "c_array_sqrt_omp", sources = ["./src/c_array_sqrt_omp....
normal
{ "blob_id": "c24bf42cfeaa1fb8ac188b9e08146762e0e86fed", "index": 1542, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n from numpy.distutils.core import setup\n setup(name='array-sqrt-openmp', description=\n 'Illustration of Python extensions using OpenMP', author=...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class GeneralizedRCNN(nn.Module): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class GeneralizedRCNN(nn.Module): def __init__(self, backbone, rpn, roi_heads, transform): super(GeneralizedRCNN,...
flexible
{ "blob_id": "83ecb6b6237d7ee61f762b191ebc891521067a41", "index": 9206, "step-1": "<mask token>\n\n\nclass GeneralizedRCNN(nn.Module):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass GeneralizedRCNN(nn.Module):\n\n def __init__(self, backbone, rpn, roi_heads, transform):\n s...
[ 1, 2, 3, 4, 5 ]
import boto3 from botocore.exceptions import ClientError import logging import subprocess import string import random import time import os import sys import time import json from ProgressPercentage import * import logging def upload_file(file_name, object_name=None): RESULT_BUCKET_NAME = "worm4047bucket2" s...
normal
{ "blob_id": "f405a3e9ccabbba6719f632eb9c51809b8deb319", "index": 999, "step-1": "<mask token>\n\n\ndef upload_file(file_name, object_name=None):\n RESULT_BUCKET_NAME = 'worm4047bucket2'\n s3_client = get_client('s3')\n max_retries = 5\n while max_retries > 0:\n try:\n response = s3_...
[ 4, 5, 6, 7, 8 ]
 class TrieTree(object): def __init__(self): self.size=0 self.childern=[None]*26 def insert(self,word): node=self for w in word: index=ord(w)-97 node.size+=1 if node.childern[index]==None: node.childern[index]=TrieTree() ...
normal
{ "blob_id": "a18fad746a1da3327d79ac0a61edd156c5fb8892", "index": 6127, "step-1": "\n\nclass TrieTree(object):\n def __init__(self):\n self.size=0\n self.childern=[None]*26\n def insert(self,word):\n node=self\n for w in word:\n index=ord(w)-97\n node.size+...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(my_file.readlines()) my_file.close() <|reserved_special_token_0|> for i in range(5): new_file.write('new line ' + str(i + 1) + '\n') new_file.close() <|reserved_special_token_0|> new_file.writelines(a) new_file.close() ...
flexible
{ "blob_id": "d44f8a2dee35d76c152695d49d73f74e9c25bfa9", "index": 3015, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(my_file.readlines())\nmy_file.close()\n<mask token>\nfor i in range(5):\n new_file.write('new line ' + str(i + 1) + '\\n')\nnew_file.close()\n<mask token>\nnew_file.writelines(a)...
[ 0, 1, 2, 3 ]
#!/usr/bin/python """Source base class. Based on the OpenSocial ActivityStreams REST API: http://opensocial-resources.googlecode.com/svn/spec/2.0.1/Social-API-Server.xml#ActivityStreams-Service """ __author__ = ['Ryan Barrett <activitystreams@ryanb.org>'] import datetime try: import json except ImportError: imp...
normal
{ "blob_id": "29428e9ca4373c9f19d1412046ebe4fc3b1c48e3", "index": 6300, "step-1": "<mask token>\n\n\nclass Source(object):\n <mask token>\n\n def __init__(self, handler):\n self.handler = handler\n\n def get_activities(self, user_id=None, group_id=None, app_id=None,\n activity_id=None, star...
[ 5, 6, 7, 8, 10 ]
<|reserved_special_token_0|> def get_json_buques(centerx, centery, zoom): count = 0 while True: ignore = False count += 1 print(centerx, centery, zoom) out = check_output(['phantomjs', 'GetBarcos.js', str(centerx), str( centery), str(zoom)]) links = json.loa...
flexible
{ "blob_id": "9ba5af7d2b6d4f61bb64a055efb15efa8e08d35c", "index": 5379, "step-1": "<mask token>\n\n\ndef get_json_buques(centerx, centery, zoom):\n count = 0\n while True:\n ignore = False\n count += 1\n print(centerx, centery, zoom)\n out = check_output(['phantomjs', 'GetBarcos....
[ 1, 2, 3, 4, 5 ]