code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
# coding: utf-8 # In[1]: import pandas as pd import numpy as np import itertools # Save a nice dark grey as a variable almost_black = '#262626' import matplotlib import seaborn as sns import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap sns.set() get_ipython().magic('matplotlib inline') # I...
normal
{ "blob_id": "f2786e445bdf66cf6bb66f4cde4c7b2bf819d8aa", "index": 3299, "step-1": "<mask token>\n", "step-2": "<mask token>\nsns.set()\nget_ipython().magic('matplotlib inline')\n<mask token>\nif header_included:\n header = 0\n<mask token>\nfor item in combinations:\n index = ax[i]\n x_vis = X[:, [featu...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python3 def file_to_code(fname): mem = [] for line in open(fname,"r"): mem.extend([int(i) for i in line.split(",")]) return mem class Opcode(object): def __init__(self, mem, ptr, code, inc): """ >>> o = Opcode([1001, 2, 4, 1], 0, 1, 4) >>> o._Opcode__par_modes [0, 1] """ if mem[ptr]%100 !...
normal
{ "blob_id": "653e65281984ebb06467aeadb6f0e2b11f1bcb4d", "index": 496, "step-1": "<mask token>\n\n\nclass Opcode1(Opcode):\n <mask token>\n\n def __init__(self, mem, ptr):\n super().__init__(mem, ptr, 1, 4)\n self.__first = self.get_val(1)\n self.__second = self.get_val(2)\n self...
[ 43, 44, 55, 57, 62 ]
import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import QIcon, QFont from PyQt5.QtCore import QCoreApplication import pymysql import requests from twisted.internet import reactor, defer from scrapy.crawler import CrawlerRunner, CrawlerProcess from scrapy.utils.project import get_project_settings from spider....
normal
{ "blob_id": "889d465ceeac57a600b2fa3bd26632edcd90a655", "index": 2911, "step-1": "<mask token>\n\n\nclass Example(QWidget):\n\n\n class A(QWidget):\n\n def __init__(self):\n super().__init__()\n self.initUI()\n\n def initUI(self):\n self.setGeometry(300, 300, 300...
[ 7, 8, 11, 16, 17 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): def removeNthFromEnd(self, head, n): dummy = ListNode(-1) dummy.next = head first, second = dummy, dummy for ...
flexible
{ "blob_id": "7e71c97070285b051b23448c755e3d41b2909dda", "index": 3884, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def removeNthFromEnd(self, head, n):\n dummy = ListNode(-1)\n dummy.next = head\n first, s...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- import scrapy import json, time, sys, random, re, pyssdb from scrapy.utils.project import get_project_settings from spider.items import GoodsSalesItem goods_list = [] '''获取店铺内产品信息''' class PddMallGoodsSpider(scrapy.Spider): name = 'pdd_mall_goods' mall_id_hash = 'pdd_mall_id_ha...
normal
{ "blob_id": "f33190df35a6b0b91c4dd2d6a58291451d06e29a", "index": 3529, "step-1": "<mask token>\n\n\nclass PddMallGoodsSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def start_requests(self):\n mall...
[ 3, 4, 5, 9, 10 ]
<|reserved_special_token_0|> def is_mango_seller(name): return name[-1] == 'm' def search_mango_seller(name): search_queue = deque() searched = [] global graph search_queue += graph[name] while search_queue: person = search_queue.popleft() if not person in searched: ...
flexible
{ "blob_id": "e881fcfce933d8f3bafcbaab039ddcf98827bf5e", "index": 4244, "step-1": "<mask token>\n\n\ndef is_mango_seller(name):\n return name[-1] == 'm'\n\n\ndef search_mango_seller(name):\n search_queue = deque()\n searched = []\n global graph\n search_queue += graph[name]\n while search_queue:...
[ 2, 3, 4, 5, 6 ]
#ABC114 A - クイズ print("ABC" if input()=="1" else "chokudai")
normal
{ "blob_id": "14d31a4b7491a7f7a64cd151e79c23546e4a3cd2", "index": 7683, "step-1": "<mask token>\n", "step-2": "print('ABC' if input() == '1' else 'chokudai')\n", "step-3": "#ABC114 A - クイズ\nprint(\"ABC\" if input()==\"1\" else \"chokudai\")\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1,...
[ 0, 1, 2 ]
# Generated by Django 3.2 on 2021-04-21 13:21 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('rate', '0003_auto_20210421_1316'), ] operations = [ migrations.AlterField( model_name='song', name='overall_rating', ...
normal
{ "blob_id": "d46cda5354640e1c87432d39a2e949d6db034edc", "index": 6413, "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 = [('rate', '000...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python #encoding=utf8 import sys import tushare as ts def local_main(): if len(sys.argv) != 2: print sys.argv[0], " [stock id]" return stock_id = sys.argv[1] df = ts.get_hist_data(stock_id) df.to_excel(stock_id + '_his.xlsx', sheet_name = stock_id) if __name__ == '__main__...
normal
{ "blob_id": "81a53d08ab36e85dd49cf1f3d9c22c1f18605149", "index": 6233, "step-1": "#!/usr/bin/python\n#encoding=utf8\n\nimport sys\nimport tushare as ts\n\ndef local_main():\n if len(sys.argv) != 2:\n print sys.argv[0], \" [stock id]\"\n return\n\n stock_id = sys.argv[1]\n df = ts.get_hist_...
[ 0 ]
<|reserved_special_token_0|> class UIMainWindow(object): <|reserved_special_token_0|> def retranslateUI(self): _translate = QtCore.QCoreApplication.translate self.main_window.setWindowTitle(_translate('main_window', 'SentiCompare')) self.add_button.setText(_translate('main...
flexible
{ "blob_id": "a555226b14223dca688d10b811eb36fb229360ce", "index": 2457, "step-1": "<mask token>\n\n\nclass UIMainWindow(object):\n <mask token>\n\n def retranslateUI(self):\n _translate = QtCore.QCoreApplication.translate\n self.main_window.setWindowTitle(_translate('main_window',\n ...
[ 4, 6, 7, 8, 9 ]
''' Statistics models module. This module contains the database models for the Statistics class and the StatisticsCategory class. @author Hubert Ngu @author Jason Hou ''' from django.db import models class Statistics(models.Model): ''' Statistics model class. This represents a single tuple in the ...
normal
{ "blob_id": "728f9402b3ce4b297be82b3ba1a17c4180ac7c0d", "index": 8839, "step-1": "<mask token>\n\n\nclass Statistics(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def comp_point_ref(self, is_set=False): """Compute the point ref of the Surface Parameters ---------- self : SurfLine A SurfLine object is_set: bool True to update the point_ref property ...
flexible
{ "blob_id": "b7721e95cfb509a7c0c6ccdffa3a8ca2c6bd6033", "index": 6713, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef comp_point_ref(self, is_set=False):\n \"\"\"Compute the point ref of the Surface\n\n Parameters\n ----------\n self : SurfLine\n A SurfLine object\n is_set: ...
[ 0, 1, 2 ]
from scipy.stats import mannwhitneyu import matplotlib.patches as patches import os import numpy import pandas from matplotlib.gridspec import GridSpec from scipy.cluster.hierarchy import fcluster, linkage, dendrogram from scipy.spatial.distance import squareform import seaborn as sns from scipy.stats import spearmanr ...
normal
{ "blob_id": "bfd31d0b80511721ee5117daced04eaf63679fd8", "index": 2230, "step-1": "<mask token>\n\n\ndef get_clusters(link, dn, inds, th=0.7):\n clst = fcluster(link, criterion='distance', t=th)\n return pandas.Series(index=inds, data=clst).iloc[dn['leaves']]\n\n\ndef draw_significant_groups(groups, dn_ax, ...
[ 4, 5, 6, 7, 8 ]
from datetime import datetime import whois def age_domain(url): try: w = whois.whois(url) if(w): for l in w.expiration_date: d1 = datetime.date(l) print(d1) for l1 in w.creation_date: d2 = datetime.date(l1) print(d2) diff = (d1 - ...
normal
{ "blob_id": "07d574060ded0d98734b4f184dcba7377b3a5480", "index": 685, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef age_domain(url):\n try:\n w = whois.whois(url)\n if w:\n for l in w.expiration_date:\n d1 = datetime.date(l)\n print(d1)\n ...
[ 0, 1, 2, 3 ]
from django import forms from . import models from .validators import validate_metadata class ServiceProviderForm(forms.ModelForm): xml = forms.CharField(label='SAML Metadata XML', widget=forms.Textarea, validators=[validate_metadata]) class Meta: ...
normal
{ "blob_id": "e018d28cbacb568596eb9a5134581db960111e14", "index": 9835, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ServiceProviderForm(forms.ModelForm):\n <mask token>\n\n\n class Meta:\n model = models.ServiceProvider\n fields = 'xml',\n", "step-3": "<mask token>\n\n\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class ForgotForm(FlaskForm): email = EmailField('Email Id*', validators=[DataRequired(), Email()]) design = SelectField(u'Designation*', choices=[('admin', 'Admin'), ( 'stud', 'Student')], validators=[DataRequired()]) submit = SubmitField('Change your Password') clas...
flexible
{ "blob_id": "32ed07a89a6f929a6c4b78fd79e687b85e01015b", "index": 535, "step-1": "<mask token>\n\n\nclass ForgotForm(FlaskForm):\n email = EmailField('Email Id*', validators=[DataRequired(), Email()])\n design = SelectField(u'Designation*', choices=[('admin', 'Admin'), (\n 'stud', 'Student')], valida...
[ 8, 10, 11, 12, 14 ]
from sklearn.model_selection import train_test_split from azureml.core import Run from sklearn.ensemble import RandomForestClassifier import pandas as pd import argparse import os import joblib import numpy as np # Get the experiment run context run = Run.get_context() # Get arguments parser = argparse.ArgumentParse...
normal
{ "blob_id": "66c2d73c100f7fc802e66f2762c92664e4b93fcd", "index": 5736, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('--in_n_estimator', type=int, default=8)\nparser.add_argument('--in_criterion', type=str, default='gini')\nparser.add_argument('--in_max_depth', type=int, default=2)\n...
[ 0, 1, 2, 3, 4 ]
""" Created on Dec 1, 2014 @author: Ira Fich """ import random from igfig.containers import WeightedList class Replacer(): """ A class that replaces itself with a subclass of itself when you instantiate it """ subclass_weight = 0 def __new__(cls, *args, **kwargs): subs = WeightedList(cls.__subclasses__(),...
normal
{ "blob_id": "3a878c91218dfbf23477ae5b7561e9eecfcd1350", "index": 5053, "step-1": "<mask token>\n\n\nclass Replacer:\n <mask token>\n <mask token>\n\n def __new__(cls, *args, **kwargs):\n subs = WeightedList(cls.__subclasses__(), [sub.subclass_weight for\n sub in cls.__subclasses__()])\...
[ 7, 10, 11, 13, 15 ]
newList = [] noDuplicate = [] while True: elem = input("Enter a letter : (type quit to quit) ") if elem.lower() != "quit": newList.append(elem) else: break for item in newList: if item not in noDuplicate: noDuplicate.append(item) print(noDuplicate)
normal
{ "blob_id": "7273592ab8fea10d9a3cde58690063690c74b746", "index": 4635, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n elem = input('Enter a letter : (type quit to quit) ')\n if elem.lower() != 'quit':\n newList.append(elem)\n else:\n break\nfor item in newList:\n i...
[ 0, 1, 2, 3 ]
import sys from arguments_parser import parse_args from open_ldap import OpenLdap from csv_parser import parse_csv, random_password from smtp_mail import SmtpServer def create_user(open_ldap, smtp, entries): """ If the 'ldap_insert' returns True, then the email will be send with the account info. """ ...
normal
{ "blob_id": "4f0a0089ad128edca3052da58a4c71f935592e25", "index": 4499, "step-1": "<mask token>\n\n\ndef create_user(open_ldap, smtp, entries):\n \"\"\"\n If the 'ldap_insert' returns True, then\n the email will be send with the account info.\n \"\"\"\n try:\n if open_ldap.ldap_insert(entrie...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(n): t, x, y = map(int, input().split()) diff = abs(x - p[0]) + abs(y - p[1]) time = t - b if diff > time or time % 2 != diff % 2: flg = False break else: b = t p[0...
flexible
{ "blob_id": "8bc465a1b546907d8a9e5eee2cae672befb1ea13", "index": 7808, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n t, x, y = map(int, input().split())\n diff = abs(x - p[0]) + abs(y - p[1])\n time = t - b\n if diff > time or time % 2 != diff % 2:\n flg = False\n...
[ 0, 1, 2, 3 ]
import csv import hashdate as hd with open('Grainger_Library.csv', newline='') as f: reader = csv.reader(f) data = list(reader) del data[0] gld = [] glo = [] data.sort(key=lambda x:x[1]) for i in range(0,len(data)): gld.append((data[i][1],data[i][2])) print('ahd:') #print(ahd) glh = hd.hashdate(365,2020...
normal
{ "blob_id": "79ff164c36cc5f0a2382a571ec183952a03e66cc", "index": 9570, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('Grainger_Library.csv', newline='') as f:\n reader = csv.reader(f)\n data = list(reader)\ndel data[0]\n<mask token>\ndata.sort(key=lambda x: x[1])\nfor i in range(0, len(d...
[ 0, 1, 2, 3, 4 ]
from copy import deepcopy from datetime import date, timedelta from hashlib import sha256 import starkbank from starkbank import BoletoPayment from .boleto import generateExampleBoletosJson example_payment = BoletoPayment( line="34191.09008 61713.957308 71444.640008 2 83430000984732", scheduled="2020-02-29", ...
normal
{ "blob_id": "383d3b35fbfb7921111b28c3160173ce1c200387", "index": 637, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generateExampleBoletoPaymentsJson(n=1, next_day=False):\n boletos = generateExampleBoletosJson(n=n)\n boletos = starkbank.boleto.create(boletos)\n payments = []\n for b...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """Success request logging. This logging is used by "CheckZope" to determine the amount of work performed by Zope (in order not to bother it with monitor probes when it is heavily active) and to detect an unreasonable error rate. This logging writes two files "<base>_good.<date>" and "<base>_b...
normal
{ "blob_id": "2edbf18c90da1ff40fd9abaf25a35dbdaf733bc1", "index": 2786, "step-1": "<mask token>\n\n\n@adapter(IProcessStarting)\ndef start_successlogging(unused):\n \"\"\"start successlogging if configured.\"\"\"\n from App.config import getConfiguration\n config = getConfiguration().product_config.get('...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class RestApiTestSuite(unittest.TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @pytest.fixture(autouse=True) def setup_gateway(self, metadata): self.gateway = proactive.ProActi...
flexible
{ "blob_id": "da2c615b8fab8de6bd63864508da254a46e65bb8", "index": 4543, "step-1": "<mask token>\n\n\nclass RestApiTestSuite(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @pytest.fixture(autouse=True)\n def setup_gateway(self, metadata):\n self.gateway...
[ 4, 7, 8, 9, 10 ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.3 on 2018-12-20 13:06 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('login', '0006_usermovies_img'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "e67cbddf10440e8a31373e05a82840677d3045f5", "index": 4388, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('login', '00...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> app_name = 'Accounts' urlpatterns = [path('update_info', views.update_info, name='update_info'), path('create_user', views.create_user, name='create_user'), path( 'change_password', views.change_password, name='change_pass...
flexible
{ "blob_id": "bfb778a2ecf43a697bc0e3449e9302142b20e1f4", "index": 4278, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'Accounts'\nurlpatterns = [path('update_info', views.update_info, name='update_info'),\n path('create_user', views.create_user, name='create_user'), path(\n 'change_passw...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def create_local_imports_files(tmp_path): path_dir = os.path.join(tmp_path, 'dir_local_imports') fln_func = os.path.join(path_dir, 'file_func.py') fln_gen = os.path.join(path_dir, 'file_gen.py') os.makedirs(path_dir, exist_ok=True) code1 = """ from bluesky_queueserver....
flexible
{ "blob_id": "ad1ec5dd8fae290ab6cb73b17c5522e062261359", "index": 6698, "step-1": "<mask token>\n\n\ndef create_local_imports_files(tmp_path):\n path_dir = os.path.join(tmp_path, 'dir_local_imports')\n fln_func = os.path.join(path_dir, 'file_func.py')\n fln_gen = os.path.join(path_dir, 'file_gen.py')\n ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): config = {'spark.jars.packages': 'io.delta:delta-core_2.12:0.8.0,org.postgresql:postgresql:9.4.1211,org.apache.spark:spark-streaming-kafka-0-10_2.12:3.0.0,org.apache.spark:spark-sql-kafka-0-10_2.12:3.0.0'...
flexible
{ "blob_id": "23099b29fb5898c2556d1612690e33860662ca35", "index": 9846, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n config = {'spark.jars.packages':\n 'io.delta:delta-core_2.12:0.8.0,org.postgresql:postgresql:9.4.1211,org.apache.spark:spark-streaming-kafka-0-10_2.12:3.0.0,or...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(msg * copies) <|reserved_special_token_1|> <|reserved_special_token_0|> name = input('Enter your name : ') age = int(input('Enter your age : ')) year = int(100 - age + datetime.now().year) copies = int(input('How many cop...
flexible
{ "blob_id": "948b793359555f98872e0bdbf6db970ed1ff3b83", "index": 7046, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(msg * copies)\n", "step-3": "<mask token>\nname = input('Enter your name : ')\nage = int(input('Enter your age : '))\nyear = int(100 - age + datetime.now().year)\ncopies = int(inp...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def gprmc_convert(line): """Translates $GPRMC line into documented array str line - the GPRMC line returns - the data documented into array """ gps = line.strip().split(',') if gps[2] == 'V': return raw_date = gps[9] time = '' date = raw_d...
flexible
{ "blob_id": "dc5630e17bb6ed85157b06108250427be41416d1", "index": 7766, "step-1": "<mask token>\n\n\ndef gprmc_convert(line):\n \"\"\"Translates $GPRMC line into documented array\n str line - the GPRMC line\n returns - the data documented into array\n \"\"\"\n gps = line.strip().split(',')\n ...
[ 2, 3, 4, 5, 6 ]
from pynput import keyboard # list of chars entered by the user list = [] number_of_chars = 0 # if entered chars go above MAX LENGTH they will be written inside a file MAX_LENGTH = 300 def on_press(key): global number_of_chars global list list.append(key) number_of_chars+=1 if number_of_cha...
normal
{ "blob_id": "e60fcf19560b4826577797c8ae8b626ff984dcfd", "index": 6923, "step-1": "<mask token>\n\n\ndef on_release(key):\n if key == keyboard.Key.esc:\n write_in_file()\n return False\n\n\ndef write_in_file():\n file = open('strokes.txt', 'a')\n for k in list:\n file.writelines('{}\...
[ 2, 3, 4, 5, 7 ]
def densenet(D,DT,F,model): import scipy.io as sio import time import os import math import numpy as np import matplotlib.pyplot as plt Dataset = D if DT == 'org': data_type = 'original' else: data_type = 'augmented' fs = model.fs fm1 = model.fm1 batch_size = model.ba...
normal
{ "blob_id": "48270f70a9d69d15f808f22ec2d11d337b2c4845", "index": 7414, "step-1": "<mask token>\n\n\nclass MyModel:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<...
[ 1, 2, 3, 5, 6 ]
#!/usr/bin/evn python #-*-coding:utf8 -*- import os, sys, json class settings(object): filename = '' config = {} def __init__(self): self.DEBUG = os.environ.get('RdsMonitor_DEBUG', 0) def get_settings(self): """Parses the settings from redis-live.conf. """ # TODO: Consider YAML. Human writable, mac...
normal
{ "blob_id": "2c960685eaa14861c1c5b3ddb38b366a3e0e8e86", "index": 1339, "step-1": "#!/usr/bin/evn python\n#-*-coding:utf8 -*-\n\n\nimport os, sys, json\n\nclass settings(object):\n\tfilename = ''\n\tconfig = {}\n\t\n\tdef __init__(self):\n\t\tself.DEBUG = os.environ.get('RdsMonitor_DEBUG', 0)\n\t\t\n\tdef get_set...
[ 0 ]
import sqlite3 import argparse import json import index_db from collections import defaultdict def query_doc(cursor, lang, title): cursor.execute(index_db.select_lang_title, (lang, title)) result = cursor.fetchone() if not result: return None return { 'lang': result[0], 'doc_id...
normal
{ "blob_id": "95e7e025660e71cbdf6a6a0812964fc26d4beec0", "index": 9657, "step-1": "<mask token>\n\n\ndef query_doc(cursor, lang, title):\n cursor.execute(index_db.select_lang_title, (lang, title))\n result = cursor.fetchone()\n if not result:\n return None\n return {'lang': result[0], 'doc_id':...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def main(forecast, name, levels, *args, **kwargs): nt = len(forecast) rows = nt / columns + 1 fig = plt.figure(figsize=(18, 10 * float(rows) / columns)) for n, cubes in enumerate(forecast): row = n / columns column = n - row * columns print(row, col...
flexible
{ "blob_id": "310e6e693cdce6ff71d06eac86214a21bef236d4", "index": 7425, "step-1": "<mask token>\n\n\ndef main(forecast, name, levels, *args, **kwargs):\n nt = len(forecast)\n rows = nt / columns + 1\n fig = plt.figure(figsize=(18, 10 * float(rows) / columns))\n for n, cubes in enumerate(forecast):\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class ProductsOrderCartSerializer(ModelSerializer): class Meta: model = Product fields = ['id', 'title', 'slug', 'image'] class ProductDetailSerializer(TaggitSerializer, ModelSerializer): tags = TagListSerializerField() gallery = SerializerMethodField() ...
flexible
{ "blob_id": "8be6031caad26ec6b6b99b8d8b8f80d16ad243d4", "index": 7706, "step-1": "<mask token>\n\n\nclass ProductsOrderCartSerializer(ModelSerializer):\n\n\n class Meta:\n model = Product\n fields = ['id', 'title', 'slug', 'image']\n\n\nclass ProductDetailSerializer(TaggitSerializer, ModelSerial...
[ 9, 15, 16, 17, 21 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def matrix(m): for i in range(len(m)): for j in range(len(m[0])): m[i][j] = m[i][j] ** 2 <|reserved_special_token_0|> <|reserved_special_token_1|> def matrix(m): for i in range(len(m)): for j in range(len(m[0])): ...
flexible
{ "blob_id": "f46dd5217c8e015546d7fff7ee52569ecc2c8e41", "index": 5487, "step-1": "<mask token>\n", "step-2": "def matrix(m):\n for i in range(len(m)):\n for j in range(len(m[0])):\n m[i][j] = m[i][j] ** 2\n\n\n<mask token>\n", "step-3": "def matrix(m):\n for i in range(len(m)):\n ...
[ 0, 1, 2, 3, 4 ]
import psycopg2 host = "datavis.cauuh8vzeelb.us-east-1.rds.amazonaws.com" database = "top5" user = "teamwonder" password = "visproject" Gentrifying = [10002,10003,10009,10026,10027,10029,10030,10031,10032,10033,10034,10035,10037,10039,10040,10454,10455,10456,10457,10458,10459,10460,10474,11102,11103,11105,11106,11206...
normal
{ "blob_id": "0ebf5646ee9693b7d0c1de61436e05b3725b2c9f", "index": 2560, "step-1": "<mask token>\n", "step-2": "<mask token>\nhost = 'datavis.cauuh8vzeelb.us-east-1.rds.amazonaws.com'\ndatabase = 'top5'\nuser = 'teamwonder'\npassword = 'visproject'\nGentrifying = [10002, 10003, 10009, 10026, 10027, 10029, 10030,...
[ 0, 1, 2, 3 ]
from .__main__ import datajson_write, datajson_read
normal
{ "blob_id": "2269e74c006833976c3a28cd52c238e2dde20051", "index": 5871, "step-1": "<mask token>\n", "step-2": "from .__main__ import datajson_write, datajson_read\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from .base import Sort
flexible
{ "blob_id": "de3a96d46b7eaf198b33efe78b21ef0207dcc609", "index": 8424, "step-1": "<mask token>\n", "step-2": "from .base import Sort\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> clf.fit(X, y) print('class_prior:', clf.class_prior) print('class_count_:', clf.class_count_) print('class_log_prior_:', clf.class_log_prior_) print('feature_count_:', clf.feature_count_) print('n_features_:', clf.n_features_) pri...
flexible
{ "blob_id": "98a1fab8cee91f37ceee2cfd868d3a5756a055b0", "index": 7628, "step-1": "<mask token>\n", "step-2": "<mask token>\nclf.fit(X, y)\nprint('class_prior:', clf.class_prior)\nprint('class_count_:', clf.class_count_)\nprint('class_log_prior_:', clf.class_log_prior_)\nprint('feature_count_:', clf.feature_cou...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for x in xs: dist += min(x, K - x) print(dist * 2) <|reserved_special_token_1|> N = int(input()) K = int(input()) xs = list(map(int, input().split())) dist = 0 for x in xs: dist += min(x, K - x) print(dist * 2)
flexible
{ "blob_id": "a65ab0faf08c13f007a132fb92f358a35834fdb7", "index": 2556, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor x in xs:\n dist += min(x, K - x)\nprint(dist * 2)\n", "step-3": "N = int(input())\nK = int(input())\nxs = list(map(int, input().split()))\ndist = 0\nfor x in xs:\n dist += min...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while count < 9: print('Number:', count) count = count + 1 print('Good Bye') <|reserved_special_token_0|> for fruit in fruits: print('current fruits:', fruit) print('Good bye') <|reserved_special_token_1|> count = 0...
flexible
{ "blob_id": "9b3040fa02cf8f039bac146f8a73384731c56722", "index": 9142, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile count < 9:\n print('Number:', count)\n count = count + 1\nprint('Good Bye')\n<mask token>\nfor fruit in fruits:\n print('current fruits:', fruit)\nprint('Good bye')\n", "...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def contruct_tree(pre_order, index=0): index += 1 if index >= len(pre_order): raise IndexError('wtf is wrong with you?') root = pre_order[index] if root is None: return None, index node = BST(...
flexible
{ "blob_id": "3aee336956ac6f962c34f51a27dc4abebf2cc7c8", "index": 8474, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef contruct_tree(pre_order, index=0):\n index += 1\n if index >= len(pre_order):\n raise IndexError('wtf is wrong with you?')\n root = pre_order[index]\n if root i...
[ 0, 1, 2, 3 ]
# V0 class Codec: def encode(self, strs): s = "" for i in strs: s += str(len(i)) + "#" + i return s def decode(self, s): i, str = 0, [] while i < len(s): sharp = s.find("#", i) l = int(s[i:sharp]) str.append(s[sharp + 1:sh...
normal
{ "blob_id": "b94392c9c6547415326d80ff0923cb8ba9251783", "index": 5724, "step-1": "<mask token>\n\n\nclass Codec:\n <mask token>\n\n def decode(self, s):\n \"\"\"Decodes a single string to a list of strings.\n \n :type s: str\n :rtype: List[str]\n \"\"\"\n i, str = ...
[ 5, 6, 7, 8, 10 ]
import uuid from datetime import date import os import humanize class Context: def __init__(self, function_name, function_version): self.function_name = function_name self.function_version = function_version self.invoked_function_arn = "arn:aws:lambda:eu-north-1:000000000000:function:{}".f...
normal
{ "blob_id": "1c685514f53a320226402a4e4d8f3b3187fad615", "index": 7814, "step-1": "<mask token>\n\n\nclass Context:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Context:\n\n def __init__(self, function_name, function_version):\n self.function_name = function_name\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class MeasurementsSerializer(serializers.ModelSerializer): class Meta: model = Measurements fields = '__all__' <|reserved_special_token_0|> class CountSerializer(serializers.Serializer): key = serializers.CharField(max_length=20) value = serializers.Int...
flexible
{ "blob_id": "44cbe1face91d3ac7edcd93d0b470bce90c8b674", "index": 2916, "step-1": "<mask token>\n\n\nclass MeasurementsSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Measurements\n fields = '__all__'\n <mask token>\n\n\nclass CountSerializer(serializers.Serializer):\n ...
[ 9, 10, 11, 12, 15 ]
#!/usr/bin/env python3 import argparse import json import os import random import timeit from glob import glob import numpy as np def parse_args(): """[summary] Returns: [type]: [description] """ parser = argparse.ArgumentParser() parser.add_argument('--train_dir', ...
normal
{ "blob_id": "71eadf5073b5ed13c7d4a58b2aeb52f550a32238", "index": 3104, "step-1": "<mask token>\n\n\ndef parse_args():\n \"\"\"[summary]\n\n Returns:\n [type]: [description]\n \"\"\"\n parser = argparse.ArgumentParser()\n parser.add_argument('--train_dir', help=\n 'directory containin...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def lm_res(snps, gene, cov): res = pd.DataFrame(np.zeros([snps.shape[0], 2], dtype=np.float32)) res.index = snps.index res.columns = ['beta', 'pval'] for i in range(snps.shape[0]): X = pd.concat([snps.ilo...
flexible
{ "blob_id": "2f64aac7032ac099870269659a84b8c7c38b2bf0", "index": 8385, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lm_res(snps, gene, cov):\n res = pd.DataFrame(np.zeros([snps.shape[0], 2], dtype=np.float32))\n res.index = snps.index\n res.columns = ['beta', 'pval']\n for i in rang...
[ 0, 1, 2, 3, 4 ]
from collections import deque def solution(play_time, adv_time, logs): ''' Strategy : adv_start_time을 log start time 부터 < 995959 - adv time sliding window Step 1. String time -> integer time Step 2. pseudo code : Two pointer algorithm max time = 0 return max time ''' ...
normal
{ "blob_id": "cb50a5352b0ad7b04dee9393c50da54fdf507376", "index": 2018, "step-1": "<mask token>\n\n\ndef str2int(strtime: str):\n hh, mm, ss = strtime.split(':')\n return 3600 * int(hh) + 60 * int(mm) + int(ss)\n\n\ndef int2str(inttime: int):\n hh = inttime // 3600\n mm = inttime % 3600 // 60\n ss ...
[ 2, 3, 4, 5, 6 ]
from http import HTTPStatus from ninja import Router mock_post_router = Router() @mock_post_router.get( "/mock_posts", url_name="mock_post_list", summary="전체 mock post의 list를 반환한다", response={200: None}, ) def retrieve_all_mock_posts(request): return HTTPStatus.OK
normal
{ "blob_id": "dcb57ecf2c72b8ac816bb06986d80544ff97c669", "index": 5915, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@mock_post_router.get('/mock_posts', url_name='mock_post_list', summary=\n '전체 mock post의 list를 반환한다', response={(200): None})\ndef retrieve_all_mock_posts(request):\n return HT...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def select(arr, k): n = len(arr) if not 0 <= k < n: raise ValueError('not valid index in array') if n <= 1: return arr[0] pivot = random.choice(arr) L, E, G = [], [], [] for data in arr: if data < pivot: L.append(data) el...
flexible
{ "blob_id": "69d3a39dc024929eaf6fb77e38a7a818d2886cf7", "index": 8512, "step-1": "<mask token>\n\n\ndef select(arr, k):\n n = len(arr)\n if not 0 <= k < n:\n raise ValueError('not valid index in array')\n if n <= 1:\n return arr[0]\n pivot = random.choice(arr)\n L, E, G = [], [], []\...
[ 1, 2, 3, 4, 5 ]
""" Question: You are given a string s consisting only of digits 0-9, commas ,, and dots . Your task is to complete the regex_pattern defined below, which will be used to re.split() all of the , and . symbols in s. It’s guaranteed that every comma and every dot in s is preceded and followed by a digit. Sample Input...
normal
{ "blob_id": "020691fe2c7e7092d45415b72ce1804618421a2a", "index": 9519, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('\\n'.join(re.split(regex_pattern, input())))\n", "step-3": "<mask token>\nregex_pattern = '[,.]'\nprint('\\n'.join(re.split(regex_pattern, input())))\n", "step-4": "<mask token...
[ 0, 1, 2, 3, 4 ]
import requests import json import io import sys names = ['abc-news', 'abc-news-au', 'aftenposten','al-jazeera-english','ars-technica','associated-press','australian-financial-review','axios', 'bbc-news', 'bbc-sport','bleacher-report', 'bloomberg','breitbart-news','business-insider', 'business-insider-uk','buzzfeed','...
normal
{ "blob_id": "590baf17d9fdad9f52869fa354112d3aa5f7d5f0", "index": 8943, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('[')\nsys.stdout.close()\nfor name in names:\n url = ('https://newsapi.org/v2/everything?sources=' + name +\n '&pageSize=100&language=en&from=2018-04-01&to=2018-04-01&apiK...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def get_jwst_coords(outDir): log.info('Creating and saving aperture') jwst_pup = poppy.MultiHexagonAperture(rings=2, flattoflat=FLAT_TO_FLAT) jwst_pup.display(colorbar=False) plt.title('JWST telescope pupil') for i in range(NB_SEG + 1): ycen, xcen = jwst_pup._h...
flexible
{ "blob_id": "e59763991974f4bfcd126879dd9aabd44bd89419", "index": 1406, "step-1": "<mask token>\n\n\ndef get_jwst_coords(outDir):\n log.info('Creating and saving aperture')\n jwst_pup = poppy.MultiHexagonAperture(rings=2, flattoflat=FLAT_TO_FLAT)\n jwst_pup.display(colorbar=False)\n plt.title('JWST te...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> def get_version(filename): import ast version = None with open(filename) as f: for line in f: if line.startswith('__version__'): version = ast.parse(line).body[0].value.s break else: raise ValueError('No v...
flexible
{ "blob_id": "d3b55863c6e3a1b6cbdcec37db81ee42b769938d", "index": 9039, "step-1": "<mask token>\n\n\ndef get_version(filename):\n import ast\n version = None\n with open(filename) as f:\n for line in f:\n if line.startswith('__version__'):\n version = ast.parse(line).body...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class PrimaryuserConfig(AppConfig): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class PrimaryuserConfig(AppConfig): name = 'PrimaryUser' <|reserved_special_token_1|> fro...
flexible
{ "blob_id": "82c10076ba73723b696e3e33280296c2a24f20b9", "index": 4187, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PrimaryuserConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass PrimaryuserConfig(AppConfig):\n name = 'PrimaryUser'\n", "step-4": "from django.app...
[ 0, 1, 2, 3 ]
# Uses python3 import numpy as np def fibonaci(n): if n <= 1: return n F = np.empty(shape=(n + 1)) F[0] = 0 F[1] = 1 for i in range(2, len(F)): F[i] = F[i - 1] + F[i - 2] return F[n] n = int(input()) print(int(fibonaci(n)))
normal
{ "blob_id": "67516551b595c02e70a0ba4005df8a97ba71b17e", "index": 1419, "step-1": "<mask token>\n\n\ndef fibonaci(n):\n if n <= 1:\n return n\n F = np.empty(shape=n + 1)\n F[0] = 0\n F[1] = 1\n for i in range(2, len(F)):\n F[i] = F[i - 1] + F[i - 2]\n return F[n]\n\n\n<mask token>\...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> etc_dictionary = {'2 30대': '이삼십대', '20~30대': '이삼십대', '20, 30대': '이십대 삼십대', '1+1': '원플러스원', '3에서 6개월인': '3개월에서 육개월인'} english_dictionary = {'Devsisters': '데브시스터즈', 'track': '트랙', 'LA': '엘에이', 'LG': '엘지', 'KOREA': '코리아', 'JSA': '제이에스에이', 'PGA': '피지에이', ...
flexible
{ "blob_id": "ccd1e57518065963158984dda52297db45ce204e", "index": 2471, "step-1": "<mask token>\n", "step-2": "etc_dictionary = {'2 30대': '이삼십대', '20~30대': '이삼십대', '20, 30대': '이십대 삼십대',\n '1+1': '원플러스원', '3에서 6개월인': '3개월에서 육개월인'}\nenglish_dictionary = {'Devsisters': '데브시스터즈', 'track': '트랙', 'LA': '엘에이',\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def test_forgotten_initialized_on_protected(): blueprint = Blueprint('Test') @blueprint.get('/protected') @protected() def protected_hello_world(request): return json({'message': 'hello world'}) @blueprint.route('/scoped') @scoped('something') async d...
flexible
{ "blob_id": "55fc197eebc4e06466e0fc0458957d0460602eef", "index": 2032, "step-1": "<mask token>\n\n\ndef test_forgotten_initialized_on_protected():\n blueprint = Blueprint('Test')\n\n @blueprint.get('/protected')\n @protected()\n def protected_hello_world(request):\n return json({'message': 'he...
[ 6, 7, 8, 11, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(X) <|reserved_special_token_0|> print(A * B) print(X[0]) print(X[0][1]) for row in X: print(row) <|reserved_special_token_0|> print(newX) print(X > 15) <|reserved_special_token_0|> plt.plot(x, y) plt.show() <|reserved_sp...
flexible
{ "blob_id": "ba702a9c5d9d31e48b047c106d77cf1707031d70", "index": 1795, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(X)\n<mask token>\nprint(A * B)\nprint(X[0])\nprint(X[0][1])\nfor row in X:\n print(row)\n<mask token>\nprint(newX)\nprint(X > 15)\n<mask token>\nplt.plot(x, y)\nplt.show()\n<mask...
[ 0, 1, 2, 3, 4 ]
import numpy as np def shufflelists(lists): li = np.random.permutation(len(lists[0]) lo = [] for i in range(len(li)):
normal
{ "blob_id": "fc01c6fb812fe78ca04496494d68fcc90ae706f5", "index": 3605, "step-1": "import numpy as np\n\ndef shufflelists(lists):\n li = np.random.permutation(len(lists[0])\n lo = []\n for i in range(len(li)):\n \n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ ...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for line in fhand: line.tranc <|reserved_special_token_1|> <|reserved_special_token_0|> fhand = open('romeo-full.txt') counts = dict() for line in fhand: line.tranc <|reserved_special_token_1|> import string fhand = ...
flexible
{ "blob_id": "5493887e32dbe7ae27eca79d28da8488183b37a3", "index": 8792, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in fhand:\n line.tranc\n", "step-3": "<mask token>\nfhand = open('romeo-full.txt')\ncounts = dict()\nfor line in fhand:\n line.tranc\n", "step-4": "import string\nfhand...
[ 0, 1, 2, 3, 4 ]
from django.conf import settings from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden from django.views.decorators.csrf import csrf_exempt from linebot import LineBotApi, WebhookParser from linebot.exceptions import InvalidSignatureError, LineBotApiError from linebot.models import ...
normal
{ "blob_id": "19f202c32e1cf9f7ab2663827f1f98080f70b83e", "index": 8313, "step-1": "<mask token>\n\n\n@csrf_exempt\ndef callback(request):\n if request.method == 'POST':\n signature = request.META['HTTP_X_LINE_SIGNATURE']\n body = request.body.decode('utf-8')\n try:\n events = pa...
[ 1, 2, 3, 4, 5 ]
# coding: utf-8 # ## Estimating Travel Time # # # The objective of this document is proposing a prediction model for estimating the travel time of two # specified locations at a given departure time. The main idea here is predicting the velocity of the trip. Given the distance between starting and ending point of t...
normal
{ "blob_id": "c1bb7b579e6b251ddce41384aef1243e411c5d0e", "index": 1018, "step-1": "<mask token>\n\n\ndef distance(row):\n source = row['start_lat'], row['start_lng']\n dest = row['end_lat'], row['end_lng']\n return vincenty(source, dest).miles\n\n\n<mask token>\n\n\ndef dropoff_to_MH(row):\n \"\"\"fin...
[ 8, 9, 11, 12, 15 ]
"""Module containing class `Station`.""" from zoneinfo import ZoneInfo import datetime from vesper.util.named import Named class Station(Named): """Recording station.""" def __init__( self, name, long_name, time_zone_name, latitude=None, longitude=None, elevation=None...
normal
{ "blob_id": "ad09880b9e06a129b9623be2a086ebcc8dc55c2c", "index": 9079, "step-1": "<mask token>\n\n\nclass Station(Named):\n <mask token>\n\n def __init__(self, name, long_name, time_zone_name, latitude=None,\n longitude=None, elevation=None):\n super().__init__(name)\n self._long_name ...
[ 6, 7, 9, 10, 11 ]
#!/usr/bin/python3 """City Module""" from models.base_model import BaseModel class City(BaseModel): """City Class Public class attributes: state_d: type string name: type string """ state_id = "" name = ""
normal
{ "blob_id": "3f2c1a83ae0dfdba202038a209b90162ccddee36", "index": 6115, "step-1": "<mask token>\n\n\nclass City(BaseModel):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass City(BaseModel):\n <mask token>\n state_id = ''\n name = ''\n", "step-3": "<mask tok...
[ 1, 2, 3, 4, 5 ]
import numpy import yfinance as yf import pandas as pd import path import math pd.options.mode.chained_assignment = None # default='warn' all_tickers = ['2020.OL', 'ABG.OL', 'ADE.OL', 'AFG.OL', 'AKAST.OL', 'AKER.OL', 'AKBM.OL', ...
normal
{ "blob_id": "22ffda3b2d84218af22bad7835689ec3d4959ab2", "index": 3660, "step-1": "<mask token>\n\n\ndef calculate_returns(ticker_data):\n returns_list = list()\n previous_ticker_day = None\n for ticker_day in ticker_data.itertuples():\n if previous_ticker_day == None:\n returns_list.ap...
[ 6, 8, 9, 10, 11 ]
<|reserved_special_token_0|> class DehazeNet(nn.Module): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class DehazeNet(nn.Module): def __init__(self, input=16, groups=4): super(DehazeNet, self).__init__() self.conv...
flexible
{ "blob_id": "a8cf8d0965cb877d50cee403fbc30f27484f4f36", "index": 8201, "step-1": "<mask token>\n\n\nclass DehazeNet(nn.Module):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass DehazeNet(nn.Module):\n\n def __init__(self, input=16, groups=4):\n super(DehazeNet, self).__init_...
[ 1, 2, 3, 4, 5 ]
import numpy as np import time import uuid from datetime import datetime log_host = "agent1" class State: def __init__(self, path, iterations): self.path = path self.iterations = iterations def run(self): assert 0, "run not implemented" class BruteForceAttackState(State): def ...
normal
{ "blob_id": "cf3b4e2c76091f95d24e8a987a63ece46503d6e8", "index": 3459, "step-1": "<mask token>\n\n\nclass BruteForceAttackState(State):\n\n def run(self):\n os_val = np.random.choice(['Windows7', 'Windows10', 'Ubuntu16',\n 'MacOS10'])\n addr_val = np.random.choice(['127.0.0.6', '127.0...
[ 4, 7, 8, 9, 10 ]
# coding: UTF-8 import fileinput import io from locale import str import os __author__ = 'lidong' def getDirList( p ): p = p.replace( "/","\\") if p[ -1] != "\\": p = p+"\\" a = os.listdir( p ) for x in a: if(os.path.isfile( p + x )): a, b = os.path.splitext( p + x ) ...
normal
{ "blob_id": "e553da92b1bb5dfaa0fb7c702f5be4f66201c75b", "index": 8843, "step-1": "<mask token>\n\n\ndef getDirList(p):\n p = p.replace('/', '\\\\')\n if p[-1] != '\\\\':\n p = p + '\\\\'\n a = os.listdir(p)\n for x in a:\n if os.path.isfile(p + x):\n a, b = os.path.splitext(p...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def kind(): data = {} with open('dataset.json', 'r') as read_file: data = json.load(read_file) return data['kind'] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "630480e9458491a26ea9060bd36541a0d5805a11", "index": 647, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef kind():\n data = {}\n with open('dataset.json', 'r') as read_file:\n data = json.load(read_file)\n return data['kind']\n\n\n<mask token>\n", "step-3": "<mask toke...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def mais_populoso(dic): p = 0 sp = 0 for t, i in dic.items(): for m in dic[t].values(): p += m if p > sp: sp = p x = t return x
flexible
{ "blob_id": "2cbce618d1ec617d1c7dc0e9792b6a49361ec5a4", "index": 13, "step-1": "<mask token>\n", "step-2": "def mais_populoso(dic):\n p = 0\n sp = 0\n for t, i in dic.items():\n for m in dic[t].values():\n p += m\n if p > sp:\n sp = p\n x = t\n return ...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print("Usa el punto '.' para los decimales") for contador in range(1, numalumnos + 1): print(f'\nDatos del alumno número {contador} de {numalumnos}:') teorica = float(input('- Introduce la nota de la parte teórica: ')) ...
flexible
{ "blob_id": "f2056ff46ce6e38c3b6ca553bbdec7f59d60b198", "index": 1417, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\"Usa el punto '.' para los decimales\")\nfor contador in range(1, numalumnos + 1):\n print(f'\\nDatos del alumno número {contador} de {numalumnos}:')\n teorica = float(input(...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class GeneralizedExtremeValueUncertaintyTestCase(UncertaintyTestCase): def test_random_variables(self): params = self.make_params_array() params['loc'] = 2 params['scale'] = 5 expected_median = 2 - 5 * np.log(np.log(2)) results = GEVU.random_va...
flexible
{ "blob_id": "997c1c86848b59a3986a579d5b1b50313fdfdf44", "index": 8161, "step-1": "<mask token>\n\n\nclass GeneralizedExtremeValueUncertaintyTestCase(UncertaintyTestCase):\n\n def test_random_variables(self):\n params = self.make_params_array()\n params['loc'] = 2\n params['scale'] = 5\n ...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class RegPropData: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, csv_path): """ Initialize a region proposal data instance. Parameters ---------- ...
flexible
{ "blob_id": "b10badc172be119be5b2ab8ccc32cc95a0ed1e7a", "index": 2680, "step-1": "<mask token>\n\n\nclass RegPropData:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, csv_path):\n \"\"\"\n Initialize a region proposal data instance.\n\n Param...
[ 5, 7, 8, 9, 11 ]
<|reserved_special_token_0|> class Game_Service(object): def __init__(self, row_num, col_num): self._row_num = row_num self._col_num = col_num mine_percent = 0.3 self._mine_num = int(mine_percent * float(self._row_num * self. _col_num)) self.shifts = [-1, 0, 1]...
flexible
{ "blob_id": "4af72cab6444922ca66641a08d45bcfe5a689844", "index": 6763, "step-1": "<mask token>\n\n\nclass Game_Service(object):\n\n def __init__(self, row_num, col_num):\n self._row_num = row_num\n self._col_num = col_num\n mine_percent = 0.3\n self._mine_num = int(mine_percent * f...
[ 5, 6, 7, 9, 10 ]
#Program written and maintained by Matthew Meyerink #File responsible for defining the game based on user input from cpu_game import CPU_Game from warning_color import Warning class User_Game(CPU_Game): #Get the user phrase to start the game def get_user_phrase(self): correct_form = False w...
normal
{ "blob_id": "d0dbf5a13b8e718ed426a254546ba13da12b2c3e", "index": 4149, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass User_Game(CPU_Game):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass User_Game(CPU_Game):\n\n def get_user_phrase(self):\n correct_form = False\n whi...
[ 0, 1, 2, 3, 4 ]
from setuptools import setup, find_packages import sys, os version = '0.1' setup( name='ckanext-MYEXTENSION', version=version, description="description", long_description="""\ """, classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers keywords='', author='ldhspace', author...
normal
{ "blob_id": "9d2c0d59b0b2b4e4fca942e648059738053c53d0", "index": 9376, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='ckanext-MYEXTENSION', version=version, description=\n 'description', long_description='\\t', classifiers=[], keywords='',\n author='ldhspace', author_email='ldhspace@yah...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in soup.find_all('a'): if 'href' in i.attrs: print(i.attrs['href']) <|reserved_special_token_1|> <|reserved_special_token_0|> url = 'http://www.dytt8.net/' user = {'User-Agent': 'Mozilla/5.0 (Windows NT 10...
flexible
{ "blob_id": "2e571e3412bf9f3a42bf87976ea9a5ec68d5815c", "index": 9056, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in soup.find_all('a'):\n if 'href' in i.attrs:\n print(i.attrs['href'])\n", "step-3": "<mask token>\nurl = 'http://www.dytt8.net/'\nuser = {'User-Agent':\n 'Mozilla/5...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def get_files_api(): """Get the files API client.""" return get_api_client(cloudsmith_api.FilesApi) def validate_request_file_upload(owner, repo, filepath, md5_checksum=None): """Validate parameters for requesting a file upload.""" client = get_files_api() md5_checks...
flexible
{ "blob_id": "ee03263d92372899ec1feaf3a8ea48677b053676", "index": 6281, "step-1": "<mask token>\n\n\ndef get_files_api():\n \"\"\"Get the files API client.\"\"\"\n return get_api_client(cloudsmith_api.FilesApi)\n\n\ndef validate_request_file_upload(owner, repo, filepath, md5_checksum=None):\n \"\"\"Valid...
[ 2, 3, 4, 5, 6 ]
import art import random print(art.guess) print(art.the) print(art.number) print("I'm thinking of a number between 1 and 100") number = random.randint(1,100) turns = 0 difficulty = input("Chose a difficulty. 'easy' or 'hard'?\n") if difficulty == 'easy': turns +=10 else: turns +=5 gameover = False while n...
normal
{ "blob_id": "f2bf4f5b057af1d2362ec8d1472aa76e774be1c7", "index": 2736, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(art.guess)\nprint(art.the)\nprint(art.number)\nprint(\"I'm thinking of a number between 1 and 100\")\n<mask token>\nif difficulty == 'easy':\n turns += 10\nelse:\n turns += 5\...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python """ Script to download and plot RaspberryShake station data Also computes and plots theoretical phase arrival times and raypaths. See https://docs.obspy.org/packages/obspy.taup.html for more info on Earth models and phase-nmaing nomenclature. Stephen Hicks Imperial College London Feb 2020 """ ...
normal
{ "blob_id": "8d8ea6ad7a3ed1a1e6e96ab75260ecf6e8211d32", "index": 1305, "step-1": "<mask token>\n", "step-2": "<mask token>\nst.merge()\nst.detrend(type='demean')\nst.remove_response()\nst.filter('bandpass', freqmin=F1, freqmax=F2, corners=4)\nst.trim(t1, t2)\n<mask token>\nplt.suptitle(LABEL)\n<mask token>\nax...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class _GenericBot: <|reserved_special_token_0|> def __init__(self, pos, inventory=None): """Initialize with an empty inventory. inventory is a dictionary. If None, an empty one will be used.""" if inventory is None: self._inventory = {} ...
flexible
{ "blob_id": "54f0ed5f705d5ada28721301f297b2b0058773ad", "index": 2, "step-1": "<mask token>\n\n\nclass _GenericBot:\n <mask token>\n\n def __init__(self, pos, inventory=None):\n \"\"\"Initialize with an empty inventory.\n\n inventory is a dictionary. If None, an empty one will be used.\"\"\"\...
[ 52, 53, 58, 60, 79 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ImageForm(forms.ModelForm): <|reserved_special_token_0|> class Meta: model = Profile fields = ['userimage'] <|reserved_special_token_1|> <|reserved_special_token_0|> class ImageForm(forms.Mod...
flexible
{ "blob_id": "9081d0f75ac53ab8d0bafb39cd46a2fec8a5135f", "index": 3813, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ImageForm(forms.ModelForm):\n <mask token>\n\n\n class Meta:\n model = Profile\n fields = ['userimage']\n", "step-3": "<mask token>\n\n\nclass ImageForm(fo...
[ 0, 1, 2, 3, 4 ]
# coding: utf-8 # # Configuration # In[1]: CONNECTION_STRING = "mongodb://localhost:27017" DATABASE_NAME = "off" COLLECTION_NAME = "products" # # MongDB connection # In[2]: from pymongo import MongoClient from bson.code import Code import plotly, pymongo plotly.offline.init_notebook_mode() from plotly.graph_obj...
normal
{ "blob_id": "2ecd234753fabbca2829dc86db2f740e371e4ea7", "index": 6499, "step-1": "\n# coding: utf-8\n\n# # Configuration\n\n# In[1]:\n\nCONNECTION_STRING = \"mongodb://localhost:27017\"\nDATABASE_NAME = \"off\"\nCOLLECTION_NAME = \"products\"\n\n\n# # MongDB connection\n\n# In[2]:\n\nfrom pymongo import MongoCli...
[ 0 ]
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to us...
normal
{ "blob_id": "b77c40c89c88b49c851e9a14c67cf0799d6de847", "index": 9235, "step-1": "<mask token>\n\n\ndef register(locator: str, entry_point, **kwargs):\n \"\"\"Register an AgentSpec with the zoo.\n\n In order to load a registered AgentSpec it needs to be reachable from a\n directory contained in the PYTH...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> {'name': 'ldap_user', 'summary': '', 'description': '域账号用户管理,登录及查询用户信息', 'author': '', 'website': '', 'source': {'git': 'https://github.com/LeiQiao/Parasite-Plugins.git', 'branch': 'master'}, 'category': '', 'version': '0.1', 'api': {'/user/token'...
flexible
{ "blob_id": "b95619f3f52ff3747e38ecc153123962d0122a4d", "index": 387, "step-1": "<mask token>\n", "step-2": "{'name': 'ldap_user', 'summary': '', 'description': '域账号用户管理,登录及查询用户信息',\n 'author': '', 'website': '', 'source': {'git':\n 'https://github.com/LeiQiao/Parasite-Plugins.git', 'branch': 'master'},\...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def isPrime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i = i + 6 return True <|reserved_s...
flexible
{ "blob_id": "fe5050fdf010ce1c4d458b8a52ac92485a7d8cea", "index": 5706, "step-1": "<mask token>\n\n\ndef isPrime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i...
[ 1, 2, 3, 4, 5 ]
import FWCore.ParameterSet.Config as cms from RecoTracker.MeasurementDet.UpdaterService_cfi import * from RecoTracker.MeasurementDet.MeasurementTrackerESProducer_cfi import *
normal
{ "blob_id": "e79505e802a06f091bbb12708c45e04c4e80da60", "index": 7618, "step-1": "<mask token>\n", "step-2": "import FWCore.ParameterSet.Config as cms\nfrom RecoTracker.MeasurementDet.UpdaterService_cfi import *\nfrom RecoTracker.MeasurementDet.MeasurementTrackerESProducer_cfi import *\n", "step-3": null, ...
[ 0, 1 ]
# This script is for character creation. print ("Welcome to the character wizard creation!") # Here you will select your race from the list. race = ["human", "ork", "elf"] print race race = raw_input("Please choose your race: ") print "You have choosen %r" %race # Here you will select your gender. gender = ...
normal
{ "blob_id": "243016b14f503a09147f434e7bec31dc204fafdf", "index": 1158, "step-1": "# This script is for character creation.\r\nprint (\"Welcome to the character wizard creation!\")\r\n\r\n# Here you will select your race from the list.\r\nrace = [\"human\", \"ork\", \"elf\"]\r\nprint race\r\nrace = raw_input(\"Pl...
[ 0 ]
import shlex class MockSOLR(object): class MockHits(list): @property def hits(self): return len(self) @property def docs(self): return self def __init__(self): self.db = {} def add(self, objects): for o in objects: o['...
normal
{ "blob_id": "4774c1f4eafc0132bab0073b60c4bcad6b69380d", "index": 9068, "step-1": "<mask token>\n\n\nclass MockSOLR(object):\n\n\n class MockHits(list):\n\n @property\n def hits(self):\n return len(self)\n\n @property\n def docs(self):\n return self\n <mask ...
[ 3, 5, 6, 7, 8 ]
from share_settings import Settings import urllib.request,json import pprint as p s = Settings() prefix = "http://finance.google.com/finance?client=ig&output=json&q=" def get(symbol,exchange): url = prefix+"%s:%s"%(exchange,symbol) u = urllib.request.urlopen(url) #translates url to string c = u.re...
normal
{ "blob_id": "7247ef463998f6738c21ad8efa988a32f7fb99c0", "index": 4760, "step-1": "<mask token>\n\n\ndef get_lp(s):\n \"\"\"gets latest prices from google\"\"\"\n sl = []\n for stock in s.symbols:\n quote = get(stock, 'LON')\n x = quote.replace(',', '')\n x = float(x)\n sl.app...
[ 1, 2, 3, 4, 5 ]
from flask import jsonify, request, render_template, redirect, session, flash from init import app from init import mysql #Devuelve la pagina de reportes @app.route('/reportes') def reportes(): try: cur = mysql.connect().cursor() if 'usuario' in session: return render_template('views/re...
normal
{ "blob_id": "77995aab723fb118be3f986b8cd93f349690baca", "index": 2090, "step-1": "<mask token>\n\n\n@app.route('/reportes')\ndef reportes():\n try:\n cur = mysql.connect().cursor()\n if 'usuario' in session:\n return render_template('views/reportes.html', id=session['id'])\n el...
[ 4, 5, 6, 7, 8 ]
N = int(input()) K = int(input()) xs = list(map(int, input().split())) dist = 0 for x in xs: dist += min(x, K - x) print(dist * 2)
normal
{ "blob_id": "a65ab0faf08c13f007a132fb92f358a35834fdb7", "index": 2556, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor x in xs:\n dist += min(x, K - x)\nprint(dist * 2)\n", "step-3": "N = int(input())\nK = int(input())\nxs = list(map(int, input().split()))\ndist = 0\nfor x in xs:\n dist += min...
[ 0, 1, 2 ]
<|reserved_special_token_0|> @router.get('/{prefix_id}') def redirect_to_board(project: Project=Depends(get_project_by_prefix)): return RedirectResponse(url=project.notion_board_url) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @router.get('/{prefix_id}') def redir...
flexible
{ "blob_id": "49b295c3e323695779eb32181193ef88b678b34d", "index": 6340, "step-1": "<mask token>\n\n\n@router.get('/{prefix_id}')\ndef redirect_to_board(project: Project=Depends(get_project_by_prefix)):\n return RedirectResponse(url=project.notion_board_url)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): def moveZeroes(self, nums): """ 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 --- 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] --- ...
flexible
{ "blob_id": "ece80a7765674f9d2991029bb86486b616a90f58", "index": 3944, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def moveZeroes(self, nums):\n \"\"\"\n\t\t给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。\n\t\t---\n\t\t...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def stationarity_test(mylynxts): from statsmodels.tsa.stattools import adfuller print('Results of Dickey-Fuller Test:') df_test = adfuller(mylynxts, autolag='AIC') df_output = pd.Series(df_test[0:4], index=['Test Statistic', 'p-value', '#lags_used', 'Number of Obse...
flexible
{ "blob_id": "8e28135da60f8e11459697c4ae9c63e60c437d7a", "index": 9501, "step-1": "<mask token>\n\n\ndef stationarity_test(mylynxts):\n from statsmodels.tsa.stattools import adfuller\n print('Results of Dickey-Fuller Test:')\n df_test = adfuller(mylynxts, autolag='AIC')\n df_output = pd.Series(df_test...
[ 1, 2, 3, 4, 5 ]
import os import stat from optparse import OptionParser from bbpgsql.configuration import get_config_from_filename_and_set_up_logging from bbpgsql.configuration.general import get_data_dir from subprocess import check_output import sys VERSION = '' class BadArgumentException(Exception): def __init__(self, msg): ...
normal
{ "blob_id": "eed79a3895975a0475c0b192bd8a42e80def2e78", "index": 2502, "step-1": "<mask token>\n\n\nclass BadArgumentException(Exception):\n\n def __init__(self, msg):\n self.msg = msg\n\n def __str__(self):\n return self.msg\n\n\nclass TooManyArgumentsException(Exception):\n\n def __init_...
[ 25, 26, 29, 31, 32 ]