code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
import datetime count = 0 for y in xrange(1901,2001): for m in xrange(1,13): if datetime.date(y,m,1).weekday() == 6: count += 1 print count
normal
{ "blob_id": "7430e17d1c424362399cf09a0c3ecae825d04567", "index": 2996, "step-1": "import datetime\ncount = 0\nfor y in xrange(1901,2001):\n\tfor m in xrange(1,13):\n\t\tif datetime.date(y,m,1).weekday() == 6:\n\t\t\tcount += 1\n\nprint count\n", "step-2": null, "step-3": null, "step-4": null, "step-5": n...
[ 0 ]
from telegram.ext import Updater, Filters, MessageHandler, PicklePersistence import telegram import logging logging.basicConfig(format='%(asctime)s %(message)s\n', level=logging.INFO,filename='log.json') logger = logging.getLogger(__name__) def main(): # my_persistence = PicklePersistence(...
normal
{ "blob_id": "0a90f29a4e18c2aed23cb31b4239d44d23526327", "index": 9133, "step-1": "<mask token>\n\n\ndef main():\n updater = Updater('', use_context=True)\n dp = updater.dispatcher\n jobs = updater.job_queue\n dp.add_error_handler(error)\n updater.start_polling()\n updater.idle()\n\n\n<mask toke...
[ 1, 2, 3, 4, 5 ]
def group(arr): low, mid, high = 0, 0, len(arr)-1 while mid <= high: print(arr) if arr[mid] == 'R' : arr[low], arr[mid] = arr[mid], arr[low] low += 1 mid += 1 elif arr[mid] == 'G': mid += 1 else: arr[high], ar...
normal
{ "blob_id": "8ad47bf292e0046550cc0ef6f6bb75cf179ebd4b", "index": 7477, "step-1": "<mask token>\n", "step-2": "def group(arr):\n low, mid, high = 0, 0, len(arr) - 1\n while mid <= high:\n print(arr)\n if arr[mid] == 'R':\n arr[low], arr[mid] = arr[mid], arr[low]\n low +...
[ 0, 1, 2, 3, 4 ]
n, a, b = map(int, input().split()) cl = list(map(int, input().split())) for i in range(n): if cl[i] == a + b: print(i + 1)
normal
{ "blob_id": "ff081a5ff46ab37dc5a144fb4616c06ef3bca490", "index": 7286, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n if cl[i] == a + b:\n print(i + 1)\n", "step-3": "n, a, b = map(int, input().split())\ncl = list(map(int, input().split()))\nfor i in range(n):\n if cl[...
[ 0, 1, 2 ]
"""Test an example.""" from . import main def test_readme_escaping() -> None: """Ensure the demo matches expected.""" assert main() == "<div>&lt;span&gt;Escaping&lt;/span&gt;</div>"
normal
{ "blob_id": "7b459aad399a31f61b8686e1919b38d5538924b8", "index": 2014, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_readme_escaping() ->None:\n \"\"\"Ensure the demo matches expected.\"\"\"\n assert main() == '<div>&lt;span&gt;Escaping&lt;/span&gt;</div>'\n", "step-3": "<mask token...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python """ .. module:: convert :synopsis: used to create info.txt and the <txname>.txt files. """ import sys import os import argparse argparser = argparse.ArgumentParser(description = 'create info.txt, txname.txt, twiki.txt and sms.py') argparser.add_argument ('-utilsPath', '--utilsPath', help ...
normal
{ "blob_id": "c80b31bc154d5c1c8f9fc0ac226295160f2f9473", "index": 4249, "step-1": "<mask token>\n", "step-2": "<mask token>\nargparser.add_argument('-utilsPath', '--utilsPath', help=\n 'path to the package smodels_utils', type=str)\nargparser.add_argument('-smodelsPath', '--smodelsPath', help=\n 'path to ...
[ 0, 1, 2, 3, 4 ]
import os import sys import socket __target__ = '${EXTERNAL_HOST}' sources = {} def process_the_source(fname, dest=None, host_ip=None, verbose=False): assert (os.path.exists(fname) and os.path.isfile(fname)), 'Cannot proceed without the fname in process_the_source().' the_lines = [] with open(fname, 'r')...
normal
{ "blob_id": "d6af9a75fbe8bdf1a81a352cee71ac81fb373b86", "index": 9926, "step-1": "<mask token>\n\n\ndef process_the_source(fname, dest=None, host_ip=None, verbose=False):\n assert os.path.exists(fname) and os.path.isfile(fname\n ), 'Cannot proceed without the fname in process_the_source().'\n the_li...
[ 1, 2, 3, 4, 5 ]
import re # Wordcount: count the occurrences of each word in that phrase. def word_count(phrase): phrase = re.sub(r'\W+|_', ' ', phrase.lower(), flags=re.UNICODE) word_list = phrase.split() wordfreq = [word_list.count(p) for p in word_list] return dict(zip(word_list, wordfreq))
normal
{ "blob_id": "e12905efa0be7d69e2719c05b40d18c50e7e4b2e", "index": 4933, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef word_count(phrase):\n phrase = re.sub('\\\\W+|_', ' ', phrase.lower(), flags=re.UNICODE)\n word_list = phrase.split()\n wordfreq = [word_list.count(p) for p in word_list]...
[ 0, 1, 2, 3 ]
import loops class Card(): #to make a card you must type Card("Name of Card") def check_cat(self,string): if "Cat" in string: return True return False def __init__(self,string): self.type = string self.cat = self.check_cat(self.type) # self.ima...
normal
{ "blob_id": "3b71ef6c3681b8c5e6aadf2d125c35cbf3a12661", "index": 6248, "step-1": "<mask token>\n\n\nclass Card:\n\n def check_cat(self, string):\n if 'Cat' in string:\n return True\n return False\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def steal(...
[ 4, 6, 8, 10, 12 ]
import numpy as np from scipy.stats import loguniform import sys def generate_parameters(seed): np.random.seed(seed) out={} out['nfeatures'] = np.random.randint(3, 25) out['lr'] = float(loguniform.rvs(0.001, 0.01, size=1)) out['gamma'] = np.random.uniform(0.75, 0.05) out['penalty'] = float(logu...
normal
{ "blob_id": "7571e86be1077ae0f7ae542824cfcaaa2949dc83", "index": 8731, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_parameters(seed):\n np.random.seed(seed)\n out = {}\n out['nfeatures'] = np.random.randint(3, 25)\n out['lr'] = float(loguniform.rvs(0.001, 0.01, size=1))\n ...
[ 0, 1, 2, 3, 4 ]
from django.db import models # Create your models here. class Task(models.Model): level = models.PositiveSmallIntegerField() topic = models.CharField(max_length=100) content = models.TextField() correct_answer = models.CharField(max_length=50) class Answer(models.Model): content = models.TextField...
normal
{ "blob_id": "06e01dce7e2342be994569099ed51d1fe28eea1c", "index": 5784, "step-1": "<mask token>\n\n\nclass Answer(models.Model):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Task(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token...
[ 1, 3, 4, 5, 6 ]
from util import * def K_step(x): if not x.shape: return S.One assert len(x.shape) == 1 n = x.shape[0] if n == 2: return x[1] return Piecewise((1, Equal(n, 1)), (x[1], Equal(n, 2)), (K(x[:n - 1]) * x[n - 1] + K(x[:n - 2]), True)) K = Fun...
normal
{ "blob_id": "b00c07ee3cdba55800c9701b7b8b0e3c9079e9f8", "index": 6272, "step-1": "<mask token>\n\n\ndef K_step(x):\n if not x.shape:\n return S.One\n assert len(x.shape) == 1\n n = x.shape[0]\n if n == 2:\n return x[1]\n return Piecewise((1, Equal(n, 1)), (x[1], Equal(n, 2)), (K(x[:n...
[ 3, 4, 5, 6, 7 ]
from math import * def eval_loop(): line = input('Please enter a sting') while True: if line == 'done': break else: output = eval(line) print(output) line = input('Please enter a sting') eval_loop()
normal
{ "blob_id": "b0062dde448c450131f578a2afe130ca663f0902", "index": 2041, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef eval_loop():\n line = input('Please enter a sting')\n while True:\n if line == 'done':\n break\n else:\n output = eval(line)\n ...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 """ Python class to access Netonix® WISP Switch WebAPI ** NEITHER THIS CODE NOR THE AUTHOR IS ASSOCIATED WITH NETONIX® IN ANY WAY.** This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software,...
normal
{ "blob_id": "743d261052e4532c1304647501719ad897224b4e", "index": 8991, "step-1": "<mask token>\n\n\nclass Netonix:\n <mask token>\n\n def _get(self, url, params=None, timeout=15, **kwargs):\n full_url = 'https://' + self.ip + self.url[url]\n return self.s.get(full_url, params=params, timeout=...
[ 9, 11, 13, 14, 20 ]
#Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd #importing the data dataset=pd.read_csv('Social_Network_Ads.csv') X=dataset.iloc[:,0:2].values y=dataset.iloc[:,2].values #spiliting the data into training data and testing data from sklearn.model_selection impo...
normal
{ "blob_id": "149f8b453786ec54668a55ec349ac157d2b93b5d", "index": 2397, "step-1": "<mask token>\n", "step-2": "<mask token>\nlog.fit(X_train, y_train)\nlog.predict(sc.transform([[45, 87000]]))\n<mask token>\nnp.set_printoptions(precision=2)\nnp.concatenate((y_pred.reshape(len(y_pred), 1), y_test.reshape(len(y_t...
[ 0, 1, 2, 3, 4 ]
import matplotlib.pyplot as plt class Scatter: def __init__(self, values, ylabel, title): self.values = values self.range = list(range(len(values))) self.ylabel = ylabel self.title = title def plot(self): fig = plt.figure() ax = fig.add_axes([0, 0, ...
normal
{ "blob_id": "58385a7713a8f88925ced714d25f1522bc7e39d8", "index": 1181, "step-1": "<mask token>\n\n\nclass Scatter:\n <mask token>\n <mask token>\n\n\nclass Pie:\n\n def __init__(self, values, labels, title):\n self.style = 'fivethirtyeight'\n self.values = values\n self.labels = lab...
[ 5, 6, 7, 8, 9 ]
import torch import torch.nn as nn class DehazeNet(nn.Module): def __init__(self, input=16, groups=4): super(DehazeNet, self).__init__() self.conv1 = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=5) self.relu1 = nn.ReLU() self.conv2 = nn.Conv2d(in_channels=4, out_channels=...
normal
{ "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 spacy nlp = spacy.load("en_core_web_sm") text = ( "Chick-fil-A is an American fast food restaurant chain headquartered in " "the city of College Park, Georgia, specializing in chicken sandwiches." ) # Disable the tagger and parser with ____.____(____): # Process the text doc = ____ # Print ...
normal
{ "blob_id": "6eecf0ff1ad762089db6e9498e906e68b507370c", "index": 1875, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith ____.____(____):\n doc = ____\n print(____)\n", "step-3": "<mask token>\nnlp = spacy.load('en_core_web_sm')\ntext = (\n 'Chick-fil-A is an American fast food restaurant ch...
[ 0, 1, 2, 3, 4 ]
import os import subprocess import discord import asyncio import traceback import sys import ast from discord.ext import commands # Import Cogs from cogs.misc import Miscellaneous from cogs.serversettings import ServerSettings from cogs.mod import Moderator from cogs.automod import AutoMod from cogs.google import Goo...
normal
{ "blob_id": "4f9729e396e01cb3d6c9011f79a1ebe618a8e762", "index": 7787, "step-1": "<mask token>\n\n\ndef insert_returns(body):\n if isinstance(body[-1], ast.Expr):\n body[-1] = ast.Return(body[-1].value)\n ast.fix_missing_locations(body[-1])\n if isinstance(body[-1], ast.If):\n insert_r...
[ 1, 3, 4, 5, 6 ]
# Reddit API feed import praw import sys import os def main(): if os.getenv("REDDIT_CLIENT_ID") is None: print "Set your Reddit environment variables:" print "REDDIT_CLIENT_ID and REDDIT_CLIENT_SECRET" sys.exit() client_id = os.environ['REDDIT_CLIENT_ID'] client_secret = os.environ...
normal
{ "blob_id": "9543992e1b115f83640a07c4d4372be0fb465199", "index": 3256, "step-1": "# Reddit API feed\n\nimport praw\nimport sys\nimport os\n\ndef main():\n if os.getenv(\"REDDIT_CLIENT_ID\") is None:\n print \"Set your Reddit environment variables:\"\n print \"REDDIT_CLIENT_ID and REDDIT_CLIENT_S...
[ 0 ]
#!/usr/bin/python import os, sys import csv import glob if len(sys.argv)==3: res_dir = sys.argv[1] info = sys.argv[2] else: print "Incorrect arguments: enter outout directory" sys.exit(0) seg = dict([('PB2','1'), ('PB1','2'), ('PA','3'), ('HA','4'), ('NP','5'), ('NA','6'), ('MP','7'), ('NS','8')]) # Read th...
normal
{ "blob_id": "4a2796645f1ab585084be47c8cd984c2945aa38b", "index": 4270, "step-1": "#!/usr/bin/python\n\nimport os, sys\nimport csv\nimport glob\n\nif len(sys.argv)==3:\n res_dir = sys.argv[1]\n info = sys.argv[2]\n\nelse:\n print \"Incorrect arguments: enter outout directory\"\n sys.exit(0)\n\nseg = dict([('P...
[ 0 ]
def test_logsources_model(self): """ Comprobacion de que el modelo de la fuente de seguridad coincide con su asociado Returns: """ log_source = LogSources.objects.get(Model="iptables v1.4.21") self.assertEqual(log_source.get_model(), "iptables v1.4.21")
normal
{ "blob_id": "c645461effe288a1959b783473d62ff99ca29547", "index": 8746, "step-1": "<mask token>\n", "step-2": "def test_logsources_model(self):\n \"\"\"\n Comprobacion de que el modelo de la fuente de seguridad coincide con su asociado\n Returns:\n\n \"\"\"\n log_source = LogSources.objects.get(M...
[ 0, 1, 2 ]
#encoding=utf-8 import pytest from frame_project.实战2.main_page import MainPage class TestMian: def test_mian(self): MainPage().goto_marketpage().goto_search().search() if __name__ == '__main__': pytest.main(['test_case.py','-s','-v'])
normal
{ "blob_id": "e1751cc6f76f56e62cd02d61db65f1c27a4ff1b9", "index": 7351, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestMian:\n\n def test_mian(self):\n MainPage().goto_marketpage().goto_search().search()\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass TestMian:\n\n de...
[ 0, 2, 3, 4, 5 ]
import json import os import sys """ Course: cmps 4883 Assignemt: A03 Date: 2/10/19 Github username: acdczlc Repo url: https://github.com/acdczlc/4883-SWTools-Conley Name: Zac Conley Description: Calculates all stats for questions about stats """ ############################################################## # Mos...
normal
{ "blob_id": "2a4f57cd0fc1c50cba06c285849432c6f71f28e2", "index": 2642, "step-1": "<mask token>\n\n\ndef MostTeams(OffAndDef):\n most = []\n count = 0\n for playerid, playerdata in OffAndDef.items():\n if playerdata['name'] != '':\n if len(playerdata['Teams']) > count:\n ...
[ 8, 9, 10, 15, 17 ]
import swipe def scheduleMultipoint(driver): driver.find_element_by_id('com.dentist.android:id/calendarBt').click() driver.find_element_by_id('com.dentist.android:id/addIb').click() def time(driver):#就诊时间 driver.find_element_by_id('com.dentist.android:id/cureHourLl').click()#就诊时间 drive...
normal
{ "blob_id": "02bc97b963b970993fc947cfa41c73230dd4d9e4", "index": 2649, "step-1": "<mask token>\n\n\ndef scheduleMultipoint(driver):\n driver.find_element_by_id('com.dentist.android:id/calendarBt').click()\n driver.find_element_by_id('com.dentist.android:id/addIb').click()\n\n\ndef time(driver):\n driver...
[ 4, 6, 7, 8, 9 ]
#!/usr/bin/python import argparse import os import pipes import sys import rospy import std_msgs.msg import actionlib import time import datetime from geometry_msgs.msg import Pose, Point, Quaternion from actionlib import * from location_provider.srv import GetLocationList from std_srvs.srv import Trigger try: i...
normal
{ "blob_id": "7a0e7ede263727ef303ba23dff1949c3a7031360", "index": 7423, "step-1": "#!/usr/bin/python\nimport argparse\nimport os\nimport pipes\nimport sys\n\nimport rospy\nimport std_msgs.msg\nimport actionlib\nimport time\n\nimport datetime\nfrom geometry_msgs.msg import Pose, Point, Quaternion\nfrom actionlib i...
[ 0 ]
from django.db import models # Create your models here. class Logins(models.Model): created = models.DateTimeField(auto_now_add=True) login_addr = models.GenericIPAddressField() hostname = models.CharField(max_length=200)
normal
{ "blob_id": "9a55ccf758b4b2cc440153ab3b1f97823863a848", "index": 165, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Logins(models.Model):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Logins(models.Model):\n created = models.DateTimeField(aut...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python2 # # Author: Victor Ananjevsky, 2007 - 2010 # based on xdg-menu.py, written by Piotr Zielinski (http://www.cl.cam.ac.uk/~pz215/) # License: GPL # # This script takes names of menu files conforming to the XDG Desktop # Menu Specification, and outputs their FVWM equivalents to the # standard output. # #...
normal
{ "blob_id": "214aadb7b3fc125da12f098bde87fce295349fdf", "index": 1917, "step-1": "#!/usr/bin/python2\n#\n# Author: Victor Ananjevsky, 2007 - 2010\n# based on xdg-menu.py, written by Piotr Zielinski (http://www.cl.cam.ac.uk/~pz215/)\n# License: GPL\n#\n# This script takes names of menu files conforming to the XDG...
[ 0 ]
import pygame import time from menus import MainMenu from scenes import TestWorldGen from scenes import TestAnimation from scenes import TestLevel2 from scenes import MainGame import random class GameManager: def __init__(self): self.screen = pygame.display.set_mode((1280, 720), ...
normal
{ "blob_id": "91806afea92587476ac743346b88098b197a033c", "index": 9706, "step-1": "<mask token>\n\n\nclass GameManager:\n\n def __init__(self):\n self.screen = pygame.display.set_mode((1280, 720), flags=pygame.\n FULLSCREEN | pygame.HWSURFACE | pygame.DOUBLEBUF)\n self.running = True\n...
[ 4, 5, 6, 7, 8 ]
from django.shortcuts import render from post.models import * from .models import * from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from account.models import Profile from django.contrib.auth.models import User from django.db.models import Q # Create your views here. def index(request): posts...
normal
{ "blob_id": "ee3718dee869a58089e897489af2eec3ff72be56", "index": 3478, "step-1": "<mask token>\n\n\ndef index(request):\n posts = Post.objects.order_by('-created_at').filter(status='Published')\n paginator = Paginator(posts, 9)\n page = request.GET.get('page')\n post_listings = paginator.get_page(pag...
[ 2, 3, 4, 5, 6 ]
from django.db import models from django.contrib.auth.models import AbstractUser from django.core.validators import MinLengthValidator, MaxLengthValidator, RegexValidator from pizzaclub.settings import MAX_DNI_LENGTH, MAX_CUIL_LENGTH, PASSWORD_RESET_TIMEOUT from pizzaclub.settings import MIN_DNI_LENGTH, MIN_CUIL_LENGT...
normal
{ "blob_id": "b7511c156c241accaf1668d83ee0a5263b41af0d", "index": 3465, "step-1": "<mask token>\n\n\nclass User(AbstractUser):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def check_token(self, token):\n \"\"\"\n ...
[ 8, 13, 15, 16, 18 ]
from django.db.models import Exists from django.db.models import OuterRef from django.db.models import QuerySet from django.utils import timezone class ProductQuerySet(QuerySet): def available(self): return self.filter(available_in__contains=timezone.now(), category__public=True) def annotate_subprod...
normal
{ "blob_id": "3fdf67c3e0e4c3aa8a3fed09102aca0272b5ff4f", "index": 6938, "step-1": "<mask token>\n\n\nclass OrderQuerySet(QuerySet):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ProductQuerySet(QuerySet):\n <mask token>\n <...
[ 1, 7, 8, 9, 11 ]
import json, re, bcrypt, jwt from datetime import datetime, timedelta from django.core.exceptions import ObjectDoesNotExist from django.db.models import Avg from django.http import JsonResponse from django.views import View from room.models import Room, Category, Ro...
normal
{ "blob_id": "cc5b22a0246fcc9feaed6a0663095a6003e6cef1", "index": 6685, "step-1": "<mask token>\n\n\nclass RoomView(View):\n\n def get(self, request, room_id):\n try:\n room = Room.objects.get(id=room_id)\n rating_list = [field.name for field in Review._meta.get_fields(\n ...
[ 6, 7, 8, 9, 10 ]
import gc import sys import time import warnings import multiprocessing import numpy as np import pandas as pd import lightgbm as lgb from os import path, makedirs from tqdm import tqdm from utils import Logger from datetime import datetime from sklearn.metrics import roc_auc_score from sklearn.model_s...
normal
{ "blob_id": "74c875d00c665aabbcad4e23e6059c3445d5e7bd", "index": 1597, "step-1": "<mask token>\n\n\ndef load_dataframe(dataset):\n return pd.read_csv(dataset)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef load_dataframe(dataset):\n return pd.read_csv(dataset)\n\n\ndef augment(x, y, t=2):\n xs...
[ 1, 2, 3, 4, 5 ]
# Generated by Django 3.1.6 on 2021-02-27 23:29 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('RMS', '0001_initial'), ] operations = [ migrations.RenameField( model_name='inventorytable', old_name='Restaurant_ID', ...
normal
{ "blob_id": "ba336094d38a47457198919ce60969144a8fdedb", "index": 5374, "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 = [('RMS', '0001...
[ 0, 1, 2, 3, 4 ]
REGION_LIST = [ 'Центральный', 'Северо-Западный', 'Южный', 'Северо-Кавказский', 'Приволжский', 'Уральский', 'Сибирский', 'Дальневосточный', ] CITY_LIST = { 'Абакан': 7, 'Альметьевск': 5, 'Ангарск': 7, 'Архангельск': 2, 'Астрахань': 3, 'Барнаул': 7, 'Батайск':...
normal
{ "blob_id": "2101299d6f6bfcd4726591fc256317968373ca1f", "index": 3071, "step-1": "<mask token>\n", "step-2": "REGION_LIST = ['Центральный', 'Северо-Западный', 'Южный',\n 'Северо-Кавказский', 'Приволжский', 'Уральский', 'Сибирский',\n 'Дальневосточный']\nCITY_LIST = {'Абакан': 7, 'Альметьевск': 5, 'Ангарс...
[ 0, 1, 2 ]
from sys import exit from os import stat file = open("fiunamfs.img","r") nombre = file.read(8) file.seek(10) version = file.read(3) file.seek(20) etiqueta = file.read(15) file.seek(40) cluster = file.read(5) file.seek(47) numero = file.read(2) file.seek(52) numeroCompleto = file.read(8) file.close() archivos = [] tam...
normal
{ "blob_id": "da69fd937153fe2112b9f64411882527274247ef", "index": 1878, "step-1": "<mask token>\n\n\ndef clusterVacio():\n arreAux = []\n busca = 1\n bandera = True\n for i in range(len(clusters)):\n clu = clusters[i]\n arreAux.append(int(clu[0]))\n print(arreAux)\n while bandera:\...
[ 8, 9, 10, 12, 13 ]
"""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 ]
import setuptools setuptools.setup(name='cppersist', install_requires=['Eve'])
normal
{ "blob_id": "4f1956b34ac3b55b2d40220b79816c139b4a2f5c", "index": 9574, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetuptools.setup(name='cppersist', install_requires=['Eve'])\n", "step-3": "import setuptools\nsetuptools.setup(name='cppersist', install_requires=['Eve'])\n", "step-4": null, "step...
[ 0, 1, 2 ]
import os # Set a single thread per process for numpy with MKL/BLAS os.environ['MKL_NUM_THREADS'] = '1' os.environ['OPENBLAS_NUM_THREADS'] = '1' os.environ['MKL_DEBUG_CPU_TYPE'] = '5' import numpy as np from matplotlib import pyplot as plt from copy import deepcopy from kadal.optim_tools.MOBO import MOBO from kadal.s...
normal
{ "blob_id": "ba289bcdc0aa7c2ad70dba7fac541900d0b55387", "index": 7585, "step-1": "<mask token>\n\n\ndef generate_kriging():\n nsample = 20\n nvar = 2\n nobj = 2\n lb = -1 * np.ones(shape=[nvar])\n ub = 1 * np.ones(shape=[nvar])\n sampoption = 'halton'\n samplenorm, sample = sampling(sampopti...
[ 2, 3, 4, 5, 6 ]
#from __future__ import absolute_import #import os from celery import Celery #from django.conf import settings #os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'learning.settings') app = Celery('tasks', broker="redis://localhost") #app.config_from_object('django.conf:settings') #app.autodiscover_tasks(lambda: setti...
normal
{ "blob_id": "3ef114dd35ef3995ae73bf85bbe38db4fb7045d8", "index": 7315, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.task\ndef add(x, y):\n return x + y\n", "step-3": "<mask token>\napp = Celery('tasks', broker='redis://localhost')\n\n\n@app.task\ndef add(x, y):\n return x + y\n", "st...
[ 0, 1, 2, 3, 4 ]
import json import boto3 import os from helper import getEC2Regions, sendDataToSNS, OPTOUT_TAG, SNS_NOTIFICATION_IIAS_EC2 def getEC2FilteredRegionalInstanceInfo(region): ec2RegionalClient = boto3.client('ec2', region_name = region) paginator = ec2RegionalClient.get_paginator('describe_instances') page_ite...
normal
{ "blob_id": "d5f1601d11eb54e6c3dafab0137ec8f2358bb568", "index": 4101, "step-1": "<mask token>\n\n\ndef getEC2FilteredRegionalInstanceInfo(region):\n ec2RegionalClient = boto3.client('ec2', region_name=region)\n paginator = ec2RegionalClient.get_paginator('describe_instances')\n page_iterator = paginato...
[ 3, 4, 5, 6, 7 ]
from django.shortcuts import render # Create your views here. from django.shortcuts import render_to_response from post.models import Post #def ver_un_post(request, idpost): # post = Post.objects.get(id=idpost) # # return render_to_response("post.html",{"post":post,},) def home(request): cursos = Cur...
normal
{ "blob_id": "bd81f4431699b1750c69b0bbc82f066332349fbd", "index": 8976, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef home(request):\n cursos = Curso.objects.order_by('numero')\n return render_to_response('home.html', {'posts': posts})\n", "step-3": "from django.shortcuts import render\nf...
[ 0, 1, 2, 3 ]
import sys input = sys.stdin.readline from collections import deque size, num = map(int, input().split()) position = list(map(int, input().split())) cnt = 0 nums = [] for k in range(1, size + 1): nums.append(k) size = deque(nums) position = deque(position) while position != deque([]): if position[0] == 1: ...
normal
{ "blob_id": "c0c0ed31a09f2b49448bc1f3519aa61daaba20af", "index": 5023, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor k in range(1, size + 1):\n nums.append(k)\n<mask token>\nwhile position != deque([]):\n if position[0] == 1:\n size.popleft()\n position.popleft()\n for i i...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ Created on Tue Sep 4 15:19:49 2018 @author: haoyu """ import numpy as np def train_test_split(X, y, test_ratio = 0.2, seed = None): '''将数据X和y按照test_ratio分割成X_train,X_test,y_train,y_test''' assert X.shape[0] == y.shape[0], \ 'the size of X must be equal to the size of y' ...
normal
{ "blob_id": "beda3d13e3dc12f7527f5c5ba8a0eb05c2734fd9", "index": 6133, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef train_test_split(X, y, test_ratio=0.2, seed=None):\n \"\"\"将数据X和y按照test_ratio分割成X_train,X_test,y_train,y_test\"\"\"\n assert X.shape[0] == y.shape[0\n ], 'the size of...
[ 0, 1, 2, 3 ]
import os import sys import json import logging import argparse from glob import glob from pricewatcher.tools import ensure_mkdir from pricewatcher.parser.f21 import ForeverParser from pricewatcher.parser.jcrew import JcrewParser from pricewatcher.utils.load_es import bulk_load_es BRAND_PARSERS={ 'forever21': Forever...
normal
{ "blob_id": "2c22f891f30825bcb97987c78a98988ad2a92210", "index": 385, "step-1": "<mask token>\n\n\ndef date_handler(obj):\n return obj.isoformat() if hasattr(obj, 'isoformat') else obj\n\n\ndef run():\n parser = argparse.ArgumentParser(description='Process some integers.')\n parser.add_argument('--input...
[ 2, 3, 4, 5, 6 ]
s = input() st = '>>-->' st2 = '<--<<' sch1 = sch2 = 0 i = 0 j = 0 k = -1 while i != -1: i = s.find(st, j) if (k != i) and (i != -1): k = i sch1 += 1 j += 1 j = 0 i = 0 k = -1 while i != -1: i = s.find(st2, j) if (k != i) and (i != -1): k = i sch2 += 1 j += 1 prin...
normal
{ "blob_id": "c18e452592d53f22858f2307c60aa997b809c3c3", "index": 4356, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile i != -1:\n i = s.find(st, j)\n if k != i and i != -1:\n k = i\n sch1 += 1\n j += 1\n<mask token>\nwhile i != -1:\n i = s.find(st2, j)\n if k != i and i ...
[ 0, 1, 2, 3 ]
from ..models import Empleado, Puesto, Tareas from django.contrib.auth import login, logout from django.contrib.auth.models import User, Group from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.views import APIView from .serializers import EmpleadoSeri...
normal
{ "blob_id": "cce85d8a34fd20c699b7a87d402b34231b0d5dbb", "index": 3186, "step-1": "<mask token>\n\n\nclass UserViewSet(viewsets.ModelViewSet):\n queryset = User.objects.all()\n model = User\n serializer_class = UserSerializer\n\n def get_permissions(self):\n return (AllowAny() if self.request.m...
[ 9, 11, 14, 16, 18 ]
def gen_metadata(fn): metadata = {} lines = open(fn,'r').readlines() for line in lines: line = line.rstrip() if len(line) == 0: continue elif line.startswith('#'): continue elif line.startswith('%'): continue else: # Special case RingThresh firstWord = line.split()[0] if line.startswith('...
normal
{ "blob_id": "5066c2a5219cf1b233b4985efc7a4eb494b784ca", "index": 7363, "step-1": "<mask token>\n", "step-2": "def gen_metadata(fn):\n metadata = {}\n lines = open(fn, 'r').readlines()\n for line in lines:\n line = line.rstrip()\n if len(line) == 0:\n continue\n elif lin...
[ 0, 1, 2, 3 ]
import sys def dir_slash(): slash = '/' if 'win' in sys.platform: slash = '\\' return slash
normal
{ "blob_id": "b12c8d0cb1cd1e48df6246fe3f16467b2db296e0", "index": 745, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef dir_slash():\n slash = '/'\n if 'win' in sys.platform:\n slash = '\\\\'\n return slash\n", "step-3": "import sys\n\n\ndef dir_slash():\n slash = '/'\n if 'w...
[ 0, 1, 2 ]
n = 1 ip = [] ma = [] l = [0, 0, 0, 0, 0, 0, 0] # a, b, c, d, e, wpm, pr while n != 0: a = input().strip().split("~") n = len(a) if n == 1: break ip.append(a[0]) ma.append(a[1]) for i in ip: ipn = i.split(".") try: if 1 <= int(ipn[0]) <= 126: p = 0 elif 1...
normal
{ "blob_id": "4a13f05fbbe598242f5663d27d578d2eb977e103", "index": 6137, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile n != 0:\n a = input().strip().split('~')\n n = len(a)\n if n == 1:\n break\n ip.append(a[0])\n ma.append(a[1])\nfor i in ip:\n ipn = i.split('.')\n try:\...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # coding: utf-8 import numpy as np import copy import sys def mutate(genotype_in, mut_matrix): genotype_out = np.zeros(8) for i in range(8): rand_vec = np.random.choice(8, size=int(genotype_in[i]), p=mut_matrix[i,:]) genotype_out+=np.bincount(rand_vec, minlength=8) r...
normal
{ "blob_id": "9065842a8e90c833278547310f027bc63c7a9a47", "index": 7557, "step-1": "<mask token>\n\n\ndef mutate(genotype_in, mut_matrix):\n genotype_out = np.zeros(8)\n for i in range(8):\n rand_vec = np.random.choice(8, size=int(genotype_in[i]), p=\n mut_matrix[i, :])\n genotype_ou...
[ 7, 8, 10, 11, 12 ]
import discord from collections import Counter from db import readDB, writeDB INFO_DB_SUCCESS = 'Database updated successfully!' ERROR_DB_ERROR = 'Error: Unable to open database for writing' ERROR_DB_NOT_FOUND = 'Error: Database for specified game does not exist. Check your spelling or use !addgame first.' ERROR_PLA...
normal
{ "blob_id": "5869669f1e3f648c0ddc68683f0b1d2754b40169", "index": 8714, "step-1": "<mask token>\n\n\ndef roundMultiple(num, multiple):\n if num % multiple:\n return num + (multiple - num % multiple)\n return num\n\n\n<mask token>\n\n\ndef incrementStats(msgChannel, statsFile, winner, losers):\n da...
[ 4, 5, 6, 7, 9 ]
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This is a collection of monkey patches and workarounds for bugs in earlier versions of Numpy. """ from ...utils import minversion __all__ = ['NUMPY_LT_1_10_4', 'NUMPY_LT_1_11', 'NUMPY_LT_1_12', 'NUMPY_LT_1_13', 'NUMPY_LT_1_14', ...
normal
{ "blob_id": "9376d697158faf91f066a88e87d317e79a4d9240", "index": 6575, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['NUMPY_LT_1_10_4', 'NUMPY_LT_1_11', 'NUMPY_LT_1_12',\n 'NUMPY_LT_1_13', 'NUMPY_LT_1_14', 'NUMPY_LT_1_14_1', 'NUMPY_LT_1_14_2']\nNUMPY_LT_1_10_4 = not minversion('numpy', '1....
[ 0, 1, 2, 3 ]
import requests import json def display_response(rsp): try: print("Printing a response.") print("HTTP status code: ", rsp.status_code) h = dict(rsp.headers) print("Response headers: \n", json.dumps(h, indent=2, default=str)) try: body = rsp.json() p...
normal
{ "blob_id": "31761b9469cc579c209e070fbe7b71943404a1ff", "index": 3992, "step-1": "<mask token>\n\n\ndef test_get_from_hell():\n try:\n url = (\n 'http://127.0.0.1:5000/api/lahman2017/people?children=appearances%2Cbatting&people.nameLast=Williams&batting.yearID=1960&appearances.yearID=1960&fi...
[ 1, 2, 3, 4, 5 ]
############################################################################# ## Crytek Source File ## Copyright (C) 2013, Crytek Studios ## ## Creator: Christopher Bolte ## Date: Oct 31, 2013 ## Description: WAF based build system ############################################################################# from wafl...
normal
{ "blob_id": "5848273a76995825f01df53d6beed534e6f9f9fe", "index": 8730, "step-1": "<mask token>\n\n\n@conf\ndef load_debug_linux_x64_settings(conf):\n \"\"\"\n\tSetup all compiler and linker settings shared over all linux_x64 configurations for\n\tthe 'debug' configuration\n\t\"\"\"\n v = conf.env\n load...
[ 3, 4, 5, 6, 7 ]
from django.contrib import admin from .models import (AddressLink, Address, Child, Citation, Configuration, Event, Exclusion, FactType, Family, Group, Label, LinkAncestry, Link, MediaLink, Multimedia, Name, Person, Place, ResearchItem,...
normal
{ "blob_id": "b4d48427dddc7c0240cf05c003cbf7b0163279ee", "index": 9729, "step-1": "<mask token>\n\n\nclass FactTypeAdmin(RootsMagicModelAdmin):\n list_display = ['id', 'owner_type', 'name', 'abbreviation',\n 'gedcom_tag', 'use_value', 'use_date', 'use_place', 'sentence', 'flags'\n ]\n\n\nclass Fa...
[ 31, 35, 38, 39, 48 ]
# coding=utf-8 """ PYOPENGL-TOOLBOX UTILS General purpouse functions. MIT License Copyright (c) 2015-2019 Pablo Pizarro R. 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, inc...
normal
{ "blob_id": "cffcfa08cd919f93dfe2ab8dc676efc76feafab3", "index": 2123, "step-1": "<mask token>\n\n\ndef create_axes(length, both=False, text=False, font=_glut.\n GLUT_BITMAP_HELVETICA_18):\n \"\"\"\n Create axes system.\n\n :param length: Axes length\n :param both: Both axes\n :param text: Show...
[ 2, 3, 5, 6, 7 ]
import random def main(): #print('You rolled a die') return random.randint(1,6) if __name__== "__main__": main()
normal
{ "blob_id": "6d92b944ab8503d3635626c0c23021fc2b40dce3", "index": 5732, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n return random.randint(1, 6)\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef main():\n return random.randint(1, 6)\n\n\nif __name__ == '__main__':\n mai...
[ 0, 1, 2, 3, 4 ]
from menu_sun_integration.application.adapters.customer_adapter import CustomerAdapter from menu_sun_integration.infrastructure.brf.builders.brf_base_builder import BRFBaseBuilder from menu_sun_integration.infrastructure.brf.translators.brf_customer_translator import BRFCustomerTranslator class BRFCustomerBuilder(BRF...
normal
{ "blob_id": "8020bac94de3e68193c9891a628a48c537c5afa0", "index": 9069, "step-1": "<mask token>\n\n\nclass BRFCustomerBuilder(BRFBaseBuilder):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass BRFCustomerBuilder(BRFBaseBuilder):\n\n def define_translator(self) ->None:\n self._...
[ 1, 2, 3, 4 ]
""" Test 1, problem 1. Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder, their colleagues and Nathan Gupta. March 2016. """ # DONE: 1. PUT YOUR NAME IN THE ABOVE LINE. def main(): """ Calls the TEST functions in this module. """ test_problem1a() test_problem1b() t...
normal
{ "blob_id": "ca6a9656efe439c9e90f2724e38e652a09e46dae", "index": 7686, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef is_palindrome(n):\n \"\"\"\n What comes in: An non-negative integer n.\n What goes out: Returns True if the given integer is a palindrome,\n that is, if it reads t...
[ 0, 5, 9, 10, 11 ]
# 파이썬 딕셔너리 # 범용적으로 가장 많이 사용되는 타입 # key와 value의 대용관계 type # 순서 X, key 중복 X, 수정 O, 삭제 O # {} # class란 실세계(오브젝트)의 명사,동사적인 특징들을 추상화시키는 것, 즉 프로그램 내 인스턴트(객체)를 추출하는 템플릿이다 # class는 틀이고 인스턴스는 틀에의해 만들어지는 결과물.하여 instance.class()로 표현 #temp = {} #print(type(temp)) dic01 = {'name' : 'seop', 'age' : 48, ...
normal
{ "blob_id": "d1077107a5cd3a9f489f74b030a698b0521841f3", "index": 7721, "step-1": "<mask token>\n", "step-2": "dic01 = {'name': 'seop', 'age': 48, 'address': 'seoul', 'birth': '730919',\n 'gender': True}\ndic02 = dict([('name', 'seop'), ('age', 48), ('address', 'seoul'), ('birth',\n '730919'), ('gender', ...
[ 0, 1, 2 ]
###########Seq_Profile_Blast_Parser_tool################################ import csv import time import re import os import sys from collections import Counter import operator from fractions import * import glob import ntpath from collections import defaultdict path = open('config.txt').read().splitlines()[0].split('...
normal
{ "blob_id": "7eb8fe491a88bcfadf2a38eaa158b74b21514a1c", "index": 8431, "step-1": "###########Seq_Profile_Blast_Parser_tool################################\nimport csv\nimport time\nimport re\nimport os\nimport sys\nfrom collections import Counter\nimport operator\nfrom fractions import *\nimport glob\nimport ntp...
[ 0 ]
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 ]
import itertools def possibleNumber(digitSet, n): res = [[]] pools = [digitSet] * n # print(pools) for pool in pools: # print(res) res = [ x + [y] for x in res for y in pool] for prod in res: yield prod # def possibleNumber(digitSet, n): # res = [] # temp = itertoo...
normal
{ "blob_id": "fcc6dd61b94d5fa7f088fc75b748d976d1b30fa5", "index": 1781, "step-1": "<mask token>\n\n\ndef possibleNumber(digitSet, n):\n res = [[]]\n pools = [digitSet] * n\n for pool in pools:\n res = [(x + [y]) for x in res for y in pool]\n for prod in res:\n yield prod\n\n\n<mask token...
[ 1, 2, 3, 4, 5 ]
__version__ = '3.13.7'
normal
{ "blob_id": "01852f6dbeb78df3098b14d2f0538ad9193ea511", "index": 9873, "step-1": "<mask token>\n", "step-2": "__version__ = '3.13.7'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
'''Module for generating and plotting networks.''' from trafpy.generator.src import tools import copy import networkx as nx import matplotlib.pyplot as plt import json def gen_arbitrary_network(num_eps, ep_label=None, ep_capacity=12500, ...
normal
{ "blob_id": "4cf2829282cb0a1673e741f78f17ce27a2817ff2", "index": 651, "step-1": "<mask token>\n\n\ndef gen_arbitrary_network(num_eps, ep_label=None, ep_capacity=12500,\n num_channels=1, racks_dict=None, topology_type=None):\n \"\"\"Generates an arbitrary network with num_eps nodes labelled as ep_label.\n\n...
[ 11, 12, 13, 15, 16 ]
import os CSRF_ENABLED = True basedir = os.path.abspath(os.path.dirname(__file__)) # Heroku vs. Local Configs if os.environ.get('HEROKU') is None: # Database path SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db') # CSRF Key SECRET_KEY = os.urandom(24) # Pocket API CONSUM...
normal
{ "blob_id": "0656aba517023c003e837d5ad04daeb364f7fda8", "index": 4688, "step-1": "<mask token>\n", "step-2": "<mask token>\nif os.environ.get('HEROKU') is None:\n SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')\n SECRET_KEY = os.urandom(24)\n CONSUMER_KEY = '23571-333bb5dbab87...
[ 0, 1, 2, 3, 4 ]
from django.views import generic from .models import Project class IndexView(generic.ListView): template_name = "projects/index.html" context_object_name = "projectz" def get_queryset(self): """Return all projects.""" return Project.objects.all() class DetailView(generic.DetailView): ...
normal
{ "blob_id": "23d15c719cd26ea67a032a91a3e73f0d8d3bcfd1", "index": 6662, "step-1": "<mask token>\n\n\nclass DetailView(generic.DetailView):\n model = Project\n template_name = 'projects/detail.html'\n", "step-2": "<mask token>\n\n\nclass IndexView(generic.ListView):\n <mask token>\n <mask token>\n\n ...
[ 2, 4, 5, 6, 7 ]
from abc import ABC, abstractmethod class Shape(ABC): # Shape is a child class of ABC @abstractmethod def area(self): pass @abstractmethod def perimeter(self): pass class Square(Shape): def __init__(self, length): self.length = length square = Square(4) # this will co...
normal
{ "blob_id": "520b9246c3c617b18ca57f31ff51051cc3ff51ca", "index": 5517, "step-1": "<mask token>\n\n\nclass Shape(ABC):\n\n @abstractmethod\n def area(self):\n pass\n <mask token>\n\n\nclass Square(Shape):\n\n def __init__(self, length):\n self.length = length\n\n\n<mask token>\n", "ste...
[ 4, 5, 6, 7, 8 ]
#encoding:utf-8 from flask import Flask import config from flask_rabbitmq import Queue, RabbitMQ app = Flask(__name__) app.config.from_object(config) queue = Queue() mq = RabbitMQ(app, queue) from app import demo
normal
{ "blob_id": "ccf9c389a65d1420e87deec2100e37bccdcb5539", "index": 6323, "step-1": "<mask token>\n", "step-2": "<mask token>\napp.config.from_object(config)\n<mask token>\n", "step-3": "<mask token>\napp = Flask(__name__)\napp.config.from_object(config)\nqueue = Queue()\nmq = RabbitMQ(app, queue)\n<mask token>...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-06-07 12:30 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependenc...
normal
{ "blob_id": "c6c13ab24e4907eecf1db4fded28d4fc8126c834", "index": 1170, "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 ]
left_motor = 1563872856371375 right_motor = 7567382956378165 servo = 9275392915737265 def autonomous_setup(): print("Autonomous mode has started!") Robot.run(autonomous_actions) def autonomous_main(): pass async def autonomous_actions(): print("Autonomous action sequence started") await Actions.s...
normal
{ "blob_id": "a2d23c05e1ca04d25f5f5012881c4000e6316cb9", "index": 2504, "step-1": "left_motor = 1563872856371375\nright_motor = 7567382956378165\nservo = 9275392915737265\n\ndef autonomous_setup():\n print(\"Autonomous mode has started!\")\n Robot.run(autonomous_actions)\n\ndef autonomous_main():\n pass\...
[ 0 ]
import socket import struct def parsing_ethernet_header(data): ethernet_header=struct.unpack("!6c6c2s",data) ether_dest = convert_ethernet_address(ethernet_header[0:6]) ether_src = convert_ethernet_address(ethernet_header[6:12]) ip_header="0x"+ethernet_header[12].hex() print("=========ethernet hea...
normal
{ "blob_id": "9b715fb95e89804a57ea77a98face673b57220c6", "index": 4494, "step-1": "<mask token>\n\n\ndef parsing_ethernet_header(data):\n ethernet_header = struct.unpack('!6c6c2s', data)\n ether_dest = convert_ethernet_address(ethernet_header[0:6])\n ether_src = convert_ethernet_address(ethernet_header[6...
[ 7, 8, 9, 10, 11 ]
"""social_website URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.0/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Clas...
normal
{ "blob_id": "bf1221bc9768cff2edb67e0e5f5cea0ee2dd64e5", "index": 7740, "step-1": "<mask token>\n", "step-2": "<mask token>\nif settings.DEBUG:\n urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT\n )\n", "step-3": "<mask token>\nurlpatterns = [path('admin/', admin.site.urls...
[ 0, 1, 2, 3, 4 ]
from types import MappingProxyType from typing import Any, Dict, Mapping, Type, TypeVar, Union import yaml from typing_extensions import Protocol from mashumaro.serializer.base import DataClassDictMixin DEFAULT_DICT_PARAMS = { "use_bytes": False, "use_enum": False, "use_datetime": False, } EncodedData = ...
normal
{ "blob_id": "15edb1c051ccbc6f927c0a859288511f94a3d853", "index": 986, "step-1": "<mask token>\n\n\nclass Encoder(Protocol):\n <mask token>\n\n\nclass Decoder(Protocol):\n\n def __call__(self, packed: EncodedData, **kwargs) ->Dict[Any, Any]:\n ...\n\n\nclass DataClassYAMLMixin(DataClassDictMixin):\n\...
[ 6, 7, 8, 9, 10 ]
# pick three names names = ["Mia", "Francis", "Eva"] # propmpt user for his/her name print("Please enter your name:") user_name = input() if user_name in names: print("Hi there, {}!".format(user_name)) else: print("Who goes there?")
normal
{ "blob_id": "59c33383365d10c108253f7b5a210d40718913a2", "index": 9653, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Please enter your name:')\n<mask token>\nif user_name in names:\n print('Hi there, {}!'.format(user_name))\nelse:\n print('Who goes there?')\n", "step-3": "names = ['Mia', ...
[ 0, 1, 2, 3 ]
import numpy from scipy.spatial.distance import cosine def similarity_metric(embedding1: numpy.ndarray, embedding2: numpy.ndarray ) ->float: return numpy.nan_to_num(1 - cosine(embedding1, embedding2), 0)
normal
{ "blob_id": "ec9f27b4313f72ae6eb7e8280d47de226aeb6bb1", "index": 2270, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef similarity_metric(embedding1: numpy.ndarray, embedding2: numpy.ndarray\n ) ->float:\n return numpy.nan_to_num(1 - cosine(embedding1, embedding2), 0)\n", "step-3": "import ...
[ 0, 1, 2 ]
from .simulator import SpatialSIRSimulator as Simulator from .util import Prior from .util import PriorExperiment from .util import Truth from .util import log_likelihood
normal
{ "blob_id": "4f06eddfac38574a0ae3bdd0ea2ac81291380166", "index": 9987, "step-1": "<mask token>\n", "step-2": "from .simulator import SpatialSIRSimulator as Simulator\nfrom .util import Prior\nfrom .util import PriorExperiment\nfrom .util import Truth\nfrom .util import log_likelihood\n", "step-3": null, "s...
[ 0, 1 ]
#!/bin/python3 # TODO: implement the stack O(N) version ''' Naive: O(N^3) or sum_{k=1...N}( O(N^2 (N-K)) ) for each size N for each window of size N in the array traverse the window to find the max Naive with heap: O(N^2 log N) for each size N O(N) traverse array and accumulate window of size N O(N...
normal
{ "blob_id": "dce7fd0c9ed8e1d433f9131a8d137c8dcca4ac56", "index": 8307, "step-1": "<mask token>\n\n\ndef riddle(lst):\n \"\"\"\n Holy fuck.\n\n Better summary than above of what's happening:\n\n Define an value `v` in the list to dominate a range of size `n`, including `v`\n itself, if `v` is smaller than ...
[ 2, 3, 4, 5, 6 ]
import numpy as np def get_train_batches(data_dir='/home/yunhan/batchified'): """ return a list or generator of (large) ndarrays, in order to efficiently utilize GPU """ # todo: read in data that is preoprocessed # Use batch 1 - 52 as train (60%), 53 - 71 as validation (20%), 72 - 89 a...
normal
{ "blob_id": "c04c38d78144b6f5d3e5af4ebe9ce430e882a367", "index": 8014, "step-1": "<mask token>\n\n\ndef get_evaluate_batches(data_dir='/home/yunhan/batchified'):\n \"\"\"\n return a list or generator of (large) ndarrays,\n in order to efficiently utilize GPU\n \"\"\"\n n = 18\n idx = np...
[ 2, 4, 5, 6, 7 ]
import datetime import pendulum import requests from prefect import task, Flow, Parameter from prefect.engine.signals import SKIP from prefect.tasks.notifications.slack_task import SlackTask from prefect.tasks.secrets import Secret city = Parameter(name="City", default="San Jose") api_key = Secret("WEATHER_API_KEY") ...
normal
{ "blob_id": "7f52354487f85a0bf1783c8aa76f228ef17e6d6b", "index": 5119, "step-1": "<mask token>\n\n\n@task(max_retries=2, retry_delay=datetime.timedelta(seconds=5))\ndef pull_forecast(city, api_key):\n \"\"\"\n Extract the 5-day 3-hour forecast for the provided City.\n \"\"\"\n base_url = 'http://api....
[ 2, 3, 4, 5, 6 ]
sheik=['a','e','i','o','u','A','E','I','O','U'] s=raw_input() if(s in sheik): print('Vowel') elif(s!=sheik): print('Consonant') else: print('invalid')
normal
{ "blob_id": "0fb8a9b1073446a62b46a802da69b66e78533c2a", "index": 7293, "step-1": "<mask token>\n", "step-2": "<mask token>\nif s in sheik:\n print('Vowel')\nelif s != sheik:\n print('Consonant')\nelse:\n print('invalid')\n", "step-3": "sheik = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\ns = ...
[ 0, 1, 2, 3 ]
''' * @Author: Mohammad Fatha. * @Date: 2021-09-17 19:50 * @Last Modified by: Mohammad Fatha * @Last Modified time: 2021-09-17 19:55 * @Title: Gambler Game ''' import random def gamblerProblem(): """ Description: This function Simulates a gambler who start with stake and place fair 1 bets until ...
normal
{ "blob_id": "68904be892968d4a1d82a59a31b95a8133a30832", "index": 8790, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef gamblerProblem():\n \"\"\"\n Description:\n This function Simulates a gambler who start with stake and place fair 1 bets until\n he/she goes broke (i.e. has no...
[ 0, 1, 2, 3, 4 ]
DEFAULT_SERVER_LISTEN_PORT = 2011 DEFAULT_CLIENT_LISTEN_PORT = 2012 import pickle import socket from player import Player from averageddata import * import zlib import g import pygame from collections import defaultdict from periodic import Periodic import random from projectile import Projectile TICKTIME = 0.05 cla...
normal
{ "blob_id": "b7be9fd366d03068a5d6c3cee703d579b9866fd3", "index": 7992, "step-1": "DEFAULT_SERVER_LISTEN_PORT = 2011\nDEFAULT_CLIENT_LISTEN_PORT = 2012\n\nimport pickle\nimport socket\nfrom player import Player\nfrom averageddata import *\nimport zlib\nimport g\nimport pygame\nfrom collections import defaultdict\...
[ 0 ]
''' 多线程更新UI数据(在两个线程中传递数据) ''' from PyQt5.QtCore import QThread , pyqtSignal, QDateTime from PyQt5.QtWidgets import QApplication, QDialog, QLineEdit import time import sys class BackendThread(QThread): update_date = pyqtSignal(str) def run(self): while True: data = QDateTime.current...
normal
{ "blob_id": "ec625bf57388281b3cbd464459fc3ad1c60b7db9", "index": 3305, "step-1": "<mask token>\n\n\nclass BackendThread(QThread):\n <mask token>\n\n def run(self):\n while True:\n data = QDateTime.currentDateTime()\n currentTime = data.toString('yyyy-MM-dd hh:mm:ss')\n ...
[ 6, 7, 8, 9, 10 ]
#!/usr/bin/env python3 # coding=utf-8 # title :paramiko_sftp.py # description : # author :JackieTsui # organization :pytoday.org # date :1/16/18 9:22 PM # email :jackietsui72@gmail.com # notes : # ================================================== # Import the module n...
normal
{ "blob_id": "64cf6b03fb68be8a23c6e87c8d68d0a42db0eb54", "index": 6451, "step-1": "<mask token>\n", "step-2": "<mask token>\nparamiko.util.log_to_file('syslogin.log')\n<mask token>\nt.connect(username=jumpuser, password=jumppass)\n<mask token>\nsftp.put(localpath, remotepath)\nsftp.close()\n<mask token>\nssh.se...
[ 0, 1, 2, 3, 4 ]
import random import glob import json import time from torch.utils.data import Dataset, DataLoader, SubsetRandomSampler from SimpleDataLoader import CustomDataset, get_params_from_filename import numpy as np from DNN_model import Net import torch.optim as optim import torch.nn as nn import torch from tqdm import tqdm ...
normal
{ "blob_id": "1f63f9234596787e4859b740d3a7fbfaacc9c0c8", "index": 9930, "step-1": "<mask token>\n\n\ndef zero_pad(values, max_m):\n m = len(values)\n values += [0] * (max_m - m)\n\n\ndef solve_with_solver(values_copy, n):\n return xpress_solver(values_copy, n)\n\n\ndef solve_with_net(values_copy, n):\n ...
[ 3, 5, 7, 9, 10 ]
################## #Drawing Generic Rest of Board/ ################## def drawBoard(canvas,data): canvas.create_rectangle(10,10,data.width-10,data.height-10, fill = "dark green") canvas.create_rectangle(187, 160, 200, 550, fill = "white") canvas.create_rectangle(187, 160, 561, 173, fill = "white") can...
normal
{ "blob_id": "628e625be86053988cbaa3ddfe55f0538136e24d", "index": 3599, "step-1": "<mask token>\n", "step-2": "def drawBoard(canvas, data):\n canvas.create_rectangle(10, 10, data.width - 10, data.height - 10, fill\n ='dark green')\n canvas.create_rectangle(187, 160, 200, 550, fill='white')\n can...
[ 0, 1, 2, 3 ]
def dot_product(a, b): ans = 0 for i in range(len(a)): ans += a[i] * b[i] return ans n = int(input()) a = sorted(list(map(int, input().split()))) b = sorted(list(map(int, input().split()))) print(dot_product(a, b))
normal
{ "blob_id": "fc273a286a462cb673edaa2de2ecc6b9ca631004", "index": 9824, "step-1": "<mask token>\n", "step-2": "def dot_product(a, b):\n ans = 0\n for i in range(len(a)):\n ans += a[i] * b[i]\n return ans\n\n\n<mask token>\n", "step-3": "def dot_product(a, b):\n ans = 0\n for i in range(l...
[ 0, 1, 2, 3 ]
from typing import List class Solution: def destCity(self, paths: List[List[str]]) ->str: departCity = set() destCity = [] for i in paths: if i[1] not in departCity: destCity.append(i[1]) if i[0] in destCity: destCity.remove(i[0]) ...
normal
{ "blob_id": "03cc3bf37ea8d971550a89107161005901d842de", "index": 2514, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def destCity(self, paths: List[List[str]]) ->str:\n departCity = set()\n dest...
[ 0, 1, 2, 3 ]
import time inputStr = """crruafyzloguvxwctqmphenbkd srcjafyzlcguvrwctqmphenbkd srijafyzlogbpxwctgmphenbkd zrijafyzloguvxrctqmphendkd srijabyzloguvowcqqmphenbkd srijafyzsoguvxwctbmpienbkd srirtfyzlognvxwctqmphenbkd srijafyzloguvxwctgmphenbmq senjafyzloguvxectqmphenbkd srijafyeloguvxwwtqmphembkd srijafyzlogurxtctqmpken...
normal
{ "blob_id": "9620479e9ac27c1c7833c9a31b9cb18408b8d361", "index": 4019, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor string in inputList:\n hasDoubleDupes = False\n hasTripleDupes = False\n for char in string:\n numRepeatsChar = string.count(char)\n if numRepeatsChar == 2 and ...
[ 0, 1, 2, 3, 4 ]
from setuptools import setup, find_packages setup(name="sk_processor", packages=find_packages())
normal
{ "blob_id": "de884413dcbd0e89e8bfcf5657fe189156d9a661", "index": 1837, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='sk_processor', packages=find_packages())\n", "step-3": "from setuptools import setup, find_packages\nsetup(name='sk_processor', packages=find_packages())\n", "step-4": "fr...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Fetch screen scores with customizable search criteria that can be tailored to match your own requirements in tab format """ import requests from core import config as cfg screen_id = 178 request_url = cfg.BASE_URL + "/screen/" + str(screen_id) # These parameters ca...
normal
{ "blob_id": "80c6dd1c76b3ac56f34e36f571e8db3927994311", "index": 8162, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor row in screen:\n if row_count == 0:\n row_count = row_count + 1\n continue\n row = row.split('\\t')\n data[row[1]] = row\nprint(data['55299'])\nprint(data['5166...
[ 0, 1, 2, 3, 4 ]
from numpy import sqrt def Schout2ConTank(a, b, d): # This function converts parameters from Schoutens notation to Cont-Tankov # notation ## Code th = d * b / sqrt(a ** 2 - b ** 2) k = 1 / (d * sqrt(a ** 2 - b ** 2)) s = sqrt(d / sqrt(a ** 2 - b ** 2)) return th, k, s
normal
{ "blob_id": "4dda122a8c3a2aab62bb202945f6fb9cb73cf772", "index": 8330, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Schout2ConTank(a, b, d):\n th = d * b / sqrt(a ** 2 - b ** 2)\n k = 1 / (d * sqrt(a ** 2 - b ** 2))\n s = sqrt(d / sqrt(a ** 2 - b ** 2))\n return th, k, s\n", "step...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Dec 4 20:28:44 2019 @author: nicholustintzaw """ #################################################################################################### ####################################################################################################...
normal
{ "blob_id": "5a2716fc7b4c0a56fbd0de5d45d71fb33320adf0", "index": 2889, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.chdir(masterdir)\nexec(open('01_newqs_directory.py', 'r', encoding='utf8').read())\nexec(open('02_new_register.py', 'r', encoding='utf8').read())\nexec(open('03_moved_in.py', 'r', enco...
[ 0, 1, 2, 3, 4 ]
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 ]
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt __author__ = 'alexglenday' def group(list_df: list, df_col_index: int=0, seaborn_context: str='poster'): sns.set_context(seaborn_context) df_labels = [] for df in list_df: df_labels.append(df.columns[df_col_index]) df_al...
normal
{ "blob_id": "d2632461fcdc39509610b96d43dd1ec42dae362f", "index": 5229, "step-1": "<mask token>\n\n\ndef individual(list_df: list, seaborn_context: str='poster'):\n sns.set_context(seaborn_context)\n for df in list_df:\n df.plot()\n", "step-2": "<mask token>\n\n\ndef group(list_df: list, df_col_ind...
[ 1, 2, 3, 4 ]
import contextlib import datetime import fnmatch import os import os.path import re import subprocess import sys import click import dataset def get_cmd_output(cmd): """Run a command in shell, and return the Unicode output.""" try: data = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDO...
normal
{ "blob_id": "16446c2c5612a14d4364cbefb949da0b473f7454", "index": 7934, "step-1": "<mask token>\n\n\ndef analyze_commit(row):\n row['conventional'] = row['lax'] = False\n m = re.search(STRICT, row['subj'])\n if m:\n row['conventional'] = True\n else:\n m = re.search(LAX, row['subj'])\n ...
[ 2, 6, 7, 8, 9 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 14 09:54:28 2020 @author: rushirajsinhparmar """ import matplotlib.pyplot as plt from skimage import io import numpy as np from skimage.filters import threshold_otsu import cv2 img = io.imread("texture.png", as_gray=True) #######################...
normal
{ "blob_id": "ab6c3d3c6faa2d1fe5e064dbdebd8904b9434f15", "index": 5214, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.imshow(img_var, cmap='gray')\n<mask token>\nplt.imshow(filtered_image, cmap='gray')\n<mask token>\nplt.imshow(entropy_img)\nplt.hist(entropy_img.flat, bins=100, range=(0, 7))\n<mask t...
[ 0, 1, 2, 3, 4 ]