code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
from sqlalchemy.orm import Session
from fastapi import APIRouter, Depends, File
from typing import List
from ..models.database import ApiSession
from ..schemas.images_schema import ImageReturn
from . import image_service
router = APIRouter()
@router.get("/", response_model=List[ImageReturn])
def get_all_images(db: ... | normal | {
"blob_id": "874ca60749dba9ca8c8ebee2eecb1b80da50f11f",
"index": 3782,
"step-1": "<mask token>\n\n\n@router.get('/', response_model=List[ImageReturn])\ndef get_all_images(db: Session=Depends(ApiSession)):\n return image_service.get_all_images(db)\n\n\n@router.get('/{image_id}', response_model=ImageReturn)\nde... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def make_rules(folder):
rules_dictionary = {}
try:
path = os.path.join(os.getcwd(), 'rules', 'data', folder)
files = os.listdir(path)
except:
path = os.path.join(os.getcwd(), 'data', folder)
files = os.listdir(path)
short_files_rule = re.com... | flexible | {
"blob_id": "1bf9785135f6105301d02602e54cbbcbdd249144",
"index": 9283,
"step-1": "<mask token>\n\n\ndef make_rules(folder):\n rules_dictionary = {}\n try:\n path = os.path.join(os.getcwd(), 'rules', 'data', folder)\n files = os.listdir(path)\n except:\n path = os.path.join(os.getcwd... | [
4,
5,
7,
8,
9
] |
"""
Unit Tests for endpoints.py
"""
import unittest
import os # pylint: disable=unused-import
from mock import patch, call
from github_approval_checker.utils import util # pylint: disable=unused-import
from github_approval_checker.utils.github_handler import GithubHandler # pylint: disable=unused-import
from github... | normal | {
"blob_id": "7626202d1e3ec7321addbb028be2275b882efda2",
"index": 6453,
"step-1": "<mask token>\n\n\nclass EndpointsUnitTests(unittest.TestCase):\n <mask token>\n\n @patch('github_approval_checker.utils.util.verify_signature')\n @patch('github_approval_checker.api.endpoints.connexion')\n @patch('githu... | [
5,
6,
7,
8,
9
] |
from django.urls import path
from .authentication import GetToken, RegisterUserAPIView
from .resurses import *
urlpatterns = [
path('register/', RegisterUserAPIView.as_view()),
path('get/token/', GetToken.as_view()),
path('card/list/', ShowCardsAPIView.as_view()),
path('card/create/', CreateCardAPIVie... | normal | {
"blob_id": "aac334256c1e05ef33a54da19925911af6645a10",
"index": 9529,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('register/', RegisterUserAPIView.as_view()), path(\n 'get/token/', GetToken.as_view()), path('card/list/', ShowCardsAPIView.\n as_view()), path('card/create/', C... | [
0,
1,
2,
3
] |
from django.contrib import admin
from django.db import models
from tinymce.widgets import TinyMCE
from .models import UserInfo
# Register your models here.
class UserInfoAdmin(admin.ModelAdmin):
list_display=[
'user_name',
'user_profession',
'user_phone',
'user_email',
... | normal | {
"blob_id": "15134d7e4036c102bc9d2ba4d321fadd0467100f",
"index": 6637,
"step-1": "<mask token>\n\n\nclass UserInfoAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass UserInf... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class RemotePayView(TemplateView):
template_name = 'remotepay/pay.djhtml'
<|reserved_special_token_0|>
def pay_callback(request, checkoutid):
t = SumUpOnline.objects.get(transaction_id=checkoutid)
if t.status == 0 or t.status == 3:
return HttpResponseRedirect('/pay... | flexible | {
"blob_id": "731d2891bbc29879fd8900a11077c93550e4e88d",
"index": 4251,
"step-1": "<mask token>\n\n\nclass RemotePayView(TemplateView):\n template_name = 'remotepay/pay.djhtml'\n\n\n<mask token>\n\n\ndef pay_callback(request, checkoutid):\n t = SumUpOnline.objects.get(transaction_id=checkoutid)\n if t.st... | [
3,
4,
7,
8,
9
] |
from typing import List, Any, Callable, Iterable, TypeVar, Tuple
T = TypeVar('T')
def partition(pred: Callable[[T], bool], it: Iterable[T]) \
-> Tuple[List[T], List[T]]: ...
| normal | {
"blob_id": "8e443d136a4e9fcdd18a106192f9c097928b8c99",
"index": 7340,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef partition(pred: Callable[[T], bool], it: Iterable[T]) ->Tuple[List[T],\n List[T]]:\n ...\n",
"step-3": "<mask token>\nT = TypeVar('T')\n\n\ndef partition(pred: Callable[[T... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def simple_formatter(zipcode: str, address: str) ->str:
return f'{zipcode}は「{address}」です'
| flexible | {
"blob_id": "b1dce573e6da81c688b338277af214838bbab9dd",
"index": 8649,
"step-1": "<mask token>\n",
"step-2": "def simple_formatter(zipcode: str, address: str) ->str:\n return f'{zipcode}は「{address}」です'\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
# MolecularMatch API (MM-DATA) Python Example Sheet
# Based on documentation at https://api.molecularmatch.com
# Author: Shane Neeley, MolecularMatch Inc., Jan. 30, 2018
import requests
import json
import numpy as np
import sys
resourceURLs = {
"trialSearch": "/v2/search/trials",
"drugSearch": "/v2/search/drugs",
... | normal | {
"blob_id": "b4593b3229b88db26c5e200431d00838c357c8e0",
"index": 2359,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif apiKey == '<your api key>' and sys.argv[1]:\n apiKey = sys.argv[1]\n<mask token>\nprint(json.dumps(r.json()))\n<mask token>\nprint(r.json()['total'])\nfor i in np.arange(0, len(r.js... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def in_bound(dim, s):
"""Get inbound pixel coordinate for out-of-bound
Args:
dim (int): Image height or width
s (int): Coordinate
Returns:
int: Inbound
"""
if s <= -1:
return 0
elif s >= dim:
return dim - 1
else:
... | flexible | {
"blob_id": "591b1a2e245ae0f3c9b2a81769bbf5988574ed07",
"index": 8253,
"step-1": "<mask token>\n\n\ndef in_bound(dim, s):\n \"\"\"Get inbound pixel coordinate for out-of-bound\n\n Args:\n dim (int): Image height or width\n s (int): Coordinate \n\n Returns:\n int: Inbound\n \"\"\"... | [
8,
10,
13,
15,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [path('', view.enterMarks), path('MarkSheet', view.getMarks,
name='MarkSheet')]
<|reserved_special_token_1|>
from django.contrib import admin
from django.urls import path
from . import view
urlpatterns = [path... | flexible | {
"blob_id": "511c555c88fb646b7b87678044b43a5a623a5ac7",
"index": 4670,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', view.enterMarks), path('MarkSheet', view.getMarks,\n name='MarkSheet')]\n",
"step-3": "from django.contrib import admin\nfrom django.urls import path\nfrom . ... | [
0,
1,
2,
3
] |
"""
Stores custom FASTA sequences under a uuid in the database.
Part of the tables used for custom jobs.
"""
import uuid
from pred.webserver.errors import ClientException, ErrorType, raise_on_too_big_uploaded_data
from pred.queries.dbutil import update_database, read_database
from Bio import SeqIO
from io import String... | normal | {
"blob_id": "2e744c0cbddf64a9c538c9f33fa19ff78c515012",
"index": 6797,
"step-1": "<mask token>\n\n\nclass SequenceList(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def delete_old_and_unattached(cur... | [
8,
14,
15,
16,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(1, int(input()) + 1):
j = 1
while j < i:
print(j, end='')
j += 1
while i > 0:
print(i, end='')
i -= 1
print()
<|reserved_special_token_1|>
#!/bin/env python3
"""
ht... | flexible | {
"blob_id": "94cbd9554e3326897147dc417d9fc8f91974786a",
"index": 5098,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, int(input()) + 1):\n j = 1\n while j < i:\n print(j, end='')\n j += 1\n while i > 0:\n print(i, end='')\n i -= 1\n print()\n",
... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
add(2, 2)
sub(2, 3)
<|reserved_special_token_1|>
from package.pack import *
add(2, 2)
sub(2, 3)
| flexible | {
"blob_id": "9583a97ae4b1fbf5ecdf33d848b13bf0b28d2eb4",
"index": 2452,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadd(2, 2)\nsub(2, 3)\n",
"step-3": "from package.pack import *\nadd(2, 2)\nsub(2, 3)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
# Generated by Django 3.0.4 on 2020-03-11 17:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0003_auto_20200310_1620'),
]
operations = [
migrations.AddField(
model_name='tag',
name='name',
... | normal | {
"blob_id": "ab12468b1da20c896e3578091fd9ba245dcfa0a4",
"index": 1350,
"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', '000... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(int(c))
<|reserved_special_token_1|>
h = int(input())
a = int(input())
b = int(input())
c = (h - b + a - b - 1) // (a - b)
print(int(c))
| flexible | {
"blob_id": "eea962d6c519bee802c346fcf8d0c7410e00c30b",
"index": 9587,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(int(c))\n",
"step-3": "h = int(input())\na = int(input())\nb = int(input())\nc = (h - b + a - b - 1) // (a - b)\nprint(int(c))\n",
"step-4": null,
"step-5": null,
"step-ids"... | [
0,
1,
2
] |
<|reserved_special_token_0|>
def rectangular(f, a, b, n):
h = float(b - a) / n
result = f(a + 0.5 * h)
for i in range(1, n):
result += f(a + 0.5 * h + i * h)
result *= h
return result
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def trapezoi... | flexible | {
"blob_id": "4fbf5b4520aa4dca4c7cc80d56ba00f634d184bf",
"index": 3405,
"step-1": "<mask token>\n\n\ndef rectangular(f, a, b, n):\n h = float(b - a) / n\n result = f(a + 0.5 * h)\n for i in range(1, n):\n result += f(a + 0.5 * h + i * h)\n result *= h\n return result\n\n\n<mask token>\n",
... | [
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": "9b7601a5230bfd2370e73a71d141d6de68ade50f",
"index": 8972,
"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 = [('app01', '00... | [
0,
1,
2,
3,
4
] |
class Node(object):
<|reserved_special_token_0|>
class tree(object):
def __init__(self):
self.root = None
def insert(self, root, value):
if self.root == None:
self.root = Node(value)
elif value < root.data:
if root.left is None:
root.left =... | flexible | {
"blob_id": "64c32b3ada7fff51a7c4b07872b7688e100897d8",
"index": 81,
"step-1": "class Node(object):\n <mask token>\n\n\nclass tree(object):\n\n def __init__(self):\n self.root = None\n\n def insert(self, root, value):\n if self.root == None:\n self.root = Node(value)\n el... | [
7,
8,
9,
10,
11
] |
# MODULES
import sys
sys.path.append('~/Documents/Project_3/REPO')
from scipy import *
from scipy import linalg
import cPickle as pickle
import ConfigParser
import TobySpectralMethods as tsm
config = ConfigParser.RawConfigParser()
fp = open('config.cfg')
config.readfp(fp)
N = config.getint('General', 'N')
M = config.... | normal | {
"blob_id": "1221394dfb97cbbfb00b412f60d4df521acc1262",
"index": 8029,
"step-1": "\n# MODULES\nimport sys\nsys.path.append('~/Documents/Project_3/REPO')\nfrom scipy import *\nfrom scipy import linalg\nimport cPickle as pickle\nimport ConfigParser\nimport TobySpectralMethods as tsm\n\nconfig = ConfigParser.RawCon... | [
0
] |
class CustomPrinter(object):
<|reserved_special_token_0|>
def to_string(self):
res = '{'
for m in xrange(64):
res += hex(int(self.val[m]))
if m != 63:
res += ', '
res += ' }'
return res
<|reserved_special_token_0|>
<|reserved_special_t... | flexible | {
"blob_id": "4d5b2ed016cfc6740c3ee5397c894fabc1bec73f",
"index": 6963,
"step-1": "class CustomPrinter(object):\n <mask token>\n\n def to_string(self):\n res = '{'\n for m in xrange(64):\n res += hex(int(self.val[m]))\n if m != 63:\n res += ', '\n re... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('데이터 셋 크기:', iris['data'].shape)
<|reserved_special_token_0|>
print(type(data1))
<|reserved_special_token_0|>
print(df)
<|reserved_special_token_0|>
print('데이터셋 내용:\n', iris['data'][:7, :])
<|reserved_special_token_0|>
print... | flexible | {
"blob_id": "dc2c9293040204f0ec2156c41b8be624f4e5cf99",
"index": 8389,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('데이터 셋 크기:', iris['data'].shape)\n<mask token>\nprint(type(data1))\n<mask token>\nprint(df)\n<mask token>\nprint('데이터셋 내용:\\n', iris['data'][:7, :])\n<mask token>\nprint('데이터 프레임의 형... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
@click.command()
@click.option('-s', '--batch-size', 'batch_size', default=50)
def analyze(batch_size):
db = db_connect()
db_ensure_init(db)
cmd = db.execute('SELECT id, url FROM reports WHERE is_analyzed = 0')
for batch in iter(lambda : cmd.fetchmany(batch_size), []):
... | flexible | {
"blob_id": "88e4e6647d4720d1c99f3e3438100790903921b5",
"index": 9163,
"step-1": "<mask token>\n\n\n@click.command()\n@click.option('-s', '--batch-size', 'batch_size', default=50)\ndef analyze(batch_size):\n db = db_connect()\n db_ensure_init(db)\n cmd = db.execute('SELECT id, url FROM reports WHERE is_... | [
3,
6,
9,
10,
13
] |
from django.db import transaction
from django.forms import inlineformset_factory
from django.shortcuts import render
from django.urls import reverse_lazy
from django.views.generic import CreateView, UpdateView
from forms.models.fund_operation import FundOperation
from forms.forms.fund_operation_forms import FundOperati... | normal | {
"blob_id": "3c2fb3d09edab92da08ac8850f650a2fa22fad92",
"index": 8806,
"step-1": "<mask token>\n\n\nclass FundOperationCreateView(CreateView):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def form_valid(self, form):\n context = self.get_context_data()\n ... | [
9,
10,
11,
12,
14
] |
#!/usr/bin/env python
# coding: utf-8
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(
host = '192.168.10.28'
))
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='',
routing_key='hello',
body='... | normal | {
"blob_id": "a9a60d4bee45a4012d004bacac7812160ed4241c",
"index": 4012,
"step-1": "#!/usr/bin/env python\n# coding: utf-8\n\nimport pika\n\nconnection = pika.BlockingConnection(pika.ConnectionParameters(\n host = '192.168.10.28'\n))\nchannel = connection.channel()\nchannel.queue_declare(queue='hello')\nchannel... | [
0
] |
# генераторы списков и словарей
# lists
my_list = [1, 2, 3, 4, 5]
new_list = []
for i in my_list:
new_list.append(i**2)
new_list_comp = [el**2 for el in my_list]
lines = [line.strip() for line in open("text.txt")]
new_list_1 = [el for el in my_list if el % 2 == 0]
str_1 = 'abc'
str_2 = 'def'
str_3 = 'gh'
new_... | normal | {
"blob_id": "e54eea2261517a2b15fde23c46b3fe75c0efec64",
"index": 7746,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in my_list:\n new_list.append(i ** 2)\n<mask token>\nprint(my_dict)\n<mask token>\nprint(new_list_round)\n",
"step-3": "my_list = [1, 2, 3, 4, 5]\nnew_list = []\nfor i in my_li... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def load_dataframe(dataset):
return pd.read_csv(dataset)
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def load_dataframe(dataset):
return pd.read_csv(dataset)
def augment(x, y, t=2):
xs, xn = [], []
for i in range(t):
... | flexible | {
"blob_id": "74c875d00c665aabbcad4e23e6059c3445d5e7bd",
"index": 1597,
"step-1": "<mask token>\n\n\ndef load_dataframe(dataset):\n return pd.read_csv(dataset)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef load_dataframe(dataset):\n return pd.read_csv(dataset)\n\n\ndef augment(x, y, t=2):\n xs... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def create_parser(parser_creator=None):
parser = make_parser(parser_creator=parser_creator, formatter_class=
argparse.RawDescriptionHelpFormatter, description=
'Train a reinforcement learning agent.', epilog=... | flexible | {
"blob_id": "79a8ff0000f3be79a62d693ed6bae7480673d970",
"index": 6075,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef create_parser(parser_creator=None):\n parser = make_parser(parser_creator=parser_creator, formatter_class=\n argparse.RawDescriptionHelpFormatter, description=\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class article(models.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_... | flexible | {
"blob_id": "31801f62942337b0cdf0e022dc75a9e125be54e3",
"index": 4191,
"step-1": "<mask token>\n\n\nclass article(models.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\n def __str__(sel... | [
5,
7,
9,
10,
11
] |
from django.db import models
from django.urls import reverse
from django.conf import settings
from embed_video.fields import EmbedVideoField
from django.contrib.auth.models import AbstractBaseUser
User = settings.AUTH_USER_MODEL
# Create your models here.
"""class User(models.Model):
username = models.CharField(... | normal | {
"blob_id": "5c4a48de94cf5bfe67e6a74c33a317fa1da8d2fa",
"index": 7330,
"step-1": "<mask token>\n\n\nclass Post(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n ordering = ['parent_id', 'created_at']\n <mask token>\n <mask... | [
3,
7,
8,
9,
10
] |
import pandas as pd
import tensorflow as tf
import autokeras as ak
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import tensorflow as tf
from numpy import concatenate
from pandas import read_csv, DataFrame, concat
from sklearn.preprocessing import MinMaxScaler
np.set_printoptions(... | normal | {
"blob_id": "013189cd67cc44efd539c75ed235a0753d95f54e",
"index": 2165,
"step-1": "<mask token>\n\n\ndef getData():\n power_file = './data/power_20210129_20210429_preprocess_1hour'\n power_df = read_csv(power_file + '.csv', encoding='CP949', converters={\n 'date': int})\n print(power_df.shape)\n ... | [
1,
2,
3,
4,
5
] |
from setuptools import setup, find_packages
setup(
name='testspace-python',
version='',
packages=find_packages(include=['testspace', 'testspace.*']),
url='',
license="MIT license",
author="Jeffrey Schultz",
author_email='jeffs@s2technologies.com',
description="Module for interacting wit... | normal | {
"blob_id": "7bc2a02d85c3b1a2b7ed61dc7567d1097b63d658",
"index": 3559,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='testspace-python', version='', packages=find_packages(include=[\n 'testspace', 'testspace.*']), url='', license='MIT license', author=\n 'Jeffrey Schultz', author_email=... | [
0,
1,
2,
3
] |
from django.apps import AppConfig
class ProjectrolesConfig(AppConfig):
name = 'projectroles'
| normal | {
"blob_id": "6a4585e0e2f5ebbd0f9a7fa203f76bb88ff9c2a0",
"index": 2920,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ProjectrolesConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ProjectrolesConfig(AppConfig):\n name = 'projectroles'\n",
"step-4": "from django.... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def str_or_none(v):
if v is None:
return None
if v.lower() == 'none':
return None
else:
return v
<|reserved_special_token_0|>
def name2dic(s):
return {x.split('-')[0]: x.split('-')[1] for x in s.split('_')}
<|reserved_special_token_0|>
def l... | flexible | {
"blob_id": "a9302dbf724f9548411fbf2959f36b4cc5742ff8",
"index": 4999,
"step-1": "<mask token>\n\n\ndef str_or_none(v):\n if v is None:\n return None\n if v.lower() == 'none':\n return None\n else:\n return v\n\n\n<mask token>\n\n\ndef name2dic(s):\n return {x.split('-')[0]: x.sp... | [
5,
8,
9,
12,
13
] |
import matplotlib.pyplot as plt
x_int = list(range(1, 5001))
y_int = [i**3 for i in x_int]
plt.scatter(x_int, y_int, c=y_int, cmap=plt.cm.Blues, s=40)
plt.show()
| normal | {
"blob_id": "40e2b695d8aaaa82cb90694b85d12061b4e6eca8",
"index": 8034,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nplt.scatter(x_int, y_int, c=y_int, cmap=plt.cm.Blues, s=40)\nplt.show()\n",
"step-3": "<mask token>\nx_int = list(range(1, 5001))\ny_int = [(i ** 3) for i in x_int]\nplt.scatter(x_int, ... | [
0,
1,
2,
3,
4
] |
from flask import Flask
from raven.contrib.flask import Sentry
from flask.signals import got_request_exception
app = Flask(__name__)
sentry = Sentry(dsn=app.config['SENTRY_DSN'])
@got_request_exception.connect
def log_exception_to_sentry(app, exception=None, **kwargs):
"""
Logs an exception to sentry.
:p... | normal | {
"blob_id": "f739fb56eae1ada2409ef7d75958bad2018f5134",
"index": 2743,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@got_request_exception.connect\ndef log_exception_to_sentry(app, exception=None, **kwargs):\n \"\"\"\n Logs an exception to sentry.\n\n :param app: The current application\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def get_new_message_list(channel_id: int):
with Connection() as cn:
token, channel = cn.s.query(SlackChannel.token, SlackChannel.channel
).filter(SlackChannel.id == channel_id).one()
user_dict = {... | flexible | {
"blob_id": "2b141f12bec2006e496bf58a3fcb0167c95ab3b6",
"index": 2530,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_new_message_list(channel_id: int):\n with Connection() as cn:\n token, channel = cn.s.query(SlackChannel.token, SlackChannel.channel\n ).filter(SlackChann... | [
0,
1,
2,
3,
4
] |
class SlackEvent:
@property
def client_msg_id(self):
pass
@property
def type(self):
pass
@property
def subtype(self):
pass
@property
def text(self):
pass
@property
def time_stamp(self):
pass
@property
def ... | normal | {
"blob_id": "4a4745f202275e45fd78c12431e355fd59ac964a",
"index": 6722,
"step-1": "class SlackEvent:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @property\n def time_stamp(self):\n pass\n\n @property\n def channel(self):\n pass\n <mask token>\n\n @pr... | [
8,
10,
15,
17,
20
] |
import src.engine.functions.root_analyzer.main as main
from src.engine.functions.function import Function
class GetRootData(Function):
def __init__(self, data_display):
self.data_display = data_display
def call(self, args):
image_folder_path = args[0]
output_path = args[1]
sel... | normal | {
"blob_id": "e8ea307352805bf0b5129e2ad7f7b68c44e78fc9",
"index": 9118,
"step-1": "<mask token>\n\n\nclass GetRootData(Function):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass GetRootData(Function):\n\n def __init__(self, data_display):\n self.data_display = data_display\n... | [
1,
2,
3,
4,
5
] |
from typing import Tuple
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def lcaDeepestLeaves(self, root: TreeNode) ->TreeNode:
_, lca = self.get_lca(root, 0)
return lca
def get_lca(self, node: TreeNode, de... | normal | {
"blob_id": "0a528fb7fe4a318af8bd3111e8d67f6af6bd7416",
"index": 304,
"step-1": "<mask token>\n\n\nclass Solution:\n\n def lcaDeepestLeaves(self, root: TreeNode) ->TreeNode:\n _, lca = self.get_lca(root, 0)\n return lca\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass TreeNode:\n <m... | [
2,
4,
5,
6
] |
from sys import stdin
def main():
lines = stdin
n, k = map(int, lines.next().split())
if k > n:
print -1
else:
arr = map(int, lines.next().split())
arr.sort(reverse = True)
print "%d %d" % (arr[k - 1], arr[k - 1])
main()
| normal | {
"blob_id": "fc04623db0d07f3a0a55ad49a74643a74e5203a6",
"index": 4938,
"step-1": "from sys import stdin\n\ndef main():\n lines = stdin\n n, k = map(int, lines.next().split())\n\n if k > n:\n print -1\n else:\n arr = map(int, lines.next().split())\n arr.sort(reverse = True)\n print \"%d %d\" % (ar... | [
0
] |
sentence = input()
check_list = ["U", "C", "P", "C"]
check = True
for i in range(len(check_list)):
if check_list[i] in sentence:
check = True
idx = sentence.find(check_list[i])
sentence = sentence[idx+1:]
else:
check = False
break
if check == True:
print("I love UCP... | normal | {
"blob_id": "4545d9756d1f396ead0b0c75d319fb6a718375cd",
"index": 2108,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(len(check_list)):\n if check_list[i] in sentence:\n check = True\n idx = sentence.find(check_list[i])\n sentence = sentence[idx + 1:]\n else:\n ... | [
0,
1,
2,
3
] |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
# Copyright (c) 2018 Juniper Networks, Inc.
# All rights reserved.
# Use is subject to license terms.
#
# Author: cklewar
import os
import threading
import time
from jnpr.junos import Device
from jnpr.junos import exception
from jnpr.junos.utils.config im... | normal | {
"blob_id": "45cdf33f509e7913f31d2c1d6bfada3a84478736",
"index": 2904,
"step-1": "<mask token>\n\n\nclass SoftwareTask(Task):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, sample_device=None, shared=None):\n super(SoftwareTask, self).__... | [
9,
10,
11,
12,
13
] |
#!/usr/bin/env python
import webapp2 # web application framework
import jinja2 # template engine
import os # access file system
import csv
from google.appengine.api import users # Google account authentication
from google.appengine.ext import db # datastore
# initialise template
jinja_environment = jinja2.Envir... | normal | {
"blob_id": "aeef27d667f95e3818f73533439385ea949b96a4",
"index": 2445,
"step-1": "<mask token>\n\n\nclass Submit(webapp2.RequestHandler):\n <mask token>\n\n def post(self):\n if self.request.get('submit'):\n updated_handphone = self.request.get('handphone')\n updated_tickets_cs... | [
2,
8,
11,
12,
13
] |
import pandas as pd #@UnusedImport
import matplotlib.pyplot as plt
import matplotlib #@UnusedImport
import numpy as np #@UnusedImport
class Plotter():
def __init__(self):
self.red_hex_code = '#ff0000'
def AlkDMIonStatsSplitPlot(self, df):
PV1_DataSets_lst = df[df['inst'] == 'PV1']['DataSet'].unique()
... | normal | {
"blob_id": "81b920ab5417937dc0fc1c9675d393efc6a4d58d",
"index": 5453,
"step-1": "<mask token>\n\n\nclass Plotter:\n\n def __init__(self):\n self.red_hex_code = '#ff0000'\n\n def AlkDMIonStatsSplitPlot(self, df):\n PV1_DataSets_lst = df[df['inst'] == 'PV1']['DataSet'].unique()\n PV2_Da... | [
5,
6,
8,
9,
10
] |
import math
def sieve(n):
sieve = [1] * (n+1)
sieve[1] = 0
sieve[0] = 0
for i in range(2, int(math.sqrt(n) + 1)):
if sieve[i] == 1:
for j in range(i*i, n + 1, i):
sieve[j] = 0
return sieve
def odd_prime(a):
while a != 0:
y = a % 10
if y == 3 ... | normal | {
"blob_id": "60617ff6eda880e5467b3b79d3df13a7147f5990",
"index": 3329,
"step-1": "<mask token>\n\n\ndef sieve(n):\n sieve = [1] * (n + 1)\n sieve[1] = 0\n sieve[0] = 0\n for i in range(2, int(math.sqrt(n) + 1)):\n if sieve[i] == 1:\n for j in range(i * i, n + 1, i):\n ... | [
2,
3,
4,
5,
6
] |
class Foo:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def __setitem__(self, key, value):
print(key, value)
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Foo:
def __init__(self, name, age):
self.name = name
s... | flexible | {
"blob_id": "d4b9403366a16dfbb12a2161a996e641b3a785a5",
"index": 8027,
"step-1": "class Foo:\n <mask token>\n <mask token>\n\n def __setitem__(self, key, value):\n print(key, value)\n <mask token>\n\n\n<mask token>\n",
"step-2": "class Foo:\n\n def __init__(self, name, age):\n self... | [
2,
4,
6,
7,
8
] |
from base import *
try:
from .prod_local import *
except:
pass
# we currently don't have an interface that allows an administrator
# to create a repository for another user. Until we have added this
# capability, allow users to create repos.
ELEMENTARY_ALLOW_REPO_CREATION = True
| normal | {
"blob_id": "709271b98fc2b40c763522c54488be36968f02d8",
"index": 346,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n from .prod_local import *\nexcept:\n pass\n<mask token>\n",
"step-3": "<mask token>\ntry:\n from .prod_local import *\nexcept:\n pass\nELEMENTARY_ALLOW_REPO_CREATION =... | [
0,
1,
2,
3,
4
] |
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
# 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/LICEN... | normal | {
"blob_id": "de704bffe2e23a8a83d34204e325b7fb2454ef66",
"index": 133,
"step-1": "<mask token>\n\n\ndef build_recursive_traversal_spec(client_factory):\n rp_to_rp = client_factory.create('ns0:TraversalSpec')\n rp_to_rp.name = 'rpToRp'\n rp_to_rp.type = 'ResourcePool'\n rp_to_rp.path = 'resourcePool'\n... | [
14,
18,
20,
22,
23
] |
<|reserved_special_token_0|>
class CLI(object):
<|reserved_special_token_0|>
def hw2p2(self):
parser = argparse.ArgumentParser()
parser.add_argument('-s', type=str, default=None)
args = parser.parse_args(sys.argv[2:])
hw2p2.submit(args.s)
<|reserved_special_token_0|>
<|res... | flexible | {
"blob_id": "0f74e0f0600c373c3ddd470f18dbb86cf213fb58",
"index": 9257,
"step-1": "<mask token>\n\n\nclass CLI(object):\n <mask token>\n\n def hw2p2(self):\n parser = argparse.ArgumentParser()\n parser.add_argument('-s', type=str, default=None)\n args = parser.parse_args(sys.argv[2:])\n... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class EntityEmailerInterface(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
@staticmethod
def convert_events_to_emails():
"""
Converts unseen events to emails and marks them as seen.
"""
email_medium = get_medium()
... | flexible | {
"blob_id": "d1dc807ecc92d9108db2c9bd00ee9781e174a1aa",
"index": 558,
"step-1": "<mask token>\n\n\nclass EntityEmailerInterface(object):\n <mask token>\n <mask token>\n\n @staticmethod\n def convert_events_to_emails():\n \"\"\"\n Converts unseen events to emails and marks them as seen.\... | [
2,
3,
4,
5,
6
] |
import NLC
app = NLC.create_app()
if __name__ == '__main__':
app.run(port=NLC.port, debug=True)
| normal | {
"blob_id": "de2de26d0c82213393e8174d1144c3510c63b899",
"index": 2515,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n app.run(port=NLC.port, debug=True)\n",
"step-3": "<mask token>\napp = NLC.create_app()\nif __name__ == '__main__':\n app.run(port=NLC.port, debug=True... | [
0,
1,
2,
3
] |
while True:
print("running")
| normal | {
"blob_id": "8917481957ecd4c9692cfa93df0b759feaa344af",
"index": 4944,
"step-1": "<mask token>\n",
"step-2": "while True:\n print('running')\n",
"step-3": "while True:\n print(\"running\")\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
<|reserved_special_token_0|>
class Environment:
@abstractmethod
def __init__(self, agent):
pass
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Environment:
@abstractmethod
... | flexible | {
"blob_id": "8698aedc5c8671f46c73898a7188440254b79bbf",
"index": 307,
"step-1": "<mask token>\n\n\nclass Environment:\n\n @abstractmethod\n def __init__(self, agent):\n pass\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Environment:\n\n @abstractme... | [
2,
4,
5,
6
] |
<|reserved_special_token_0|>
class Messenger:
<|reserved_special_token_0|>
def add_message(self, message):
self.message_manager.add(message)
@list_returner
def get_room_messages(self):
messages = []
i = 6
found_messages = []
for message in self.message_manager... | flexible | {
"blob_id": "4d1ea6522a01603f0159a1f27da70b65c4f387cb",
"index": 7093,
"step-1": "<mask token>\n\n\nclass Messenger:\n <mask token>\n\n def add_message(self, message):\n self.message_manager.add(message)\n\n @list_returner\n def get_room_messages(self):\n messages = []\n i = 6\n ... | [
5,
7,
8,
9
] |
<|reserved_special_token_0|>
class TestClass(unittest.TestCase):
<|reserved_special_token_0|>
def test_入力例_1(self):
input = '1 0 1\n2 1 2\n1 0 1'
output = 'Yes'
self.assertIO(input, output)
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_... | flexible | {
"blob_id": "8b97c1e14adfcb09806e2d37e2f5c4f0b356c009",
"index": 2742,
"step-1": "<mask token>\n\n\nclass TestClass(unittest.TestCase):\n <mask token>\n\n def test_入力例_1(self):\n input = '1 0 1\\n2 1 2\\n1 0 1'\n output = 'Yes'\n self.assertIO(input, output)\n <mask token>\n <mas... | [
2,
6,
8,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [path('list/', MusicListView, name='music_list'), path(
'play/<str:name>/', MusicPlayView, name='play_music'), path('pause/',
MusicPauseView, name='pause_music'), path('unpause/', MusicUnPauseView,
name='... | flexible | {
"blob_id": "f23b002ec0eefa376890e255b1ac0137e3a1c989",
"index": 5338,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('list/', MusicListView, name='music_list'), path(\n 'play/<str:name>/', MusicPlayView, name='play_music'), path('pause/',\n MusicPauseView, name='pause_music'), ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def euclidean_dist(a: pd.Series, b: pd.Series):
diff = a.sub(other=b)
squares = diff ** 2
dist = 0
for feature_distance in squares:
if not math.isnan(feature_distance):
dist += feature_distance
return math.sqrt(dist)
def choose_centroids(data_copy... | flexible | {
"blob_id": "46b51f46f6ed73e3b9dc2f759535ba71facd2aae",
"index": 5712,
"step-1": "<mask token>\n\n\ndef euclidean_dist(a: pd.Series, b: pd.Series):\n diff = a.sub(other=b)\n squares = diff ** 2\n dist = 0\n for feature_distance in squares:\n if not math.isnan(feature_distance):\n di... | [
4,
5,
6,
7,
8
] |
import tensorflow as tf
def makeMnistModel():
mnist = tf.keras.datasets.mnist
(X_train, y_train), (_, _) = mnist.load_data()
X_train = X_train / 255.0
model = tf.keras.models.Sequential([tf.keras.layers.Flatten(input_shape
=(28, 28)), tf.keras.layers.Dense(128, activation='relu'), tf.keras
... | normal | {
"blob_id": "1555583cd3d8938cbaeeac2d1f74bb9c3858f26d",
"index": 4207,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef makeMnistModel():\n mnist = tf.keras.datasets.mnist\n (X_train, y_train), (_, _) = mnist.load_data()\n X_train = X_train / 255.0\n model = tf.keras.models.Sequential([... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class SetupGuideLandingPageTests(WagtailPageTests):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class SetupGuidePageTests(WagtailPageTests):
def test_can_create_under_landing_page(self):
self.assertCanCreateAt(SetupGuideLandingPage, SetupGuidePage)
<... | flexible | {
"blob_id": "5fdcbccb99880da79eb0efbdecd328ca1cf73d7f",
"index": 1415,
"step-1": "<mask token>\n\n\nclass SetupGuideLandingPageTests(WagtailPageTests):\n <mask token>\n <mask token>\n\n\nclass SetupGuidePageTests(WagtailPageTests):\n\n def test_can_create_under_landing_page(self):\n self.assertCa... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [path('admin_panel/', views.AdminPanel.as_view(), name=
'admin_panel'), path('admin_panel/connection/', views.Connection.
as_view(), name='connect_group-teacher'), path(
'admin_panel/connection/<str:choic... | flexible | {
"blob_id": "34a7fd66a9e2eae25994336f22a76c24c11a6e1b",
"index": 7408,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('admin_panel/', views.AdminPanel.as_view(), name=\n 'admin_panel'), path('admin_panel/connection/', views.Connection.\n as_view(), name='connect_group-teacher'),... | [
0,
1,
2
] |
<|reserved_special_token_0|>
def rebin(*args, **kwargs):
"""
Rebin the map
"""
if len(args) > 0 and type(args[0]) == 'str' or 'input_filename' in kwargs:
func = mapfile_rebin
else:
func = array_rebin
return func(*args, **kwargs)
<|reserved_special_token_1|>
<|reserved_speci... | flexible | {
"blob_id": "18dc01f3e1672407800e53d80a85ffc8d5b86c17",
"index": 7497,
"step-1": "<mask token>\n\n\ndef rebin(*args, **kwargs):\n \"\"\"\n Rebin the map\n\n \"\"\"\n if len(args) > 0 and type(args[0]) == 'str' or 'input_filename' in kwargs:\n func = mapfile_rebin\n else:\n func = arr... | [
1,
3,
4,
5,
6
] |
smodelsOutput = {'OutputStatus': {'sigmacut': 0.01, 'minmassgap': 5.0,
'maxcond': 0.2, 'ncpus': 1, 'file status': 1, 'decomposition status': 1,
'warnings': 'Input file ok', 'input file':
'inputFiles/scanExample/slha/100968509.slha', 'database version':
'1.2.0', 'smodels version': '1.2.0rc'}, 'ExptRes': ... | normal | {
"blob_id": "94d303716eac7fa72370435fe7d4d1cdac0cdc48",
"index": 6151,
"step-1": "<mask token>\n",
"step-2": "smodelsOutput = {'OutputStatus': {'sigmacut': 0.01, 'minmassgap': 5.0,\n 'maxcond': 0.2, 'ncpus': 1, 'file status': 1, 'decomposition status': 1,\n 'warnings': 'Input file ok', 'input file':\n ... | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
SECRET_KEY = os.environ['SECRET_KEY']
ALLOWED_HOSTS = ['demo.pythonic.nl']
DEBUG = False
<|reserved_special_token_1|>
from .base import *
import os
SECRET_KEY = os.environ['SECRET_KEY']
ALLOWED_HOSTS = ['demo.pythonic.nl']
DEBU... | flexible | {
"blob_id": "e5607d9893b775b216d1790897124a673b190c26",
"index": 2085,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nSECRET_KEY = os.environ['SECRET_KEY']\nALLOWED_HOSTS = ['demo.pythonic.nl']\nDEBUG = False\n",
"step-3": "from .base import *\nimport os\nSECRET_KEY = os.environ['SECRET_KEY']\nALLOWED_... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class GroupSignature:
def __init__(self, groupObj):
global util, group
util = SecretUtil(groupObj, debug)
self.group = groupObj
def pkGen(self, h1str):
gstr = (
'[617277696811968416517029136812843365281763644817374909345702342494826038... | flexible | {
"blob_id": "a90b7e44cc54d4f96a13e5e6e2d15b632d3c4983",
"index": 290,
"step-1": "<mask token>\n\n\nclass GroupSignature:\n\n def __init__(self, groupObj):\n global util, group\n util = SecretUtil(groupObj, debug)\n self.group = groupObj\n\n def pkGen(self, h1str):\n gstr = (\n ... | [
10,
19,
22,
24,
31
] |
import numpy as np
import cv2
import skimage.color
import skimage.filters
import skimage.io
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
import pickle
from sklearn.base import BaseEstimator, ClassifierMixin
from sklearn.utils import check_random_state
from keras.preprocessing.i... | normal | {
"blob_id": "42ae3804c2d8f6a0d440e2bb6231186a868630b1",
"index": 2772,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Train Benign: ' + str(np.count_nonzero(Y_Train == 0)))\nprint('Train Malignant: ' + str(np.count_nonzero(Y_Train == 1)))\nprint('Test Benign: ' + str(np.count_nonzero(Y_Test == 0))... | [
0,
1,
2,
3,
4
] |
from flask import Flask, render_template, request
app = Flask(__name__)
def convert(decimal_num):
roman = {1000:'M', 900:'CM', 500:'D', 400:'CD', 100:'C', 90:'XC', 50:'L', 40:'XL', 10:'X', 9:'IX', 5:'V', 4:'IV', 1:'I'}
num_to_roman = ''
for i in roman.keys():
num_to_roman += roman[i]*(decimal_num/... | normal | {
"blob_id": "7025cc896035c59e0bbb7943493b6ca24fd9e6ca",
"index": 9429,
"step-1": "<mask token>\n\n\ndef convert(decimal_num):\n roman = {(1000): 'M', (900): 'CM', (500): 'D', (400): 'CD', (100): 'C',\n (90): 'XC', (50): 'L', (40): 'XL', (10): 'X', (9): 'IX', (5): 'V',\n (4): 'IV', (1): 'I'}\n ... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class Score(models.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": "8c166dd4cb091dcd2d80b5ae3085b5dee77564e0",
"index": 1227,
"step-1": "<mask token>\n\n\nclass Score(models.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",
"step-2": "<mask t... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
try:
import json
except ImportError:
import simplejson as json
<|reserved_special_token_0|>
if platform.system() == 'Linux':
def SubprocessPopen(k):
devnull = open(os.devnull, 'w')
proc = subprocess.Po... | flexible | {
"blob_id": "de819a72ab659b50620fad2296027cb9f4d3e4c0",
"index": 5048,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n import json\nexcept ImportError:\n import simplejson as json\n<mask token>\nif platform.system() == 'Linux':\n\n def SubprocessPopen(k):\n devnull = open(os.devnull... | [
0,
1,
2,
3,
4
] |
from urllib.parse import quote
from top_model import db
from top_model.ext.flask import FlaskTopModel
from top_model.filesystem import ProductPhotoCIP
from top_model.webstore import Product, Labo
from unrest import UnRest
class Hydra(FlaskTopModel):
def __init__(self, *args, **kwargs):
super().__init__(*... | normal | {
"blob_id": "de3a4053b5b0d4d2d5c2dcd317e64cf9b4faeb75",
"index": 562,
"step-1": "<mask token>\n\n\nclass Hydra(FlaskTopModel):\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self.config['CLIENT_ID'] = 4\n self.config['BASE_IMAGE_URL'\n ] = 'https... | [
3,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
class testVmIsAccessibleViaSsh(BasicVmLifecycleTestBase.
VmIsAccessibleViaSshTestBase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
clas... | flexible | {
"blob_id": "79e4e37fc17462508abf259e3a7861bd76797280",
"index": 9182,
"step-1": "<mask token>\n\n\nclass testVmIsAccessibleViaSsh(BasicVmLifecycleTestBase.\n VmIsAccessibleViaSshTestBase):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass testVmI... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
cursor.execute('INSERT INTO users VALUES(?,?,?)', (1, 'ilia', 'qwerty'))
<|reserved_special_token_0|>
cursor.executemany('INSERT INTO users VALUES(?,?,?)', users)
for row in cursor.execute('SELECT * FROM users'):
print(row)
co... | flexible | {
"blob_id": "d6b49533573dfefba6286ac2bffc2bd7a4075063",
"index": 1731,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncursor.execute('INSERT INTO users VALUES(?,?,?)', (1, 'ilia', 'qwerty'))\n<mask token>\ncursor.executemany('INSERT INTO users VALUES(?,?,?)', users)\nfor row in cursor.execute('SELECT * F... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def test_lex_comment_no_newline():
lexer = gherkin.Lexer(' test comment')
new_state = lexer.lex_comment_metadata_value()
lexer.tokens.should.equal([(1, gherkin.TOKEN_META_VALUE, 'test comment')])
new_state.should.equal(lexer.lex_text)
def test_lex_comment_until_newline()... | flexible | {
"blob_id": "44649e44da4eb80e7f869ff906798d5db493b913",
"index": 4415,
"step-1": "<mask token>\n\n\ndef test_lex_comment_no_newline():\n lexer = gherkin.Lexer(' test comment')\n new_state = lexer.lex_comment_metadata_value()\n lexer.tokens.should.equal([(1, gherkin.TOKEN_META_VALUE, 'test comment')])\n ... | [
23,
35,
36,
40,
42
] |
from collections import OrderedDict
import torch
from torch import nn, Tensor
import warnings
from typing import Tuple, List, Dict, Optional, Union
class GeneralizedRCNN(nn.Module):
def __init__(self, backbone, rpn, roi_heads, transform):
super(GeneralizedRCNN, self).__init__()
self.transform = t... | normal | {
"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
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def minOps(n):
if n <= 1:
return 0
res = 0
if n % 2 == 1:
for i in range(1, n // 2 + 1):
res += i * 2
return res
else:
for j in range(1, n // 2 + 1):
res += j * 2 - 1
return res
... | flexible | {
"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
] |
<|reserved_special_token_0|>
def calc_rec_area():
length = eval(input('Enter the length: '))
width = eval(input('Enter the width: '))
area = length * width
print('Area =', area)
def calc_rec_vol():
lengthh = eval(input('Enter the length: '))
widthh = eval(input('Enter the width: '))
heig... | flexible | {
"blob_id": "076e10b3741542b7137f6ac517dba482f545b123",
"index": 2154,
"step-1": "<mask token>\n\n\ndef calc_rec_area():\n length = eval(input('Enter the length: '))\n width = eval(input('Enter the width: '))\n area = length * width\n print('Area =', area)\n\n\ndef calc_rec_vol():\n lengthh = eval... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class SnakeGame(object):
<|reserved_special_token_0|>
def reset(self):
return SnakeGame._get_image(self.surface)
def step(self, key):
length = self.snake.length
for event in pygame.event.get():
if event.type == QUIT:
pygame... | flexible | {
"blob_id": "6d61df9ac072100d01a1ce3cf7b4c056f66a163c",
"index": 502,
"step-1": "<mask token>\n\n\nclass SnakeGame(object):\n <mask token>\n\n def reset(self):\n return SnakeGame._get_image(self.surface)\n\n def step(self, key):\n length = self.snake.length\n for event in pygame.eve... | [
3,
4,
5,
6
] |
#!/usr/bin/env python
import sys
import errno
# read first line from stdin and discard it
first_line = sys.stdin.readline()
# print all other lines
for line in sys.stdin:
try:
print line,
except IOError, e:
if e.errno == errno.EPIPE:
exit(0)
| normal | {
"blob_id": "bd06b04666ade1e7591b02f8211bc9b62fd08936",
"index": 791,
"step-1": "#!/usr/bin/env python\nimport sys\nimport errno\n\n# read first line from stdin and discard it\nfirst_line = sys.stdin.readline()\n\n# print all other lines\nfor line in sys.stdin:\n try:\n print line,\n except IOError,... | [
0
] |
<|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 = [m... | flexible | {
"blob_id": "84d9400dc4ee0bebce3f5f7da0bd77a280bb54a9",
"index": 8503,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [migrations.sw... | [
0,
1,
2,
3,
4
] |
import mechanicalsoup
from bs4 import BeautifulSoup
import re
import json
def extract_title(page):
return page.find("header").find("h1").contents[0]
def extract_colours(page):
color_list = page.find("ul")
return list(dict.fromkeys(re.findall("#\w+", str(color_list.contents))))
def get_colours_from_pa... | normal | {
"blob_id": "9fd33089a9dc919ef2fb2698059e60a24a0e05e6",
"index": 6118,
"step-1": "<mask token>\n\n\ndef extract_title(page):\n return page.find('header').find('h1').contents[0]\n\n\ndef extract_colours(page):\n color_list = page.find('ul')\n return list(dict.fromkeys(re.findall('#\\\\w+', str(color_list... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
configuration = Configuration()
<|reserved_special_token_1|>
<|reserved_special_token_0|>
from __future__ import absolute_import
from .models.basic_channel_info import BasicChannelInfo
from .models.basic_follower_info import Ba... | flexible | {
"blob_id": "939011fca968d5f9250beb29a0bb700200e637df",
"index": 6274,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nconfiguration = Configuration()\n",
"step-3": "<mask token>\nfrom __future__ import absolute_import\nfrom .models.basic_channel_info import BasicChannelInfo\nfrom .models.basic_follower... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
@_Proveedor.route('/Proveedor', methods=['GET', 'POST'])
def proveedor():
frm = form.Fr_Proveedor(request.form)
if request.method == 'POST':
pr = Proveedor.query.filter_by(CI=frm.CI.data).first()
if frm.validate() and pr is None:
new_user = Proveedor(ra... | flexible | {
"blob_id": "99ecb927e22bc303dd9dffd2793887e7398dbb83",
"index": 3649,
"step-1": "<mask token>\n\n\n@_Proveedor.route('/Proveedor', methods=['GET', 'POST'])\ndef proveedor():\n frm = form.Fr_Proveedor(request.form)\n if request.method == 'POST':\n pr = Proveedor.query.filter_by(CI=frm.CI.data).first... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class LinearRegression:
def __init__(self):
self.coef_ = None
self.interception_ = None
self._theta = None
<|reserved_special_token_0|>
def fit_gd(self, X_train, y_train, eta=0.01, n_iter=10000.0):
assert X_train.shape[0] == y_train.shape[0], ... | flexible | {
"blob_id": "e47e614c88c78fb6e8ff4098ea2b89d21bfa9684",
"index": 6935,
"step-1": "<mask token>\n\n\nclass LinearRegression:\n\n def __init__(self):\n self.coef_ = None\n self.interception_ = None\n self._theta = None\n <mask token>\n\n def fit_gd(self, X_train, y_train, eta=0.01, n_... | [
5,
7,
8,
9,
10
] |
import sys
sys.stdin = open('10989.txt', 'r')
counting_list = [0 for _ in range(10001)]
N = int(sys.stdin.readline())
for n in range(N):
counting_list[int(sys.stdin.readline())] += 1
for i, v in enumerate(counting_list):
if v:
sys.stdout.write((str(i) + '\n') * v)
| normal | {
"blob_id": "efca954e1977a6f6ac9a966b3c84ba80f5b7a663",
"index": 690,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor n in range(N):\n counting_list[int(sys.stdin.readline())] += 1\nfor i, v in enumerate(counting_list):\n if v:\n sys.stdout.write((str(i) + '\\n') * v)\n",
"step-3": "<ma... | [
0,
1,
2,
3,
4
] |
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
POWER_PIN = 21
SPICLK = 18
SPIMISO = 23
SPIMOSI = 24
SPICS = 25
PAUSE = 0.1
# read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
def readadc(adcnum, clockpin, mosipin, misopin, cspin):
if ((adcnum > 7) or (adcnum < 0)):
ret... | normal | {
"blob_id": "fcdb43e36a4610ca0201a27d82b1a583f1482878",
"index": 8924,
"step-1": "<mask token>\n\n\ndef readadc(adcnum, clockpin, mosipin, misopin, cspin):\n if adcnum > 7 or adcnum < 0:\n return -1\n GPIO.output(cspin, True)\n GPIO.output(clockpin, False)\n GPIO.output(cspin, False)\n comm... | [
4,
5,
6,
7,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
cmdline.execute('scrapy crawl rapo.com'.split())
<|reserved_special_token_1|>
from scrapy import cmdline
cmdline.execute('scrapy crawl rapo.com'.split())
<|reserved_special_token_1|>
from scrapy import cmdline
cmdline.execut... | flexible | {
"blob_id": "326f1b5bee8f488382a76fcc5559f4ea13734f21",
"index": 6551,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncmdline.execute('scrapy crawl rapo.com'.split())\n",
"step-3": "from scrapy import cmdline\ncmdline.execute('scrapy crawl rapo.com'.split())\n",
"step-4": "from scrapy import cmdline\... | [
0,
1,
2,
3
] |
import serial
from settings import *
class CommunicationController:
def __init__(self):
global board
board = serial.Serial(ROBOT_SERIAL, BAUDRATE, serial.EIGHTBITS, timeout=0)
self.count = 0
print("Communication controller")
def sendCommand(self, right, back, left):
self... | normal | {
"blob_id": "48291ab3deb1ca1ba672d3e642d55635a7270171",
"index": 955,
"step-1": "<mask token>\n\n\nclass CommunicationController:\n <mask token>\n\n def sendCommand(self, right, back, left):\n self.count += 1\n if self.count >= BUFFER_RESET_BOUND:\n board.reset_output_buffer()\n ... | [
2,
3,
4,
5,
6
] |
import os
import requests
from PIL import Image
from io import BytesIO
import csv
from typing import Iterable, List, Tuple, Dict, Callable, Union, Collection
# pull the image from the api endpoint and save it if we don't have it, else load it from disk
def get_img_from_file_or_url(img_format: str = 'JPEG') -> Callabl... | normal | {
"blob_id": "f2bb44600f011a205c71985ad94c18f7e058634f",
"index": 8,
"step-1": "<mask token>\n\n\ndef from_url(url: str) ->Image.Image:\n api_response = requests.get(url).content\n response_bytes = BytesIO(api_response)\n return Image.open(response_bytes)\n\n\ndef from_file(path: str) ->Union[Image.Image... | [
2,
3,
4,
5,
6
] |
#calss header
class _WATERWAYS():
def __init__(self,):
self.name = "WATERWAYS"
self.definitions = waterway
self.parents = []
self.childen = []
self.properties = []
self.jsondata = {}
self.basic = ['waterway']
| normal | {
"blob_id": "33daf5753b27f6b4bcb7c98e28cf2168e7f0b403",
"index": 9541,
"step-1": "<mask token>\n",
"step-2": "class _WATERWAYS:\n <mask token>\n",
"step-3": "class _WATERWAYS:\n\n def __init__(self):\n self.name = 'WATERWAYS'\n self.definitions = waterway\n self.parents = []\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Cell:
<|reserved_special_token_0|>
def reveal(self):
if not self.game.is_game_over:
self.revelada = True
if self.bombs_around == 0:
self.flood()
if self.bomba:
self.game.is_game_over = True
... | flexible | {
"blob_id": "e31f1e24c319f338d728661dfd50e758526112d6",
"index": 7796,
"step-1": "<mask token>\n\n\nclass Cell:\n <mask token>\n\n def reveal(self):\n if not self.game.is_game_over:\n self.revelada = True\n if self.bombs_around == 0:\n self.flood()\n i... | [
6,
9,
10,
11,
12
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
assert len(sys.argv) == 2
<|reserved_special_token_0|>
print("""Converting maggies from catalog
%s""" % fname)
<|reserved_special_token_0|>
np.savetxt('./output/maggies.txt', to_exp)
<|reserved_special_token_1|>
<|reserved_spe... | flexible | {
"blob_id": "e8971b3d183ded99a5fc03f031ef807280b8cc7f",
"index": 1744,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nassert len(sys.argv) == 2\n<mask token>\nprint(\"\"\"Converting maggies from catalog \n%s\"\"\" % fname)\n<mask token>\nnp.savetxt('./output/maggies.txt', to_exp)\n",
"step-3": "<mask t... | [
0,
1,
2,
3,
4
] |
'''
236. Lowest Common Ancestor of a Binary Tree
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia:
“The lowest common ancestor is defined between two nodes p... | normal | {
"blob_id": "ec9184fa3562ef6015801edf316faa0097d1eb57",
"index": 4821,
"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 postorder(self, node: 'TreeNode', p: 'TreeNode', q: 'TreeNode'\n ... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
import seaborn as sns
# In[2]:
df = pd.read_csv("ipl_matches.csv")
df.head()
# In[3]:
## -----data cleaning------
## remove unwanted columns
columns_to_remove = ['mid','batsman','bowler','striker','non-striker']
df.drop(la... | normal | {
"blob_id": "3b1b3cab1fa197f75812ca5b1f044909914212c0",
"index": 9050,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndf.head()\n<mask token>\ndf.drop(labels=columns_to_remove, axis=1, inplace=True)\ndf.head()\ndf['bat_team'].unique()\n<mask token>\ndf.head()\n<mask token>\ndf.head()\n<mask token>\ndf.he... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class MSITableColumnInfo(NamedTuple):
<|reserved_special_token_0|>
number: int
attributes: int
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
@property
def length(self) ->int:
... | flexible | {
"blob_id": "566dab589cdb04332a92138b1a1faf53cd0f58b8",
"index": 5419,
"step-1": "<mask token>\n\n\nclass MSITableColumnInfo(NamedTuple):\n <mask token>\n number: int\n attributes: int\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @property\n def length(self) ->int:\n... | [
14,
21,
22,
26,
27
] |
#!/usr/bin/python
# coding=utf-8
import time
import atexit
# for signal handling
import signal
import sys
# ----------------------
# Encoder stuff
# ----------------------
import RPi.GPIO as GPIO
# init
GPIO.setmode(GPIO.BCM) # use the GPIO names, _not_ the pin numbers on the board
# Raspberry Pi pin configuratio... | normal | {
"blob_id": "53841ba56589955e09b03018af1d0ae79b3756c4",
"index": 5595,
"step-1": "<mask token>\n\n\ndef leftEncoderCallback(answer):\n global leftSteps\n leftSteps = leftSteps + 1\n global leftDistance\n leftDistance = leftDistance + 0.24\n print('Left Encoder.')\n\n\ndef rightEncoderCallback(answ... | [
5,
7,
8,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(html.read())
<|reserved_special_token_1|>
<|reserved_special_token_0|>
username = ''
link = 'https://www.instagram.com/' + username
html = urllib.request.urlopen(link)
print(html.read())
<|reserved_special_token_1|>
im... | flexible | {
"blob_id": "db93de33f537eeaf64ca8e2b2b79aba1f592305b",
"index": 5434,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(html.read())\n",
"step-3": "<mask token>\nusername = ''\nlink = 'https://www.instagram.com/' + username\nhtml = urllib.request.urlopen(link)\nprint(html.read())\n",
"step-4": "i... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
admin.site.register(Contactus, ContactusAdmin),
admin.site.register(Company, CompanyAdmin),
admin.site.register(Products, ProductsAdmin),
admin.site.register(Brands, BrandsAdmin),
<|reserved_special_token_1|>
from django.contri... | flexible | {
"blob_id": "9586dc118be4388491770d823a38e8068e3b91cb",
"index": 5960,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(Contactus, ContactusAdmin),\nadmin.site.register(Company, CompanyAdmin),\nadmin.site.register(Products, ProductsAdmin),\nadmin.site.register(Brands, BrandsAdmin),\n",
... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from copy import copy
from openprocurement.api.utils import (
json_view,
context_unpack,
APIResource,
get_now,
)
from openprocurement.tender.core.utils import save_tender, apply_patch
from openprocurement.tender.core.validation import (
validate_requirement_data,
validat... | normal | {
"blob_id": "6194079dd506553b4e5b66f1fb92bb8642704b59",
"index": 6893,
"step-1": "<mask token>\n\n\nclass BaseTenderCriteriaRGRequirementResource(APIResource):\n <mask token>\n\n @json_view(permission='view_tender')\n def collection_get(self):\n return {'data': [i.serialize('view') for i in self.... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def test_norm_cdf_dartmouth():
"""
Examples taken from:
https://math.dartmouth.edu/archive/m20f12/public_html/matlabnormal
stored in literature directory as dartmouth_normcdf_norminv.pdf
"""
assert_almost_equal(0.0062, norm_cdf(90, 100, 4), decimal=4)
<|reserved_... | flexible | {
"blob_id": "0229783467b8bcd0361baf6be07e3261f34220c7",
"index": 6581,
"step-1": "<mask token>\n\n\ndef test_norm_cdf_dartmouth():\n \"\"\"\n Examples taken from:\n https://math.dartmouth.edu/archive/m20f12/public_html/matlabnormal\n stored in literature directory as dartmouth_normcdf_norminv.pdf\n ... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class _CallableObject(object):
def __init__(self):
self._lock = threading.Lock()
self._passed_values = []
def __call__(self, value):
with self._lock:
self._passed_values.append(value)
<|reserved_special_token_0|>
class LoggingPoolTest(un... | flexible | {
"blob_id": "049950bd4bbf7903218bb8fb3a4c91492d6af17b",
"index": 3252,
"step-1": "<mask token>\n\n\nclass _CallableObject(object):\n\n def __init__(self):\n self._lock = threading.Lock()\n self._passed_values = []\n\n def __call__(self, value):\n with self._lock:\n self._pas... | [
8,
10,
11,
12,
13
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.