code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> config.read('dwh.cfg') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> config = configparser.ConfigParser() config.read('dwh.cfg') drop_schema = 'DROP SCHEMA IF EXISTS sparkifydb;' set_sea...
flexible
{ "blob_id": "652918e09a3506869c939be39b71a06467459f8a", "index": 5992, "step-1": "<mask token>\n", "step-2": "<mask token>\nconfig.read('dwh.cfg')\n<mask token>\n", "step-3": "<mask token>\nconfig = configparser.ConfigParser()\nconfig.read('dwh.cfg')\ndrop_schema = 'DROP SCHEMA IF EXISTS sparkifydb;'\nset_se...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ max_len = max(len(a)...
flexible
{ "blob_id": "9655cba5b459ae8b6812bcebc31cc46e19e52386", "index": 2741, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def addBinary(self, a, b):\n \"\"\"\n :type a: str\n :type b: str\n :rtype: str\n ...
[ 0, 1, 2, 3 ]
#!/bin/python3 import sys # import numpy as np def _get_change_making_matrix(set_of_coins, r): matrix = [[0 for _ in range(r + 1)] for _ in range(len(set_of_coins) + 1)] # matrix = np.array(matrix) for i in range(1,len(set_of_coins) + 1): matrix[i][0] = i return matrix def change_making(co...
normal
{ "blob_id": "f15bc62fad2c47fed2e9e5d269284ebe7487b789", "index": 2297, "step-1": "<mask token>\n\n\ndef _get_change_making_matrix(set_of_coins, r):\n matrix = [[(0) for _ in range(r + 1)] for _ in range(len(set_of_coins) + 1)\n ]\n for i in range(1, len(set_of_coins) + 1):\n matrix[i][0] = i\...
[ 2, 3, 4, 5, 6 ]
#Embedded file name: c:/depot/games/branches/release/EVE-TRANQUILITY/eve/client/script/paperDoll/SkinRaytracing.py import trinity import blue import telemetry import ctypes import math import time import geo2 import struct import itertools import weakref import uthread import paperDoll as PD import log import random my...
normal
{ "blob_id": "3c01ca27a5eef877b606b93b04ffe6f73168cd6b", "index": 9090, "step-1": "#Embedded file name: c:/depot/games/branches/release/EVE-TRANQUILITY/eve/client/script/paperDoll/SkinRaytracing.py\nimport trinity\nimport blue\nimport telemetry\nimport ctypes\nimport math\nimport time\nimport geo2\nimport struct\...
[ 0 ]
from django.db import models from datetime import datetime class Message(models.Model): text = models.CharField(max_length=200) votes = models.IntegerField() date_added = models.DateTimeField(default=datetime.now) score = models.BigIntegerField() next_vote = models.IntegerField(default=3600) # 8640...
normal
{ "blob_id": "7159b447ed6fcb2005f63c7b7359970defbc9d43", "index": 1496, "step-1": "<mask token>\n\n\nclass Message(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Message(models.Model):\n <mask t...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> CORS(app) app.config.from_object(Config) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> app = Flask(__name__) CORS(app) app.config.from_object(Config) app.config['SQLALCHEMY_DATABASE_URI'...
flexible
{ "blob_id": "f494d8aeee8c72cce8fc14e44ca896bcf30c100a", "index": 5627, "step-1": "<mask token>\n", "step-2": "<mask token>\nCORS(app)\napp.config.from_object(Config)\n<mask token>\n", "step-3": "<mask token>\napp = Flask(__name__)\nCORS(app)\napp.config.from_object(Config)\napp.config['SQLALCHEMY_DATABASE_UR...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python3 # -*- coding: UTF-8 -*- import RPi.GPIO as gpio # 导入Rpi.GPIO库函数命名为GPIO import time gpio.setmode(gpio.BOARD) #将GPIO编程方式设置为BOARD模式 pin = 40 gpio.setup(pin, gpio.OUT) #控制pin号引脚 gpio.output(pin, gpio.HIGH) #11号引脚输出高电平 time.sleep(5) #计时0.5秒 gpio.output(pin, gpio.LOW) #11号引脚输出低电平 time.sleep(1) #计时1秒 ...
normal
{ "blob_id": "cfdfc490396546b7af732417b506100357cd9a1f", "index": 6762, "step-1": "<mask token>\n", "step-2": "<mask token>\ngpio.setmode(gpio.BOARD)\n<mask token>\ngpio.setup(pin, gpio.OUT)\ngpio.output(pin, gpio.HIGH)\ntime.sleep(5)\ngpio.output(pin, gpio.LOW)\ntime.sleep(1)\ngpio.cleanup()\n", "step-3": "<...
[ 0, 1, 2, 3, 4 ]
import matplotlib.pyplot as plt from partisan_symmetry_noplot import partisan_symmetry for k in range(1,100): a=[] for i in range(1,100): a.append([]) for j in range(1,100): a[i-1].append(partisan_symmetry([5*i/100,.20,5*j/100],1000,False)) plt.imshow(a) plt.colorbar() p...
normal
{ "blob_id": "cfa0937f1c49b52283c562d9ab1cb0542e71b990", "index": 5970, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor k in range(1, 100):\n a = []\n for i in range(1, 100):\n a.append([])\n for j in range(1, 100):\n a[i - 1].append(partisan_symmetry([5 * i / 100, 0.2, 5...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import fileinput #open the file with the matched DNA short reads #create a file with the modified version f1 = open('CompleteDNAsequence.txt', 'r') f2 = open('CompleteDNAsequence.txt.tmp', 'w') for line in f1: f2.write(line.replace('_', '\n')) #replaces _ with tab f1.close() f2.close() #ope...
normal
{ "blob_id": "d02ef5fc27cde353e90dda4090905b89b5be5c49", "index": 2897, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in f1:\n f2.write(line.replace('_', '\\n'))\nf1.close()\nf2.close()\n<mask token>\nopen('ANSWER.txt', 'w').writelines(lines[:+1])\n", "step-3": "<mask token>\nf1 = open('Com...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class HelloApiHandler(Resource): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class HelloApiHandler(Resource): def get(self): return {'resultStatus': 'SUCCESS', 'message': 'Hello Api Handler'}...
flexible
{ "blob_id": "80c3d9165c1b592122fabf6382e265465604989c", "index": 1450, "step-1": "<mask token>\n\n\nclass HelloApiHandler(Resource):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass HelloApiHandler(Resource):\n\n def get(self):\n return {'resultStatus': 'SUCCESS', 'message':...
[ 1, 2, 3, 4, 5 ]
# !/usr/bin/env python3 # -*- coding:utf-8 -*- # @Time : 2021/05/08 20:06 # @Author : Yi # @FileName: show_slices.py import os import pydicom import glob import shutil import random import numpy as np import cv2 import skimage.io as io from data_Parameter import parse_args import matplotlib.pyplot as plt def d...
normal
{ "blob_id": "4905b820f33619a80a9915d0603bc39e0d0368d9", "index": 6175, "step-1": "<mask token>\n\n\ndef dir_create(path):\n \"\"\"创造新的文件夹。\n\n :param path: 文件夹路径\n :return:\n \"\"\"\n if os.path.exists(path) and os.listdir(path) != []:\n shutil.rmtree(path)\n os.makedirs(path)\n i...
[ 7, 8, 9, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(type(list1)) print(list1[0]) print(list1[len(list1) - 1]) <|reserved_special_token_0|> print(list1) <|reserved_special_token_0|> list4 <|reserved_special_token_0|> list4 <|reserved_special_token_0|> list4 <|reserved_special_...
flexible
{ "blob_id": "32b22cccac75c87b8638c76c0c6d27db0de4d750", "index": 8480, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(type(list1))\nprint(list1[0])\nprint(list1[len(list1) - 1])\n<mask token>\nprint(list1)\n<mask token>\nlist4\n<mask token>\nlist4\n<mask token>\nlist4\n<mask token>\nlist4\n<mask to...
[ 0, 1, 2, 3 ]
from .cli import cli if __name__ == "__main__": exit(cli.main(prog_name="htmap"))
normal
{ "blob_id": "069338b188f3cf16357b2502cbb3130b69918bd9", "index": 286, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n exit(cli.main(prog_name='htmap'))\n", "step-3": "from .cli import cli\nif __name__ == '__main__':\n exit(cli.main(prog_name='htmap'))\n", "step-4": "...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Solution: <|reserved_special_token_0|> class Solution: def countArrangement(self, n: int) ->int: @cache def dfs(bm, i): if i == 0: return 1 cnt = 0 for num in range(n): if not bm & 1 << n...
flexible
{ "blob_id": "e6acc7b022001d8419095ad6364a6ae9504ec7aa", "index": 508, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\nclass Solution:\n\n def countArrangement(self, n: int) ->int:\n\n @cache\n def dfs(bm, i):\n if i == 0:\n return 1\n cnt ...
[ 5, 6, 7, 8, 10 ]
#!/usr/bin/env python import os, time, sys fifoname = '/dev/pi-blaster' # must open same name def child( ): pipeout = os.open(fifoname, os.O_WRONLY) # open fifo pipe file as fd zzz = 0 while 1: time.sleep(zzz) os.write(pipeout, 'Spam %03d\n' % zzz) zzz = (z...
normal
{ "blob_id": "7502e28197cb40044303a0a2163546f42375aeb6", "index": 6119, "step-1": "#!/usr/bin/env python\nimport os, time, sys\nfifoname = '/dev/pi-blaster' # must open same name\n\ndef child( ):\n pipeout = os.open(fifoname, os.O_WRONLY) # open fifo pipe file as fd\n zzz = 0\n ...
[ 0 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Module that defines a controller for database's operations over business rules """ # built-in dependencies import functools import typing # external dependencies import sqlalchemy from sqlalchemy.orm import sessionmaker # project dependencies from database.table im...
normal
{ "blob_id": "c024e12fe06e47187c25a9f384ceed566bf94645", "index": 6909, "step-1": "<mask token>\n\n\nclass _DatabaseResourceTableController:\n <mask token>\n <mask token>\n\n def register_peer(self, peer_id: str, peer_ip: str, peer_port: int,\n resource_name: str, resource_path: str, resource_hash...
[ 5, 6, 7, 9, 11 ]
import requests if __name__ == "__main__": # individual datacake webhook url # Change this to the webhook url of your datacake device/product datacake_url = "https://api.datacake.co/integrations/api/ae6dd531-4cf6-4966-b5c9-6c43939aae90/" # Serial number # Include Serial Number in Payload so Datac...
normal
{ "blob_id": "00af9627242648a5a16a34a18bfc117945f1bc08", "index": 4936, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n datacake_url = (\n 'https://api.datacake.co/integrations/api/ae6dd531-4cf6-4966-b5c9-6c43939aae90/'\n )\n serial = 'python0001'\n numbe...
[ 0, 1, 2, 3 ]
########################################################################################## ## Scene Classification ## ## Authors : Chris Andrew, Santhoshini Reddy, Nikath Yasmeen, Sai Hima, Sriya Ragini ## ###############################################...
normal
{ "blob_id": "b8b20d6c977a6c1df6a592188c6e799f12da6a23", "index": 9734, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in f:\n l = line.strip()\n l = l.split(',')\n l = map(float, l)\n data.append(l)\nf.close()\nfor i in range(100):\n shuffle(data)\nfor l in data:\n train_data.a...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python import argparse import keyring import papercut import ConfigParser import getpass import time import os config = ConfigParser.ConfigParser() config.read([os.path.expanduser('~/.papercut')]) try: username = config.get('papercut','username') except ConfigParser.NoSectionError: username = No...
normal
{ "blob_id": "33cc8814d9397bcb0041728407efef80a136f151", "index": 505, "step-1": "#!/usr/bin/env python\nimport argparse\nimport keyring\nimport papercut\nimport ConfigParser\nimport getpass\nimport time\nimport os\n\nconfig = ConfigParser.ConfigParser()\nconfig.read([os.path.expanduser('~/.papercut')])\ntry:\n ...
[ 0 ]
#!/usr/bin/env python import rospy from mark1.srv import WordCount, WordCountResponse s= set('',) def count_words(request): s.update(set( request.words.split() )) print s return WordCountResponse( len( request.words.split())) rospy.init_node('mark_service_server') service = rospy.Service('Word_count', W...
normal
{ "blob_id": "e90e4d2c777554999ab72d725d7e57bdfd508d3a", "index": 3966, "step-1": "#!/usr/bin/env python\nimport rospy\nfrom mark1.srv import WordCount, WordCountResponse\n\ns= set('',)\n\ndef count_words(request):\n s.update(set( request.words.split() ))\n print s\n return WordCountResponse( len( reques...
[ 0 ]
from flask_wtf import FlaskForm from wtforms import StringField, SelectField,SubmitField, PasswordField, RadioField, MultipleFileField, SubmitField, TextAreaField from wtforms.fields.html5 import EmailField, TelField, DateField from wtforms.validators import DataRequired, Email, Length, InputRequired class SignUpForm(...
normal
{ "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 ]
#!/usr/bin/env python3 import json import sqlite3 import sys from scorelib import * #from .scorelib import * from collections import defaultdict def __map2list(mp): if len(mp.keys()) == 0: return [] lst = [None] * max(mp.keys()) for idx in mp.keys(): lst[idx-1] = mp[idx] return lst d...
normal
{ "blob_id": "9f6e5c219f7b668720b5379dde912ff22ef434d1", "index": 9072, "step-1": "<mask token>\n\n\ndef __map2list(mp):\n if len(mp.keys()) == 0:\n return []\n lst = [None] * max(mp.keys())\n for idx in mp.keys():\n lst[idx - 1] = mp[idx]\n return lst\n\n\ndef __translate_keys(translati...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class GetDefaultUsers(APIView): <|reserved_special_token_0|> <|reserved_special_token_0|> class GetSpecificUser(APIView): permission_classes = [permissions.IsAuthenticated] def post(self, request, id=None, *args, **kwargs): try: queryset = users.obje...
flexible
{ "blob_id": "c5a7f269f579bd1960afa4f700b5c3436ac6d91a", "index": 2733, "step-1": "<mask token>\n\n\nclass GetDefaultUsers(APIView):\n <mask token>\n <mask token>\n\n\nclass GetSpecificUser(APIView):\n permission_classes = [permissions.IsAuthenticated]\n\n def post(self, request, id=None, *args, **kwa...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> admin.site.register(username) <|reserved_special_token_1|> from django.contrib import admin from get_my_tweets.models import username admin.site.register(username)
flexible
{ "blob_id": "84ece5d1a9e38b83a5b60052fc3ab089c498d2fc", "index": 9147, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(username)\n", "step-3": "from django.contrib import admin\nfrom get_my_tweets.models import username\nadmin.site.register(username)\n", "step-4": null, "step-5":...
[ 0, 1, 2 ]
#!/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 ]
<|reserved_special_token_0|> class TestCommand(ExternalNotificationsPatchTestCase): <|reserved_special_token_0|> @patch('intake.management.commands.send_followups.is_the_weekend') @patch('intake.management.commands.send_followups.FollowupsService') def test_doesnt_do_anything_on_the_weekend(self, Fol...
flexible
{ "blob_id": "5cb67e5fcedafca4ce124e4094cbd8e1e9d95bb4", "index": 3740, "step-1": "<mask token>\n\n\nclass TestCommand(ExternalNotificationsPatchTestCase):\n <mask token>\n\n @patch('intake.management.commands.send_followups.is_the_weekend')\n @patch('intake.management.commands.send_followups.FollowupsSe...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> T = List[int] C = Callable[[int], None] <|reserved_special_token_1|> from typing import List, Callable T = List[int] C = Callable[[int], None] <|reserved_special_token_1|> from typing import List, Callable #: A list of int ...
flexible
{ "blob_id": "aaee69d339cf1c14e54366633155ee57026e6487", "index": 2071, "step-1": "<mask token>\n", "step-2": "<mask token>\nT = List[int]\nC = Callable[[int], None]\n", "step-3": "from typing import List, Callable\nT = List[int]\nC = Callable[[int], None]\n", "step-4": "from typing import List, Callable\n\...
[ 0, 1, 2, 3 ]
from __future__ import absolute_import import sys from apscheduler.executors.base import BaseExecutor, run_job try: import gevent except ImportError: # pragma: nocover raise ImportError('GeventExecutor requires gevent installed') class GeventExecutor(BaseExecutor): """ Runs jobs as greenlets. ...
normal
{ "blob_id": "afcadc11d23fb921eb6f8038a908de02ee763ca4", "index": 693, "step-1": "<mask token>\n\n\nclass GeventExecutor(BaseExecutor):\n <mask token>\n\n def _do_submit_job(self, job, run_times):\n\n def callback(greenlet):\n try:\n events = greenlet.get()\n exce...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def boundarytester(playerinput): if playerinput[1][0] > 14 or playerinput[1][0] < 0 or playerinput[1][1 ] > 14 or playerinput[1][1] < 0: return False if playerinput[2] == 'h': if playerinput[1][1] + len(list(playerinput[0])) - 1 > 14: return Fal...
flexible
{ "blob_id": "2cb0f2fbf3ceddb2f1ee65614506dbfb3b5c8089", "index": 4736, "step-1": "<mask token>\n\n\ndef boundarytester(playerinput):\n if playerinput[1][0] > 14 or playerinput[1][0] < 0 or playerinput[1][1\n ] > 14 or playerinput[1][1] < 0:\n return False\n if playerinput[2] == 'h':\n ...
[ 6, 7, 8, 9, 10 ]
from sys import stdin read = lambda: stdin.readline().strip() class Trie: def __init__(self, me, parent=None): self.me = me self.parent = parent self.children = {} def get_answer(trie, count): print(("--" * count) + trie.me) trie.children = dict(sorted(trie.children.items(), key...
normal
{ "blob_id": "c5605f4770d61d435cc1817bad4d5cbe0aaf1d18", "index": 8824, "step-1": "<mask token>\n\n\nclass Trie:\n\n def __init__(self, me, parent=None):\n self.me = me\n self.parent = parent\n self.children = {}\n\n\n<mask token>\n\n\ndef main():\n trie_dict = {}\n for i in range(in...
[ 3, 5, 6, 7, 8 ]
from tkinter import * import mathcalc as c root= Tk() root.title("CALCULATOR") ent=Entry(root,width=35) ent.grid(row=0,column=0,columnspan=3,padx=10,pady=10) #ent.grid(row=0,column=0) ch='' num=ent.get() def clicked(num): current=ent.get() ent.delete(0,END) ent.insert(0,str(current)+str(num)) def click...
normal
{ "blob_id": "bdd9ebfa9a2f14d57efd527ca88032bfb0160a5e", "index": 7504, "step-1": "<mask token>\n\n\ndef clicked(num):\n current = ent.get()\n ent.delete(0, END)\n ent.insert(0, str(current) + str(num))\n\n\ndef click_clear():\n ent.delete(0, END)\n\n\ndef add():\n global ch\n ch = '+'\n clic...
[ 7, 8, 9, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> try: fh = open('testfile', 'w') fh.write('test') except IOError: print('Error:没有找到文件') else: print('sucess') fh.close() <|reserved_special_token_1|> try: fh = open("testfile","w") fh.write("test") except IOError: print("Error:没有找...
flexible
{ "blob_id": "15e0b396a4726f98ce5ae2620338d7d48985707e", "index": 9533, "step-1": "<mask token>\n", "step-2": "try:\n fh = open('testfile', 'w')\n fh.write('test')\nexcept IOError:\n print('Error:没有找到文件')\nelse:\n print('sucess')\n fh.close()\n", "step-3": "try:\r\n\tfh = open(\"testfile\",\"w\...
[ 0, 1, 2 ]
name = input("Enter your name: ") print("Hi buddy! Today we will play a game " + name + "!") print("Are you ready?") question = input("Are you ready ? Yes or no: ") print(name + " we are starting!") liste1 = ['My neighbor ', 'My girlfriend ', 'My boyfriend ', 'My dog '] num = input("Enter a number: ") ...
normal
{ "blob_id": "4ef6002480fcaa514f41227978bae76f6e02c22d", "index": 6401, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Hi buddy! Today we will play a game ' + name + '!')\nprint('Are you ready?')\n<mask token>\nprint(name + ' we are starting!')\n<mask token>\nprint(liste1 + liste2 + liste3 + liste4...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import random import gym import numpy as np from collections import deque from keras.models import Sequential from keras.layers import Dense from keras.optimizers import Adam from simulation_utils import box, simulation from kinematics import pose3D a = np.log(2)/25 apdataX = np.random.random(...
normal
{ "blob_id": "7e7e96fb9377e4dc59a46a46951f5057ecae419a", "index": 201, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(np.linalg.norm(mat))\n", "step-3": "<mask token>\na = np.log(2) / 25\napdataX = np.random.random((5, 35))\nquarter_way_arr = [False, False, False]\nquarter_way_arr[0] = True\nquart...
[ 0, 1, 2, 3, 4 ]
from django.urls import path from jobscrapper.views import * urlpatterns = [ path('', home_vacancies_view, name="vacancy-home"), path('list/', vacancies_view, name="vacancy"), ]
normal
{ "blob_id": "3ee20391d56d8c429ab1bd2f6b0e5b261721e401", "index": 7965, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', home_vacancies_view, name='vacancy-home'), path(\n 'list/', vacancies_view, name='vacancy')]\n", "step-3": "from django.urls import path\nfrom jobscrapper.vie...
[ 0, 1, 2, 3 ]
""" k-element subsets of the set [n] 3-element subsets of the set [6] 123 """ result = [] def get_subset(A, k, n): a_list = [i for i in A] if len(a_list) == k: result.append(a_list) return s_num = max(a_list)+1 if a_list else 1 for i in range(s_num, n+1): a_list.append(i) ...
normal
{ "blob_id": "d48353caa07d3bfa003ea9354b411fe0c79591db", "index": 2725, "step-1": "<mask token>\n\n\ndef get_subset(A, k, n):\n a_list = [i for i in A]\n if len(a_list) == k:\n result.append(a_list)\n return\n s_num = max(a_list) + 1 if a_list else 1\n for i in range(s_num, n + 1):\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class NewScrape: def scrape_main(self): """ Top-level function. Use links from below, scrape a page, sleep for 5s, and restart on the next link. """ for i in self.gen_links(): index = str(self.gen_links().index(i)) link ...
flexible
{ "blob_id": "ed3fbae19c88100690dd5c558c0dc6d36a4849c8", "index": 1451, "step-1": "<mask token>\n\n\nclass NewScrape:\n\n def scrape_main(self):\n \"\"\"\n Top-level function.\n Use links from below, scrape a page, sleep for 5s, and restart on the next link.\n \"\"\"\n for i ...
[ 9, 12, 13, 14, 15 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def index(request): baseball = League.objects.filter(name__contains='Baseball') women_league = League.objects.filter(name__contains='women') hockey_league = League.objects.filter(sport__contains='hockey') not_foo...
flexible
{ "blob_id": "49703775da87e8cbbe78a69c91a68128c3fd78e1", "index": 3363, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef index(request):\n baseball = League.objects.filter(name__contains='Baseball')\n women_league = League.objects.filter(name__contains='women')\n hockey_league = League.obje...
[ 0, 1, 2, 3, 4 ]
from app_auth.recaptcha.services.recaptcha_service import validate_recaptcha from django.shortcuts import render, redirect from django.contrib import auth from django.views import View from rest_framework.permissions import IsAuthenticated from rest_framework.views import APIView from rest_framework.response import Res...
normal
{ "blob_id": "b2eb2d006d6285947cc5392e290af50f25a9f566", "index": 4724, "step-1": "<mask token>\n\n\nclass Signup(Auth):\n <mask token>\n <mask token>\n\n\nclass UserViewSet(APIView):\n authentication_classes = [CustomBearerAuthentication]\n permission_classes = [IsAuthenticated]\n\n def get(self, ...
[ 12, 14, 16, 18, 22 ]
#!/usr/bin/python3 # encoding: utf-8 import sys import argparse import logging from pathlib import Path module = sys.modules['__main__'].__file__ __author__ = 'FFX' __version__ = '1.0' log = logging.getLogger(module) def parse_command_line(argv): """Parse command line argument. See -h option :param argv: ...
normal
{ "blob_id": "46adb1834f6013ca0f13a64f280182a805d76278", "index": 215, "step-1": "<mask token>\n\n\ndef parse_command_line(argv):\n \"\"\"Parse command line argument. See -h option\n :param argv: arguments on the command line must include caller file name.\n \"\"\"\n formatter_class = argparse.RawDesc...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class Estoque(object): <|reserved_special_token_0|> def save_categoria(self, categoria): pass <|reserved_special_token_0|> def save_produtos(self, produto): pass <|reserved_special_token_0|> def create_subcategoria(self): """" Cri...
flexible
{ "blob_id": "9f3ca0d5a10a27d926a0f306665889418f8d6a0c", "index": 5884, "step-1": "<mask token>\n\n\nclass Estoque(object):\n <mask token>\n\n def save_categoria(self, categoria):\n pass\n <mask token>\n\n def save_produtos(self, produto):\n pass\n <mask token>\n\n def create_subca...
[ 7, 11, 12, 17, 18 ]
# # linter.py # Linter for SublimeLinter version 4. # # Written by Brian Schott (Hackerpilot) # Copyright © 2014-2019 Economic Modeling Specialists, Intl. # # License: MIT # """This module exports the D-Scanner plugin class.""" from SublimeLinter.lint import Linter, STREAM_STDOUT class Dscanner(Linter): """Pro...
normal
{ "blob_id": "fda73b5dac038f077da460d6ebfb432b756909d9", "index": 3125, "step-1": "<mask token>\n\n\nclass Dscanner(Linter):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Dsca...
[ 1, 2, 3, 4, 5 ]
# Copyright (c) 2011-2020 Eric Froemling # # 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 use, copy, modify, merge, publish,...
normal
{ "blob_id": "7c63abacce07ee9d4c2b3941d05f951b75c8d0ff", "index": 1157, "step-1": "<mask token>\n\n\nclass PlayerRecord:\n <mask token>\n character: str\n <mask token>\n\n @property\n def team(self) ->ba.SessionTeam:\n \"\"\"The ba.SessionTeam the last associated player was last on.\n\n ...
[ 17, 23, 28, 29, 30 ]
''' IplNorm.py Description: Normalizing 0 - 255 initial fingerprint to a normalized image. Using energy normalization. Input: -image Output: -norm_im @author: Edoardo Foco ''' import cv2 import numpy as np def normalise(image): dbl_image = image.astype(float) #...
normal
{ "blob_id": "f51d85ff352d9c84a8ded29ad94b24ca6dda46ad", "index": 7593, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef normalise(image):\n dbl_image = image.astype(float)\n mean = np.mean(dbl_image)\n iplImage = cv2.cv.CreateImageHeader((image.shape[1], image.shape[0]),\n cv2.cv.IP...
[ 0, 1, 2, 3 ]
import sys import psyco sys.stdin = open("/home/shiva/Learning/1.txt", "r") sys.stdout = open("/home/shiva/Learning/2.txt", "w") def compute(plus,minus,total,inp): if plus == 1 and minus == 0: print(total); return elif (plus == 1 and minus == 1): print("Impossible"); return elif (abs(plus-minus) > total): pl...
normal
{ "blob_id": "d29c8ec737b8e962d381c8fdd0999e7e01847836", "index": 5274, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef compute(plus, minus, total, inp):\n if plus == 1 and minus == 0:\n print(total)\n return\n elif plus == 1 and minus == 1:\n print('Impossible')\n ...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def compute_integrated_acquisition(acquisition, x): """ Used to compute the acquisition function when samples of the hyper-parameters have been generated (used in GP_MCMC model). :param acquisition: acquisition function with GpyOpt model type GP_MCMC. :param x: location w...
flexible
{ "blob_id": "4e7cfbf51ec9bad691d8dd9f103f22728cf5e952", "index": 1229, "step-1": "<mask token>\n\n\ndef compute_integrated_acquisition(acquisition, x):\n \"\"\"\n Used to compute the acquisition function when samples of the hyper-parameters have been generated (used in GP_MCMC model).\n\n :param acquisi...
[ 7, 9, 12, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(c) <|reserved_special_token_1|> i = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] f = [10.5, 12.2, 13.7, 14.9, 14.9, 18.8, 19.7, 23.6, 90.9, 25.7] s = ['Arpi', 'world', 'Hello', 'Python', 'Consultadd', 'job', 'c++', 'Concepts', 'in...
flexible
{ "blob_id": "87d1c28819d187944a3cf99b35b1d41eab11b139", "index": 6652, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(c)\n", "step-3": "i = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nf = [10.5, 12.2, 13.7, 14.9, 14.9, 18.8, 19.7, 23.6, 90.9, 25.7]\ns = ['Arpi', 'world', 'Hello', 'Python', 'Consultadd', 'jo...
[ 0, 1, 2, 3 ]
""" Tests based on: https://github.com/pydata/xarray/blob/071da2a900702d65c47d265192bc7e424bb57932/xarray/tests/test_backends_file_manager.py """ import concurrent.futures import gc import pickle from unittest import mock import pytest from rioxarray._io import URIManager def test_uri_manager_mock_write(): mock...
normal
{ "blob_id": "8fe71e87512dfd2ccfcd21c9c175cb50274d9661", "index": 1867, "step-1": "<mask token>\n\n\ndef test_uri_manager_mock_write():\n mock_file = mock.Mock()\n opener = mock.Mock(spec=open, return_value=mock_file)\n manager = URIManager(opener, 'filename')\n f = manager.acquire()\n f.write('con...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> @app.route('/') def home_page(): """Offer user choice of Madlib Games""" return render_template('index.html', stories=stories.values()) <|reserved_special_token_0|> @app.route('/story') def show_story(): """Display Madlib Story""" answers = request.args story_title...
flexible
{ "blob_id": "08ed57ffb7a83973059d62f686f77b1bea136fbd", "index": 3828, "step-1": "<mask token>\n\n\n@app.route('/')\ndef home_page():\n \"\"\"Offer user choice of Madlib Games\"\"\"\n return render_template('index.html', stories=stories.values())\n\n\n<mask token>\n\n\n@app.route('/story')\ndef show_story(...
[ 2, 4, 5, 6, 7 ]
import xlsxwriter workbook = xlsxwriter.Workbook('商品编码.xlsx') worksheet = workbook.add_worksheet() with open('商品编码.txt', 'rt') as f: data = f.read() data = data.splitlines(True) count = 1 row = 0 for x in data: if count < 3: count += 1 continue x = x.split(',') column = 0 for e in x:...
normal
{ "blob_id": "59a8a4cf4b04a191bfb70fd07668141dbfeda790", "index": 6822, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('商品编码.txt', 'rt') as f:\n data = f.read()\n<mask token>\nfor x in data:\n if count < 3:\n count += 1\n continue\n x = x.split(',')\n column = 0\n fo...
[ 0, 1, 2, 3 ]
class IndividualStack: def __init__(self): self.stack=[None]*5 class StackwithStacks: def __init__(self): self.stacks = [] self.stackcount=-1 self.count=0 self.st = None def push(self, element): if self.count%5==0: self.stackcount = self.stackco...
normal
{ "blob_id": "a8f52772522d1efc097c3d17d9c08199816f1168", "index": 3785, "step-1": "class IndividualStack:\n def __init__(self):\n self.stack=[None]*5\n\n\nclass StackwithStacks:\n def __init__(self):\n self.stacks = []\n self.stackcount=-1\n self.count=0\n self.st = None\n...
[ 0 ]
import cv2,os import sqlite3 cam = cv2.VideoCapture(0) detector = cv2.CascadeClassifier('Classifiers/face.xml') i = 0 offset = 50 def create_or_open_db(db_file): db_is_new = not os.path.exists(db_file) conn = sqlite3.connect(db_file) if db_is_new: print 'Creating schema' sql = '''create ta...
normal
{ "blob_id": "3beaea1f2b1b085a60bdc5e53f4e6d9aff7e8b6f", "index": 5538, "step-1": "import cv2,os\nimport sqlite3\ncam = cv2.VideoCapture(0)\ndetector = cv2.CascadeClassifier('Classifiers/face.xml')\ni = 0\noffset = 50\n\n\ndef create_or_open_db(db_file):\n db_is_new = not os.path.exists(db_file)\n conn = sq...
[ 0 ]
def lcs(X, Y, m, n): dp = [[0]*(n+1) for i in range(m+1)] for i in range(1,m+1): for j in range(1,n+1): if X[i-1] == Y[j-1]: dp[i][j] = 1 + dp[i-1][j-1] else: dp[i][j] = max(dp[i-1][j], dp[i][j-1]) index = dp[m][n] s = "" ...
normal
{ "blob_id": "247e352b7772a1da74a26f007228355f5af8d3b3", "index": 191, "step-1": "<mask token>\n", "step-2": "def lcs(X, Y, m, n):\n dp = [([0] * (n + 1)) for i in range(m + 1)]\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if X[i - 1] == Y[j - 1]:\n dp[i][j] =...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def update(a, b): global counter if b == 'x': b = 0 a = week counter = 0 else: counter += b a += counter train_set = get_train_set(a) txtLbl1.configure(text=train_set[0]) txtLbl2.configure(text=train_set[2]) txtLbl3.confi...
flexible
{ "blob_id": "62fe29b0ac4dee8fec4908cf803dba9bd7e92fa5", "index": 4602, "step-1": "<mask token>\n\n\ndef update(a, b):\n global counter\n if b == 'x':\n b = 0\n a = week\n counter = 0\n else:\n counter += b\n a += counter\n train_set = get_train_set(a)\n txtLbl1.c...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(name * 1000) <|reserved_special_token_1|> name = 'valentina ' print(name * 1000)
flexible
{ "blob_id": "aff1a9263e183610f403a4d6a7f27b45eacb7ff2", "index": 0, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(name * 1000)\n", "step-3": "name = 'valentina '\nprint(name * 1000)\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
A = [] ans = 0 def merge(left, mid, right): global A global ans n1 = mid - left n2 = right - mid l = [] r = [] for i in range(n1): l += [A[left + i]] for i in range(n2): r += [A[mid + i]] l += [10**18] r += [10**18] i = 0 j = 0 ans += right - left for k in range(left, right): if l[i] <= r[j]: A[...
normal
{ "blob_id": "dc81ab808720c3a2c76174264c9be9bcdd99c292", "index": 1265, "step-1": "<mask token>\n\n\ndef Msort(left, right):\n if left + 1 < right:\n mid = int((left + right) / 2)\n Msort(left, mid)\n Msort(mid, right)\n merge(left, mid, right)\n\n\ndef main():\n global ans\n ...
[ 2, 3, 4, 5, 6 ]
from cobra.model.fabric import HIfPol from createMo import * DEFAULT_AUTO_NEGOTIATION = 'on' DEFAULT_SPEED = '10G' DEFAULT_LINK_DEBOUNCE_INTERVAL = 100 AUTO_NEGOTIATION_CHOICES = ['on', 'off'] SPEED_CHOICES = ['100M', '1G', '10G', '40G'] def input_key_args(msg='\nPlease Specify Link Level Policy:'): print msg ...
normal
{ "blob_id": "36ab827b889adcd4d54296e7da432d3b39d5a2e6", "index": 2246, "step-1": "from cobra.model.fabric import HIfPol\n\nfrom createMo import *\n\nDEFAULT_AUTO_NEGOTIATION = 'on'\nDEFAULT_SPEED = '10G'\nDEFAULT_LINK_DEBOUNCE_INTERVAL = 100\n\nAUTO_NEGOTIATION_CHOICES = ['on', 'off']\nSPEED_CHOICES = ['100M', '...
[ 0 ]
list = input().split() n = int(list[0]) k = int(list[1]) list.clear() for i in range(0, n): list.append("") tmp = input().split() list[i] = tmp[0] + list[int(tmp[1])-1] for i in range(0, k): start = input() print(len([word for word in list if word.startswith(start)]))
normal
{ "blob_id": "1808be09c2730af5829bb0c7c0c7cfe9f80fe84c", "index": 7546, "step-1": "<mask token>\n", "step-2": "<mask token>\nlist.clear()\nfor i in range(0, n):\n list.append('')\n tmp = input().split()\n list[i] = tmp[0] + list[int(tmp[1]) - 1]\nfor i in range(0, k):\n start = input()\n print(le...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Player(object): def __init__(self, player_num, px, py, sx, sy, start_direction): self.player_num = player_num self.rect = pygame.Rect(px, py, sx, sy) self.direction = start_direction self.moto = Moto(player_num, start_direction) self.moto...
flexible
{ "blob_id": "1d1f1c9b70ca487b48593c85c3e0b5afc10f0b07", "index": 6642, "step-1": "<mask token>\n\n\nclass Player(object):\n\n def __init__(self, player_num, px, py, sx, sy, start_direction):\n self.player_num = player_num\n self.rect = pygame.Rect(px, py, sx, sy)\n self.direction = start_...
[ 13, 15, 19, 22, 24 ]
<|reserved_special_token_0|> def remove_zero_bars(dgm): """ remove zero bars from diagram """ inds = dgm[:, 0] != dgm[:, 1] return dgm[inds, :] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def remove_filler(dgm, val=np.inf): """ remove fille...
flexible
{ "blob_id": "ac459bff6d4281ce07b70dbccde3243412ddb414", "index": 3155, "step-1": "<mask token>\n\n\ndef remove_zero_bars(dgm):\n \"\"\"\n remove zero bars from diagram\n \"\"\"\n inds = dgm[:, 0] != dgm[:, 1]\n return dgm[inds, :]\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef remove_fil...
[ 1, 2, 3, 4, 5 ]
# __author__ = 'Vasudev Gupta' import tf_lightning as tl import tensorflow as tf class TestModel(tl.LightningModule): # just a random model with random dataset def __init__(self): # simple test model super().__init__() self.model = tf.keras.Sequential([ tf.keras.layers.D...
normal
{ "blob_id": "f2397ba3fe1452238f251111f35b06b4a93e0359", "index": 2441, "step-1": "<mask token>\n\n\nclass TestModel(tl.LightningModule):\n <mask token>\n <mask token>\n <mask token>\n\n def training_step(self, batch, batch_idx, optimizer_idx):\n pred = self(batch)\n loss = tf.reduce_mea...
[ 7, 11, 12, 14, 15 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def merge(L1, L2): if L1 == []: return L2 if L2 == []: return L1 x1, R1 = L1[0], L1[1:] x2, R2 = L2[0], L2[1:] if x1 <= x2: return [x1] + merge(R1, L2) else: return [x2] + ...
flexible
{ "blob_id": "056636e2220e529d3f66872a4a48c0984cda1ce4", "index": 6617, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef merge(L1, L2):\n if L1 == []:\n return L2\n if L2 == []:\n return L1\n x1, R1 = L1[0], L1[1:]\n x2, R2 = L2[0], L2[1:]\n if x1 <= x2:\n return ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Player(pygame.sprite.Sprite): def __init__(self, group): super().__init__(group) self.weapon = Weapon(self, 'Green laser gun') self.image = load_image('player.jpg', -1) self.rect = self.image.get_rect() self.coords = self.rect.x, self.rec...
flexible
{ "blob_id": "244191087fcab2a6f03bf024708484b9838731ed", "index": 9301, "step-1": "<mask token>\n\n\nclass Player(pygame.sprite.Sprite):\n\n def __init__(self, group):\n super().__init__(group)\n self.weapon = Weapon(self, 'Green laser gun')\n self.image = load_image('player.jpg', -1)\n ...
[ 7, 13, 16, 22, 30 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print(' whats your name boi ?') <|reserved_special_token_0|> if name == 'arrya': print('u are a boi') elif name == 'jon': print('basterd') elif name == 'ned': print('you are dead man') elif name == 'rob': print('the king in the north') else: ...
flexible
{ "blob_id": "483a5e95a7bfca2cc6b1e7e81740620468fb5623", "index": 9646, "step-1": "<mask token>\n", "step-2": "print(' whats your name boi ?')\n<mask token>\nif name == 'arrya':\n print('u are a boi')\nelif name == 'jon':\n print('basterd')\nelif name == 'ned':\n print('you are dead man')\nelif name ==...
[ 0, 1, 2, 3 ]
#!/usr/bin/python # -*- coding: UTF-8 -*- from connect import Connect class Resource: def __init__(self, row: tuple): self.video_path = row[0] self.pic_path = row[1]
normal
{ "blob_id": "65aa27addaec6014fe5fd66df2c0d3632231a314", "index": 3124, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Resource:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Resource:\n\n def __init__(self, row: tuple):\n self.video_path = row[0]\n self.pic_path = ...
[ 0, 1, 2, 3, 4 ]
import cv2 import numpy as np from matplotlib import pyplot as plt #cargar la imagen a analizar imagen= cv2.imread("tomate22.jpg") #cv2.imshow("Original", imagen) #cv2.waitKey(0) # Convertimos en escala de grise gris = cv2.cvtColor(imagen, cv2.COLOR_BGR2GRAY) #cv2.imshow("En gris", gris) #cv2.waitKey(0) # Aplicar s...
normal
{ "blob_id": "9f42a9d0ca622d6c4e2cf20bc2e494262c16055b", "index": 7744, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.subplot(121), plt.imshow(canny, cmap='gray')\nplt.title('Canny'), plt.xticks([]), plt.yticks([])\n<mask token>\ncv2.drawContours(imagen, contornos, -1, (255, 0, 0), 2)\ncv2.imshow('co...
[ 0, 1, 2, 3, 4 ]
# list audio files import glob def listFiles(path): return glob.glob(path + '*.wav') import random def getNextFile(files): return random.choice(files) import pyaudio import wave CHUNK = 1024 def getRandomFile(folder = 'test/'): files = listFiles(folder) filename = getNextFile(files) return filename def pl...
normal
{ "blob_id": "a3bcd383656284a2236e79b5d5d7acdfe433a13b", "index": 8409, "step-1": "<mask token>\n\n\ndef getNextFile(files):\n return random.choice(files)\n\n\n<mask token>\n\n\ndef getRandomFile(folder='test/'):\n files = listFiles(folder)\n filename = getNextFile(files)\n return filename\n\n\ndef pl...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class Timer(object): <|reserved_special_token_0|> def reset(self): self.time_ = 0.0 self.start_ = 0.0 def start(self): self.start_ = time.clock() def end(self): self.time_ += time.clock() - self.start_ <|reserved_special_token_0|> <|r...
flexible
{ "blob_id": "0cf5b009f384d2ca7162b5a88699afb3702ae1f6", "index": 1147, "step-1": "<mask token>\n\n\nclass Timer(object):\n <mask token>\n\n def reset(self):\n self.time_ = 0.0\n self.start_ = 0.0\n\n def start(self):\n self.start_ = time.clock()\n\n def end(self):\n self.t...
[ 4, 5, 6, 7, 8 ]
from elements import Node, Bar, Material, Group, Load from pprint import pprint # query # next((e for e in result['coordinates']['nodes'] if e.n == int(el[0])), None) class Reader(): def read(self, filePath): """ Reads text file with nodes and returns the result dict with all objects and their nested p...
normal
{ "blob_id": "c796123fbbf3adcde59779a104dcafb30a673a79", "index": 6422, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Reader:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Reader:\n\n def read(self, filePath):\n \"\"\"\n Reads text file with nodes and returns the resul...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print(auto.head()) sns.pairplot(auto, kind='reg', hue='origin') plt.show() <|reserved_special_token_1|> # EXERCISE: # Plotting distributions pairwise (2) # In this exercise, you will generate pairwise joint distributions again. This time, you will make t...
flexible
{ "blob_id": "0eaaa81d3c8bc61368701e1916b42ede88b90d04", "index": 412, "step-1": "<mask token>\n", "step-2": "print(auto.head())\nsns.pairplot(auto, kind='reg', hue='origin')\nplt.show()\n", "step-3": "# EXERCISE:\n\n# Plotting distributions pairwise (2)\n\n# In this exercise, you will generate pairwise joint...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models import django.core.validators class Migration(migrations.Migration): dependencies = [ ('Registration', '0015_auto_20150525_1815'), ] operations = [ migrations.AlterField( ...
normal
{ "blob_id": "7a1be5c9c48413ba1969631e99ecb45cf15ef613", "index": 559, "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 = [('Registration...
[ 0, 1, 2, 3, 4 ]
# coding: utf8 from __future__ import unicode_literals from nltk.tag import stanford from .SequenceTagger import SequenceTagger class POSTagger(SequenceTagger): """ >>> tagger = POSTagger(model='resources/postagger.model') >>> tagger.tag(['من', 'به', 'مدرسه', 'رفته_بودم', '.']) [('من', 'PRO'), ('به', 'P'), ('مدر...
normal
{ "blob_id": "1ac3630e6433a2d11c716b558640cab7c559f6ba", "index": 4483, "step-1": "<mask token>\n\n\nclass StanfordPOSTagger(stanford.StanfordPOSTagger):\n <mask token>\n\n def __init__(self, model_filename, path_to_jar, *args, **kwargs):\n self._SEPARATOR = '/'\n super(stanford.StanfordPOSTag...
[ 3, 5, 7, 8, 9 ]
/Users/apple/anaconda/lib/python3.5/operator.py
normal
{ "blob_id": "b4a267873c5823ecfa62a5e90b67c37f9cca3cd2", "index": 8181, "step-1": "/Users/apple/anaconda/lib/python3.5/operator.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while n > 0: r = n % 10 sum = sum + r n = n // 10 print('The total sum of digits is:', sum) <|reserved_special_token_1|> n = int(input('Enter a number:\n')) sum = 0 while n > 0: r = n % 10 sum = sum + r ...
flexible
{ "blob_id": "78e3750a1bbe9f2f6680937729c1a810bd29fd4d", "index": 4232, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile n > 0:\n r = n % 10\n sum = sum + r\n n = n // 10\nprint('The total sum of digits is:', sum)\n", "step-3": "n = int(input('Enter a number:\\n'))\nsum = 0\nwhile n > 0:\n ...
[ 0, 1, 2, 3 ]
from django.urls import path from . import views urlpatterns = [ path('', views.home, name ='park-home'), path('login/', views.login, name ='park-login'), ]
normal
{ "blob_id": "2fd490ca54f5d038997cec59a3e07c3f2c2d2538", "index": 6757, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.home, name='park-home'), path('login/', views\n .login, name='park-login')]\n", "step-3": "from django.urls import path\nfrom . import views\nurlpattern...
[ 0, 1, 2, 3 ]
def swap(a,b): print(a,b) a=input("enter a value 1 : ") b=input("enter b value 2 : ") a,b=b,a print("the vaalues after swaping the variables are below:") print("the value of a is : ",a) print("the value of b is : ",b)
normal
{ "blob_id": "4fbe4d474e10e08eafee3bcc6173f8cd6b797dde", "index": 3203, "step-1": "<mask token>\n", "step-2": "def swap(a, b):\n print(a, b)\n\n\n<mask token>\n", "step-3": "def swap(a, b):\n print(a, b)\n\n\n<mask token>\nprint('the vaalues after swaping the variables are below:')\nprint('the value of ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class AmplitudeLogger: <|reserved_special_token_0|> async def log_event(self, event): event = {'api_key': self.api_key, 'events': [event]} try: validate(instance=event, schema=self.api_schema) except ValidationError: log.error('Inva...
flexible
{ "blob_id": "d32f009f373249b7b602ac36f29982273a2ed192", "index": 2289, "step-1": "<mask token>\n\n\nclass AmplitudeLogger:\n <mask token>\n\n async def log_event(self, event):\n event = {'api_key': self.api_key, 'events': [event]}\n try:\n validate(instance=event, schema=self.api_s...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def zero_pad(values, max_m): m = len(values) values += [0] * (max_m - m) def solve_with_solver(values_copy, n): return xpress_solver(values_copy, n) def solve_with_net(values_copy, n): start = time.time() sum_vals = sum(values_copy) new_values = [(val / sum_val...
flexible
{ "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 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open(tree_csv, 'rU') as csvinput: with open('../harbordvillage/outfile.csv', 'w+') as csvoutput: writer = csv.writer(csvoutput, quoting=csv.QUOTE_NONNUMERIC) reader = csv.reader(csvinput) all = [] ...
flexible
{ "blob_id": "40b9114e4348bab5d76d68a937b3abe95a90c230", "index": 4130, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(tree_csv, 'rU') as csvinput:\n with open('../harbordvillage/outfile.csv', 'w+') as csvoutput:\n writer = csv.writer(csvoutput, quoting=csv.QUOTE_NONNUMERIC)\n r...
[ 0, 1, 2, 3, 4 ]
# Copyright The Cloud Custodian Authors. # SPDX-License-Identifier: Apache-2.0 from c7n_azure.provider import resources from c7n_azure.resources.arm import ArmResourceManager from c7n.utils import type_schema from c7n.filters.core import ValueFilter @resources.register('mysql-flexibleserver') class MySQLFlexibleServ...
normal
{ "blob_id": "b9bc6a9dbb3dbe51fbae45078bd499fb97fa003f", "index": 3950, "step-1": "<mask token>\n\n\n@MySQLFlexibleServer.filter_registry.register('server-parameter')\nclass ServerParametersFilter(ValueFilter):\n <mask token>\n schema = type_schema('server-parameter', required=['type', 'name'],\n rin...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(data) <|reserved_special_token_0|> print(mx, my) <|reserved_special_token_0|> for i in range(len(x)): num += (x[i] - mx) * (y[i] - my) den += (x[i] - mx) ** 2 <|reserved_special_token_0|> print(beta1, beta0) <|reserv...
flexible
{ "blob_id": "ca6b064dbd8200c49665eaa944fdf1fc80c25726", "index": 1047, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(data)\n<mask token>\nprint(mx, my)\n<mask token>\nfor i in range(len(x)):\n num += (x[i] - mx) * (y[i] - my)\n den += (x[i] - mx) ** 2\n<mask token>\nprint(beta1, beta0)\n<mas...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python from setuptools import setup import NagAconda setup(name=NagAconda.__name__, version=NagAconda.__version__, description="NagAconda is a Python Nagios wrapper.", long_description=open('README').read(), author='Steven Schlegel', author_email='steven@schlegel.tech', ...
normal
{ "blob_id": "c3719f30bcf13061134b34b0925dfa2af4535f14", "index": 7854, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name=NagAconda.__name__, version=NagAconda.__version__, description=\n 'NagAconda is a Python Nagios wrapper.', long_description=open('README'\n ).read(), author='Steven Schle...
[ 0, 1, 2, 3 ]
# 0=RED, 1=GREEN, 2=BLUE, 3=ALPHA #import tkinter as tk #import tkinter.ttk as ttk #from tkcolorpicker import askcolor import time c1 = [0,0,0,0] #this color c2 = [0,0,0] #over this color c3 = [0,0,0] #result cont='y' #-------------------------------- while cont=='y': print('--enter underlay co...
normal
{ "blob_id": "5fa8ae36c4b4a5bffa64f4c65b74b74b29ba246f", "index": 4578, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile cont == 'y':\n print('--enter underlay color in r,g,b--')\n c2[0] = int(input('red: '))\n c2[1] = int(input('green: '))\n c2[2] = int(input('blue: '))\n print('')\n ...
[ 0, 1, 2, 3, 4 ]
# coding: utf-8 from pyquery import PyQuery as pq html = ''' <div id="container"> <ul class="list"> <li class="item-0">first item</li> <li class="item-1"><a href="link2.html">second item</a></li> <li class="item-0 active"><a href="link3.html">third item</a></li> ...
normal
{ "blob_id": "02ab822dacb26d623a474fa45ebb034f9c1291b8", "index": 1604, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a, type(a))\nprint(a.attr('href'))\nprint(a.attr.href)\n", "step-3": "<mask token>\nhtml = \"\"\"\n <div id=\"container\">\n <ul class=\"list\">\n <li class=\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @app.route('/') def index(): result_plot = compute_model_output() return render_template('index.html', graphJSON=result_plot) def compute_model_output(): num_steps = 500 init_inf = 5 t_inc = 5 t_inf = 9 r_t = 2.5 rho = 1.0 kappa_0 = 0.0 kappa = 0....
flexible
{ "blob_id": "7d099012584b84e9767bf0ce9d9df1596ca3bbab", "index": 542, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n result_plot = compute_model_output()\n return render_template('index.html', graphJSON=result_plot)\n\n\ndef compute_model_output():\n num_steps = 500\n init_inf = 5\n ...
[ 2, 3, 4, 5, 6 ]
import datetime import operator import geopy from django.db import models from django.db.models import Q from django.db.models.query import QuerySet from django.db.models import permalink from django.contrib.auth.models import User geocoder = geopy.geocoders.Google() class City(models.Model): name = models.C...
normal
{ "blob_id": "89ba805e47a9727573e1e25371a70fb887ee170d", "index": 9141, "step-1": "<mask token>\n\n\nclass Area(models.Model):\n <mask token>\n <mask token>\n\n\n class Meta:\n unique_together = 'name', 'city'\n ordering = 'name',\n <mask token>\n\n\nclass ApartmentQuerySet(QuerySet):\n\...
[ 15, 19, 20, 21, 23 ]
#!/usr/bin/python # Copyright (c) 2020 Maryushi3 import emoji_data_python as edp import sys import pyautogui from Xlib import display from PyQt5.QtWidgets import QApplication, QGridLayout, QLabel, QLineEdit, QScrollArea, QSizePolicy, QStackedLayout, QVBoxLayout, QWidget from PyQt5.QtCore import QEvent, QSettings, Qt, ...
normal
{ "blob_id": "c860c1fa6e7610c60077f0eab1572895a23393fd", "index": 3725, "step-1": "<mask token>\n\n\ndef fill_grid_with_char_list(charList):\n global emojiToShowCount\n global fullRowsCount\n global lastRowEmojiCount\n emojiToShowCount = min(len(charList), emojiGridColumnCount *\n emojiGridRowC...
[ 17, 19, 21, 24, 29 ]
# Create your models here. from django.db import models from django.utils import timezone from django.db import models # Create your models here. #필드 개수가 다르다. class Post(models.Model): #이 Post의 저자이다라는 의미, CASCADE : 종속이라는 의미 author = models.ForeignKey('auth.User', on_delete=models.CASCADE) title = models.C...
normal
{ "blob_id": "fe5398b03d2f0cfc7c972677faa0ea3ec701469e", "index": 7858, "step-1": "<mask token>\n\n\nclass Post(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def publish(self):\n self.published_date = timezone.now()\n self.save()\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def DFS(idx, cost, cur_loc): global min_cost if min_cost < cost: return if idx == N and arr[cur_loc][0]: if min_cost > cost + arr[cur_loc][0]: min_cost = cost + arr[cur_loc][0] return for i in range(1, N): ...
flexible
{ "blob_id": "4ff7e83c6e85a041578a8b3471cbbb7e0c2543e6", "index": 2663, "step-1": "<mask token>\n", "step-2": "def DFS(idx, cost, cur_loc):\n global min_cost\n if min_cost < cost:\n return\n if idx == N and arr[cur_loc][0]:\n if min_cost > cost + arr[cur_loc][0]:\n min_cost = c...
[ 0, 1, 2, 3, 4 ]
import os import json import librosa # Constants # Dataset used for training DATASET_PATH = "dataset" # Where the data is stored JSON_PATH = "data.json" # Number of samples considered to preprocess data SAMPLES_TO_CONSIDER = 22050 # 1 sec worth of sound # Main function to preprocess the data def prepare_dataset(dat...
normal
{ "blob_id": "ba808d23f6a8226f40e1c214012a1535ee1e9e98", "index": 2947, "step-1": "<mask token>\n\n\ndef prepare_dataset(dataset_path, json_path, n_mfcc=13, hop_length=512,\n n_fft=2048):\n data = {'mappings': [], 'labels': [], 'MFCCs': [], 'files': []}\n for i, (dir_path, dir_names, filenames) in enumer...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class _PULPIER: <|reserved_special_token_0|> <|reserved_special_token_1|> class _PULPIER: def __init__(self): self.name = 'PULPIER' self.definitions = pulpy self.parents = [] self.childen = [] self.propertie...
flexible
{ "blob_id": "a1d1056f302cf7bc050537dd8cc53cdb2da7e989", "index": 5507, "step-1": "<mask token>\n", "step-2": "class _PULPIER:\n <mask token>\n", "step-3": "class _PULPIER:\n\n def __init__(self):\n self.name = 'PULPIER'\n self.definitions = pulpy\n self.parents = []\n self.c...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python """ This code is fot testing the region growing. """ import os import sys import time import nibabel as nib import region_growing as rg import matplotlib.pyplot as plt import numpy as np img = nib.load("zstat1.nii.gz") data = img.get_data() #test coor [36,60,28] [21,39,30] [23,38,30] coor = [23,...
normal
{ "blob_id": "6bcddd1b2ec8653400f710e5cab552d4bec75b6b", "index": 1162, "step-1": "#!/usr/bin/env python\n\"\"\"\nThis code is fot testing the region growing.\n\"\"\"\nimport os\nimport sys\nimport time\nimport nibabel as nib\nimport region_growing as rg\nimport matplotlib.pyplot as plt \nimport numpy as np\n\nim...
[ 0 ]
#https://docs.python.org/3.4/library/itertools.html#module-itertools l = [(1, 2, 9), (1, 3, 12), (2, 3, 8), (2, 4, 4), (2, 5, 7), (3, 5, 5), (3, 6, 2), (4, 5, 2), (4, 7, 10), (5, 6, 11), (5, 7, 2), (6, 8, 4), (7, 8, 4), (7, 9, 3), (8, 9, 13)] b = ['America', 'Sudan', 'Srilanka', 'Pakistan', 'Nepal', 'India'...
normal
{ "blob_id": "629353392e3a4f346f734543ae3f2b8dc616a6c3", "index": 5816, "step-1": "<mask token>\n\n\ndef itertools_groupby_example(list_of_nodes):\n graph = defaultdict(list)\n for key, group in groupby(l, lambda x: x[0]):\n graph[key].append(list(group))\n print(dict(graph))\n\n\ndef itertools_fa...
[ 7, 10, 11, 12, 14 ]
#!/bin/python from flask import Flask, jsonify, request import subprocess import os app = Flask(__name__) text = "" greetings = "'/play' and '/replay'\n" @app.route('/') def index(): return greetings @app.route('/play', methods=['POST']) def play(): global text text = request.data.decode('utf-8') o...
normal
{ "blob_id": "956e63bf06255df4a36b5fa97aa62c0ed805c3f3", "index": 9452, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return greetings\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef index():\n return greetings\n\n\n@app.route('/play', methods=['POST'])\ndef play():\...
[ 1, 4, 5, 6, 7 ]
import random import tqdm from keras.models import load_model from ModelUtil import precision, recall, f1 from tqdm import tqdm import cv2 as cv import numpy as np import os import pandas as pd from PIL import Image os.environ['CUDA_VISIBLE_DEVICES']='1' model_path = '/home/bo/Project/densenet.hdf5' train_img_path...
normal
{ "blob_id": "c2b3594d25e2d1670d9b99e0d3484c680f59421f", "index": 9465, "step-1": "<mask token>\n\n\ndef preprocess_image(image_path, desired_size=SIZE):\n \"\"\"\n Resize the picture to the desired size\n :param image_path: the path of image folder\n :param desired_size: the size that image will be c...
[ 9, 10, 12, 13, 14 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): graphics = BreakoutGraphics() lives = NUM_LIVES graphics.window.add(graphics.scoreboard, 0, graphics.window_height) while True: pause(FRAME_RATE) if graphics.ball_fall_down(): ...
flexible
{ "blob_id": "b218f5e401510f844006cb6079737b54aa86827b", "index": 2194, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n graphics = BreakoutGraphics()\n lives = NUM_LIVES\n graphics.window.add(graphics.scoreboard, 0, graphics.window_height)\n while True:\n pause(FRAME_RA...
[ 0, 2, 3, 4, 5 ]
from django import template from apps.account.models import User, Follow, RequestFollow from apps.post.models import Post register = template.Library() @register.inclusion_tag('user/user_list.html') def user_list(): """show user name list""" users = User.objects.all() return {"users": users} # @regist...
normal
{ "blob_id": "999c19fd760ffc482a15f5a14e188d416fcc5f21", "index": 7218, "step-1": "<mask token>\n\n\n@register.inclusion_tag('user/user_list.html')\ndef user_list():\n \"\"\"show user name list\"\"\"\n users = User.objects.all()\n return {'users': users}\n\n\n@register.simple_tag()\ndef accept_request(pk...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class TestTaniHub: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestTaniHub: <|reserved_special_token_0|> <|reserved_special_to...
flexible
{ "blob_id": "777dc2056443f0404ccb75d570f2ddc3a3aa747b", "index": 6669, "step-1": "<mask token>\n\n\nclass TestTaniHub:\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass TestTaniHub:\n <mask token>\n <mask token>\n\n def test_tanihub_number_2...
[ 1, 2, 4, 6, 8 ]
from django.db.models import Q from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponseRedirect from django.shortcuts import render, redirect from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView from carga_horaria.models import Profesor, Asignat...
normal
{ "blob_id": "d0d86d8b5b276218add6dd11a44d5c3951cc4e14", "index": 3846, "step-1": "<mask token>\n\n\nclass AsistenteDetailView(LoginRequiredMixin, DetailView):\n \"\"\"\n Detalle de Asistente\n \"\"\"\n model = Asistente\n template_name = 'carga_horaria/asistente/detalle_asistente.html'\n\n\ncl...
[ 52, 53, 56, 73, 85 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> router.register('users', views.CategoryView) <|reserved_special_token_0|> if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT ) <|reserved_special_token_1|> <|reserved_spec...
flexible
{ "blob_id": "4a8fa195a573f8001e55b099a8882fe71bcca233", "index": 8335, "step-1": "<mask token>\n", "step-2": "<mask token>\nrouter.register('users', views.CategoryView)\n<mask token>\nif settings.DEBUG:\n urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT\n )\n", "step-3": ...
[ 0, 1, 2, 3, 4 ]