code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @api_view(['GET', 'POST']) @renderer_classes([JSONRenderer, BrowsableAPIRenderer]) def feedback_list(request, format=None): """ List all feedback or create a new feedback """ if request.method == 'GET': f...
flexible
{ "blob_id": "bd6c72c3215265a349c5f47573063a9288f64198", "index": 5227, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@api_view(['GET', 'POST'])\n@renderer_classes([JSONRenderer, BrowsableAPIRenderer])\ndef feedback_list(request, format=None):\n \"\"\"\n List all feedback or create a new feedba...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestDummy(unittest.TestCase): pass <|reserved_special_token_1|> import unittest import achemkit.properties_wnx class TestDummy(unittest.TestCase): pass
flexible
{ "blob_id": "5f0e6f6dc645996b486f1292fe05229a7fae9b17", "index": 2342, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestDummy(unittest.TestCase):\n pass\n", "step-3": "import unittest\nimport achemkit.properties_wnx\n\n\nclass TestDummy(unittest.TestCase):\n pass\n", "step-4": null,...
[ 0, 1, 2 ]
from django.shortcuts import render # from emaillist.models import Emaillist from emaillist.models import Emaillist from django.http import HttpResponseRedirect # Create your views here. # def index(request): # emaillist_list = Emaillist.objects.all().order_by('-id') # db에서 objects 전체를 불러와서 변수에 저장 # data =...
normal
{ "blob_id": "5220ad793788927e94caf7d6a42df11292851c67", "index": 2734, "step-1": "<mask token>\n\n\ndef test_form(request):\n print('test 함수 실행하자 ')\n return render(request, 'emaillist/test_form.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef test_form(request):\n print('test 함수 실행하자 ')\...
[ 1, 2, 3, 4, 5 ]
import re from collections import defaultdict def count_words(sentence): # extract all the words as per definition sentence = re.findall(r"\b[\w'-]+\b", sentence.lower().replace('_', ' ')) counts = defaultdict(lambda: 0) # Counting the frequency of each words for word in sentence: counts[w...
normal
{ "blob_id": "7f5f16ea10980e0ade7357cdae38f47f8d7cdf01", "index": 2446, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef count_words(sentence):\n sentence = re.findall(\"\\\\b[\\\\w'-]+\\\\b\", sentence.lower().replace('_', ' '))\n counts = defaultdict(lambda : 0)\n for word in sentence:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> #----------- writing our for loop """ number = [1,2,3,4,5] friends = ['ahmet', 'mehmet','ayşe'] # for n in number: # print(n) # for n in friends: # print(n) def my_for_loop(my_iterable): my_iterator = iter(my_iterable) while True: t...
flexible
{ "blob_id": "70325d0e5eb9dcd7a065f83eaf14647bc30bd7f3", "index": 9053, "step-1": "<mask token>\n", "step-2": "\n#----------- writing our for loop\n\"\"\" number = [1,2,3,4,5]\nfriends = ['ahmet', 'mehmet','ayşe']\n\n# for n in number:\n# print(n)\n# for n in friends:\n# print(n)\n\ndef my_for_loop(my_i...
[ 0, 1 ]
<|reserved_special_token_0|> class VirtualChassis(Base): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, parent): super(VirtualChassis, self).__init__(parent) <|reserved_special_token_0|> @property def Hypervisor(self): ...
flexible
{ "blob_id": "4b78c99dd6156afe960effcacb25804446310f7c", "index": 9708, "step-1": "<mask token>\n\n\nclass VirtualChassis(Base):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, parent):\n super(VirtualChassis, self).__init__(parent)\n <mask token>\n\n @property\n de...
[ 12, 13, 16, 17, 19 ]
def _make_key(*args, **kwargs): all_args = [str(arg) for arg in args] all_args += [str(arg) + '=' + str(value) for arg, value in kwargs.items()] return '|'.join(all_args) class DoubleLinked: def __init__(self, prv, nxt, key): self.prv = prv self.nxt = nxt self.key = key class...
normal
{ "blob_id": "9c251e0224979877b9ce244e4871fd4c403abb8e", "index": 1583, "step-1": "<mask token>\n\n\nclass LRUCache:\n\n def __init__(self, get_from_origin, max_size=1024):\n if max_size == 0:\n raise NotImplementedError()\n if max_size < 0:\n raise ValueError()\n sel...
[ 10, 14, 16, 23, 24 ]
<|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": "deb8ee1d6327a6406244147a819821e8d2b2890e", "index": 1385, "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 scrapy from yijing64.items import Yijing64Item # import pymysql class ZhouyiSpider(scrapy.Spider): name = 'zhouyi' allowed_domains = ['m.zhouyi.cc'] start_urls = ['https://m.zhouyi.cc/zhouyi/yijing64/'] def parse(self, response): li_list = response.xpath("//div[@class='gualist1 tip_tex...
normal
{ "blob_id": "cd9f25a2810b02f5588e4e9e8445e7aaec056bf8", "index": 7704, "step-1": "<mask token>\n\n\nclass ZhouyiSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def parse_detail(self, response):\n item = response.meta['item']\n item['hexagram1'] ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Notification(BaseAbstractModel): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_tok...
flexible
{ "blob_id": "1066f86d3a35e892ca2a7054dfc89fe79f1d32c8", "index": 7496, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Notification(BaseAbstractModel):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Notification(...
[ 0, 1, 2, 3, 4 ]
from django.test import TestCase, SimpleTestCase from django.urls import reverse, resolve from .views import profile, order_history """ Url Testing """ class TestUrls(SimpleTestCase): def test_profile_resolves(self): url = reverse('profile') self.assertEqual(resolve(url).func, profile) def t...
normal
{ "blob_id": "5dc6b54357df87077d8159192cd52697b2616db8", "index": 9186, "step-1": "<mask token>\n\n\nclass TestUrls(SimpleTestCase):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TestUrls(SimpleTestCase):\n\n def test_profile_resolves(self):\n url = reverse('profile')\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ALLOWED_HOSTS = [] INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.c...
flexible
{ "blob_id": "b42414b7d8ed80d8794ab7c49dfde1e5df0721f1", "index": 1318, "step-1": "<mask token>\n", "step-2": "<mask token>\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\nALLOWED_HOSTS = []\nINSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth',\n 'django.contrib.contentty...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('Temp in ', celsius, 'celsius=', fah, ' Fahrenheit') <|reserved_special_token_1|> celsius = input('Enter temperature in Celsius') celsius = int(celsius) fah = celsius * 9 / 5 + 32 print('Temp in ', celsius, 'celsius=', fa...
flexible
{ "blob_id": "e1172cadeb8b2ce036d8431cef78cfe19bda0cb8", "index": 2161, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Temp in ', celsius, 'celsius=', fah, ' Fahrenheit')\n", "step-3": "celsius = input('Enter temperature in Celsius')\ncelsius = int(celsius)\nfah = celsius * 9 / 5 + 32\nprint('Tem...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- from route4me import Route4Me API_KEY = "11111111111111111111111111111111" def main(): r4m = Route4Me(API_KEY) route = r4m.route response = route.get_routes(limit=1, offset=0) if isinstance(response, dict) and 'errors' in response.keys(): print('. '.join(response['err...
normal
{ "blob_id": "bc4684d255a46427f708d8ce8bda2e12fb8c8ffe", "index": 238, "step-1": "<mask token>\n\n\ndef main():\n r4m = Route4Me(API_KEY)\n route = r4m.route\n response = route.get_routes(limit=1, offset=0)\n if isinstance(response, dict) and 'errors' in response.keys():\n print('. '.join(respo...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # Enter your code here. Read input from STDIN. Print output to STDOUT n= input() vals= list(map(int,input().split())) def median(values): n=len(values) values = sorted(values) if n%2==1: return values[(n+1)//2 - 1] else: return int(sum(values[int((n/...
normal
{ "blob_id": "9d6b5baa8462b2996e4518dd39b5bb1efde1fd9d", "index": 894, "step-1": "<mask token>\n\n\ndef quartiles(values):\n n = len(values)\n values.sort()\n Q2 = median(values)\n Q1 = median(values[:int(n / 2)])\n if n % 2 == 0:\n Q3 = median(values[int(n / 2):])\n else:\n Q3 = m...
[ 1, 2, 3, 4, 5 ]
# # Wrappers for model evaluation # import torch import torch.nn.functional as F from torch.utils.data import Dataset, DataLoader from modules import Classifier from typing import Generator, NamedTuple, Optional, Union from utils import expand_generator class Evaluator(object): class Result(NamedTuple): ...
normal
{ "blob_id": "493dbf85069f2115896a5f5f5d593c8d95b85cff", "index": 4594, "step-1": "<mask token>\n\n\nclass ModelEvaluator(Evaluator):\n\n def __init__(self, dataset: Dataset, batch_size: int, num_workers: int,\n mixed_precision: bool=True):\n self.dataset = dataset\n self.mixed_precision =...
[ 5, 6, 7, 8, 9 ]
import discord from discord.ext import commands from os import path import os import datetime as dt import numpy as np import math # client = commands.Bot(command_prefix = '.', case_insensitive=True) # UTOPIA = 679921845671035034 # DEV_BOT_TOKEN = 'NzUzMzg1MjE1MTAzMzM2NTg4.X1laqA.vKvoV8Gz9jBWDWvIaBGDC4xbLB4' # BO...
normal
{ "blob_id": "bc8d3a5e3ed845b4ab2d203bec47881be64ba3f8", "index": 3723, "step-1": "<mask token>\n", "step-2": "import discord\nfrom discord.ext import commands\nfrom os import path\nimport os\nimport datetime as dt\nimport numpy as np\nimport math\n", "step-3": "import discord\nfrom discord.ext import command...
[ 0, 1, 2 ]
from com.kakao.cafe.menu.tea.milkTea import MilkTea class MatchaMilkTea(MilkTea): def __init__(self): super().__init__() self.__matcha = 1 self.__condensedMilk = 1 self.name = "MatchaMilkTea" self.__price = 4500 self.__milk = 400 self.__blackTea = 2 de...
normal
{ "blob_id": "96b113678a3453520cd2e62eb11efd9582710409", "index": 2087, "step-1": "<mask token>\n\n\nclass MatchaMilkTea(MilkTea):\n <mask token>\n\n def getName(self) ->str:\n return self.name\n <mask token>\n <mask token>\n\n def setPrice(self, price: int) ->None:\n self.__price = p...
[ 9, 15, 20, 23, 24 ]
class TimeEntry: def __init__(self, date, duration, togglproject='default toggl', tdproject='default td', togglID='NULL', tdID='Null'): self.duration = duration self.date = date self.togglProject = togglproject self.tdProject = tdproject self.togglID = togglID ...
normal
{ "blob_id": "bdf2c35c12820dd31bd242ce1b6dae7271ceb2b7", "index": 8433, "step-1": "<mask token>\n", "step-2": "class TimeEntry:\n <mask token>\n", "step-3": "class TimeEntry:\n\n def __init__(self, date, duration, togglproject='default toggl',\n tdproject='default td', togglID='NULL', tdID='Null'...
[ 0, 1, 2 ]
from collections import deque def my_queue(n=5): return deque([], n) pass if __name__ == '__main__': mq = my_queue() for i in range(10): mq.append(i) print((i, list(mq))) """Queue size does not go beyond n int, this outputs: (0, [0]) (1, [0, 1]) (2, [0, 1, 2]) (3,...
normal
{ "blob_id": "499baaa8c739c1bd846edc944e510542d76bbed5", "index": 9312, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef my_queue(n=5):\n return deque([], n)\n pass\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef my_queue(n=5):\n return deque([], n)\n pass\n\n\nif __name__ == '_...
[ 0, 1, 2, 3 ]
#!/user/bin/env python3 -tt """ https://adventofcode.com/2017/day/7 """ import sys import re # Global variables task="d-7" infile=task + ".input" with open('input/' + infile) as file: input = file.read() file.close() class Node: parent = None children = None weight_sum = 0 def __init__(self, na...
normal
{ "blob_id": "679ca76212b90261683d59899c1189280b6b6e8c", "index": 5953, "step-1": "<mask token>\n\n\nclass Node:\n parent = None\n children = None\n weight_sum = 0\n\n def __init__(self, name, weight, linked):\n self.name = name\n self.weight = int(weight)\n self.weight_sum += sel...
[ 6, 8, 10, 12, 13 ]
import multiprocessing import time def foo(): time.sleep(0.1) p = multiprocessing.Process(target=foo) p.start() print("process running: ", p, p.is_alive()) p.terminate() print("process running: ", p, p.is_alive()) p.join() print("process running: ", p, p.is_alive()) print("process exit code:", p.exitcode)
normal
{ "blob_id": "19aad7d45416e311530aa2ce3e854cf1f65d18f5", "index": 960, "step-1": "<mask token>\n\n\ndef foo():\n time.sleep(0.1)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef foo():\n time.sleep(0.1)\n\n\n<mask token>\np.start()\nprint('process running: ', p, p.is_alive())\np.terminate()\nprint('...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Created on Sat Aug 3 17:16:12 2019 @author: Meagatron """ import numpy as np import pandas as pd import matplotlib.pyplot as plt from collections import defaultdict import math import itertools from dtw import dtw import timeit from helper_functions import normalize,alphabetize_ts,hammin...
normal
{ "blob_id": "16215ee42c4ea284dca0ebb7372fef04c0cc54b9", "index": 2149, "step-1": "<mask token>\n\n\ndef segment_ts():\n ts_len = len(x1)\n mod = ts_len % window_size\n rnge = 0\n if skip_offset == 0:\n ts_len = int((ts_len - mod - window_size) / 1)\n rnge = int(ts_len / window_size)\n ...
[ 4, 5, 6, 7, 8 ]
"""Coroutine utilities.""" from decorator import decorator @decorator def coroutine(f, *a, **kw): """This decorator starts the coroutine for us.""" i = f(*a, **kw) i.next() return i
normal
{ "blob_id": "6bde0ce30f33b155cc4c9ce9aa2ea6a6c5a1231d", "index": 5472, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@decorator\ndef coroutine(f, *a, **kw):\n \"\"\"This decorator starts the coroutine for us.\"\"\"\n i = f(*a, **kw)\n i.next()\n return i\n", "step-3": "<mask token>\nfr...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class CachedS3Storage(CachedFilesMixin, S3Boto3Storage): pass <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class CachedS3Storage(CachedFilesMixin, S3Boto3Storage): pass ...
flexible
{ "blob_id": "e99ff1c75d5108efc8d587d4533c34eeb15c6978", "index": 9425, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CachedS3Storage(CachedFilesMixin, S3Boto3Storage):\n pass\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass CachedS3Storage(CachedFilesMixin, S3Boto3Storage):\n p...
[ 0, 1, 2, 3 ]
from __future__ import absolute_import, division, print_function from .core import Bag, Item, from_sequence, from_filenames from ..context import set_options
normal
{ "blob_id": "4e77c7ac784ec235e9925004069131d16717e89a", "index": 9676, "step-1": "<mask token>\n", "step-2": "from __future__ import absolute_import, division, print_function\nfrom .core import Bag, Item, from_sequence, from_filenames\nfrom ..context import set_options\n", "step-3": null, "step-4": null, ...
[ 0, 1 ]
# # Copyright (C) 2017 Red Hat, Inc # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
normal
{ "blob_id": "a34584a71fdff65e5b1bb15a6304af79774dac2c", "index": 1315, "step-1": "<mask token>\n\n\ndef upgrade():\n op.drop_constraint('component_files_component_id_fkey', 'component_files')\n op.drop_constraint('components_topic_id_fkey', 'components')\n op.drop_constraint('files_job_id_fkey', 'files'...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def classify(inX, dataSet, labels, k): dataSetSize = dataSet.shape[0] diffMat = tile(inX, (dataSetSize, 1)) - dataSet sqDiffMat = diffMat ** 2 sqDistances = sqDiffMat.sum(axis=1) distances = sqDistances ** 0.5 sortedDistIndicies = distances.argsort() classCount...
flexible
{ "blob_id": "1ab5147ed8ce808de9667052b6d17f320d62484f", "index": 4694, "step-1": "<mask token>\n\n\ndef classify(inX, dataSet, labels, k):\n dataSetSize = dataSet.shape[0]\n diffMat = tile(inX, (dataSetSize, 1)) - dataSet\n sqDiffMat = diffMat ** 2\n sqDistances = sqDiffMat.sum(axis=1)\n distances...
[ 3, 5, 6, 7, 8 ]
from django.test import TestCase from django.urls import reverse from django.utils import timezone from recensioni_site import settings from django.contrib.auth.models import User from forum.models import Sezione,Post,UserDataReccomandation class testRegistrazione(TestCase): def setUp(self): self.credent...
normal
{ "blob_id": "cf9339659f49b4093c07e3723a2ede1543be41b8", "index": 4900, "step-1": "<mask token>\n\n\nclass testRegistrazione(TestCase):\n <mask token>\n\n def tearDown(self):\n self.proprietario1.delete()\n self.proprietario2.delete()\n self.user1.delete()\n self.user2.delete()\n...
[ 3, 4, 5, 6, 7 ]
import requests import time import urllib import argparse from bs4 import BeautifulSoup from selenium import webdriver from selenium.webdriver.common.keys import Keys from fake_useragent import UserAgent from multiprocessing import Pool from lxml.html import fromstring import os, sys #text = 'chowchowbaby' #url='https...
normal
{ "blob_id": "142a2ba3ec2f6b35f4339ed9fffe7357c1a85fa0", "index": 219, "step-1": "<mask token>\n\n\ndef search(url):\n browser = webdriver.Chrome(executable_path=\n 'C:\\\\Users\\\\inaee\\\\Downloads\\\\chromedriver_win32\\\\chromedriver.exe')\n browser.get(url)\n time.sleep(1)\n element = brow...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class BruteForce(Mono): <|reserved_special_token_0|> def _count_inconsistencies(self): if self.num_cores == 1: for ni in self.nonmatch_indices: self.index2count[ni] = 0 fo...
flexible
{ "blob_id": "32c18bd578bbf91c76604f063421a65a4f7a8b63", "index": 2204, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BruteForce(Mono):\n <mask token>\n\n def _count_inconsistencies(self):\n if self.num_cores == 1:\n for ni in self.nonmatch_indices:\n self...
[ 0, 3, 4, 5, 6 ]
# boj, 9237 : 이장님 초대, python3 # 그리디 알고리즘 import sys def tree(l): return max([i+j+2 for i,j in enumerate(l)]) N = int(sys.stdin.readline()) t = sorted(list(map(int, sys.stdin.readline().split())), reverse = True) print(tree(t))
normal
{ "blob_id": "e79cdd32977eb357c3f6709887b671c50eb1fa45", "index": 7071, "step-1": "<mask token>\n\n\ndef tree(l):\n return max([(i + j + 2) for i, j in enumerate(l)])\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef tree(l):\n return max([(i + j + 2) for i, j in enumerate(l)])\n\n\n<mask token>\npri...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append('.') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append('.') BROKER_CONF = {'uid': '{{ mq_user }}', 'pass': '{{ mq_password }}', 'host': '{{ mq_host }}', '...
flexible
{ "blob_id": "1a569b88c350124968212cb910bef7b09b166152", "index": 8990, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('.')\n<mask token>\n", "step-3": "<mask token>\nsys.path.append('.')\nBROKER_CONF = {'uid': '{{ mq_user }}', 'pass': '{{ mq_password }}', 'host':\n '{{ mq_host }}', '...
[ 0, 1, 2, 3, 4 ]
# Author: Kenneth Lui <hkkenneth@gmail.com> # Last Updated on: 01-11-2012 ## Usage: python ~/code/python/001_Fastq_Trimming.py <FIRST BASE> <LAST BASE> <FASTQ FILES....> ## Bases are inclusive and 1-based #from Bio.SeqIO.QualityIO import FastqGeneralIterator #handle = open(sys.argv[2], 'w') #for title, seq, qual in Fa...
normal
{ "blob_id": "4a8663531f303da29371078e34dc7224fc4580e3", "index": 6283, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor s in sys.argv[3:]:\n file = open(s + '.' + sys.argv[1] + '-' + sys.argv[2] + '.trimmed', 'w')\n r_list = []\n size = 0\n for r in SeqIO.parse(s, 'fastq'):\n r_list....
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Reader(Thread): <|reserved_special_token_0|> def __del__(self): self._frame = None self._stream.release() <|reserved_special_token_0|> def read(self): return self._frame <|reserved_special_token_1|> <|reserved_special_token_0|> class Re...
flexible
{ "blob_id": "73bf31e43394c3f922b00b2cfcd5d88cc0e01094", "index": 2339, "step-1": "<mask token>\n\n\nclass Reader(Thread):\n <mask token>\n\n def __del__(self):\n self._frame = None\n self._stream.release()\n <mask token>\n\n def read(self):\n return self._frame\n", "step-2": "<...
[ 3, 4, 5, 6 ]
import torch as th from tpp.processes.hawkes.r_terms_recursive_v import get_r_terms from tpp.utils.test import get_test_events_query def run_test(): marks = 3 events, query = get_test_events_query(marks=marks) beta = th.rand([marks, marks]) get_r_terms(events=events, beta=beta) if __name__ == '__mai...
normal
{ "blob_id": "2681bd9fe93a4d61214b7c45e5d73097ab73dc07", "index": 5486, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run_test():\n marks = 3\n events, query = get_test_events_query(marks=marks)\n beta = th.rand([marks, marks])\n get_r_terms(events=events, beta=beta)\n\n\n<mask token>...
[ 0, 1, 2, 3 ]
import unittest2 as unittest from zope.component import getUtility from plone.registry.interfaces import IRegistry from plone.testing.z2 import Browser from plone.app.testing import SITE_OWNER_NAME, SITE_OWNER_PASSWORD from openmultimedia.imagewatchdog.configlet import IImageWatchDogSettings from openmultimedia.image...
normal
{ "blob_id": "ce5f91aa04065aac4d4bc7bdbaab3b74c5a85a93", "index": 8752, "step-1": "<mask token>\n\n\nclass TestConfiglet(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_default_config(self):\n \"\"\" Validate the default values\n \"\"\"\n registry = getUtility(IRegistr...
[ 4, 6, 7, 8, 9 ]
# -*- coding: utf-8 -*- # __author__ = 'XingHuan' # 3/27/2018 import os import imageio import time os.environ['IMAGEIO_FFMPEG_EXE'] = 'D:/Program Files/ffmpeg-3.4/bin/ffmpeg.exe' reader = imageio.get_reader('test1080.mov') print reader fps = reader.get_meta_data()['fps'] print fps # for i, im in enumerate(reader)...
normal
{ "blob_id": "1e292872c0c3c7f4ec0115f0769f9145ef595ead", "index": 8325, "step-1": "# -*- coding: utf-8 -*-\n# __author__ = 'XingHuan'\n# 3/27/2018\n\nimport os\nimport imageio\nimport time\n\nos.environ['IMAGEIO_FFMPEG_EXE'] = 'D:/Program Files/ffmpeg-3.4/bin/ffmpeg.exe'\n\n\nreader = imageio.get_reader('test1080...
[ 0 ]
# 自定义购物车项类 class CartItem(): def __init__(self, book, amount): self.book = book self.amount = int(amount) # 自定义购物车 class Cart(): def __init__(self): self.book_list = [] self.total = 0 self.save = 0 def total_price(self): ele = 0 for i in self.book_li...
normal
{ "blob_id": "58efaad41d02bb5dffbf71c478c7fad12af68e5b", "index": 9900, "step-1": "<mask token>\n\n\nclass Cart:\n\n def __init__(self):\n self.book_list = []\n self.total = 0\n self.save = 0\n\n def total_price(self):\n ele = 0\n for i in self.book_list:\n ele ...
[ 5, 6, 7, 8, 9 ]
"""APP Cloud Connect errors""" class CCEError(Exception): pass class ConfigException(CCEError): """Config exception""" pass class FuncException(CCEError): """Ext function call exception""" pass class HTTPError(CCEError): """ HTTPError raised when HTTP request returned a error.""" de...
normal
{ "blob_id": "e2840eb1b0d731d6b0356835ba371d05ba351ff6", "index": 5323, "step-1": "<mask token>\n\n\nclass HTTPError(CCEError):\n \"\"\" HTTPError raised when HTTP request returned a error.\"\"\"\n\n def __init__(self, reason=None):\n \"\"\"\n Initialize HTTPError with `response` object and `s...
[ 8, 9, 10, 12, 14 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while i >= 100: print(i) i -= 1 print(i) <|reserved_special_token_1|> i = 100 while i >= 100: print(i) i -= 1 print(i)
flexible
{ "blob_id": "9527743802a0bb680ab3dcf325c0f7749a51afc6", "index": 5949, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile i >= 100:\n print(i)\ni -= 1\nprint(i)\n", "step-3": "i = 100\nwhile i >= 100:\n print(i)\ni -= 1\nprint(i)\n", "step-4": null, "step-5": null, "step-ids": [ 0, ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class RegexCompiles: re_compile_product_id = re.compile('Product-Id=[0-9]*') re_compile_id = re.compile('[0-9]+') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class RegexCompiles: re_compile_product_id = re.compile('Product-Id=[...
flexible
{ "blob_id": "b1c06e9c5516a378c0bbce2ce9e17afaeae01928", "index": 668, "step-1": "<mask token>\n\n\nclass RegexCompiles:\n re_compile_product_id = re.compile('Product-Id=[0-9]*')\n re_compile_id = re.compile('[0-9]+')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass RegexCompiles:\n re_compile_...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> @require_superuser def index(request): template_name = 'users/index.html' msg = '' try: users = User.objects.exclude(id=request.user.id) except: msg = _('Unable to list users.') LOG.error(msg) users = [] paginator = Paginator(users, PAGE...
flexible
{ "blob_id": "b739a5d359b4d1c0323c7cd8234e4fe5eb9f3fcb", "index": 6286, "step-1": "<mask token>\n\n\n@require_superuser\ndef index(request):\n template_name = 'users/index.html'\n msg = ''\n try:\n users = User.objects.exclude(id=request.user.id)\n except:\n msg = _('Unable to list users...
[ 8, 9, 10, 11, 12 ]
<|reserved_special_token_0|> def appendix_and_index_pages(): """ Prompt user to input appendix pages (if one exists) and index pages :return: start and end pages of the appendix and index """ def index_pages(): """ Prompt user to input index pages :return: start and end pa...
flexible
{ "blob_id": "2b3a42fed98b43cdd78edd751b306ba25328061a", "index": 8652, "step-1": "<mask token>\n\n\ndef appendix_and_index_pages():\n \"\"\"\n Prompt user to input appendix pages (if one exists) and index pages\n :return: start and end pages of the appendix and index\n \"\"\"\n\n def index_pages()...
[ 2, 5, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> eval(compile(base64.b64decode(code), '<string>', 'exec')) <|reserved_special_token_1|> <|reserved_special_token_0|> code = ( b'CmltcG9ydCBweW1vbmdvCmltcG9ydCByYW5kb20KaW1wb3J0IHJlCmltcG9ydCBzdHJpbmcKaW1wb3J0IHN5cwppbXBvcnQg...
flexible
{ "blob_id": "c7f26978333c7e6cccf7451ea5d10511a66b62c2", "index": 1908, "step-1": "<mask token>\n", "step-2": "<mask token>\neval(compile(base64.b64decode(code), '<string>', 'exec'))\n", "step-3": "<mask token>\ncode = (\n b'CmltcG9ydCBweW1vbmdvCmltcG9ydCByYW5kb20KaW1wb3J0IHJlCmltcG9ydCBzdHJpbmcKaW1wb3J0IH...
[ 0, 1, 2, 3, 4 ]
#到达终点的最小步数 leetcode原题 754 https://leetcode.com/problems/reach-a-number/solution/ # 分情况讨论:到target与到abs(target)的情况是一样的 # 1. total = 1+2+...+k,求total刚好大于等于n的k,可知到达target至少要用k步,此时超出d=total-k # 2. 如果d为偶数,则只需将d/2步反向即可,k步即可到达target # 3. 如果d为奇数,则k步不可能到达,因为任何反转都会改变偶数距离,不可能消去d,则再走一步判断d+k+1是否为偶数 # 4. 如果为偶数,说明k+1步可到 # 5. 如果d+k+1为奇...
normal
{ "blob_id": "4b255b648f67e6bcc30eecc7975bbb1a356b2499", "index": 2656, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution(object):\n\n def reachNumber(self, target):\n target = abs(target)\n k = 0\n while ta...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class BFCell: <|reserved_special_token_0|> def __init__(self, r, c, id, occupied): """BFCell(row, col)""" self.r = r self.c = c self.id = id self.occupied = occupied def __repr__(self): return str(self) def __str__(self): ...
flexible
{ "blob_id": "86d3e90493ed04bbe23792716f46a68948911dc3", "index": 6861, "step-1": "<mask token>\n\n\nclass BFCell:\n <mask token>\n\n def __init__(self, r, c, id, occupied):\n \"\"\"BFCell(row, col)\"\"\"\n self.r = r\n self.c = c\n self.id = id\n self.occupied = occupied\...
[ 7, 12, 15, 16, 20 ]
# python examples/mnist_rnn.py --bsz 128 --bsz-eval 256 import sys from argparse import ArgumentParser import pytorch_lightning as pl import torch.nn as nn import torch.optim as optim from loguru import logger from slp.config.config_parser import make_cli_parser, parse_config from slp.data.collators import SequenceCl...
normal
{ "blob_id": "d8a09f9952856da69120fae6221636dd5bd8c93e", "index": 3567, "step-1": "<mask token>\n\n\nclass Net(nn.Module):\n\n def __init__(self, input_size, hidden_size=40, num_classes=10,\n bidirectional=False):\n super().__init__()\n self.encoder = RNN(input_size, hidden_size, bidirecti...
[ 4, 5, 6, 7, 9 ]
from rest_framework.views import APIView from rest_framework.response import Response from drf_yasg.utils import swagger_auto_schema from theme.models import UserProfile from hs_core.views import serializers class UserInfo(APIView): @swagger_auto_schema(operation_description="Get information about the logged in ...
normal
{ "blob_id": "c45ffe8cba8d152e346182252dbc43e22eaf83e2", "index": 3498, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass UserInfo(APIView):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass UserInfo(APIView):\n\n @swagger_auto_schema(operation_description=\n 'Get information abo...
[ 0, 1, 2, 3, 4 ]
import os as os import io as io import re class Stopwords: def __init__(self, base_dir='data'): self.base_dir = base_dir def load_stopwords(self, base_dir=None, stopwords_file='stopwords.csv'): # Load stopwords from file. if base_dir is not None: self.base_dir = base_dir ...
normal
{ "blob_id": "dad4e14da734f2e2329f4cbe064c73c82a4ae27c", "index": 8119, "step-1": "<mask token>\n\n\nclass Stopwords:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Stopwords:\n\n def __init__(self, base_dir='data'):\n self.base_dir = base_dir\n <mask token>\n", "step-...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def counter(count): for i in range(count): time.sleep(1) print('[%s] => %s' % (os.getpid(), i)) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def counter(count)...
flexible
{ "blob_id": "fd564d09d7320fd444ed6eec7e51afa4d065ec4d", "index": 6945, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef counter(count):\n for i in range(count):\n time.sleep(1)\n print('[%s] => %s' % (os.getpid(), i))\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef counter...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python # -*- coding: utf-8 -*- # Import the otb applications package import otbApplication def ComputeHaralick(image, chan, xrad, yrad): # The following line creates an instance of the HaralickTextureExtraction application HaralickTextureExtraction = otbApplication.Registry.CreateApplication("Haral...
normal
{ "blob_id": "b4992a5b396b6809813875443eb8dbb5b00eb6a9", "index": 4865, "step-1": "#!/usr/bin/python \n# -*- coding: utf-8 -*-\n\n# Import the otb applications package \nimport otbApplication \n \ndef ComputeHaralick(image, chan, xrad, yrad):\n\n\t# The following line creates an instance of the HaralickTextureExt...
[ 0 ]
from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ class SearchConfig(AppConfig): name = 'search' verbose_name = _("Search")
normal
{ "blob_id": "f47e4d6ff079b6ac2320467d87b34ae82face032", "index": 4506, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SearchConfig(AppConfig):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass SearchConfig(AppConfig):\n name = 'search'\n verbose_name = _('Search...
[ 0, 1, 2, 3, 4 ]
"""Primer3 input form. For details on input params see: https://primer3.org/manual.html#globalTags """ from django import forms from django.core.exceptions import ValidationError from .fasta import Fasta class PrimerForm(forms.Form): """Collect user input to run primer prediction.""" fasta = forms.CharFie...
normal
{ "blob_id": "6291375738db7914d551f9a1c6d2897b7d236b87", "index": 1742, "step-1": "<mask token>\n\n\nclass PrimerForm(forms.Form):\n <mask token>\n fasta = forms.CharField(initial='')\n primer_min = forms.IntegerField(initial=18, max_value=35)\n primer_max = forms.IntegerField(initial=27, max_value=35...
[ 3, 4, 5, 6, 7 ]
import json import random from time import sleep url = "data/data.json" def loop(run_state): error = 1 simulations = 1 while run: error_margin = str((error/simulations) * 100) + "%" prediction = get_prediction() print("Prediction: %s" % prediction) print("Error Margin: %...
normal
{ "blob_id": "25ff54a969651d365de33f2420c662518dd63738", "index": 864, "step-1": "<mask token>\n\n\ndef loop(run_state):\n error = 1\n simulations = 1\n while run:\n error_margin = str(error / simulations * 100) + '%'\n prediction = get_prediction()\n print('Prediction: %s' % predict...
[ 5, 6, 7, 8, 9 ]
"""byte - property model module.""" from __future__ import absolute_import, division, print_function class BaseProperty(object): """Base class for properties.""" def get(self, obj): """Get property value from object. :param obj: Item :type obj: byte.model.Model """ ra...
normal
{ "blob_id": "382f7119beba81087c497baf170eb6814c26c03e", "index": 5458, "step-1": "<mask token>\n\n\nclass BaseProperty(object):\n <mask token>\n <mask token>\n\n def set(self, obj, value):\n \"\"\"Set property value on object.\n\n :param obj: Item\n :type obj: byte.model.Model\n\n ...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/python import sys,os import argparse import subprocess from pprint import pprint chroot_start_path="/srv/chroot" chroots_conf="/etc/schroot/chroot.d" build_pkgs = 'build-essential fakeroot devscripts apt-utils' include = 'eatmydata,ccache,lintian' distro_conf={ 'debootstrap_mirror':None, 'componen...
normal
{ "blob_id": "600691b87f7776e96bbf439d7195b870ed86090b", "index": 1145, "step-1": "<mask token>\n\n\ndef configure_distro(distro='debian', arch='i386', release='unstable'):\n if distro not in ['ubuntu', 'debian']:\n print('Unknown Distro %s' % distro)\n return False\n if distro == 'ubuntu':\n ...
[ 2, 3, 4, 5, 6 ]
from matplotlib.backends.backend_pdf import PdfPages import matplotlib.pyplot as plt from scipy.misc import imread import os import numpy as np files = [ "oracle.PNG", "SQL.jpg" ] def plotImage(f): folder = "C:/temp/" im = imread(os.path.join(folder, f)).astype(np.float32) / 255 plt.im...
normal
{ "blob_id": "146db68fb84569b914fa741457c595108088dc63", "index": 7199, "step-1": "<mask token>\n\n\ndef plotImage(f):\n folder = 'C:/temp/'\n im = imread(os.path.join(folder, f)).astype(np.float32) / 255\n plt.imshow(im)\n a = plt.gca()\n a.get_xaxis().set_visible(False)\n a.get_yaxis().set_vis...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> """ 《Engineering a Compiler》 即《编译器设计第二版》 https://www.clear.rice.edu/comp412/ """ # 《parsing-techniques》 讲前端 ## http://parsing-techniques.duguying.net/ebook/2/1/3.html """ 前端看Parsing Techniques,后端看鲸书,都是最好的。 """ # 《essential of programming language》 # sicp ...
flexible
{ "blob_id": "5663ded291405bcf0d410041485487bb17560223", "index": 3106, "step-1": "<mask token>\n", "step-2": "\n\"\"\"\n《Engineering a Compiler》\n即《编译器设计第二版》\nhttps://www.clear.rice.edu/comp412/\n\"\"\"\n# 《parsing-techniques》 讲前端\n## http://parsing-techniques.duguying.net/ebook/2/1/3.html\n\n\"\"\"\n前端看Parsin...
[ 0, 1 ]
import struct def parse(message): return IGENMessage.from_bytes(message) class IGENMessage(object): def __init__(self): self.serial = None self.temperature = None self.pv1 = 0 self.pv2 = 0 self.pv3 = 0 self.pa1 = 0 self.pa2 = 0 self.pa3 = 0 ...
normal
{ "blob_id": "5df42a024e1edbe5cc977a814efe580db04b8b76", "index": 2386, "step-1": "<mask token>\n\n\nclass IGENMessage(object):\n\n def __init__(self):\n self.serial = None\n self.temperature = None\n self.pv1 = 0\n self.pv2 = 0\n self.pv3 = 0\n self.pa1 = 0\n s...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> def GetPage5Docx(fileNameWithPath): word = Dispatch('Word.Application') word.Visible = False word = word.Documents.Open(fileNameWithPath) word.Repaginate() num_of_sheets = word.ComputeStatistics(2) return num_of_sheets def GetPage5PPT(fileNameWithPath): Appli...
flexible
{ "blob_id": "67f09cd8b41c7a4fe457766dfed916aaf71cc20d", "index": 9489, "step-1": "<mask token>\n\n\ndef GetPage5Docx(fileNameWithPath):\n word = Dispatch('Word.Application')\n word.Visible = False\n word = word.Documents.Open(fileNameWithPath)\n word.Repaginate()\n num_of_sheets = word.ComputeStat...
[ 2, 3, 4, 5, 6 ]
# Input Output test (입출력 테스트 ) """ 날짜 : 2021/04/27 이름 : 이지영 내용 : 파이썬 표준입출력 실습 _ 교재 p42 """ # 파이썬 표준 출력 print('hello', end='!') #print : 출력함수 (자바에선 document.write('hello');) print('python') print('010', '1234', '1111', sep='-') # seperate 값 # 파이썬 표준 입력 num = input('숫자입력 : ') print('입력한 숫자 :', num) print('num type :'...
normal
{ "blob_id": "cc628270a973866025a5e2a5d07e39b4dbdcd324", "index": 1718, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('hello', end='!')\nprint('python')\nprint('010', '1234', '1111', sep='-')\n<mask token>\nprint('입력한 숫자 :', num)\nprint('num type :', type(num))\n<mask token>\nprint('result :', resu...
[ 0, 1, 2, 3 ]
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import copy import json import os import convlab from convlab.modules.dst.multiwoz.dst_util import init_state from convlab.modules.dst.multiwoz.dst_util import normalize_value from convlab.modules.dst.state_tracker import Tracker from convlab.mo...
normal
{ "blob_id": "8de82d09c8a9a1c1db59b0cac9cf8dda04f35847", "index": 3335, "step-1": "<mask token>\n\n\nclass RuleDST(Tracker):\n <mask token>\n\n def __init__(self):\n Tracker.__init__(self)\n self.state = init_state()\n prefix = os.path.dirname(os.path.dirname(convlab.__file__))\n ...
[ 3, 4, 5, 6, 7 ]
import boto3 import os from trustedadvisor import authenticate_support accountnumber = os.environ['Account_Number'] rolename = os.environ['Role_Name'] rolesession = accountnumber + rolename def lambda_handler(event, context): sts_client = boto3.client('sts') assumerole = sts_client.assume_role( Role...
normal
{ "blob_id": "539431649e54469ddbe44fdbd17031b4449abdd9", "index": 5867, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lambda_handler(event, context):\n sts_client = boto3.client('sts')\n assumerole = sts_client.assume_role(RoleArn='arn:aws:iam::' +\n accountnumber + ':role/' + rolena...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class GoldenTemplate(BasicTemplate): <|reserved_special_token_0|> sidebar_width = param.Integer(default=20, constant=True, doc= """ The width of the sidebar in percent.""") _css = pathlib.Path(__file__).parent / 'golden.css' _template = pathlib.Path(__file_...
flexible
{ "blob_id": "5bfb69d1608b397d6a19e663164a30089e4f67ad", "index": 2859, "step-1": "<mask token>\n\n\nclass GoldenTemplate(BasicTemplate):\n <mask token>\n sidebar_width = param.Integer(default=20, constant=True, doc=\n \"\"\"\n The width of the sidebar in percent.\"\"\")\n _css = pathlib.Pa...
[ 4, 5, 6, 7, 8 ]
import sys numList = list(range(3)) for i in range(3): numList[i] = int(sys.stdin.readline()) result = numList[0] * numList[1] * numList[2] resultList = list(str(result)) intList = list(range(10)) for i in intList: print(resultList.count(str(i)))
normal
{ "blob_id": "c3de6cd76ca7180a1a4d236bb2a6a18f7594f38b", "index": 1304, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(3):\n numList[i] = int(sys.stdin.readline())\n<mask token>\nfor i in intList:\n print(resultList.count(str(i)))\n", "step-3": "<mask token>\nnumList = list(range(3)...
[ 0, 1, 2, 3 ]
def get_bios_boot_order(self): result = { } boot_device_list = [] boot_device_details = [] key = 'Bios' bootsources = 'BootSources' response = self.get_request((self.root_uri + self.systems_uri)) if (response['ret'] is False): return response result['ret'] = True ...
normal
{ "blob_id": "bbe7df31a44ccf51c305cd620dc7c4155b7e1a97", "index": 2668, "step-1": "<mask token>\n", "step-2": "def get_bios_boot_order(self):\n result = {}\n boot_device_list = []\n boot_device_details = []\n key = 'Bios'\n bootsources = 'BootSources'\n response = self.get_request(self.root_ur...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def read_chunk(reader, chunk_size): data = {} for i in range(chunk_size): ret = reader.read_next() for k, v in ret.items(): if k not in data: data[k] = [] data[k].a...
flexible
{ "blob_id": "dc28c3426f47bef8b691a06d54713bc68696ee44", "index": 8309, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef read_chunk(reader, chunk_size):\n data = {}\n for i in range(chunk_size):\n ret = reader.read_next()\n for k, v in ret.items():\n if k not in data:\...
[ 0, 1, 2, 3 ]
from django.apps import AppConfig class FitnerappConfig(AppConfig): name = 'fitnerapp'
normal
{ "blob_id": "6546d04d3755d62d1a8756bdec1a10f6f018dcea", "index": 5638, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass FitnerappConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass FitnerappConfig(AppConfig):\n name = 'fitnerapp'\n", "step-4": "from django.apps impo...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class WorkersOrchestrator: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class WorkersOrchestrator: @classmethod def worker_func(cls, worker): worker.start_consumption() <|reserved_spec...
flexible
{ "blob_id": "6a4a5eac1b736ee4f8587adba298571f90df1cf9", "index": 8864, "step-1": "<mask token>\n\n\nclass WorkersOrchestrator:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass WorkersOrchestrator:\n\n @classmethod\n def worker_func(cls, worker):\n worker.start_consumption...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> class PlayOut(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.wavefiles = [f for f in listdir('./en') if path.isfile(path. join('./en', f))] def run(self): for wav in list(self.wavefiles): global flgPlay...
flexible
{ "blob_id": "8c458d66ab2f9a1bf1923eecb29c3c89f2808d0b", "index": 3889, "step-1": "<mask token>\n\n\nclass PlayOut(threading.Thread):\n\n def __init__(self):\n threading.Thread.__init__(self)\n self.wavefiles = [f for f in listdir('./en') if path.isfile(path.\n join('./en', f))]\n\n ...
[ 3, 4, 5, 6, 7 ]
from flask import Flask, request, render_template from utils import get_result app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') @app.route("/result", methods=["POST"]) def result(): form_data = request.form sentence = form_data['sentence'] output = get_result...
normal
{ "blob_id": "264da5a2ab7d5c311d8a59b06c81ea2156cefd76", "index": 9627, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('index.html')\n\n\n@app.route('/result', methods=['POST'])\ndef result():\n form_data = request.form\n sentence = form_data['sentence']\n output =...
[ 2, 3, 4, 5, 6 ]
class car: def info(self): print(self.speed, self.color, self.model) def increment(self): print('increment') <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class car: def info(self): print(self.speed, self.color, self.model) de...
flexible
{ "blob_id": "022f588455d8624d0b0107180417f65816254cb1", "index": 8687, "step-1": "class car:\n\n def info(self):\n print(self.speed, self.color, self.model)\n\n def increment(self):\n print('increment')\n <mask token>\n\n\n<mask token>\n", "step-2": "class car:\n\n def info(self):\n ...
[ 3, 4, 5, 6 ]
files = [ "arria2_ddr3.qip" ]
normal
{ "blob_id": "cad881dd29be16de8375b3ce6e4a437562a05097", "index": 5426, "step-1": "<mask token>\n", "step-2": "files = ['arria2_ddr3.qip']\n", "step-3": "files = [\n \"arria2_ddr3.qip\"\n ]\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from arma_scipy.fit import fit, predict
flexible
{ "blob_id": "0f6512bb734336a67eab2f13949dd960f5ffc1d5", "index": 7758, "step-1": "<mask token>\n", "step-2": "from arma_scipy.fit import fit, predict\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#-*- coding: utf-8 -*- from SPARQLWrapper import SPARQLWrapper, SPARQLWrapper2, JSON import time, random # testes NOW=time.time() sparql = SPARQLWrapper("http://dbpedia.org/sparql") sparql.setQuery(""" PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label WHERE { <http://dbpedia.org/resource/L...
normal
{ "blob_id": "c5b50420788ddde7483a46c66aca3922ddb47952", "index": 6199, "step-1": "<mask token>\n\n\ndef document_features(documento):\n features = {}\n for palavra in palavras_escolhidas:\n features['contains(%s)' % (palavra,)] = palavra in documento\n return features\n\n\n<mask token>\n", "ste...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def hmac_sha1_token(): timestamp = str(time.time()) hmac_pass = hmac.new(b'some very secret string', timestamp.encode( 'utf-8'), hashlib.sha1).hexdigest() token = '%s:%s' % (timestamp, hmac_pass) return t...
flexible
{ "blob_id": "65ef3b2ed5eef3d9d9e682ca18cf84457e929df2", "index": 2222, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef hmac_sha1_token():\n timestamp = str(time.time())\n hmac_pass = hmac.new(b'some very secret string', timestamp.encode(\n 'utf-8'), hashlib.sha1).hexdigest()\n toke...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def test_create_table_with_default_options(pawprint_default_tracker_db): """Ensure the table is correctly created with the default schema.""" tracker = pawprint_default_tracker_db assert tracker.create_table() is None with pytest.raises(ProgrammingError): tracker.c...
flexible
{ "blob_id": "89a75ae980b7b48d33d0e8aa53ec92296dbfbc8e", "index": 2843, "step-1": "<mask token>\n\n\ndef test_create_table_with_default_options(pawprint_default_tracker_db):\n \"\"\"Ensure the table is correctly created with the default schema.\"\"\"\n tracker = pawprint_default_tracker_db\n assert track...
[ 8, 15, 18, 20, 21 ]
from funct import read_excel import requests import unittest import HTMLTestReportCN class v2exapi(unittest.TestCase): def test_node_api(self): url = "https://www.v2ex.com/api/nodes/show.json" #querystring = {"name":"php"} a=read_excel("xx.xlsx",0,0) for node_name in a: #fo...
normal
{ "blob_id": "5cd573f2b7f91a8b20e96deb1004c0ef7fc62398", "index": 8072, "step-1": "<mask token>\n\n\nclass v2exapi(unittest.TestCase):\n\n def test_node_api(self):\n url = 'https://www.v2ex.com/api/nodes/show.json'\n a = read_excel('xx.xlsx', 0, 0)\n for node_name in a:\n respon...
[ 2, 3, 4, 5, 6 ]
from tkinter import * # Everything in tkinter is a widget # We start with the Root Widget root = Tk() # Creating a Label Widget myLabel1 = Label(root, text="Hello User!") myLabel2 = Label(root, text="Welcome to medBOT") # Put labels onto the screen myLabel1.grid(row=0, column=0) myLabel2.grid(row=1, column=0) # Grid...
normal
{ "blob_id": "93fe16e5a97ec2652c4f6b8be844244d9776ea2e", "index": 4921, "step-1": "<mask token>\n", "step-2": "<mask token>\nmyLabel1.grid(row=0, column=0)\nmyLabel2.grid(row=1, column=0)\nroot.mainloop()\n", "step-3": "<mask token>\nroot = Tk()\nmyLabel1 = Label(root, text='Hello User!')\nmyLabel2 = Label(ro...
[ 0, 1, 2, 3, 4 ]
from __future__ import absolute_import from __future__ import division from __future__ import print_function from keras.layers import Dense, Input from keras.layers import Conv2D, Flatten, Lambda from keras.layers import Reshape, Conv2DTranspose from keras.models import Model from keras.losses import mse, binary_cross...
normal
{ "blob_id": "88343b9c5cac3510e8cea75ac5b11f517ddc164b", "index": 5943, "step-1": "<mask token>\n\n\ndef sampling(args):\n \"\"\"Reparameterization trick by sampling fr an isotropic unit Gaussian.\n # Arguments\n args (tensor): mean and log of variance of Q(z|X)\n # Returns\n z (tensor): sa...
[ 2, 3, 4, 5, 6 ]
from bs4 import BeautifulSoup import os, re, json import pandas as pd from urllib import request from openpyxl import load_workbook from bilibili.append_xlsx import append_df_to_excel # 获取页面的所有的avid, title, url def parse_html(content): arr = [] # 使用beautifulsoup解析html文档 soup = BeautifulSoup(content) ...
normal
{ "blob_id": "a63718ba5f23d6f180bdafcb12b337465d6fa052", "index": 4734, "step-1": "<mask token>\n\n\ndef read_path(path):\n path_set = set()\n dir_path = os.listdir(path)\n for item in dir_path:\n child = os.path.join('%s/%s' % (path, item))\n path_set.add(child)\n return path_set\n\n\nd...
[ 4, 5, 7, 8, 10 ]
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns sns.set() import bootcamp_utils import numba @numba.jit(nopython=True) def backtrack_steps(): """ Compute the number of steps it takes a 1d random walker starting at zero to get to +1. """ # Initialize p...
normal
{ "blob_id": "00a2992af78f9edadd3f4cbc7d073c1f74fcd9a2", "index": 2810, "step-1": "<mask token>\n\n\n@numba.jit(nopython=True)\ndef backtrack_steps():\n \"\"\"\n Compute the number of steps it takes a 1d random walker starting\n at zero to get to +1.\n \"\"\"\n x = 0\n n_steps = 0\n while x <...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class CollectionMixin(with_metaclass(ABCMeta, object)): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class CollectionMixin(with_metaclass(ABCMeta, object)): <|reserved_special_token_0|> def iterat...
flexible
{ "blob_id": "b63ed9e09b9e8c539aff765d719f3610283663fe", "index": 4496, "step-1": "<mask token>\n\n\nclass CollectionMixin(with_metaclass(ABCMeta, object)):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass CollectionMixin(with_metaclass(ABCMeta, object)):\n <mask token>\n\n def i...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class RelationshipPrediction(object): <|reserved_special_token_0|> <|reserved_special_token_0|> def __unicode__(self): return u'%s <- %s: %f, %s' % (self.subject, self.object_, self. expectancy, ...
flexible
{ "blob_id": "c3de9e6129bcafd863cd330ac281345fb563cc8c", "index": 6259, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass RelationshipPrediction(object):\n <mask token>\n <mask token>\n\n def __unicode__(self):\n return u'%s <- %s: %f, %s' % (self.subject, self.object_, self.\n ...
[ 0, 2, 3, 4, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': with open('id_generator.bin', 'rb') as f: print(pickle.load(f)) <|reserved_special_token_1|> import pickle if __name__ == '__main__': with open('id_generator.bin', 'rb') as f: ...
flexible
{ "blob_id": "080110e404cf5edfe53622a5942b53f9188ddd76", "index": 1854, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n with open('id_generator.bin', 'rb') as f:\n print(pickle.load(f))\n", "step-3": "import pickle\nif __name__ == '__main__':\n with open('id_gene...
[ 0, 1, 2 ]
""" Python package setup file. """ from setuptools import setup setup( name="TF_Speech", version="0.2.0", extras_require={'tensorflow': ['tensorflow'], 'tensorflow with gpu': ['tensorflow-gpu']}, )
normal
{ "blob_id": "97ebdeada3d797a971b5c3851b75f9754595f67c", "index": 358, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='TF_Speech', version='0.2.0', extras_require={'tensorflow': [\n 'tensorflow'], 'tensorflow with gpu': ['tensorflow-gpu']})\n", "step-3": "<mask token>\nfrom setuptools impo...
[ 0, 1, 2, 3 ]
# __author__: Stanley # date: 2018/10/22 class Foo: def __init__(self, name, age): self.name = name self.age = age def __getitem__(self, item): return item + 10 def __setitem__(self, key, value): print(key, value) def __delitem__(self, key): print(key) obj =...
normal
{ "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 ]
# # 8/19/2020 # Of course, binary classification is just a single special case. Target encoding could be applied to any target variable type: # For binary classification usually mean target encoding is used # For regression mean could be changed to median, quartiles, etc. # For multi-class classification with N classe...
normal
{ "blob_id": "5433e75bdc46d5a975969e7ece799174dc9b8713", "index": 2918, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(test[['RoofStyle', 'RoofStyle_enc']].drop_duplicates())\n", "step-3": "train['RoofStyle_enc'], test['RoofStyle_enc'] = mean_target_encoding(train=\n train, test=test, target='S...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class RwidSpider(scrapy.Spider): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def parse(self, response): data = {'username': 'user', 'password': 'user12345'} return scrapy.FormRequest(url='http://0.0.0.0:9999/login...
flexible
{ "blob_id": "2185d332f7cd4cbf17d6b72a19297d156c2182a1", "index": 2233, "step-1": "<mask token>\n\n\nclass RwidSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n\n def parse(self, response):\n data = {'username': 'user', 'password': 'user12345'}\n return scrapy.FormReq...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): os.chdir(common.root) shutil.rmtree('shared/target', ignore_errors=True) shutil.rmtree('platform/build', ignore_errors=True) shutil.rmtree('platform/target', ignore_errors=True) shutil.rmtree('tes...
flexible
{ "blob_id": "2305d0b7ec0d9e08e3f1c0cedaafa6ed60786e50", "index": 7359, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n os.chdir(common.root)\n shutil.rmtree('shared/target', ignore_errors=True)\n shutil.rmtree('platform/build', ignore_errors=True)\n shutil.rmtree('platform/ta...
[ 0, 1, 2, 3, 4 ]
import tkinter as tk import random root = tk.Tk() main_frame = tk.Frame(root) var = tk.StringVar() ch = [ "hello world" , "HI Pyton", "Mar Java", "Mit Java", "Lut Java" ] var.set("Hello world I am a Label") label = tk.Label(main_frame,textvariable=var, bg="black",fg="white",font=("Times New Roman",24,"bold")) ...
normal
{ "blob_id": "33938a28aad29e996255827825a0cdb1db6b70b7", "index": 5842, "step-1": "<mask token>\n\n\ndef change_label():\n var.set(random.choice(ch))\n\n\n<mask token>\n\n\ndef slove():\n expr.set(eval(expr.get()))\n\n\n<mask token>\n\n\ndef clear():\n expr.set('')\n\n\n<mask token>\n", "step-2": "<mas...
[ 3, 4, 5, 6, 7 ]
import copy import os from datetime import datetime import numpy as np from sklearn.neighbors import NearestNeighbors from sklearn.preprocessing import normalize ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../') DATA_FILE = os.path.join(ROOT_DIR, 'data/data_train.csv') TRAINING_FILE_NAME = os....
normal
{ "blob_id": "af1eab58fd641b14ac054fa26e28d52c9741fb16", "index": 7675, "step-1": "<mask token>\n\n\ndef ratings_to_matrix(ratings):\n matrix_rows = USER_COUNT\n matrix_cols = ITEM_COUNT\n matrix = np.zeros([matrix_rows, matrix_cols])\n for row, col, rating in ratings:\n matrix[row, col] = rati...
[ 16, 19, 21, 22, 24 ]
#! /usr/bin/env python import os import re from codecs import open from setuptools import find_packages, setup here = os.path.abspath(os.path.dirname(__file__)) def get_changelog(): with open(os.path.join(here, 'CHANGELOG'), encoding='utf-8') as f: text = f.read() header_matches = list(re.finditer...
normal
{ "blob_id": "c81889cf4d87933b562aa4618bc5185a8d213107", "index": 8075, "step-1": "<mask token>\n\n\ndef get_changelog():\n with open(os.path.join(here, 'CHANGELOG'), encoding='utf-8') as f:\n text = f.read()\n header_matches = list(re.finditer('^=+$', text, re.MULTILINE))\n text = text[:header_ma...
[ 1, 2, 3, 4, 5 ]
import sys n = int(sys.stdin.readline().rstrip()) l = list(map(int,sys.stdin.readline().rstrip().split())) m = int(sys.stdin.readline().rstrip()) v = list(map(int,sys.stdin.readline().rstrip().split())) card = [0] * (max(l)-min(l)+1) a = min(l) b = max(l) for i in l: card[i-a]+=1 for j in v: if ((j>=a)&(j<...
normal
{ "blob_id": "6b0081e829f9252e44fa7b81fbfcdd4115856373", "index": 3748, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in l:\n card[i - a] += 1\nfor j in v:\n if (j >= a) & (j <= b):\n print(card[j - a], end=' ')\n else:\n print(0, end=' ')\n", "step-3": "<mask token>\nn = i...
[ 0, 1, 2, 3, 4 ]
from django.urls import path from main.views import IndexView, BuiltinsView, CustomView app_name = 'main' urlpatterns = [path('', IndexView.as_view(), name='index'), path( 'builtins/', BuiltinsView.as_view(), name='builtins'), path('custom/', CustomView.as_view(), name='custom')]
normal
{ "blob_id": "7b527f9ec66ddf35f3395d78c857c021975402c7", "index": 5141, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'main'\nurlpatterns = [path('', IndexView.as_view(), name='index'), path(\n 'builtins/', BuiltinsView.as_view(), name='builtins'), path('custom/',\n CustomView.as_view(),...
[ 0, 1, 2 ]
from django.db import models class TestModel(models.Model): name = models.CharField(max_length=15) surname = models.CharField(max_length=10) age = models.IntegerField() class Example(models.Model): integer_field = models.IntegerField() positive_field = models.PositiveIntegerField() positive_...
normal
{ "blob_id": "8afce5b47c7c9c67a8be493f7f4de1510352b1c7", "index": 4559, "step-1": "<mask token>\n\n\nclass Place(models.Model):\n name = models.CharField(max_length=50)\n address = models.CharField(max_length=80)\n\n def __str__(self):\n return self.name\n\n\nclass Restaurant(models.Model):\n p...
[ 10, 12, 16, 17, 21 ]
from django.conf import settings from django.contrib.sites.models import RequestSite from django.contrib.sites.models import Site from fish.labinterface.models import * from registration import signals from registration.forms import RegistrationForm from registration.models import RegistrationProfile from labinterfac...
normal
{ "blob_id": "201279c0cba2d52b6863204bfadb6291a0065f60", "index": 3961, "step-1": "<mask token>\n\n\nclass CustomRegistrationBackend(object):\n <mask token>\n\n def activate(self, request, activation_key):\n activated = RegistrationProfile.objects.activate_user(activation_key)\n if activated:\...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): if len(sys.argv) != 2: print('usage : %s port') sys.exit() port = int(sys.argv[1]) count = 0 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCK...
flexible
{ "blob_id": "68b9f7317f7c6dcda791338ee642dffb653ac694", "index": 4804, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n if len(sys.argv) != 2:\n print('usage : %s port')\n sys.exit()\n port = int(sys.argv[1])\n count = 0\n sock = socket.socket(socket.AF_INET, soc...
[ 0, 1, 2, 3, 4 ]
############################################################### # Yolanda Gunter # Lab 4 # My program uses decisions, repetition, functions, files, lists # and exception handling that will get the input from a file to # run program that asks User for current date, reads a contact file # list that contains...
normal
{ "blob_id": "661f94f5770df1026352ee344d0006466662bb3c", "index": 2537, "step-1": "def main():\n try:\n contacts = open('contactsLab4.txt', 'r')\n names = []\n birthdates = []\n name = contacts.readline()\n while name != '':\n names.append(name.rstrip('\\n'))\n ...
[ 2, 3, 4, 6, 7 ]