code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
import torch.nn as nn from layers import maskAConv, MaskBConvBlock class PixelCNN(nn.Module): def __init__(self, n_channel=3, h=128, discrete_channel=256): """PixelCNN Model""" super(PixelCNN, self).__init__() self.discrete_channel = discrete_channel self.MaskAConv = maskAConv(n_...
normal
{ "blob_id": "3185b6b1902099caed66ce6f97cd1b9940261fc1", "index": 7533, "step-1": "<mask token>\n\n\nclass PixelCNN(nn.Module):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass PixelCNN(nn.Module):\n <mask token>\n\n def forward(self, x):\n \"\"\"\n Args:\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class TextSplitterConfig(BaseTextProcessorConfig): max_split_length: int = 512 split_stride: int = 0 document_id_key: Optional[str] class TextSplitter(BaseTextPreprocessor): def preprocess_input(self, input_list: List[TextPayload], config: TextSplitterConfig, **...
flexible
{ "blob_id": "151cc71ff1a63897238e2cc55269bd20cc6ee577", "index": 2336, "step-1": "<mask token>\n\n\nclass TextSplitterConfig(BaseTextProcessorConfig):\n max_split_length: int = 512\n split_stride: int = 0\n document_id_key: Optional[str]\n\n\nclass TextSplitter(BaseTextPreprocessor):\n\n def preproce...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> @click.command() @click.option('--fastq', help='FASTQ file to subset, can be compressed') @click.option('--subset', metavar='<INT>', help= 'Take every N reads (default:10)', default=10) @click.option('--log_file', metavar='<FILE>', default='./subset_fastq.log', help='File to write...
flexible
{ "blob_id": "873a53983e3aeb66bd290450fb9c15a552bd163c", "index": 4017, "step-1": "<mask token>\n\n\n@click.command()\n@click.option('--fastq', help='FASTQ file to subset, can be compressed')\n@click.option('--subset', metavar='<INT>', help=\n 'Take every N reads (default:10)', default=10)\n@click.option('--lo...
[ 1, 2, 3, 4, 5 ]
import logging class ConsoleLogger: handlers = [ (logging.StreamHandler, dict(), "[%(name)s]\t %(asctime)s [%(levelname)s] %(message)s ", logging.DEBUG) ] def set_level(self, level): self.logger.setLevel(level) def debug(self, message): self.logger...
normal
{ "blob_id": "5299f2c66fd287be667ecbe11b8470263eafab5c", "index": 702, "step-1": "<mask token>\n\n\nclass ConsoleLogger:\n <mask token>\n\n def set_level(self, level):\n self.logger.setLevel(level)\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __...
[ 3, 6, 7, 8, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> name = 'flask_gunicorn' workers = multiprocessing.cpu_count() * 2 + 1 loglevel = 'debug' bind = f'0.0.0.0:18080' <|reserved_special_token_1|> import multiprocessing name = 'flask_gunicorn' workers = multiprocessing.cpu_count() ...
flexible
{ "blob_id": "2ad326f739b42b9c7c252078b8c28e90da17b95d", "index": 1802, "step-1": "<mask token>\n", "step-2": "<mask token>\nname = 'flask_gunicorn'\nworkers = multiprocessing.cpu_count() * 2 + 1\nloglevel = 'debug'\nbind = f'0.0.0.0:18080'\n", "step-3": "import multiprocessing\nname = 'flask_gunicorn'\nworke...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('^$', jsonre_data), url('^serialize/$', SerializeView. as_view()), url('^serialize/$', SerializeView.as_view()), url('^all/$', Serializeall.as_view()), url('^cbv1/$', jsonView.as_view()), url( '^cbv2...
flexible
{ "blob_id": "b3b5f7eeb81e10a51eb0322bc5278d33ee5f8e97", "index": 9222, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^$', jsonre_data), url('^serialize/$', SerializeView.\n as_view()), url('^serialize/$', SerializeView.as_view()), url('^all/$',\n Serializeall.as_view()), url('^...
[ 0, 1, 2, 3 ]
from editor.editor import Editor e = Editor() e.showWindow()
normal
{ "blob_id": "46d6771fd9f589e2498cd019ba72232cbda06e5a", "index": 3108, "step-1": "<mask token>\n", "step-2": "<mask token>\ne.showWindow()\n", "step-3": "<mask token>\ne = Editor()\ne.showWindow()\n", "step-4": "from editor.editor import Editor\ne = Editor()\ne.showWindow()\n", "step-5": null, "step-id...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 import optparse from bs4 import BeautifulSoup import re import jieba import pickle import requests import asyncio if __name__ == '__main__': # 读取10000个关键词 fs = open("./src/keywords.txt", "rb") keywords = fs.read().decode("utf-8").split(",") fs.close() # 找出特征 def find_f...
normal
{ "blob_id": "88590aef975f7e473ef964ee0c4004cff7e24b07", "index": 1049, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n fs = open('./src/keywords.txt', 'rb')\n keywords = fs.read().decode('utf-8').split(',')\n fs.close()\n\n def find_features(doc):\n words = ...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """Part of speech mapping constants and functions for NLPIR/ICTCLAS. This module is used by :mod:`pynlpir` to format segmented words for output. """ import logging logger = logging.getLogger("pynlpir.pos_map") #: A dictionary that maps part of speech codes returned by NLPIR to #: human-read...
normal
{ "blob_id": "093b2afef7cdfb7070eb5e94e84624afe495db66", "index": 1948, "step-1": "<mask token>\n\n\ndef get_pos_name(code, name='parent', english=True, pos_tags=POS_MAP):\n \"\"\"Gets the part of speech name for *code*.\n\n :param str code: The part of speech code to lookup, e.g. ``'nsf'``.\n :param str...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sense.set_pixels(prenume) <|reserved_special_token_1|> <|reserved_special_token_0|> sense = SenseHat() b = 0, 0, 204 w = 255, 255, 255 e = 0, 0, 0 y = 255, 255, 0 r = 255, 0, 0 prenume = [e, e, e, e, e, e, e, e, e, e, e, e, e, ...
flexible
{ "blob_id": "b9eeccbed63aa42afa09fe7ef782066f300255a1", "index": 2173, "step-1": "<mask token>\n", "step-2": "<mask token>\nsense.set_pixels(prenume)\n", "step-3": "<mask token>\nsense = SenseHat()\nb = 0, 0, 204\nw = 255, 255, 255\ne = 0, 0, 0\ny = 255, 255, 0\nr = 255, 0, 0\nprenume = [e, e, e, e, e, e, e,...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(max(d1.values())) print(min(d1.values())) <|reserved_special_token_1|> d1 = {(6): 10, (2): 20, (5): 30, (4): 40, (1): 50, (3): 60} print(max(d1.values())) print(min(d1.values())) <|reserved_special_token_1|> #Write a P...
flexible
{ "blob_id": "53e397068fcf88bbbce4dcc1bf1b441a2fbbee48", "index": 2261, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(max(d1.values()))\nprint(min(d1.values()))\n", "step-3": "d1 = {(6): 10, (2): 20, (5): 30, (4): 40, (1): 50, (3): 60}\nprint(max(d1.values()))\nprint(min(d1.values()))\n", "step...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3.4 from flask import Flask, render_template, request, jsonify from time import time application = Flask(__name__) @application.route("/chutesnladders") @application.route("/cnl") @application.route("/snakesnladders") @application.route("/snl") def chutesnladders(): response = application.m...
normal
{ "blob_id": "a2c62091b14929942b49853c4a30b851ede0004b", "index": 4563, "step-1": "<mask token>\n\n\n@application.route('/chutesnladders')\n@application.route('/cnl')\n@application.route('/snakesnladders')\n@application.route('/snl')\ndef chutesnladders():\n response = application.make_response(render_template...
[ 1, 3, 4, 5, 6 ]
#!/usr/bin/python #import Bio def findLCS(read, cassette, rIndex, cIndex,cassettes): LCS='' while True: if read[rIndex] == cassette[cIndex]: LCS+= read[rIndex] rIndex= rIndex +1 cIndex= cIndex +1 #elif checkLCS(cIndex,cassettes)==True: else: break #print(LCS) ret...
normal
{ "blob_id": "5cec9e82aa994d07e25d8356a8218fc461bb8b4e", "index": 4728, "step-1": "def findLCS(read, cassette, rIndex, cIndex, cassettes):\n LCS = ''\n while True:\n if read[rIndex] == cassette[cIndex]:\n LCS += read[rIndex]\n rIndex = rIndex + 1\n cIndex = cIndex + 1...
[ 4, 5, 6, 7, 9 ]
# -*- encoding: utf-8 -*- from openerp.tests.common import TransactionCase from openerp.exceptions import ValidationError class GlobalTestOpenAcademySession(TransactionCase): ''' Global Test to openacademy session model. Test create session and trigger constraint ''' # Pseudo-constructor methods...
normal
{ "blob_id": "7edd833103e1de92e57559c8a75379c26266963b", "index": 7835, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass GlobalTestOpenAcademySession(TransactionCase):\n <mask token>\n\n def setUp(self):\n super(GlobalTestOpenAcademySession, self).setUp()\n self.session = self....
[ 0, 4, 5, 6, 7 ]
""" Given a random set of numbers, Print them in sorted order. Example 1: Input: N = 4 arr[] = {1, 5, 3, 2} Output: {1, 2, 3, 5} Explanation: After sorting array will be like {1, 2, 3, 5}. """ #complexity--> n*log n def sortarray(arr): for i in range(1,len(arr)): key=arr[i] j=i-1 while(j>...
normal
{ "blob_id": "70cef88f3fe93d370e5d21a2b00b761ce530a099", "index": 6366, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sortarray(arr):\n for i in range(1, len(arr)):\n key = arr[i]\n j = i - 1\n while j >= 0 and arr[j] > key:\n arr[j + 1] = arr[j]\n j ...
[ 0, 1, 2, 3 ]
class HashTable: def __init__(self): self.dados = [] def hash(self, chave): return int(chave) def __put(self, int, chave, valor): self.dados.append({chave: valor}) """ backup = dados dados = novo_array(t * 2) for elemento in backup: hash = hash(elemento.chave) __put(...
normal
{ "blob_id": "f14d46bedd5f6e0081a982251ad45e95860ef310", "index": 209, "step-1": "class HashTable:\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "class HashTable:\n <mask token>\n\n def hash(self, chave):\n return int(chave)\n <mask token>\n\n\n<mask token...
[ 1, 2, 3, 4, 5 ]
from django.shortcuts import render from django.views.generic import TemplateView from django.conf import settings import os, csv class InflationView(TemplateView): template_name = 'inflation.html' def get(self, request, *args, **kwargs): # чтение csv-файла и заполнение контекста context = {}...
normal
{ "blob_id": "6645887b25d75f4657fb231b80d8ebdec2bac7c9", "index": 8718, "step-1": "<mask token>\n\n\nclass InflationView(TemplateView):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass InflationView(TemplateView):\n <mask token>\n\n def get(self, request, *args, **kwargs):\n ...
[ 1, 2, 3, 4, 5 ]
from django import forms from .models import Diagnosis, TODOItem class DiagnosisForm(forms.ModelForm): class Meta: model = Diagnosis fields = ['name', 'Rostered_physician', 'condition', 'details', 'date_of_diagnosis', 'content'] class TODOItemForm(forms.ModelForm): class Meta...
normal
{ "blob_id": "aa6464c53176be9d89c6c06997001da2b3ee1e5c", "index": 6583, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TODOItemForm(forms.ModelForm):\n\n\n class Meta:\n model = TODOItem\n fields = ['job', 'due_date', 'medication_details', 'completed']\n", "step-3": "<mask tok...
[ 0, 1, 2, 3 ]
string="Rutuja MaluSare" print(string.casefold()) print(len(string)) """string1=input("enter string 1") print("string1") print(len(string1)) string2=input("enter string 2") print("string2") print(len(string2)) string3=string1+string2 print(len(string3))""" #lower case print(string.lower()) #upper case print(string...
normal
{ "blob_id": "024bc95f7255bb8be5c3c4ade9d212c9555a4f01", "index": 3034, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(string.casefold())\nprint(len(string))\n<mask token>\nprint(string.lower())\nprint(string.upper())\n<mask token>\nprint(a)\nprint(a.strip())\n<mask token>\nprint(b)\n", "step-3": ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class RDt(RPackage): <|reserved_special_token_0|> <|reserved_special_token_0|> version('0.23', sha256= '360ae2fcb1141125a1b16448570fc37d14c4dd3f78a872c26df4fda1787cdc70') version('0.20', sha256= 'c66d7f49ec101fdbb91c6d26c06fb1373f9ebdefe29fe99f2ae1a641220ab...
flexible
{ "blob_id": "c88e2336432f93d95b4e2285aa532b673a4a410b", "index": 1095, "step-1": "<mask token>\n\n\nclass RDt(RPackage):\n <mask token>\n <mask token>\n version('0.23', sha256=\n '360ae2fcb1141125a1b16448570fc37d14c4dd3f78a872c26df4fda1787cdc70')\n version('0.20', sha256=\n 'c66d7f49ec1...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Write: def __writeHeader(fd): """Write html header""" print('<!DOCTYPE html>', '<html>', ' <head>', ' <title>Super Tableau 3000</title>', " <meta charset='utf-8' />", ' <style>', ' table { border-collapse: collapse; }', ...
flexible
{ "blob_id": "cb77696a90716acdee83a1cf6162a8f42c524e11", "index": 7612, "step-1": "<mask token>\n\n\nclass Write:\n\n def __writeHeader(fd):\n \"\"\"Write html header\"\"\"\n print('<!DOCTYPE html>', '<html>', ' <head>',\n ' <title>Super Tableau 3000</title>',\n \" <meta c...
[ 8, 11, 12, 13, 16 ]
from setuptools import setup import os.path # Get the long description from the README file with open('README.rst') as f: long_description = f.read() setup(name='logging_exceptions', version='0.1.8', py_modules=['logging_exceptions'], author="Bernhard C. Thiel", author_email="thiel@tbi.un...
normal
{ "blob_id": "7f7adc367e4f3b8ee721e42f5d5d0770f40828c9", "index": 9365, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('README.rst') as f:\n long_description = f.read()\nsetup(name='logging_exceptions', version='0.1.8', py_modules=[\n 'logging_exceptions'], author='Bernhard C. Thiel', auth...
[ 0, 1, 2, 3 ]
i = 0 while i >= 0: a=input("Name is: ") print(a) if a == "Zeal": print("""Name_Zeal. Age_16. Interested in Programming.""") elif a=="HanZaw": print("""Name_Han Zaw. Age_18. Studying Code at Green Hacker.""") elif a == "Murphy": print("""Name_Murphy. ...
normal
{ "blob_id": "38184ed4117b1b7dcf9e135ce8612fa13c44a99c", "index": 5891, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile i >= 0:\n a = input('Name is: ')\n print(a)\n if a == 'Zeal':\n print('Name_Zeal.\\n Age_16.\\n Interested in Programming.')\n elif a == 'HanZaw':\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def run_bwa(reference_genome, forward_read, reverse_read, threads, output, i): """ Run bwa to align reads to reference genome """ print('Align reads with BWA MEM') bwa_index_args = ['bwa', 'index', reference_genome] process = subprocess.Popen(bwa_index_args, stdin=subproce...
flexible
{ "blob_id": "fdfb71595bf86fbe1763535814ec9c3cfd312d87", "index": 2722, "step-1": "<mask token>\n\n\ndef run_bwa(reference_genome, forward_read, reverse_read, threads, output, i):\n \"\"\" Run bwa to align reads to reference genome \"\"\"\n print('Align reads with BWA MEM')\n bwa_index_args = ['bwa', 'in...
[ 3, 4, 6, 7, 8 ]
#!/usr/bin/env python3 import sys import os import math import random if hasattr(sys, '__interactivehook__'): del sys.__interactivehook__ print('Python3 startup file loaded from ~/.config/pystartup.py')
normal
{ "blob_id": "5ddde3aa6eaa30b70743272a532874663067eed6", "index": 3157, "step-1": "<mask token>\n", "step-2": "<mask token>\nif hasattr(sys, '__interactivehook__'):\n del sys.__interactivehook__\nprint('Python3 startup file loaded from ~/.config/pystartup.py')\n", "step-3": "import sys\nimport os\nimport m...
[ 0, 1, 2, 3 ]
import shutil import tempfile import salt.runners.net as net from tests.support.mixins import LoaderModuleMockMixin from tests.support.mock import MagicMock from tests.support.runtests import RUNTIME_VARS from tests.support.unit import TestCase, skipIf @skipIf(not net.HAS_NAPALM, "napalm module required for this tes...
normal
{ "blob_id": "0fb288e3ab074e021ec726d71cbd5c8546a8455b", "index": 744, "step-1": "<mask token>\n\n\n@skipIf(not net.HAS_NAPALM, 'napalm module required for this test')\nclass NetTest(TestCase, LoaderModuleMockMixin):\n <mask token>\n <mask token>\n\n def test_interfaces(self):\n ret = net.interfac...
[ 5, 6, 8, 10, 11 ]
class Pwm(): def __init__(self, number, path, features): self.id = number self.path = path + 'pwm' + number self.features = features self.duty = self.get_feature('') self.enable = self.get_feature('_enable') def get_feature(self, feature): return self.features['pwm' + self.id + feature] def set_featu...
normal
{ "blob_id": "c38aff77a7beebc13e7486150d549b876c830db8", "index": 6104, "step-1": "class Pwm:\n\n def __init__(self, number, path, features):\n self.id = number\n self.path = path + 'pwm' + number\n self.features = features\n self.duty = self.get_feature('')\n self.enable = s...
[ 2, 3, 4, 5, 6 ]
# coding=utf-8 from __future__ import print_function import os import sys os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' basedir = os.getcwd() os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.path.append('trainer') sys.path.append('downloader') from gen.gen_captcha import gen_dataset, load_templates, candidates fr...
normal
{ "blob_id": "8e34b5e15c5b6107d6841e7b567abf967c631f1b", "index": 7440, "step-1": "<mask token>\n\n\ndef show_im(dataset):\n data = np.uint8(dataset[0]).reshape((30, 96)) * 255\n im = Image.fromarray(data)\n im.show()\n\n\ndef test_model(captcha):\n im = Image.open(os.path.join(basedir, 'downloader', ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def sieve(limit): numbers = list(range(3, limit, 2)) for prime in numbers: for multiplier in reversed(range(2, limit)): try: numbers.remove(prime * multiplier) except ValueError: pass ...
flexible
{ "blob_id": "ec7ca03f627eaa635aac56e302b9c40bf0a3da38", "index": 1796, "step-1": "<mask token>\n", "step-2": "def sieve(limit):\n numbers = list(range(3, limit, 2))\n for prime in numbers:\n for multiplier in reversed(range(2, limit)):\n try:\n numbers.remove(prime * mult...
[ 0, 1 ]
<|reserved_special_token_0|> def get_card_size(card_width, image): card_height = image.get_height() / (image.get_width() / card_width) return round(card_height) <|reserved_special_token_0|> def upload_card_images(card_name): card_n = pygame.image.load(os.path.join('images', card_name + '.png')) ca...
flexible
{ "blob_id": "9c478c59398618d0e447276f9ff6c1c143702f12", "index": 2360, "step-1": "<mask token>\n\n\ndef get_card_size(card_width, image):\n card_height = image.get_height() / (image.get_width() / card_width)\n return round(card_height)\n\n\n<mask token>\n\n\ndef upload_card_images(card_name):\n card_n =...
[ 6, 7, 8, 9, 10 ]
class Solution: def divide(self, dividend, divisor): """ :type dividend: int :type divisor: int :rtype: int """ negative = (dividend < 0) ^ (divisor < 0) dividend, divisor = abs(dividend), abs(divisor) result = 0 while dividend >= divisor: ...
normal
{ "blob_id": "4a0213351f8e9dcb2c6e71317a5ff1064974652e", "index": 3418, "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 divide(self, dividend, divisor):\n \"\"\"\n :type dividend: int\n :type divisor: int...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def wait_condition(cond, timeout=1, sleeptime=0.01): """Wait for condition to return anything other than None """ if timeout is None: timeout = 1 if timeout < sleeptime: print('Warning, timeout cannot be smaller than', sleeptime) timeout = sleeptime...
flexible
{ "blob_id": "7f220a970d65a91228501f7db59089e6c0604fb5", "index": 9915, "step-1": "<mask token>\n\n\ndef wait_condition(cond, timeout=1, sleeptime=0.01):\n \"\"\"Wait for condition to return anything other than None\n \"\"\"\n if timeout is None:\n timeout = 1\n if timeout < sleeptime:\n ...
[ 7, 11, 13, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): return random.randint(1, 6) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): return random.randint(1, 6) if __name__ == '__main__': main() <|re...
flexible
{ "blob_id": "6d92b944ab8503d3635626c0c23021fc2b40dce3", "index": 5732, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n return random.randint(1, 6)\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef main():\n return random.randint(1, 6)\n\n\nif __name__ == '__main__':\n mai...
[ 0, 1, 2, 3, 4 ]
''' The while statement allows you to repeatedly execute a block of statements as long as a condition is true. A while statement is an example of what is called a looping statement. A while statement can have an optional else clause. ''' #Modifying the values using while loop in a list l1: list = [1,2,3,4,5,6,7,8,9,10...
normal
{ "blob_id": "6a3fd3323ed8792853afdf5af76161f3e20d4896", "index": 4443, "step-1": "<mask token>\n", "step-2": "<mask token>\nl1: list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nprint('The original list: ', l1)\n<mask token>\nwhile i < len(l1):\n l1[i] = l1[i] + 100\n i = i + 1\nprint('The modified new list is: ',...
[ 0, 1, 2, 3 ]
def fun(st,n): suffix=[0 for i in range(n)] prefix=[0 for i in range(n)] count=0 for i,val in enumerate(st): if(val=='*'): if(i==0): prefix[i]=0 count+=1 else: prefix[i]=prefix[i-1] count+=1 else: ...
normal
{ "blob_id": "77c7ca3391426d1e56e15a93ef3e6227a45140fc", "index": 2829, "step-1": "<mask token>\n", "step-2": "def fun(st, n):\n suffix = [(0) for i in range(n)]\n prefix = [(0) for i in range(n)]\n count = 0\n for i, val in enumerate(st):\n if val == '*':\n if i == 0:\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class TestGetExamTickets(ApiTestCase): get_exams: ApiClient session: ExamSession student_session: UserSession questions: List[Question] tickets: List[ExamTicket] ticket_map: Dict[str, ExamTicket] def setUp(self): super().setUp() self.get_exam_q...
flexible
{ "blob_id": "44e4151279884ce7c5d5a9e5c82916ce2d3ccbc2", "index": 9789, "step-1": "<mask token>\n\n\nclass TestGetExamTickets(ApiTestCase):\n get_exams: ApiClient\n session: ExamSession\n student_session: UserSession\n questions: List[Question]\n tickets: List[ExamTicket]\n ticket_map: Dict[str,...
[ 15, 34, 42, 44, 45 ]
<|reserved_special_token_0|> def convert2numeral(rom): cur = 0 num = 0 while cur < len(rom): if cur + 1 == len(rom): num += e[rom[cur]] elif e[rom[cur]] > e[rom[cur + 1]]: num += e[rom[cur]] cur += 1 elif e[rom[cur]] < e[rom[cur + 1]]: ...
flexible
{ "blob_id": "1a29b3138f6a33fbe2781f044c1bcccd03ecd48d", "index": 7590, "step-1": "<mask token>\n\n\ndef convert2numeral(rom):\n cur = 0\n num = 0\n while cur < len(rom):\n if cur + 1 == len(rom):\n num += e[rom[cur]]\n elif e[rom[cur]] > e[rom[cur + 1]]:\n num += e[ro...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_week(year, month, day): str_time = '%d-%d-%d' % (year, month, day) time_tuple = time.strptime(str_time, '%Y-%m-%d') tuple_week = '星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日' return tuple_week[time_tupl...
flexible
{ "blob_id": "012d9b5aa13c557ad958343cadf935b73c808a56", "index": 4535, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_week(year, month, day):\n str_time = '%d-%d-%d' % (year, month, day)\n time_tuple = time.strptime(str_time, '%Y-%m-%d')\n tuple_week = '星期一', '星期二', '星期三', '星期四', '星期...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class ThalesSpider(scrapy.Spider): <|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 ThalesSpider(scrapy.Spider): <|reserved_special_t...
flexible
{ "blob_id": "fd1b871c5cf79874acf8d5c4f1f73f7a381e23f7", "index": 8278, "step-1": "<mask token>\n\n\nclass ThalesSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ThalesSpider(scrapy.Spider):\n <mask token>\n <mask token>\...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if n % 2 == 0: for i in range(0, n // 2): a[i], a[n // 2 + i] = a[n // 2 + i], a[i] print('after swap:', a) else: for i in range(0, n // 2): a[i], a[n // 2 + i + 1] = a[n // 2 + i + 1], a[i] print('...
flexible
{ "blob_id": "18435f43e2f52e3d2e9ff6411f8dd0510d2da54d", "index": 656, "step-1": "<mask token>\n", "step-2": "<mask token>\nif n % 2 == 0:\n for i in range(0, n // 2):\n a[i], a[n // 2 + i] = a[n // 2 + i], a[i]\n print('after swap:', a)\nelse:\n for i in range(0, n // 2):\n a[i], a[n // ...
[ 0, 1, 2, 3 ]
# addtwo_run-py """ Train and test a TCN on the add two dataset. Trying to reproduce https://arxiv.org/abs/1803.01271. """ print('Importing modules') import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F from torch.utils.tensorboard import SummaryWriter from torch.uti...
normal
{ "blob_id": "fe1a9804862942491b11b9baceecd37bf628fbb8", "index": 8732, "step-1": "<mask token>\n\n\ndef run():\n torch.manual_seed(1729)\n \"\"\" Setup \"\"\"\n args = parse()\n device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')\n print(device)\n \"\"\" Dataset \"\"\"\n ...
[ 1, 2, 3, 4, 5 ]
class IOString: <|reserved_special_token_0|> def get_String(self): self.str1 = input() <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class IOString: <|reserved_special_token_0|> def get_String(self): self.str1 = input() def print_S...
flexible
{ "blob_id": "cf2973b94f1113013fe9baa946202ec75488f7d2", "index": 9697, "step-1": "class IOString:\n <mask token>\n\n def get_String(self):\n self.str1 = input()\n <mask token>\n\n\n<mask token>\n", "step-2": "class IOString:\n <mask token>\n\n def get_String(self):\n self.str1 = in...
[ 2, 3, 4, 5, 7 ]
class Solution: def minWindow(self, s: str, t: str) -> str: char_cnt = {} for character in t: if character not in char_cnt: char_cnt[character] = 1 else: char_cnt[character] += 1 dq = [] # add index & character min_substring = ...
normal
{ "blob_id": "22706d7d9c04bb660c9bf0df66de89ed6bd480c2", "index": 8210, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def minWindow(self, s: str, t: str) ->str:\n char_cnt = {}\n for character in t:\n if character not in...
[ 0, 1, 2, 3 ]
import os import codecs import json #~ from lxml import etree import lxml.html target = "test/index.html" url = "http://de.wikipedia.org/wiki/Liste_von_Bergen_in_der_Schweiz" command = "wget %s -O %s" % (url, target) #~ os.popen(command) f = open(target) html = lxml.html.fromstring(f.read()) f.close() tables = html....
normal
{ "blob_id": "89499ea8dd02d5e1b2ff635ab5203a65ceee4276", "index": 8536, "step-1": "import os\nimport codecs\nimport json\n#~ from lxml import etree\nimport lxml.html\n\ntarget = \"test/index.html\"\nurl = \"http://de.wikipedia.org/wiki/Liste_von_Bergen_in_der_Schweiz\"\ncommand = \"wget %s -O %s\" % (url, target)...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): print('Load a ply point cloud, print it, and render it') pcd = read_point_cloud('11.ply') """ read_point_cloud reads a point cloud from a file. It tries to decode the file based on the extensio...
flexible
{ "blob_id": "30e8e269cf6500ab804566a85c9b96b3ef9bda36", "index": 4143, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n print('Load a ply point cloud, print it, and render it')\n pcd = read_point_cloud('11.ply')\n \"\"\" read_point_cloud reads a point cloud from a file.\n ...
[ 0, 1, 2, 3, 4 ]
import numpy as np from cost_functions import trajectory_cost_fn import time class Controller(): def __init__(self): pass # Get the appropriate action(s) for this state(s) def get_action(self, state): pass class RandomController(Controller): def __init__(self, env): """ YOUR CODE HERE """ ...
normal
{ "blob_id": "7112eb52aea9be6f8e682b4dacc6b615365c8cea", "index": 7510, "step-1": "<mask token>\n\n\nclass Controller:\n <mask token>\n <mask token>\n\n\nclass RandomController(Controller):\n\n def __init__(self, env):\n \"\"\" YOUR CODE HERE \"\"\"\n pass\n\n def get_action(self, state)...
[ 8, 9, 10, 11, 12 ]
from .. import CURRENT_NAME from ..cmd import call_cmd from .config import Configurator from .config import USER_INI from icemac.install.addressbook._compat import Path import argparse import os import pdb # noqa: T002 import sys def update(stdin=None): """Update the current address book installation.""" cur...
normal
{ "blob_id": "f5274f5d838d484ca0c1cc5a5192a2fd698cf827", "index": 9432, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef update(stdin=None):\n \"\"\"Update the current address book installation.\"\"\"\n curr_path = Path.cwd() / CURRENT_NAME\n if not curr_path.exists():\n print('ERROR...
[ 0, 1, 2, 3, 4 ]
import requests as r from .security import Security, Securities from .data import Data url_base = 'https://www.alphavantage.co/query' def _build_url(**kargs): query = { 'function': 'TIME_SERIES_DAILY', 'symbol': 'SPY', 'outputsize': 'full', 'datatype': 'json', 'apikey': 'JPIO2GNGBMFRLGMN' } query.update(kar...
normal
{ "blob_id": "e99d3ae82d8eea38d29d6c4f09fdb3858e36ca50", "index": 6518, "step-1": "<mask token>\n\n\ndef _build_url(**kargs):\n query = {'function': 'TIME_SERIES_DAILY', 'symbol': 'SPY', 'outputsize':\n 'full', 'datatype': 'json', 'apikey': 'JPIO2GNGBMFRLGMN'}\n query.update(kargs)\n query_str = '...
[ 3, 4, 5, 6, 7 ]
import urllib.request import praw from praw import reddit from praw.models.listing.mixins import submission def download_subreddit(sub): reddit = praw.Reddit(client_id='oFOYuOd31vUb4UstBWDhnQ', client_secret='0W_86zufGFCJlSE4lK3CwF_0UEQEQw', username='MarshallBranin', ...
normal
{ "blob_id": "d19310a45a684a7bbb456555a954439df8ae92b6", "index": 1392, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef download_subreddit(sub):\n reddit = praw.Reddit(client_id='oFOYuOd31vUb4UstBWDhnQ', client_secret=\n '0W_86zufGFCJlSE4lK3CwF_0UEQEQw', username='MarshallBranin',\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @receiver(post_save, sender=User) def save_profile(sender, created, instance, **kwargs): if created: profile = Profile.objects.create(user=instance) profile.save() <|reserved_special_token_1|> <|reserved_s...
flexible
{ "blob_id": "4f93af104130f5a7c853ee0e7976fd52847e588a", "index": 4988, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@receiver(post_save, sender=User)\ndef save_profile(sender, created, instance, **kwargs):\n if created:\n profile = Profile.objects.create(user=instance)\n profile.sa...
[ 0, 1, 2, 3, 4 ]
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x < 0: return False t = [] while x != 0: t.append(x % 10) x /= 10 i, j = 0, len(t) - 1 while i < j: if t[i]...
normal
{ "blob_id": "ef1b759872de6602646ce095823ff37f043ffd9d", "index": 5148, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def isPalindrome(self, x):\n \"\"\"\n :type x: int\n :rtype: bool\n \"\"\"\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def plot(identifiers, chipIndexes, firstRunChipHistory, recentRunChipHistory, specificRunChipHistory, groupedChipHistory, mode_parameters=None): if mode_parameters is None: mode_parameters = {} mode_param...
flexible
{ "blob_id": "49ae9e90402d784fc3af3b47e96842fbfe842104", "index": 9480, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef plot(identifiers, chipIndexes, firstRunChipHistory,\n recentRunChipHistory, specificRunChipHistory, groupedChipHistory,\n mode_parameters=None):\n if mode_parameters is N...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class CreateAlertForm(forms.ModelForm): class Meta: model = Alert exclude = ['role', 'age_analysis', 'Date_Uploaded', 'alias_name', 'CAMT_Reveiewer', 'Date_Regularised', 'alert_message', 'Count2...
flexible
{ "blob_id": "bfcf6e241881c4f668f926e087ab0f7dcad61dee", "index": 5260, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CreateAlertForm(forms.ModelForm):\n\n\n class Meta:\n model = Alert\n exclude = ['role', 'age_analysis', 'Date_Uploaded', 'alias_name',\n 'CAMT_Revei...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def get_data(): r = requests.get(url) return '{ "data": ' + str(r.text) + '}' def main(): args = ccloud_lib.parse_args() config_file = args.config_file topic = args.topic conf = ccloud_lib.read_ccloud_config(config_file) producer_conf = ccloud_lib.pop_schema_...
flexible
{ "blob_id": "b4f522398cd2658c2db926216e974781e10c44df", "index": 7897, "step-1": "<mask token>\n\n\ndef get_data():\n r = requests.get(url)\n return '{ \"data\": ' + str(r.text) + '}'\n\n\ndef main():\n args = ccloud_lib.parse_args()\n config_file = args.config_file\n topic = args.topic\n conf ...
[ 2, 4, 5, 6, 7 ]
"""######################################################################### Author: Yingru Liu Institute: Stony Brook University Descriptions: transer the numpy files of the midi songs into midi files. (Cause the code privided by RNN-RBM tutorial to save midi runs in python 2.7 but my ...
normal
{ "blob_id": "af152e0b739305866902ee141f94641b17ff03ea", "index": 6496, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(20):\n print('The ' + str(i) + '-th graph.')\n Ground_sample = np.load(Ground_FOLDER + 'Ground-True-' + str(i) + '.npy')\n CGRNN_sample = np.load(CGRNN_FOLDER + 'C...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> os.chdir('/mnt/cwd') <|reserved_special_token_0|> with open('/mnt/scripts/outputs/instcat_list_subset' + str(subset_index) + '.json', 'r') as f: instcat_list_subset = json.load(f) sys.path.append('/mnt/scripts') <|reserved...
flexible
{ "blob_id": "e2e5ca388d67f2a13eaef6067fc19e2dfe284a55", "index": 4469, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.chdir('/mnt/cwd')\n<mask token>\nwith open('/mnt/scripts/outputs/instcat_list_subset' + str(subset_index) +\n '.json', 'r') as f:\n instcat_list_subset = json.load(f)\nsys.path.a...
[ 0, 1, 2, 3, 4 ]
#coding: utf-8 import mmh3 from bitarray import bitarray BIT_SIZE = 1 << 30 class BloomFilter: def __init__(self): # Initialize bloom filter, set size and all bits to 0 bit_array = bitarray(BIT_SIZE) bit_array.setall(0) self.bit_array = bit_array def add(self, val): ...
normal
{ "blob_id": "5a103a4f72b9cd3ea3911aeefeeb2194c8ad7df0", "index": 589, "step-1": "<mask token>\n\n\nclass BloomFilter:\n\n def __init__(self):\n bit_array = bitarray(BIT_SIZE)\n bit_array.setall(0)\n self.bit_array = bit_array\n\n def add(self, val):\n point_list = self.get_posti...
[ 4, 5, 6, 7, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for j in range(N): for i in range(n): r = random.uniform(0, 1) if r < p: x = 1 else: x = 0 Y.append(x) outcome = sum(Y) b[outcome] = b[outcome] + 1 Y.clear() ...
flexible
{ "blob_id": "9a1b268386b4652bf50af0365892ef7338329727", "index": 9631, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor j in range(N):\n for i in range(n):\n r = random.uniform(0, 1)\n if r < p:\n x = 1\n else:\n x = 0\n Y.append(x)\n outcome = su...
[ 0, 1, 2, 3, 4 ]
import cv2 import numpy as np LOWEST_MATCHES_NUMBER = 30 sift = cv2.xfeatures2d.SIFT_create() bf = cv2.BFMatcher(); train_img = cv2.imread('Photo/demo2.jpg', 0) train_kp, train_desc = sift.detectAndCompute(train_img, None); camera = cv2.VideoCapture(0); while (True): det, frame_with_color = camera.read(); f...
normal
{ "blob_id": "1a78d9e0807824263fd46547d5b75c61610456d4", "index": 1912, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n det, frame_with_color = camera.read()\n frame = cv2.cvtColor(frame_with_color, cv2.COLOR_BGR2GRAY)\n frame_kp, frame_desc = sift.detectAndCompute(frame, None)\n ...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Automatically create and parse commands based on a YAML configuration file. NOTE: we can't have a logger here, before knowing the level of debug. """ import os import sys import argparse from controller import __version__, PROJECTRC, PROJECTRC_ALTERNATIVE from controller.conf_utilities im...
normal
{ "blob_id": "94559d9fd296acd468c33d6b0541b974575b8852", "index": 4119, "step-1": "<mask token>\n\n\nclass ArgParser:\n <mask token>\n\n def add_parser_argument(self, parser, option_name, options):\n params = self.prepare_params(options)\n alias = params.pop('alias', None)\n positional ...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_import_error(): from cnct import ClientError as MovedClientError assert MovedClientError == ClientError <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_impo...
flexible
{ "blob_id": "e5a71250ca9f17798011d8fbfaee6a3d55446598", "index": 6145, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_import_error():\n from cnct import ClientError as MovedClientError\n assert MovedClientError == ClientError\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef tes...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class RegisterUserSerializer(serializers.ModelSerializer): class Meta: model = User fields = '__all__' def validate_password(self, password): user = _build_initial_user(self.initial_data) validate_password(password, user=user) return pass...
flexible
{ "blob_id": "88e34878cdad908ed4ac30da82355aaa46ed719b", "index": 5429, "step-1": "<mask token>\n\n\nclass RegisterUserSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = User\n fields = '__all__'\n\n def validate_password(self, password):\n user = _build_initial_user(s...
[ 10, 13, 14, 15, 21 ]
""" Make html galleries from media directories. Organize by dates, by subdirs or by the content of a diary file. The diary file is a markdown file organized by dates, each day described by a text and some medias (photos and movies). The diary file can be exported to: * an html file with the text and subset of medias a...
normal
{ "blob_id": "6018f35afc6646d0302ca32de649ffe7d544a765", "index": 3377, "step-1": "<mask token>\n\n\nclass Post:\n\n def __init__(self, date, text, medias):\n self.date = date\n self.text = text\n self.medias = medias\n self.dcim = []\n self.daterank = 0\n self.extra =...
[ 79, 84, 88, 100, 110 ]
<|reserved_special_token_0|> class Node: def __init__(self): self.metadata = list() self.children = list() def checksum(self): return sum([x for x in self.metadata]) def add_child(self, child): self.children.append(child) pass def value(self): if len...
flexible
{ "blob_id": "3bea4413a41a9eecb5e3184d090b646e17892b5c", "index": 5277, "step-1": "<mask token>\n\n\nclass Node:\n\n def __init__(self):\n self.metadata = list()\n self.children = list()\n\n def checksum(self):\n return sum([x for x in self.metadata])\n\n def add_child(self, child):\...
[ 8, 9, 10, 11, 12 ]
C = {i:0 for i in range(9)} N = int(input()) A = list(map(int,input().split())) for i in range(N): a = A[i] if a<400: C[0] += 1 elif a<800: C[1] += 1 elif a<1200: C[2] += 1 elif a<1600: C[3] += 1 elif a<2000: C[4] += 1 elif a<2400: C[5] += 1 ...
normal
{ "blob_id": "a1ca6c258298feda99b568f236611c1c496e3262", "index": 8993, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(N):\n a = A[i]\n if a < 400:\n C[0] += 1\n elif a < 800:\n C[1] += 1\n elif a < 1200:\n C[2] += 1\n elif a < 1600:\n C[3] += 1\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def solve_problem(input): parents = {} for i, line in enumerate(input.split('\n')): about, object = line.split(')') parents[object] = about orbit_counts = {'COM': 0} for object in tuple(parents.keys()): stack = [object] while stack[-1] not i...
flexible
{ "blob_id": "e57680c9bd09866e68ade0cfea7ce83cd6d50f58", "index": 1596, "step-1": "<mask token>\n\n\ndef solve_problem(input):\n parents = {}\n for i, line in enumerate(input.split('\\n')):\n about, object = line.split(')')\n parents[object] = about\n orbit_counts = {'COM': 0}\n for obje...
[ 3, 4, 5, 6, 7 ]
from room import Room from player import Player from item import Item # Declare all the rooms room = { 'outside': Room("Outside Cave Entrance", "North of you, the cave mount beckons"), 'foyer': Room("Foyer", """Dim light filters in from the south. Dusty passages run north and east."""...
normal
{ "blob_id": "beb536b6d8883daaa7e41da03145dd98aa223cbf", "index": 5036, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n print('\\nPlayer Items:')\n for item in player.items:\n print('\\t', item)\n print('Room - ', player.current_room)\n print('Items in Room:')\n for item...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # @File :fi_handlers.py # @Author:ZengYu # @Date :2019/5/16 # @software:PyCharm import tornado.web import tornado.websocket from PIL import Image import base64 from model.flower_identify import flower_identify class FlowersInfo(): flowersInfo = ["月季花(学名:Rosa chinensis Jacq.)...
normal
{ "blob_id": "1c3b1776f14a085bec90be11028c87dc47f00293", "index": 1722, "step-1": "<mask token>\n\n\nclass FlowerIdentify(tornado.web.RequestHandler):\n\n def get(self):\n self.render('flower_identify.html')\n\n\nclass IdentifyHandler(tornado.websocket.WebSocketHandler):\n\n def post(self):\n ...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class ImagemProfessor(models.Model): professor = models.ForeignKey(Professor, on_delete=models.CASCADE) foto = models.ImageField(upload_to='fotos/%d/%m/%Y/', blank=True) <|reserved_special_token_1|> <|reserved_special_token_0|> class Professor(models.Model): <|reserved_sp...
flexible
{ "blob_id": "acb879cb72e5b3ac897a271dc680e4ca763d2122", "index": 7541, "step-1": "<mask token>\n\n\nclass ImagemProfessor(models.Model):\n professor = models.ForeignKey(Professor, on_delete=models.CASCADE)\n foto = models.ImageField(upload_to='fotos/%d/%m/%Y/', blank=True)\n", "step-2": "<mask token>\n\n...
[ 2, 3, 5, 6 ]
import pandas as pd import numpy as np from datetime import timedelta import scipy.optimize as optim from scipy import stats import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from gen_utils.gen_io import read_run_params,log_msg ############################################# params = read_run_pa...
normal
{ "blob_id": "dcef5f34a62939d992a109e991552e612bf5bad5", "index": 4619, "step-1": "<mask token>\n\n\ndef my_logistic(x, a, b, c):\n return c / (1 + a * np.exp(-b * x))\n\n\n<mask token>\n", "step-2": "<mask token>\nmatplotlib.use('Agg')\n<mask token>\ndf_mrns.sort_values('COLLECTION_DT', inplace=True)\ndf_mr...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def generate_launch_description(): return LaunchDescription([Node(package='beckhoff_ros', executable= 'beckhoff_ros_node', name='beckhoff_ros_node', parameters=[params], output='screen')]) <|reserved_specia...
flexible
{ "blob_id": "ae4f8eb71939ff212d05d12f65edeaecf66f2205", "index": 4874, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_launch_description():\n return LaunchDescription([Node(package='beckhoff_ros', executable=\n 'beckhoff_ros_node', name='beckhoff_ros_node', parameters=[params],...
[ 0, 1, 2, 3 ]
""" Have the function CharlietheDog(strArr) read the array of strings stored in strArr which will be a 4x4 matrix of the characters 'C', 'H', 'F', 'O', where C represents Charlie the dog, H represents its home, F represents dog food, and O represents and empty space in the grid. Your goal is to figure out the least...
normal
{ "blob_id": "731110b02c8a09dc84042a99c14eef990ae33cd2", "index": 5913, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef CharlietheDog(strArr):\n\n def walk(food_home, dog, matriz, steps=0):\n food_home_dx = food_home[0][0] - dog[0]\n food_home_dy = food_home[0][1] - dog[1]\n ...
[ 0, 1, 2, 3, 4 ]
from django.contrib.auth import get_user_model from django.core.urlresolvers import reverse_lazy from django.shortcuts import get_object_or_404 from rest_framework import status, viewsets from rest_framework.exceptions import PermissionDenied from rest_framework.permissions import IsAuthenticatedOrReadOnly from rest_f...
normal
{ "blob_id": "4d059d1ca407ef60f1fbf9d8bead1cf45c90c28a", "index": 8227, "step-1": "<mask token>\n\n\nclass RegisterViewSet(viewsets.ModelViewSet):\n queryset = models.Register.objects.all()\n serializer_class = serializers.RegisterSerializer\n permission_classes = IsAuthenticatedOrReadOnly, ForumPermissi...
[ 10, 17, 18, 20, 22 ]
# Generated by Django 2.2.17 on 2020-12-05 07:43 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('service', '0001_initial'), ] operations = [ migrations.AlterField( model_name='identification', name='id_card_img',...
normal
{ "blob_id": "b6a0a49e05fbc0ac7673d6c9e8ca4d263c8bb5cd", "index": 7132, "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 = [('service', '...
[ 0, 1, 2, 3, 4 ]
from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.serialization import load_ssh_public_key from ingredients_http.schematics.types import ArrowType, KubeName from schematics import Model from schematics.exceptions import ...
normal
{ "blob_id": "a521220ac287a840b5c69e2d0f33daa588132083", "index": 4983, "step-1": "<mask token>\n\n\nclass RequestCreateKeypair(Model):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass ResponseKeypair(Model):\n name = KubeName(required=True, min_length=3)\n public_key = StringType(required=T...
[ 4, 6, 10, 11, 12 ]
<|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 combo(self, n): if n == 0: return ['0'] elif n == 1: return ['0', '1'] e...
flexible
{ "blob_id": "e9a929dfef327737b54723579d3c57884fe61057", "index": 7061, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n <mask token>\n", "step-3": "class Solution:\n\n def combo(self, n):\n if n == 0:\n return ['0']\n elif n == 1:\n return [...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def read_assembly_file(file: str) ->List: if not os.path.isfile(file): return [-1, -1, -1, -1, -1, -1] with open(file, 'r') as f: file_content_string = f.read() if 'LKH_Contigs:\nLKH_Objective' in file_content_string: lkh_gaps = -1 else:...
flexible
{ "blob_id": "edd98e3996b0fce46d33dd33340018ab5b029637", "index": 2333, "step-1": "<mask token>\n\n\ndef read_assembly_file(file: str) ->List:\n if not os.path.isfile(file):\n return [-1, -1, -1, -1, -1, -1]\n with open(file, 'r') as f:\n file_content_string = f.read()\n if 'LKH_Contigs...
[ 5, 7, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> CARD_SIZE = 70, 90 SPACING = 3 <|reserved_special_token_1|> CARD_SIZE = (70, 90) SPACING = 3
flexible
{ "blob_id": "b8ebbef7403a71d6165a5462bc08e2634b4cebc5", "index": 4287, "step-1": "<mask token>\n", "step-2": "CARD_SIZE = 70, 90\nSPACING = 3\n", "step-3": "CARD_SIZE = (70, 90)\nSPACING = 3", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
from math import log result = [] formula = int(input("For exit press 0\nChoose the formula #1 #2 #3: ")) while (formula >= 0) and (formula <= 3): a = float(input("Enter a:")) min_x = float(input("Enter minx:")) max_x = float(input("Enter maxx:")) step = int(input("Enter steps:")) x = min_x if...
normal
{ "blob_id": "44c4a1f4b32b45fd95eb8b0a42a718d05d967e04", "index": 2536, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile formula >= 0 and formula <= 3:\n a = float(input('Enter a:'))\n min_x = float(input('Enter minx:'))\n max_x = float(input('Enter maxx:'))\n step = int(input('Enter steps...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for _ in range(int(input())): n = int(input()) temp = n rev = 0 while temp: rev = rev * 10 + temp % 10 temp //= 10 print('Yes' if rev == n else 'No') <|reserved_special_token_1|> """ Problem ...
flexible
{ "blob_id": "ea12ede51881f6e826a044df5d7aba457c434658", "index": 6050, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(int(input())):\n n = int(input())\n temp = n\n rev = 0\n while temp:\n rev = rev * 10 + temp % 10\n temp //= 10\n print('Yes' if rev == n else ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class BaseException(Exception): <|reserved_special_token_0|> <|reserved_special_token_1|> class BaseException(Exception): def __init__(self, message=''): super(BaseException, self).__init__() self.message = message <|reserved_spe...
flexible
{ "blob_id": "2ee1539e051677ad38ab7727ff5edefb1aebd015", "index": 9946, "step-1": "<mask token>\n", "step-2": "class BaseException(Exception):\n <mask token>\n", "step-3": "class BaseException(Exception):\n\n def __init__(self, message=''):\n super(BaseException, self).__init__()\n self.me...
[ 0, 1, 2, 3 ]
import random OPTIONS = ['rock', 'paper', 'scissors'] def get_human_choice(): print('(1) Rock\n(2) Paper\n(3) Scissors') return OPTIONS[int(input('Enter the number of your choice: ')) - 1] def get_computer_choice(): return random.choice(OPTIONS) def print_choices(human_choice, computer_choice): pr...
normal
{ "blob_id": "2e6bce05c8ba21aa322e306d2cdb8871531d7341", "index": 5499, "step-1": "<mask token>\n\n\ndef get_human_choice():\n print('(1) Rock\\n(2) Paper\\n(3) Scissors')\n return OPTIONS[int(input('Enter the number of your choice: ')) - 1]\n\n\ndef get_computer_choice():\n return random.choice(OPTIONS)...
[ 6, 7, 8, 9 ]
<|reserved_special_token_0|> class WGANUpdater(chainer.training.updaters.StandardUpdater): def __init__(self, *args, **kwargs): self.gen, self.dis = kwargs.pop('models') self.n_dis = kwargs.pop('n_dis') self.lam = kwargs.pop('lam') self.iteration = 0 super(WGANUpdater, sel...
flexible
{ "blob_id": "a7099b2506de08893ca849146813505d88784895", "index": 2402, "step-1": "<mask token>\n\n\nclass WGANUpdater(chainer.training.updaters.StandardUpdater):\n\n def __init__(self, *args, **kwargs):\n self.gen, self.dis = kwargs.pop('models')\n self.n_dis = kwargs.pop('n_dis')\n self....
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def custom_proc(request): """ 自定义context_processors """ return {'context_test': 'test'} <|reserved_special_token_1|> #!/usr/bin/env python #coding:utf-8 ''' Created on 2016年8月29日 @author: lichen ''' def cus...
flexible
{ "blob_id": "43ecb173e3d306284f2122410b5b74945572f683", "index": 8104, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef custom_proc(request):\n \"\"\"\n 自定义context_processors\n \"\"\"\n return {'context_test': 'test'}\n", "step-3": "#!/usr/bin/env python\n#coding:utf-8\n\n'''\nCreated...
[ 0, 1, 2 ]
import tkinter as tk import tkinter.ttk as ttk import GUIForm import sys def main(): global window global _form print("You are using Python {}.{}.{}".format(sys.version_info.major, sys.version_info.minor, sys.version_info.micro)) window=tk.Tk() GUIForm.BuildInterface(window) window.mainloop()...
normal
{ "blob_id": "ca5057a5fdfef0edf4cf0c3ff3e2a371907ca4ee", "index": 1270, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n global window\n global _form\n print('You are using Python {}.{}.{}'.format(sys.version_info.major,\n sys.version_info.minor, sys.version_info.micro))\n ...
[ 0, 1, 2, 3, 4 ]
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param A : root node of tree # @return a list of integers def solve(self, root): if not root: return result = [] result.append(root.val) ...
normal
{ "blob_id": "a49ee1e3f600d83486d0cf2396ed261c61fdf926", "index": 1711, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n def leaf_nodes_util(self, curr, result):\n if not curr:\n return\n self.leaf_nodes_util(self, curr.left, result)\n if not curr.left and not ...
[ 3, 6, 7, 8, 9 ]
# Written by Jagannath Bilgi <jsbilgi@yahoo.com> import sys import json import re """ Program accepts *.md document and converts to csv in required format Program parse line by line and uses recursive method to traverse from leaf to root. Single turn object (string, int etc) is used as point of return from recursio...
normal
{ "blob_id": "739921a6a09edbb81b442f4127215746c601a69a", "index": 4990, "step-1": "<mask token>\n\n\ndef obj_rec(obj, t, flag=0, acc=''):\n v_obj = type(obj)\n r = ''\n if type(obj) not in [dict, list, map]:\n ref_url = re.findall('\\\\((http.*?)\\\\)', obj)\n ref_title = re.findall('\\\\[[...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding: UTF-8 -*- from multiprocess.managers import BaseManager from linphonebase import LinphoneBase class MyManager(BaseManager): pass MyManager.register('LinphoneBase', LinphoneBase) manager = MyManager() manager.start() linphoneBase = manager.LinphoneBase()
normal
{ "blob_id": "3bb25cedc29f9063046329db1c00e7d9e10ce1cc", "index": 5089, "step-1": "<mask token>\n\n\nclass MyManager(BaseManager):\n pass\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass MyManager(BaseManager):\n pass\n\n\nMyManager.register('LinphoneBase', LinphoneBase)\n<mask token>\nmanager.sta...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class SyncTestCase(tests.unittest.HomeserverTestCase): <|reserved_special_token_0|> servlets = [admin.register_servlets, knock.register_servlets, login. register_servlets, room.register_servlets] def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer ...
flexible
{ "blob_id": "fc5b9117ecf56401a888e2b6a5e244f9ab115e41", "index": 3999, "step-1": "<mask token>\n\n\nclass SyncTestCase(tests.unittest.HomeserverTestCase):\n <mask token>\n servlets = [admin.register_servlets, knock.register_servlets, login.\n register_servlets, room.register_servlets]\n\n def pre...
[ 6, 8, 9, 10, 11 ]
from collections import deque class Solution: def slidingPuzzle(self, board: List[List[int]]) -> int: def board2str(board: List[List[int]]) -> str: return ''.join([str(board[i][j]) for i in range(2) for j in range(3)]) start = board2str(board) bfs = deque([(start, 0)]) ...
normal
{ "blob_id": "dc934f8db4e0c1113e1398b051b58369d909fff8", "index": 6471, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def slidingPuzzle(self, board: List[List[int]]) ->int:\n\n def board2str(board: List...
[ 0, 1, 2, 3, 4 ]
from Cars import Bmw from Cars import Audi from Cars import Nissan # Press the green button in the gutter to run the script. if __name__ == '__main__': print('In Sample.py........') # Import classes from your brand new package # Create an object of Bmw class & call its method ModBMW = Bmw.Bmw() ...
normal
{ "blob_id": "e15524d7ae87cbf0b10c54ee0bdc613ba589c1a9", "index": 3812, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n print('In Sample.py........')\n ModBMW = Bmw.Bmw()\n ModBMW.outModels()\n ModAudi = Audi.Audi()\n ModAudi.outModels()\n ModNissan = Nissan.N...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class RollBot: <|reserved_special_token_0|> def __init__(self): """initializes the attributes of the class""" self.input_last_roll = '' self.last_roll = [] self.result = 0 self.error = '' self.number_of_dice = '' self.size_o...
flexible
{ "blob_id": "301a6ec56bd265ff63a924ecd64d6708cb6b139c", "index": 8419, "step-1": "<mask token>\n\n\nclass RollBot:\n <mask token>\n\n def __init__(self):\n \"\"\"initializes the attributes of the class\"\"\"\n self.input_last_roll = ''\n self.last_roll = []\n self.result = 0\n ...
[ 4, 7, 8, 9, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while test_case != 0: test_case -= 1 n, m = map(int, input().split()) ans = n * m A = [] for i in range(n): t = list(map(int, input().split())) A.append(t) for i in range(1, n - 1): ...
flexible
{ "blob_id": "dbc3e51fed63fe0fadea67d05c4b4efc693938a3", "index": 1487, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile test_case != 0:\n test_case -= 1\n n, m = map(int, input().split())\n ans = n * m\n A = []\n for i in range(n):\n t = list(map(int, input().split()))\n ...
[ 0, 1, 2, 3 ]
from django.db import models class Building(models.Model): Number = models.CharField(max_length=60) Description = models.CharField(max_length=120) OSMWAYID = models.DecimalField(decimal_places=0, max_digits=15) # the osm way id Lat = models.CharField(max_length=20) #lat/lon of then center Lon = m...
normal
{ "blob_id": "02ddf213cd3f455f8d8fbde8621fc4788124d5a9", "index": 3714, "step-1": "<mask token>\n\n\nclass Logger(models.Model):\n Facinet = models.ForeignKey('Facinet', null=False, blank=False,\n related_name='Loggers')\n loggerindex = models.IntegerField(unique=True, db_column='LoggerIndex')\n n...
[ 4, 6, 7, 11, 12 ]
from django.conf.urls.defaults import * ## reports view urlpatterns = patterns('commtrack_reports.views', (r'^commtrackreports$', 'reports'), (r'^sampling_points$', 'sampling_points'), (r'^commtrack_testers$', 'testers'), (r'^date_range$', 'date_range'), (r'^create_report$', 'create_report'), (...
normal
{ "blob_id": "6d244b719200ae2a9c1a738e746e8c401f8ba4e2", "index": 3342, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('commtrack_reports.views', ('^commtrackreports$',\n 'reports'), ('^sampling_points$', 'sampling_points'), (\n '^commtrack_testers$', 'testers'), ('^date_range...
[ 0, 1, 2, 3 ]
from django.conf.urls import patterns, url urlpatterns = patterns( '', url( r'^create_new/$', 'hx_lti_assignment.views.create_new_assignment', name="create_new_assignment", ), url( r'^(?P<id>[0-9]+)/edit/', 'hx_lti_assignment.views.edit_assignment', name=...
normal
{ "blob_id": "2194fb4f0b0618f1c8db39f659a4890457f45b1d", "index": 3963, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', url('^create_new/$',\n 'hx_lti_assignment.views.create_new_assignment', name=\n 'create_new_assignment'), url('^(?P<id>[0-9]+)/edit/',\n 'hx_lti_assign...
[ 0, 1, 2, 3 ]
# coding: UTF-8 import os import sys if len(sys.argv) == 3: fname = sys.argv[1] out_dir = sys.argv[2] else: print "usage: vcf_spliter <input file> <output dir>" exit() count = 0 if not os.path.exists(out_dir): os.makedirs(out_dir) with open(fname, 'r') as f: for l in f: if l.strip()...
normal
{ "blob_id": "f410a77d4041514383110d9fd16f896178924d59", "index": 8871, "step-1": "# coding: UTF-8\n\nimport os \nimport sys\n\nif len(sys.argv) == 3:\n fname = sys.argv[1]\n out_dir = sys.argv[2]\nelse:\n print \"usage: vcf_spliter <input file> <output dir>\"\n exit()\n\ncount = 0\nif not os.path.exi...
[ 0 ]
<|reserved_special_token_0|> class RPCStub(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class RPCStub(object): def __init__(self): pass <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_...
flexible
{ "blob_id": "74f85732b4e1f4ef2b82a48818cbaedb18a56083", "index": 8122, "step-1": "<mask token>\n\n\nclass RPCStub(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass RPCStub(object):\n\n def __init__(self):\n pass\n <mask token>\n", "step-3": "<mask token>\n\n\ncl...
[ 1, 2, 3, 4, 5 ]
from field import print_field from math_utilite import sign, col def start_parameter_2(par): global cell_king, castling_control, trans, take_on_aisle cell_king = par[0] castling_control = par[1] trans = par[2] take_on_aisle = par[3] def det_cell_king(field): global cell_king cell_king...
normal
{ "blob_id": "90c9456bf22745d99fa76dbc752beae1a3835682", "index": 7672, "step-1": "<mask token>\n\n\ndef det_cell_king(field):\n global cell_king\n cell_king = {sign(fig): (x, y) for x, row in enumerate(field) for y,\n fig in enumerate(row) if abs(fig) == 6}\n return cell_king\n\n\n<mask token>\n\...
[ 4, 8, 9, 10, 11 ]
import csv import sys if len(sys.argv[1:]) == 5 : (name_pos, start_pos, length_pos, first_note_pos, second_note_pos) = [int(pos) for pos in sys.argv[1:]] elif len(sys.argv[1:]) == 4 : (name_pos, start_pos, length_pos, first_note_pos) = [int(pos) for pos in sys.argv[1:]] second_note_pos = None e...
normal
{ "blob_id": "d7653a205fb8203fed4009846780c63dd1bcb505", "index": 3603, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv[1:]) == 5:\n name_pos, start_pos, length_pos, first_note_pos, second_note_pos = [int\n (pos) for pos in sys.argv[1:]]\nelif len(sys.argv[1:]) == 4:\n name_pos...
[ 0, 1, 2, 3, 4 ]