code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> class windowed_incStat: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class windowed_incStat_2D: def __init__(self, L): se...
flexible
{ "blob_id": "7b2ca3db44c5f71c2975bd8af701dafca3b3d081", "index": 5492, "step-1": "<mask token>\n\n\nclass windowed_incStat:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass windowed_incStat_2D:\n\n def __init__(self, L):\n self.incSt...
[ 18, 32, 35, 44, 46 ]
<|reserved_special_token_0|> class BaseApplication(Shop): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class BaseApplication(Shop): catalogue_app = catalogue_app <|reserved_special_token_0|> <|reserved_special_token_1|> <|reser...
flexible
{ "blob_id": "c8bb6ead7e305f466e24b47811d6ed38c8cfec0a", "index": 2691, "step-1": "<mask token>\n\n\nclass BaseApplication(Shop):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass BaseApplication(Shop):\n catalogue_app = catalogue_app\n\n\n<mask token>\n", "step-3": "<mask token>\n...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def generate_launch_description(): cart_sdf = os.path.join(get_package_share_directory('crs_support'), 'sdf', 'cart.sdf') cart_spawner = launch_ros.actions.Node(node_name='spawn_node', package= 'gazebo_ro...
flexible
{ "blob_id": "cc74163d5dbcc2b2ca0fe5222692f6f5e45f73fe", "index": 2377, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_launch_description():\n cart_sdf = os.path.join(get_package_share_directory('crs_support'),\n 'sdf', 'cart.sdf')\n cart_spawner = launch_ros.actions.Node(nod...
[ 0, 1, 2 ]
from abc import ABC, abstractmethod, abstractproperty from pytz import timezone class EngageScraper(ABC): def __init__(self, tz_string): super().__init__() self._agenda_locations = [] self._tz = timezone(tz_string) @property def agenda_locations(self): return self._agenda...
normal
{ "blob_id": "ec224924206c41cf8203c6aa8002ddf6b0e70e9b", "index": 1116, "step-1": "<mask token>\n\n\nclass EngageScraper(ABC):\n\n def __init__(self, tz_string):\n super().__init__()\n self._agenda_locations = []\n self._tz = timezone(tz_string)\n\n @property\n def agenda_locations(s...
[ 8, 10, 11, 12 ]
<|reserved_special_token_0|> class ProtestDataset(Dataset): <|reserved_special_token_0|> <|reserved_special_token_0|> def __len__(self): return len(self.label_frame) <|reserved_special_token_0|> class ProtestDatasetEval(Dataset): """ dataset for just calculating the output (does not...
flexible
{ "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 ]
<|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": "e67cbddf10440e8a31373e05a82840677d3045f5", "index": 4388, "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 = [('login', '00...
[ 0, 1, 2, 3, 4 ]
''' Exercício 1: Estenda a classe Stack , que escrevemos durante as explicações do conteúdo, adicionando uma nova função chamada min_value() que irá retornar o menor valor inteiro presente na pilha. ''' from stack import Stack class Other_Operations_Stack(Stack): def min_value(self): min_value = self.pee...
normal
{ "blob_id": "0b2fd671b99b7012a14b132db2322318873b826c", "index": 1345, "step-1": "<mask token>\n\n\nclass Other_Operations_Stack(Stack):\n\n def min_value(self):\n min_value = self.peek()\n for value in self._data:\n if value < min_value:\n min_value = value\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def simple_get(url): """ Attempts to get the content at `url` by making an HTTP GET request. If the content-type of response is some kind of HTML/XML, return the text content, otherwise return None. """ try: with closing(get(url, stream=True)) as resp: ...
flexible
{ "blob_id": "4c9a3983180cc75c39da41f7f9b595811ba0dc35", "index": 8390, "step-1": "<mask token>\n\n\ndef simple_get(url):\n \"\"\"\n Attempts to get the content at `url` by making an HTTP GET request.\n If the content-type of response is some kind of HTML/XML, return the\n text content, otherwise retu...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(sslist) print('입력하신 날짜의 10년 후 -> ', end='') <|reserved_special_token_0|> print(str(year) + '년', end='') print(sslist[1] + '월', end='') print(sslist[2] + '일') <|reserved_special_token_1|> ss = input('날짜: 년/월/일 입력-> ') ssli...
flexible
{ "blob_id": "fb2ef5a90b6e2582450726905868dd1b78e36166", "index": 5008, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(sslist)\nprint('입력하신 날짜의 10년 후 -> ', end='')\n<mask token>\nprint(str(year) + '년', end='')\nprint(sslist[1] + '월', end='')\nprint(sslist[2] + '일')\n", "step-3": "ss = input('날짜: 년...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def search(request): return render(request, 'ui/search.html') def search_printed(request): print_url = '' setting = Setting.objects.filter(name='printer').first() if setting != None: print_url = setting.value return render(request, 'ui/search.html', {'print_u...
flexible
{ "blob_id": "f16d43d9dfb3e9b9589fa92eb82aaa4c73fe48cd", "index": 1264, "step-1": "<mask token>\n\n\ndef search(request):\n return render(request, 'ui/search.html')\n\n\ndef search_printed(request):\n print_url = ''\n setting = Setting.objects.filter(name='printer').first()\n if setting != None:\n ...
[ 2, 3, 4, 5 ]
import numpy as np np.random.seed(1) class MonteCarloGameDriver(): def __init__(self): self.default_moves = np.array(['w','a','s','d']) self.probability_distribution = np.array([.25,.25,.25,.25]) def run_game(self, simulation_size=20): from game import GameLayout from copy ...
normal
{ "blob_id": "aeb986360c6990f9375f2552cbdeef595af815b4", "index": 6432, "step-1": "<mask token>\n\n\nclass MonteCarloGameDriver:\n\n def __init__(self):\n self.default_moves = np.array(['w', 'a', 's', 'd'])\n self.probability_distribution = np.array([0.25, 0.25, 0.25, 0.25])\n <mask token>\n\n...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> class Posts(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|> def __repr__(self): re...
flexible
{ "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 ]
#Aplicacion de la funcion super() class Persona(): def __init__(self,nombre,edad,lugar_residencia): self.nombre = nombre self.edad = edad self.residencia = lugar_residencia def descripcion(self): print("Nombre: ",self.nombre," Edad: ", self.edad," Lugar de residencia: ",s...
normal
{ "blob_id": "92a50bcdbb4c03d1a4813a93c2e0986250516f14", "index": 1117, "step-1": "class Persona:\n <mask token>\n <mask token>\n\n def hola(self):\n print('Hola Mundo')\n\n\nclass Empleado(Persona):\n\n def __init__(self, salario, antiguedad, nombre_empleado, edad_empleado,\n residencia...
[ 5, 6, 8, 9, 10 ]
#!/usr/bin/env python # Standardised set up import RPi.GPIO as GPIO # External module imports GPIO import time # Library to slow or give a rest to the script import timeit # Alternative timing library for platform specific timing import sys # Library to access program arguments and call exits import os # Library provi...
normal
{ "blob_id": "4e9fd3ee2a78fae164d9f38704443ac5b2f4c11c", "index": 1189, "step-1": "<mask token>\n\n\nclass colour:\n purple = '\\x1b[95m'\n cyan = '\\x1b[96m'\n darkcyan = '\\x1b[36m'\n blue = '\\x1b[94m'\n green = '\\x1b[92m'\n yellow = '\\x1b[93m'\n red = '\\x1b[91m'\n bold = '\\x1b[1m'\...
[ 2, 3, 4, 5, 6 ]
class Node: def __init__ (self, val): self.childleft = None self.childright = None self.nodedata = val root = Node("Kaif") root.childleft = Node("name") root.childright = Node("!") root.childleft.childleft = Node("My") root.childleft.childright = Node("is") message = input(...
normal
{ "blob_id": "73e4346007acae769b94a55ef53a48a9d3325002", "index": 7262, "step-1": "class Node:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Node:\n\n def __init__(self, val):\n self.childleft = None\n self.childright = None\n self.nodedata = val\n\n\n<mask token>\n\n\ndef try...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def print_results(r): """Checks for errors and prints the results of a request""" print(r.text) if r.status_code != 200: raise RuntimeError( 'Could not obtain data from the BSE. Check the error information above' ) <|reserved_special_token_0|>...
flexible
{ "blob_id": "168a76fd3bb43afe26a6a217e90f48704b4f2042", "index": 6738, "step-1": "<mask token>\n\n\ndef print_results(r):\n \"\"\"Checks for errors and prints the results of a request\"\"\"\n print(r.text)\n if r.status_code != 200:\n raise RuntimeError(\n 'Could not obtain data from t...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: def minRemoveToMakeValid(self, s: str) ->str: bracketsToRemove = set() stack = [] for i, c in enumerat...
flexible
{ "blob_id": "1bab6b039462bb5762aa588d5ba7c3e74362d0a7", "index": 823, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution:\n\n def minRemoveToMakeValid(self, s: str) ->str:\n bracketsToRemove = set()\n stack = []\n f...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: def getDescentPeriods(self, prices: List[int]) ->int: ans = 1 dp = 1 for i in range(1, len(prices)): if prices[i] == pric...
flexible
{ "blob_id": "d10468d2d0aefa19a7d225bfffad03ec6cb6e082", "index": 4079, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def getDescentPeriods(self, prices: List[int]) ->int:\n ans = 1\n dp = 1\n for i in range(1, len(prices)):...
[ 0, 1, 2, 3 ]
import numpy as np import cv2 def optical_flow_from_video(): cap = cv2.VideoCapture("/home/ubuntu/data1.5TB/异常dataset/Avenue_dataset/training_videos/01.avi") # 设置 ShiTomasi 角点检测的参数 feature_params = dict(maxCorners=100, qualityLevel=0.3, minDistance=7, blockSize=7) # 设置 lucas kanade 光流场的参数 # maxLe...
normal
{ "blob_id": "ae0547aa1af2d4dd73bb60154574e64e74107a58", "index": 4062, "step-1": "<mask token>\n\n\ndef optical_flow_from_video():\n cap = cv2.VideoCapture(\n '/home/ubuntu/data1.5TB/异常dataset/Avenue_dataset/training_videos/01.avi'\n )\n feature_params = dict(maxCorners=100, qualityLevel=0.3,...
[ 5, 6, 7, 8, 10 ]
<|reserved_special_token_0|> def _check_tags(generator: InputOutputGenerator, name: str): for output, inputs in generator.items(): necessary_tags = dict(collections.Counter(get_tags(output))) for index, input in enumerate(inputs): input_tags = dict(collections.Counter(get_tags(input)))...
flexible
{ "blob_id": "0bbc8aa77436193ab47c0fe8cf0d7c6dffcfe097", "index": 8066, "step-1": "<mask token>\n\n\ndef _check_tags(generator: InputOutputGenerator, name: str):\n for output, inputs in generator.items():\n necessary_tags = dict(collections.Counter(get_tags(output)))\n for index, input in enumera...
[ 4, 5, 6, 7, 8 ]
import subprocess from flask import Flask, render_template, request from subprocess import Popen, PIPE, check_output def toggle_relay(value): session = subprocess.Popen("./relay " + value, stdout=PIPE, stderr=PIPE, shell=True) stdout, stderr = session.communicate() if stderr: raise Exception("Error...
normal
{ "blob_id": "18d1722529a63f9a1696b09c40dabb1c68ed55f4", "index": 3423, "step-1": "<mask token>\n\n\ndef toggle_relay(value):\n session = subprocess.Popen('./relay ' + value, stdout=PIPE, stderr=PIPE,\n shell=True)\n stdout, stderr = session.communicate()\n if stderr:\n raise Exception('Err...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class ItemCrawlSpider(CrawlSpider): <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, keyword=None, *args, **kwargs): super(ItemCrawlSpider, self).__init__(*args, **kwargs) keyword.replace(' ', '+') self.start_urls = [ ...
flexible
{ "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 ]
import copy import random def parse_arrow(string): return tuple(string.split(' -> ')) def parse_sig(string, vals=None): parts = string.split() if len(parts) == 1: return resolve(parts[0], vals) elif parts[1] == 'AND': return resolve(parts[0], vals) & resolve(parts[2], vals) elif ...
normal
{ "blob_id": "a4492af775899ec2dcc0cac44b2740edd8422273", "index": 6012, "step-1": "import copy\nimport random\n\n\ndef parse_arrow(string):\n return tuple(string.split(' -> '))\n\n\ndef parse_sig(string, vals=None):\n parts = string.split()\n if len(parts) == 1:\n return resolve(parts[0], vals)\n ...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(np.linalg.norm(mat)) <|reserved_special_token_1|> <|reserved_special_token_0|> a = np.log(2) / 25 apdataX = np.random.random((5, 35)) quarter_way_arr = [False, False, False] quarter_way_arr[0] = True quarter_way_arr[1] = ...
flexible
{ "blob_id": "7e7e96fb9377e4dc59a46a46951f5057ecae419a", "index": 201, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(np.linalg.norm(mat))\n", "step-3": "<mask token>\na = np.log(2) / 25\napdataX = np.random.random((5, 35))\nquarter_way_arr = [False, False, False]\nquarter_way_arr[0] = True\nquart...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.2.5 on 2019-10-24 05:11 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('student', '0008_studentbasic_stu_class_num'), ] operations = [ migrations.AlterModelOptions( name='onduty', options=...
normal
{ "blob_id": "289aa48b4433be533c3916dd039136df45e0ac0b", "index": 1073, "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 = [('student', '...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('^coffeeshops/(\\d+)$', ShopView.as_view()), url( '^coffeeshops$', ShopListView.as_view())] <|reserved_special_token_1|> from django.conf.urls import url from . import views from .views import ShopView, S...
flexible
{ "blob_id": "54a705de2597140a72e47f5afe86614b619461b7", "index": 1109, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^coffeeshops/(\\\\d+)$', ShopView.as_view()), url(\n '^coffeeshops$', ShopListView.as_view())]\n", "step-3": "from django.conf.urls import url\nfrom . import view...
[ 0, 1, 2, 3 ]
from board.ttt import TTT from mctsai.mcts import MCTS import unittest # skip = [0, 1] skip = [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(tt...
normal
{ "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|> class AsyncHandler(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class AsyncHandler(object): <|reserved_special_token_0|> ...
flexible
{ "blob_id": "f4e287f5fce05e039c54f1108f6e73020b8d3d8f", "index": 9346, "step-1": "<mask token>\n\n\nclass AsyncHandler(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass AsyncHandler(object):\n <mask token>\n\n def __init__(self, future...
[ 1, 3, 4, 5, 6 ]
import whoosh.index as index from whoosh.fields import * from whoosh.qparser import MultifieldParser from whoosh import scoring w = scoring.BM25F(B=0.75, content_B=1.0, K1=1.5) fieldnames = ["bill_text", "bill_title", "year", "sponsor_name", "subject"] boosts = {"bill_text": 1, "bill_title": 2.5, "year": 0, "sponsor_n...
normal
{ "blob_id": "6a400419c26c62471dfc6893cc2d1ff6d88e49f4", "index": 7518, "step-1": "import whoosh.index as index\nfrom whoosh.fields import *\nfrom whoosh.qparser import MultifieldParser\nfrom whoosh import scoring\n\nw = scoring.BM25F(B=0.75, content_B=1.0, K1=1.5)\nfieldnames = [\"bill_text\", \"bill_title\", \"...
[ 0 ]
<|reserved_special_token_0|> def create_item(user_id): flag = False while flag == False: product_name = input('Enter the name of the product : ') flag = validate_product_name(product_name) flag = False while flag == False: price = input('Enter the price : ') flag = vali...
flexible
{ "blob_id": "d5dae7ab6eb34c82ae795730ecae666c4f81f10a", "index": 4160, "step-1": "<mask token>\n\n\ndef create_item(user_id):\n flag = False\n while flag == False:\n product_name = input('Enter the name of the product : ')\n flag = validate_product_name(product_name)\n flag = False\n wh...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class WaitForException(Exception): """WaitForException: if func doesn't return expected result within the specified time""" def _wait_for(func: Callable, expected_result: Any=True, timeout: int=10, print_error: bool=True, sleep_for: int=1, **kwargs) ->None: """ Run speci...
flexible
{ "blob_id": "0069a61127c5968d7014bdf7f8c4441f02e67df0", "index": 6541, "step-1": "<mask token>\n\n\nclass WaitForException(Exception):\n \"\"\"WaitForException: if func doesn't return expected result within the specified time\"\"\"\n\n\ndef _wait_for(func: Callable, expected_result: Any=True, timeout: int=10,...
[ 4, 5, 6, 7, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def role_required(role): """ 带参数的装饰器,可以用它来保护一个路由处理函数智能被特定的用户访问 :param role: :return: """ def decorator(func): @wraps(func) def wrapper(*args, **kwargs): if not current_user.i...
flexible
{ "blob_id": "b3f6d255830bdb2b0afc99aab6e3715616ac4dec", "index": 4298, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef role_required(role):\n \"\"\"\n 带参数的装饰器,可以用它来保护一个路由处理函数智能被特定的用户访问\n :param role:\n :return:\n \"\"\"\n\n def decorator(func):\n\n @wraps(func)\n de...
[ 0, 1, 2, 3, 4 ]
from celery import shared_task import tweepy from datetime import datetime, timedelta from .models import Tweet from django.db import IntegrityError CONSUMER_KEY = 'Vp7FVQLSwESvE9oTQruw0TnhW' CONSUMER_SECRET = 'miy6EsGklNYxAaVn37vTjAVGwP0c67IOyuY71AAyL1p2Ba4VPN' ACCESS_TOKEN = '1952022900-5WAHk6l5d3GllFtqDPaucSpnraIo...
normal
{ "blob_id": "d4d19411f0c48ffb99bd17e8387f1741144e43b4", "index": 870, "step-1": "<mask token>\n\n\n@shared_task(name='clean_tweetdb')\ndef clean_tweetdb():\n tweets = Tweet.objects.all()\n for tweets.tweet_date in tweets:\n if tweets.tweet_date <= datetime.now() - timedelta(days=8):\n twe...
[ 2, 3, 4, 5, 6 ]
from setuptools import setup, find_packages setup( name='spt_compute', version='2.0.1', description='Computational framework for the Streamflow Prediciton Tool', long_description='Computational framework to ingest ECMWF ensemble runoff forcasts ' ' or otherLand Surface Model foreca...
normal
{ "blob_id": "53b6d30bf52c43daaebe8158002db1072e34f127", "index": 7956, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='spt_compute', version='2.0.1', description=\n 'Computational framework for the Streamflow Prediciton Tool',\n long_description=\n \"Computational framework to ingest ...
[ 0, 1, 2, 3 ]
import turtle hexagon = turtle.Turtle() for i in range(6): hexagon.forward(100) hexagon.left(60)
normal
{ "blob_id": "f6401eca2dc0ea86a934e859c35fa2d6c85a61b3", "index": 8695, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(6):\n hexagon.forward(100)\n hexagon.left(60)\n", "step-3": "<mask token>\nhexagon = turtle.Turtle()\nfor i in range(6):\n hexagon.forward(100)\n hexagon.left...
[ 0, 1, 2, 3 ]
import json from pets.pet import Pet from store_requests.store import Store from user_requests.user import User SUCCESS = 200 NotFound = 404 url_site = 'https://petstore.swagger.io/v2' new_username = "Khrystyna" new_id = 12345 invalid_new_id = 1234 error_message = "oops we have a problem!" store_inventory = { "1": ...
normal
{ "blob_id": "54ed0683d0f8d907c27e2f3809f9533556593392", "index": 5546, "step-1": "<mask token>\n", "step-2": "<mask token>\nSUCCESS = 200\nNotFound = 404\nurl_site = 'https://petstore.swagger.io/v2'\nnew_username = 'Khrystyna'\nnew_id = 12345\ninvalid_new_id = 1234\nerror_message = 'oops we have a problem!'\ns...
[ 0, 1, 2, 3 ]
# coding: utf-8 def init_list(): print("=== init_list ===") l = list() print(l) l2 = [] print(l2) l3 = list((1, 2)) print(l3) l4 = [1, 2] print(l4) def insert_append_and_extend_list(): print("=== insert_append_and_extend_list ===") l = ['e', 'h'] l.insert(-1, 'g') ...
normal
{ "blob_id": "1a710916461644a0676a3bd84926aeabb2aa3f71", "index": 7127, "step-1": "<mask token>\n\n\ndef get_len_count_index_list():\n print('=== get_len_count_index_list ===')\n l = ['a', 'b', 'c', 'd', 'e', 'e']\n print(l[0])\n print('len: {}'.format(len(l)))\n print('count d: {}'.format(l.count(...
[ 10, 11, 12, 14, 15 ]
# -*- coding: utf-8 -*- import requests import csv from lxml import html import json class ycombinatorParser(): siteurl = 'https://news.ycombinator.com/' def getNextPage(pageurl): response = requests.get(pageurl) parsed_body = html.fromstring(response.text) nextpage=parsed_body.xpa...
normal
{ "blob_id": "87c27711c0089ca2c7e5c7d0e9edb51b9d4008d9", "index": 6717, "step-1": "<mask token>\n\n\nclass ycombinatorParser:\n <mask token>\n\n def getNextPage(pageurl):\n response = requests.get(pageurl)\n parsed_body = html.fromstring(response.text)\n nextpage = parsed_body.xpath('//...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for the file entry implementation using pyfshfs.""" import unittest from dfvfs.lib import definitions from dfvfs.path import factory as path_spec_factory from dfvfs.resolver import context from dfvfs.vfs import hfs_attribute from dfvfs.vfs import hfs_file_entry f...
normal
{ "blob_id": "520672f8607751b65fe9e4b975a9978ed0ab71b6", "index": 8242, "step-1": "<mask token>\n\n\nclass HFSFileEntryTest(shared_test_lib.BaseTestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def tearDown(self):\n \"\"\"Cleans up...
[ 18, 19, 20, 25, 27 ]
import requests import pandas as pd import time def job_spider(jid="1913e38066dd3c8e1Hd40t--FVE~", ka="search_list_1", i=0): # request info. job_url = "https://www.zhipin.com/job_detail/" + jid + ".html" headers = { 'cache-control': "no-cache", 'user-agent': 'Mozilla/5.0 (Windows NT 10.0;...
normal
{ "blob_id": "5b894eac93bff44931df4ef8d845c23071a03227", "index": 3461, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef job_spider(jid='1913e38066dd3c8e1Hd40t--FVE~', ka='search_list_1', i=0):\n job_url = 'https://www.zhipin.com/job_detail/' + jid + '.html'\n headers = {'cache-control': 'no-c...
[ 0, 1, 2, 3, 4 ]
from django.db.models import Q from django.contrib import messages from django.views.generic import ListView, DetailView from django.shortcuts import get_object_or_404, redirect, render from django.contrib.auth.decorators import login_required from django.http import HttpResponse from django.views.decorators.http im...
normal
{ "blob_id": "3c193decc4a1f284de953003fbba434d6e798b24", "index": 2827, "step-1": "<mask token>\n\n\nclass PillListView(ListView):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass PillDetailView(DetailView):\n model = Pills\n template_nam...
[ 3, 6, 8, 9, 11 ]
<|reserved_special_token_0|> class UserProfile(ndb.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @classmethod def query_profile(cls, ancestor_key): return cls.query(ancestor=ancestor_key).get() class UserProfileHandler(webapp2.RequestHand...
flexible
{ "blob_id": "309090167c2218c89494ce17f7a25bd89320a202", "index": 3855, "step-1": "<mask token>\n\n\nclass UserProfile(ndb.Model):\n <mask token>\n <mask token>\n <mask token>\n\n @classmethod\n def query_profile(cls, ancestor_key):\n return cls.query(ancestor=ancestor_key).get()\n\n\nclass ...
[ 5, 7, 8, 9, 10 ]
<|reserved_special_token_0|> class Demo: def __init__(self): self.log = logging.getLogger(self.__class__.__name__) def start(self, filename: str): self.log.debug('analyse file: ' + filename) astmodif = AstModifier(filename) originTree = astmodif.origin() self.log.info...
flexible
{ "blob_id": "e989f73011559080f96802dba4db30361d5626f9", "index": 4002, "step-1": "<mask token>\n\n\nclass Demo:\n\n def __init__(self):\n self.log = logging.getLogger(self.__class__.__name__)\n\n def start(self, filename: str):\n self.log.debug('analyse file: ' + filename)\n astmodif =...
[ 3, 4, 5, 6, 7 ]
class Person: country = "INDIA" def __init__(self): print("its base constructor") def takeBreath(self): print("Yes Iam breathing.") class Emp(Person): # inherits person def takeBreath(self): print("Yes Iam EMP and Iam also breathing.") class Prog(Emp): def ...
normal
{ "blob_id": "cb2e2ef70935a22854c70fedf4f4a6715b089291", "index": 1990, "step-1": "<mask token>\n\n\nclass Prog(Emp):\n\n def __init__(self):\n super().__init__()\n print('its child constructor')\n\n def takeBreath(self):\n super().takeBreath()\n print('Iam a programmer and breat...
[ 4, 6, 8, 11, 13 ]
""" Card rarity parameters """ from typing import List, Optional from django.db.models.query import Q from cards.models.rarity import Rarity from cardsearch.parameters.base_parameters import ( OPERATOR_MAPPING, OPERATOR_TO_WORDY_MAPPING, CardTextParameter, CardSearchContext, ParameterArgs, Que...
normal
{ "blob_id": "c7d9bbdff9148c5d928de66f4406ee8b4e1bcdac", "index": 2672, "step-1": "<mask token>\n\n\nclass CardRarityParam(CardTextParameter):\n <mask token>\n\n @classmethod\n def get_parameter_name(cls) ->str:\n return 'rarity'\n <mask token>\n <mask token>\n <mask token>\n <mask tok...
[ 4, 5, 6, 8, 12 ]
<|reserved_special_token_0|> def DSA_2048(filename, key): with open(filename, 'rb') as f: message = f.read() hash_obj = SHA256.new(message) signer = DSS.new(key, 'fips-186-3') signature = signer.sign(hash_obj) f = open('public_key.pem', 'r') hash_obj = SHA256.new(me...
flexible
{ "blob_id": "d24bbfc3587a2a79891a11e00ec865498c01c286", "index": 2101, "step-1": "<mask token>\n\n\ndef DSA_2048(filename, key):\n with open(filename, 'rb') as f:\n message = f.read()\n hash_obj = SHA256.new(message)\n signer = DSS.new(key, 'fips-186-3')\n signature = signer.sign(h...
[ 1, 2, 3, 4, 5 ]
import xadmin from .models import EmailVerifyRecord,Banner from xadmin import views class EmailVerifyRecordAdmin(object): pass class BannerAdmin(object): list_display=('title','url','index') class BaseSetting(object): enable_themes=True user_bootswatch=True #设置xadmin页面标题和页脚 class GlobalSetting(objec...
normal
{ "blob_id": "263a853f33eb9724101ca87f12b914282dea9981", "index": 1441, "step-1": "<mask token>\n\n\nclass BannerAdmin(object):\n list_display = 'title', 'url', 'index'\n\n\nclass BaseSetting(object):\n enable_themes = True\n user_bootswatch = True\n\n\nclass GlobalSetting(object):\n site_title = '西游记...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> class TreeAdjustorTest: <|reserved_special_token_0|> def __init__(self): return def getAdjustedTreesTest(self): T = ParseTree() nodes = [Node(index=-1, word='DEFAULT', posTag='DEFAULT') for i in range(0, 8)] nodes[0] = Node(index=0...
flexible
{ "blob_id": "1db397df2d030b2f622e701c46c15d653cb79e55", "index": 5079, "step-1": "<mask token>\n\n\nclass TreeAdjustorTest:\n <mask token>\n\n def __init__(self):\n return\n\n def getAdjustedTreesTest(self):\n T = ParseTree()\n nodes = [Node(index=-1, word='DEFAULT', posTag='DEFAULT...
[ 3, 4, 8, 9, 10 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Dec 30 14:34:56 2019 ref : https://stackoverflow.com/questions/11140163/plotting-a-3d-cube-a-sphere-and-a-vector-in-matplotlib @author: jiedeng """ import numpy as np from itertools import product, combinations from mpl_toolkits.mplot3d.art3d impor...
normal
{ "blob_id": "086c74669b6762a6b35e8a46f816db2f4f172caa", "index": 1437, "step-1": "<mask token>\n\n\ndef switch_y_z(inter, liq_cutoff, vap_cutoff, liq_in, vap_in, int_in):\n triangles = inter.triangulated_surface[0][inter.triangulated_surface[1]]\n interface1 = np.zeros_like(triangles)\n interface2 = np....
[ 2, 3, 4, 5, 6 ]
def tobin(n): bin = ""; while(n/2!=0): if n%2==0: bin = bin + "0" else: bin = bin + "1" if n%2==1: bin = bin + "1" return bin n = int(input()) bin = tobin(5) print(bin)
normal
{ "blob_id": "1c5ca920fe1f116a5bc52c9e5c53c13b1e1c925f", "index": 2412, "step-1": "<mask token>\n", "step-2": "def tobin(n):\n bin = ''\n while n / 2 != 0:\n if n % 2 == 0:\n bin = bin + '0'\n else:\n bin = bin + '1'\n if n % 2 == 1:\n bin = bin + '1'\n ret...
[ 0, 1, 2, 3, 4 ]
from flask_marshmallow import Marshmallow from models import Uservet ma = Marshmallow() class UserVetSchema(ma.Schema): class Meta: model = Uservet user_vet_1 = ['dni', 'email', 'nombre', 'apellidos', 'telefono', 'tipo_uservet' ]
normal
{ "blob_id": "677154aa99a5a4876532f3e1edfec45b1790384c", "index": 9511, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass UserVetSchema(ma.Schema):\n\n\n class Meta:\n model = Uservet\n\n\n<mask token>\n", "step-3": "<mask token>\nma = Marshmallow()\n\n\nclass UserVetSchema(ma.Schema):\...
[ 0, 1, 2, 3 ]
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import os import pandas as pd print('tensorflow version: {}'.format(tf.__version__)) def __prepare_train_data(df, feature): group...
normal
{ "blob_id": "55030648a6b76636e456990c1d2b02baa35a695d", "index": 9221, "step-1": "<mask token>\n\n\ndef __prepare_train_data(df, feature):\n groups = df.groupby(['event', 'start'])\n data = []\n labels = []\n for id, group in groups:\n values = group['CylinderBorePressure'].values\n dat...
[ 2, 3, 4, 5, 6 ]
def digital_sum(n): if n < 10: return n return n % 10 + digital_sum(n // 10) def digital_root(n): if n < 10: return n return digital_root(digital_sum(n))
normal
{ "blob_id": "e3e6f1b6580a223558791cebfcb1a92d45553162", "index": 1823, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef digital_root(n):\n if n < 10:\n return n\n return digital_root(digital_sum(n))\n", "step-3": "def digital_sum(n):\n if n < 10:\n return n\n return n % ...
[ 0, 1, 2 ]
# -*- coding:utf-8 -*- from spider.driver.base.driver import Driver from spider.driver.base.mysql import Mysql import time from pyquery import PyQuery from spider.driver.base.field import Field,FieldName,Fieldlist,FieldType from spider.driver.base.page import Page from spider.driver.base.listcssselector import ListCssS...
normal
{ "blob_id": "1a7a28a2264ed0204184ab1dd273b0b114657fa7", "index": 3004, "step-1": "<mask token>\n\n\nclass WeixinSpider(Driver):\n <mask token>\n\n def get_article(self, data_list=[]):\n article_list = (self.\n until_presence_of_all_elements_located_by_css_selector(\n css_select...
[ 3, 4, 5, 6, 7 ]
import numpy import numpy.fft import numpy.linalg import copy from astropy.io import fits from scipy.interpolate import RectBivariateSpline from scipy.signal import convolve import offset_index # some basic definitions psSize = 9 # psSize x psSize postage stamps of stars # zero padded RectBivariateSpline, if on def R...
normal
{ "blob_id": "2ab6488276c74da8c3d9097d298fc53d1caf74b1", "index": 6243, "step-1": "<mask token>\n\n\ndef RectBivariateSplineZero(y1, x1, map1, kx=1, ky=1):\n return RectBivariateSpline(y1, x1, map1, kx=kx, ky=ky)\n y2 = numpy.zeros(numpy.size(y1) + 2)\n y2[1:-1] = y1\n y2[0] = 2 * y2[1] - y2[2]\n y...
[ 13, 14, 15, 18, 23 ]
def readfasta (fasta): input = open(fasta, 'r') seqs = {} for line in input: if line[0] == '>': name = line[1:].rstrip() seqs[name] = [] else: seqs[name].append(line.rstrip()) for name in seqs: seqs[name] = ''.join(seqs[name]) r...
normal
{ "blob_id": "6072fc22872ee75c9501ac607a86ee9137af6a5d", "index": 4918, "step-1": "def readfasta (fasta):\r\n input = open(fasta, 'r')\r\n seqs = {}\r\n for line in input:\r\n if line[0] == '>':\r\n name = line[1:].rstrip()\r\n seqs[name] = [] \r\n else:\r\n ...
[ 0 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Created on 7/02/2014 @author: marco Generador de ambientes FACIL 2014 ''' import wx from formgenerador import FrameGeneral from Dial_Pagina import ObjPagina class IncioInterface(FrameGeneral): def __init__(self): #self.log = ObLog('Inicio programa') #self.lo...
normal
{ "blob_id": "9bd1fd2df7da068ac8aa4e6e24fe14d163a7e6b3", "index": 2362, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*- \n'''\nCreated on 7/02/2014\n\n@author: marco\nGenerador de ambientes FACIL 2014\n'''\n\n\nimport wx\n\nfrom formgenerador import FrameGeneral\nfrom Dial_Pagina import ObjPagina\n\n\nc...
[ 0 ]
from tensorflow.keras.applications.resnet50 import ResNet50 from tensorflow.keras.preprocessing import image from tensorflow.keras.applications.resnet50 import preprocess_input, decode_predictions import numpy as np model = ResNet50(weights='imagenet', # Learned weights on imagenet include_top=True) ...
normal
{ "blob_id": "1af6e66c19078a9ee971f608daa93247911d8406", "index": 5881, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(decoded_predictions)\n", "step-3": "<mask token>\nmodel = ResNet50(weights='imagenet', include_top=True)\nimg_input = image.load_img('my_picture.jpg', target_size=(224, 224))\nimg...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 import sys import hashlib # Usage if len(sys.argv) != 2: print("usage: part2.py puzzle_input") exit(1) # Get Secret puzzle_input = sys.argv[1] input_num = 0 # Calcuate for i in range(sys.maxsize): digest = hashlib.md5(puzzle_input.encode('utf-8')+str(i).encode('utf-8')).hexdigest() if (d...
normal
{ "blob_id": "1219f7b7ac335f3a69e289d1ab2b6318a2aef23f", "index": 1900, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv) != 2:\n print('usage: part2.py puzzle_input')\n exit(1)\n<mask token>\nfor i in range(sys.maxsize):\n digest = hashlib.md5(puzzle_input.encode('utf-8') + str(i)....
[ 0, 1, 2, 3, 4 ]
# x = 10 # # def increment(): # x += 1 # # ^^ Non-working code x = 10 def increment(number): number += 1 return number # If we want to change a global variable, # we have to do it like this x = increment(x)
normal
{ "blob_id": "a0460b100a750b685f3e831a19379b0e26da4b35", "index": 7368, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef increment(number):\n number += 1\n return number\n\n\n<mask token>\n", "step-3": "x = 10\n\n\ndef increment(number):\n number += 1\n return number\n\n\nx = increment...
[ 0, 1, 2, 3 ]
import weakref from soma.controller import Controller from soma.functiontools import SomaPartial from traits.api import File, Undefined, Instance class MatlabConfig(Controller): executable = File(Undefined, output=False, desc='Full path of the matlab executable') def load_module(capsul_...
normal
{ "blob_id": "4a8e8994ec8734664a5965b81da9d146d8504f8d", "index": 6096, "step-1": "<mask token>\n\n\nclass MatlabConfig(Controller):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass MatlabConfig(Controller):\n executable = File(Undefined, output=False, desc=\n 'Full path of t...
[ 1, 4, 5, 6, 7 ]
group = {'A': 20, 'B': 15, 'C': 10} def split_the_bill(x): owed_dict = {} sum = 0 people = 0 for key in x: sum = sum + x[key] people = people + 1 price_pp = sum / people for key in x: owed_value = x[key] - price_pp owed_dict[key] = round(owed_value, 2) retur...
normal
{ "blob_id": "69d7e7eb644a67ee921086005f0a55f39507f361", "index": 2864, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef split_the_bill(x):\n owed_dict = {}\n sum = 0\n people = 0\n for key in x:\n sum = sum + x[key]\n people = people + 1\n price_pp = sum / people\n f...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def exeObj(count, idObj, id, obj, guild, nom): dateID = int(strftime('%y') + strftime('%m') + strftime('%d')) connexionGL, curseurGL = connectSQL(guild.id, nom, 'Stats', 'GL', '') connexion, curseur = connectSQL(guild.id, nom, 'Stats', strftime('%m'), strftime('%y')) ...
flexible
{ "blob_id": "19ff064f8c27b9796eb435c7d2b9ebf87ee90ad6", "index": 7982, "step-1": "<mask token>\n\n\ndef exeObj(count, idObj, id, obj, guild, nom):\n dateID = int(strftime('%y') + strftime('%m') + strftime('%d'))\n connexionGL, curseurGL = connectSQL(guild.id, nom, 'Stats', 'GL', '')\n connexion, curseur...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) self.setWindowTitle('Cover Letter Developer') self.label1 = QLabel('Input Company Name') self.edit1 = QLineEdit('') self.label2 = QLabel('Input Position Ti...
flexible
{ "blob_id": "bad13218a7a9e687fbd29099ca80771296789d36", "index": 1321, "step-1": "<mask token>\n\n\nclass Form(QDialog):\n\n def __init__(self, parent=None):\n super(Form, self).__init__(parent)\n self.setWindowTitle('Cover Letter Developer')\n self.label1 = QLabel('Input Company Name')\n...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> @app.route('/') def addRegion(): return render_template('Website WordCount.html') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.route('/') def addRegion(): return render_template('Website WordCount.html') @app.route('/output_d...
flexible
{ "blob_id": "11dfb09286b8a5742550b5300c776ed82e69ead5", "index": 2577, "step-1": "<mask token>\n\n\n@app.route('/')\ndef addRegion():\n return render_template('Website WordCount.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef addRegion():\n return render_template('Website W...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for [ix, iy], [jx, jy] in itertools.combinations(a, 2): ans += ((jx - ix) ** 2 + (jy - iy) ** 2) ** 0.5 * 2 print(ans / n) <|reserved_special_token_1|> <|reserved_special_token_0|> n = int(input()) a = [list(map(int, input(...
flexible
{ "blob_id": "a210a015284130f23bfec99898f2f21163a33a67", "index": 9897, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor [ix, iy], [jx, jy] in itertools.combinations(a, 2):\n ans += ((jx - ix) ** 2 + (jy - iy) ** 2) ** 0.5 * 2\nprint(ans / n)\n", "step-3": "<mask token>\nn = int(input())\na = [list...
[ 0, 1, 2, 3, 4 ]
import fnmatch import hashlib from .mplog import MachopLog from .utils import MachopProcess, wait_for_interrupt from watchdog.observers import Observer from watchdog.events import PatternMatchingEventHandler class MachopWatchCommand(MachopProcess): class MachopHandler(PatternMatchingEventHandler): """...
normal
{ "blob_id": "4e30f0a9b420123c28858aad2a71040dcc952829", "index": 1391, "step-1": "<mask token>\n\n\nclass MachopWatchCommand(MachopProcess):\n\n\n class MachopHandler(PatternMatchingEventHandler):\n \"\"\" watcher for a file system event \"\"\"\n\n def on_modified(self, event):\n if e...
[ 4, 5, 7, 8, 9 ]
import unittest from pattern.multiplier import Multiplier, FixedWidth, Range from pattern.multiplier import WHATEVER, ONE_OR_MORE class TestMultipler(unittest.TestCase): def test__create__fixed_width(self): self.assertIsInstance(Multiplier.create(23), FixedWidth) def test__create__range(self): ...
normal
{ "blob_id": "5a7e535f2ae585f862cc792dab77f2fe0584fddc", "index": 9986, "step-1": "<mask token>\n\n\nclass TestWhatever(unittest.TestCase):\n\n def test_compile(self):\n self.assertEqual(WHATEVER.compile(), '*')\n\n\nclass TestOneOrMore(unittest.TestCase):\n\n def test_compile(self):\n self.as...
[ 8, 10, 12, 13, 15 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def encode(strs): """Encodes a list of strings to a single string. :type strs: List[str] :rtype: str """ res = '' for string in strs.split(): res += str(len(string)) + ':' + string ret...
flexible
{ "blob_id": "2561db1264fe399db85460e9f32213b70ddf03ff", "index": 1864, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef encode(strs):\n \"\"\"Encodes a list of strings to a single string.\n :type strs: List[str]\n :rtype: str\n \"\"\"\n res = ''\n for string in strs.split(...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def vector_to_message(vector): vocab_file = open('data/vocab.txt', 'r') vocab = vocab_file.readlines() message_words = [] for vocab_record, vector_enterance in zip(vocab, vector): is_trigger_word = bool(vector_enterance) word = vocab_record.split()[1] ...
flexible
{ "blob_id": "f5820824b5b7e473b79b5dfee2f203684c3755be", "index": 5154, "step-1": "<mask token>\n\n\ndef vector_to_message(vector):\n vocab_file = open('data/vocab.txt', 'r')\n vocab = vocab_file.readlines()\n message_words = []\n for vocab_record, vector_enterance in zip(vocab, vector):\n is_t...
[ 2, 3, 4, 5, 6 ]
""" A web-page. """ import re import pkg_resources from .components import Link, Javascript, inject class Page: """A web-page presenting container. Args: favicon (str): The file name for the favorite icon displayed in a browser tab(default=None) title (str): The page title, disp...
normal
{ "blob_id": "2c2ad4b6e8c5055afa3dfb3b540a44bda65fa004", "index": 5991, "step-1": "<mask token>\n\n\nclass Page:\n <mask token>\n <mask token>\n <mask token>\n\n def background(self, color=None, image=None, position=None, size=None,\n repeat=None, origin=None, clip=None, attachment=None):\n ...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class Trie: def __init__(self): self.dicts = dict() def add(self, word): node = self.dicts for w in word: if w not in node: node[w] = dict() node = node[w] <|reserved_special_token_0|> class Solution: def...
flexible
{ "blob_id": "57de9a46dfbf33b117c2dfbb534a5020e019d520", "index": 8513, "step-1": "<mask token>\n\n\nclass Trie:\n\n def __init__(self):\n self.dicts = dict()\n\n def add(self, word):\n node = self.dicts\n for w in word:\n if w not in node:\n node[w] = dict()\n...
[ 5, 7, 8, 10, 12 ]
<|reserved_special_token_0|> class I2CTargetApplet(GlasgowApplet, name='i2c-target'): logger = logging.getLogger(__name__) help = 'accept I²C transactions' description = """ Process transactions on the I²C bus as a software-defined target. This applet allows emulating any I²C device in Python, pr...
flexible
{ "blob_id": "0f2882971f08450e970e188ed2a06ae1683c682c", "index": 7552, "step-1": "<mask token>\n\n\nclass I2CTargetApplet(GlasgowApplet, name='i2c-target'):\n logger = logging.getLogger(__name__)\n help = 'accept I²C transactions'\n description = \"\"\"\n Process transactions on the I²C bus as a soft...
[ 7, 12, 13, 16, 18 ]
sum_value = 0 for _ in range(5): sum_value += int(input()) print(sum_value)
normal
{ "blob_id": "4add80894036e0395a6e6eb13e8a2db0d963de8c", "index": 9654, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(5):\n sum_value += int(input())\nprint(sum_value)\n", "step-3": "sum_value = 0\nfor _ in range(5):\n sum_value += int(input())\nprint(sum_value)\n", "step-4": nul...
[ 0, 1, 2 ]
import numpy as np from sklearn.ensemble import RandomForestClassifier from sklearn.grid_search import GridSearchCV import matplotlib.pyplot as plt def loadTrainSet(filepath): raw = np.loadtxt(filepath, delimiter=',', dtype=np.str, skiprows=1) X, y = raw[:,1:], raw[:,0] trainSet = np.hstack((X, y.reshape(-...
normal
{ "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 sys import os import json from collections import OrderedDict from config import folder, portfolio_value from datetime import datetime import logging # Logger setup logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) def valid_date(datestring): """ Determine if something is a valid...
normal
{ "blob_id": "0bc72a558b9bd3b5f74ce5dfce586dd66c579710", "index": 5776, "step-1": "<mask token>\n\n\ndef valid_date(datestring):\n \"\"\" Determine if something is a valid date \"\"\"\n try:\n datetime.strptime(datestring, '%Y-%m-%d')\n return True\n except ValueError as e:\n logger....
[ 4, 5, 6, 7, 8 ]
# author Dominik Capkovic # contact: domcapkovic@gmail.com; https://www.linkedin.com/in/dominik-čapkovič-b0ab8575/ # GitHub: https://github.com/kilimetr packings_str = ''' Raschig Super-Ring | metal | 0.3 | 180000 | 315.0 | 0.960 | 3.560 | 2.340 | 0.750 | 0.760 | 1.500 | 0.450 Raschig Super-Ring | met...
normal
{ "blob_id": "c4f656b96ddc86ab2575bd5ec646833cce95e6a9", "index": 1717, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in packings_str.strip().splitlines():\n line_items = line.split(' | ')\n line_items = [s.strip() for s in line_items]\n name, material, size, N, a, eps, CS, CFl, Ch, CP0...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def getTitlesFromAll(amount, rating='all'): output = '' for i in range(1, amount + 1): try: if rating == 'all': html = urllib.request.urlopen('https://habr.com/all/page' + ...
flexible
{ "blob_id": "d6cfea95c76021bdbfbb4471878c653564c9accd", "index": 1816, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getTitlesFromAll(amount, rating='all'):\n output = ''\n for i in range(1, amount + 1):\n try:\n if rating == 'all':\n html = urllib.request....
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def slices(series, length): if length <= 0: raise ValueError('Length has to be at least 1') elif length > len(series) or len(series) == 0: raise ValueError('Length has to be larger than len of series') elif length == len(series): ...
flexible
{ "blob_id": "207bb7c79de069ad5d980d18cdfc5c4ab86c5197", "index": 6544, "step-1": "<mask token>\n", "step-2": "def slices(series, length):\n if length <= 0:\n raise ValueError('Length has to be at least 1')\n elif length > len(series) or len(series) == 0:\n raise ValueError('Length has to be...
[ 0, 1, 2 ]
# You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e. 0 <= i < n). # In one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] # (i.e. perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the...
normal
{ "blob_id": "d67842c05af9241dbe7e038a9b2dc4223ee7ef4d", "index": 8055, "step-1": "<mask token>\n", "step-2": "def minOps(n):\n if n <= 1:\n return 0\n res = 0\n if n % 2 == 1:\n for i in range(1, n // 2 + 1):\n res += i * 2\n return res\n else:\n for j in rang...
[ 0, 1, 2, 3, 4 ]
from graphviz import Digraph from math import log2, ceil def hue_to_rgb(p, q, t): if t < 0: t += 1 if t > 1: t -= 1 if t < 1/6: return p + (q - p) * 6 * t if t < 1/2: return q if t < 2/3: return p + (q - p) * (2/3 - t) * 6 return p def hsl_to_rgb(h, s, l): h /= 360 q = l * (1 + s) if l...
normal
{ "blob_id": "881afd6877508243fa5056d2a82d88ba69ffb8c0", "index": 7801, "step-1": "<mask token>\n\n\nclass Node:\n\n def __init__(self, val, children=None, parent=None):\n self.id = str(val)\n self.val = val\n self.parent = parent\n self.depth = -1\n self.size = -1\n s...
[ 21, 22, 25, 29, 33 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def getData(): weather_data = pd.read_csv('data/weather_data.csv') currentMonth = datetime.now().month currentHour = datetime.now().hour currentMonthGroup = currentMonth // 2 hoep_data = [] temp = weather...
flexible
{ "blob_id": "7a1bd2b4734527a414c6173ea8edb150221f8042", "index": 363, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getData():\n weather_data = pd.read_csv('data/weather_data.csv')\n currentMonth = datetime.now().month\n currentHour = datetime.now().hour\n currentMonthGroup = current...
[ 0, 1, 2, 3 ]
import logging from typing import Sequence from django.core.exceptions import ValidationError from django.db import IntegrityError from django.db.models import F, Q from django.utils import timezone from sentry_sdk import capture_exception from sentry.models import ( Environment, Project, Release, Rel...
normal
{ "blob_id": "eb4271aa5abe3ddc05048858205e6ef807a4f8ac", "index": 6863, "step-1": "<mask token>\n\n\n@instrumented_task(name=\n 'sentry.release_health.tasks.monitor_release_adoption', queue=\n 'releasemonitor', default_retry_delay=5, max_retries=5)\ndef monitor_release_adoption(**kwargs) ->None:\n metric...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- import scrapy class Heiyan2Spider(scrapy.Spider): name = 'heiyan2' allowed_domains = ['heiyan.com'] start_urls = ['http://heiyan.com/'] def parse(self, response): pass
normal
{ "blob_id": "d13c6d71bb871496b0c6ad2451a2f561484e7c68", "index": 9634, "step-1": "<mask token>\n\n\nclass Heiyan2Spider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Heiyan2Spider(scrapy.Spider):\n <mask token>\n <mask token...
[ 1, 2, 3, 4, 5 ]
#Multiple Word Palindromes #Ex 72 extended word = input("Word: ") new = [] o = [] r = [] #canceling out the spaces for i in range(len(word)): if word[i] in ".,?!" or word[i] == ' ': pass else: new.append(word[i]) #original for i in range(len(new)): o.append(new[i]) #reverse for i in range(...
normal
{ "blob_id": "c6ab82d7f59faeee2a74e90a96c2348b046d0889", "index": 7382, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(word)):\n if word[i] in '.,?!' or word[i] == ' ':\n pass\n else:\n new.append(word[i])\nfor i in range(len(new)):\n o.append(new[i])\nfor i in ra...
[ 0, 1, 2, 3 ]
#-*- coding: utf-8 -*- # Copyright (C) 2011 by # Jordi Torrents <jtorrents@milnou.net> # Aric Hagberg <hagberg@lanl.gov> # All rights reserved. # BSD license. import itertools import networkx as nx __author__ = """\n""".join(['Jordi Torrents <jtorrents@milnou.net>', 'Aric Hagb...
normal
{ "blob_id": "a21c132ba9f24ff2c695bf66cae074705025d6b1", "index": 8063, "step-1": "<mask token>\n\n\ndef cc_dot(nu, nv):\n return float(len(nu & nv)) / len(nu | nv)\n\n\ndef cc_max(nu, nv):\n return float(len(nu & nv)) / max(len(nu), len(nv))\n\n\n<mask token>\n\n\ndef average_clustering(G, nodes=None, mode...
[ 4, 8, 9, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def extractLetters(sourceFolder, trainRatio=0.8, destFolder= './data/separateLetters'): """ Parameters ---------- sourceFolder : string DESCRIPTION. trainRatio : float, optional DESCR...
flexible
{ "blob_id": "6109efeb3462ac2c5a94a68fbfa4f2f0617dd927", "index": 1221, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef extractLetters(sourceFolder, trainRatio=0.8, destFolder=\n './data/separateLetters'):\n \"\"\" \n\n Parameters\n ----------\n sourceFolder : string\n DESC...
[ 0, 1, 2, 3 ]
import csv import glob import random import sys from math import ceil, floor from os.path import basename, exists, dirname, isfile import numpy as np import keras from keras import Model, Input, regularizers from keras.layers import TimeDistributed, LSTMCell, Reshape, Dense, Lambda, Dropout, Concatenate from keras.cal...
normal
{ "blob_id": "c925bed2f4d8120e156caebbe8e6bf9d6a51ee37", "index": 3330, "step-1": "<mask token>\n\n\nclass VideoClassifier:\n\n def __init__(self, train_mode='late_fusion', video_model_path=None,\n time_step=16, base_path='/user/vlongobardi/AFEW/aligned/',\n feature_name='emobase2010_100', stride...
[ 7, 11, 13, 14, 18 ]
import pyaudio import numpy as np from collections import OrderedDict import utils class MasterPlayer(object): def __init__(self, volume=1., samplesPerSecond=44100): self.p = pyaudio.PyAudio() self.volume = volume self.samplesPerSecond = samplesPerSecond self.individual_callbacks =...
normal
{ "blob_id": "c4e4e54ac93c2acdbd3a1cd22b200341a6e45688", "index": 224, "step-1": "import pyaudio\nimport numpy as np\nfrom collections import OrderedDict\nimport utils\n\n\nclass MasterPlayer(object):\n def __init__(self, volume=1., samplesPerSecond=44100):\n self.p = pyaudio.PyAudio()\n self.vol...
[ 0 ]
#!/usr/bin/env python #------------------------------------------------------------------------------ # imsrg_pairing.py # # author: H. Hergert # version: 1.5.0 # date: Dec 6, 2016 # # tested with Python v2.7 # # Solves the pairing model for four particles in a basis of four doubly # degenerate states by me...
normal
{ "blob_id": "0eb86fc64b74c79cace838e2d71ed92533123229", "index": 9910, "step-1": "<mask token>\n\n\ndef ph_transform_2B(Gamma, bas2B, idx2B, basph2B, idxph2B):\n dim = len(basph2B)\n Gamma_ph = np.zeros((dim, dim))\n for i1, (a, b) in enumerate(basph2B):\n for i2, (c, d) in enumerate(basph2B):\n ...
[ 17, 18, 20, 21, 29 ]
import pytest from mine.models import Application class TestApplication: """Unit tests for the application class.""" app1 = Application("iTunes") app1.versions.mac = "iTunes.app" app2 = Application("HipChat") app3 = Application("Sublime Text") app3.versions.linux = "sublime_text" app4 = ...
normal
{ "blob_id": "f4df7688ed927e1788ada0ef11f528eab5a52282", "index": 4899, "step-1": "<mask token>\n\n\nclass TestApplication:\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 @pytest.mark.parametrize('string,applic...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def GE_pearson(this_looper, core_list=None): if core_list is None: core_list = np.unique(this_looper.tr.core_ids) name = this_looper.sim_name thtr = this_looper.tr mask = movie_frames.quantized_mask(this_looper).flatten() times = thtr.times[mask] + 0 times....
flexible
{ "blob_id": "0762c5bec2d796bb7888e3de45e29fb20f88f491", "index": 392, "step-1": "<mask token>\n\n\ndef GE_pearson(this_looper, core_list=None):\n if core_list is None:\n core_list = np.unique(this_looper.tr.core_ids)\n name = this_looper.sim_name\n thtr = this_looper.tr\n mask = movie_frames.q...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class SmallMobileNetV2(nn.Module): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class SmallMobileNetV2Part(nn.Module): def __init__(self, widen_factor=1.0, num_classes=68 * 2): super(SmallMobileNetV2Part, self).__init__(...
flexible
{ "blob_id": "be1638638c70cf761bf5d2f0eb474b44684dfa47", "index": 4657, "step-1": "<mask token>\n\n\nclass SmallMobileNetV2(nn.Module):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass SmallMobileNetV2Part(nn.Module):\n\n def __init__(self, widen_factor=1.0, num_classes=68 * 2):\n super(...
[ 7, 11, 13, 15, 17 ]
<|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": "b1d8a454e590dfa4afa257ca665376c320a4acb5", "index": 5264, "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 = [('CRUD', '000...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): dependencies = [(...
flexible
{ "blob_id": "afacc2c54584c070963c4cb3cabbae64bb0e3159", "index": 1858, "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 = [('course', '0...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python import utils def revcomp(s): comp = {'A':'T', 'T':'A', 'G':'C', 'C':'G'} return ''.join([comp[c] for c in reversed(s)]) def reverse_palindromes(s): results = [] l = len(s) for i in range(l): for j in range(4, 13): if i + j > l: continue ...
normal
{ "blob_id": "1f40c0ed8e449354a5a87ef18bb07978a9fb8a1c", "index": 3368, "step-1": "#!/usr/bin/env python\n\nimport utils\n\ndef revcomp(s):\n comp = {'A':'T', 'T':'A', 'G':'C', 'C':'G'}\n return ''.join([comp[c] for c in reversed(s)])\n\ndef reverse_palindromes(s):\n results = []\n l = len(s)\n for...
[ 0 ]
import common import student_code class bcolors: RED = "\x1b[31m" GREEN = "\x1b[32m" NORMAL = "\x1b[0m" def check_result(title, map1, map2): result=True print(title) for y in range(0,common.constants.MAP_HEIGHT): v="" for x in range(0,common.constants.MAP_WIDTH): if (map1[y][x]==map2[y]...
normal
{ "blob_id": "602d2c545c6e3eabe5c6285d2ab0c7f4216a00f5", "index": 1563, "step-1": "<mask token>\n\n\nclass bcolors:\n RED = '\\x1b[31m'\n GREEN = '\\x1b[32m'\n NORMAL = '\\x1b[0m'\n\n\ndef check_result(title, map1, map2):\n result = True\n print(title)\n for y in range(0, common.constants.MAP_HE...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def MLmodel(data): import pickle import numpy as np from google.cloud import storage storage_client = storage.Client() bucket = storage_client.get_bucket('testing-gcp-mandar') blob = bucket.blob('model.pkl') model_local = 'TwitterSA_model.pkl' blob.download...
flexible
{ "blob_id": "93a2385d9ebdbc1a7a88185c0a0d5d1f227e46a3", "index": 8159, "step-1": "<mask token>\n\n\ndef MLmodel(data):\n import pickle\n import numpy as np\n from google.cloud import storage\n storage_client = storage.Client()\n bucket = storage_client.get_bucket('testing-gcp-mandar')\n blob = ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(n): a = [] dcc.append(a) <|reserved_special_token_0|> for i in range(m): x = input().split(' ') a = int(x[0]) b = int(x[1]) available.append([a, b]) dcc[a - 1].append(b) dcc[b - 1].ap...
flexible
{ "blob_id": "062b6133ba4de24f7eaf041e4b6c039501b47b9a", "index": 8873, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n a = []\n dcc.append(a)\n<mask token>\nfor i in range(m):\n x = input().split(' ')\n a = int(x[0])\n b = int(x[1])\n available.append([a, b])\n dc...
[ 0, 1, 2, 3 ]
import configparser import shutil def get_imagemagick_path(): config = configparser.ConfigParser() config.read("settings/settings.ini") return config['commands'].get('convert', shutil.which("convert")) # try: # except KeyError: # EXIV2_PATH = shutil.which("exiv2")
normal
{ "blob_id": "5fa9c9908d4aea507cf0ca8287a6b8e5b391470a", "index": 9297, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_imagemagick_path():\n config = configparser.ConfigParser()\n config.read('settings/settings.ini')\n return config['commands'].get('convert', shutil.which('convert'))\...
[ 0, 1, 2, 3 ]