code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
import os import numpy as np from keras.models import Sequential, Model from keras.layers import Dense, Dropout, Flatten, concatenate from keras.layers import Conv2D, MaxPooling2D, GlobalAveragePooling2D, Activation from keras.layers.normalization import BatchNormalization from keras.optimizers import SGD from keras....
normal
{ "blob_id": "ebc050544da69837cc2b8977f347380b94474bab", "index": 576, "step-1": "<mask token>\n\n\ndef _build(_input, *nodes):\n x = _input\n for node in nodes:\n if callable(node):\n x = node(x)\n elif isinstance(node, list):\n x = [_build(x, branch) for branch in node]...
[ 1, 2, 3, 4, 5 ]
# -*- encoding: utf-8 -*- import requests import time import random STATS = True INFINITE = True VOTING_ENDPOINT = 'http://www.adressa.no/poll/vote.do' # These are the required fields from the voting form payload = { "vote": "svar4", "mentometerId": "10790638", "publicationId": "167", "redirectTo": "...
normal
{ "blob_id": "1e344330b88b336598295e2a7be6a6dc57cb3d59", "index": 8207, "step-1": "# -*- encoding: utf-8 -*-\n\nimport requests\nimport time\nimport random\n\nSTATS = True\nINFINITE = True\nVOTING_ENDPOINT = 'http://www.adressa.no/poll/vote.do'\n\n# These are the required fields from the voting form\npayload = {\...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> forbidden = ['Key.esc', 'Key.cmd', 'Key.cmd_r', 'Key.menu', 'Key.pause', 'Key.scroll_lock', 'Key.print_screen', 'Key.enter', 'Key.space', 'Key.backspace', 'Key.ctrl_l', 'Key.ctrl_r', 'Key.alt_l', 'Key.alt_gr', 'Key.caps_lock', 'Key.num_lock', 'Key...
flexible
{ "blob_id": "995dc34ea32de4566e2804b6797d9b551b733ff3", "index": 3406, "step-1": "<mask token>\n", "step-2": "forbidden = ['Key.esc', 'Key.cmd', 'Key.cmd_r', 'Key.menu', 'Key.pause',\n 'Key.scroll_lock', 'Key.print_screen', 'Key.enter', 'Key.space',\n 'Key.backspace', 'Key.ctrl_l', 'Key.ctrl_r', 'Key.alt...
[ 0, 1 ]
import os os.environ.setdefault('DJANGO_SETTINGS_MODULE','mkrandom.settings') import django django.setup() from main.models import Character, Vehicle, Tire, Glider char_names = [ 'Mario', 'Luigi', 'Peach', 'Daisy', 'Rosalina', 'Mario Tanooki', 'Peach cat', 'Yoshi', 'Yoshi (LBlue)', ...
normal
{ "blob_id": "dbda5df7dff3f8acc320ffe7b9c7c279ebed2cc2", "index": 7108, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mkrandom.settings')\n<mask token>\ndjango.setup()\n<mask token>\nfor char in char_names:\n index = x - y + 1\n name = char_names[x]\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def watch(): print('시청하다') <|reserved_special_token_0|> <|reserved_special_token_1|> def watch(): print('시청하다') watch() print('tv.py의 module 이름은', __name__) <|reserved_special_token_1|> def watch(): print("시청하다") watch() print("tv.py의 m...
flexible
{ "blob_id": "b9622bede471c76ae36d3f59130d2be113310d4c", "index": 7045, "step-1": "<mask token>\n", "step-2": "def watch():\n print('시청하다')\n\n\n<mask token>\n", "step-3": "def watch():\n print('시청하다')\n\n\nwatch()\nprint('tv.py의 module 이름은', __name__)\n", "step-4": "def watch():\n print(\"시청하다\")\...
[ 0, 1, 2, 3 ]
#!/usr/bin/python import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D import numpy as np occl_frac = 0.445188 result = [1-occl_frac, occl_frac, 0] #Reading res_data.txt mnfa = [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9] #min NN factor array nna = [2,3,4,5,6,7,8,9,10,11,12,1...
normal
{ "blob_id": "1c8b843174521f1056e2bac472c87d0b5ec9603e", "index": 3370, "step-1": "#!/usr/bin/python\nimport matplotlib.pyplot as plt\nfrom matplotlib import cm\nfrom mpl_toolkits.mplot3d import Axes3D\nimport numpy as np\n\noccl_frac = 0.445188\nresult = [1-occl_frac, occl_frac, 0]\n\n#Reading res_data.txt\nmnfa...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> parser.add_argument('-u', '--user') parser.add_argument('-c', '--color') <|reserved_special_token_0|> print(combined['color']) print(combined['user']) <|reserved_special_token_1|> <|reserved_special_token_0|> defaults = {'color...
flexible
{ "blob_id": "3c31e3f2a6f320bc5ae33f0ba1d234a089371899", "index": 9199, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('-u', '--user')\nparser.add_argument('-c', '--color')\n<mask token>\nprint(combined['color'])\nprint(combined['user'])\n", "step-3": "<mask token>\ndefaults = {'colo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Solution: def sortElemsByFrequency(self, arr): if arr: x = [] res = [] mydict = {} for k, v in enumerate(arr): mydict[v] = mydict.get(v, 0) + 1 for k, v in mydict.items(): heapq....
flexible
{ "blob_id": "dcb12e282962c63f8e7de5d29c4c81ad177a387e", "index": 7775, "step-1": "<mask token>\n\n\nclass Solution:\n\n def sortElemsByFrequency(self, arr):\n if arr:\n x = []\n res = []\n mydict = {}\n for k, v in enumerate(arr):\n mydict[v] =...
[ 2, 3, 4, 5, 6 ]
#from tinyTensor.Node import Node import tinyTensor import plotly.plotly as py from graphviz import render #from tinyTensor.Operation import Operation def init(): global _default_graph _default_graph = None def postOrder(node): nodes_postorder = [] def recurse(node): if isinstan...
normal
{ "blob_id": "7bd2a29bff1e435cf813dd54109d7f4e17612425", "index": 474, "step-1": "<mask token>\n\n\nclass Graph:\n <mask token>\n\n def appendNode(self, node):\n if node.name in self.placeholderNames and node.isPlaceholder:\n raise Exception(\n 'Placeholder name \"{}\" is al...
[ 5, 7, 8, 9, 10 ]
from ttkwidgets import CheckboxTreeview from tkinter import * from tkinter.ttk import * from tkinter import messagebox import json import os from DbDataloader import * class DataLoader(): def __init__(self,master): self.anne={} self.master=Toplevel(master) master.wait_visibility(self.master)...
normal
{ "blob_id": "a70dae504a4dfa3997a11e4c605accfab0024318", "index": 8796, "step-1": "<mask token>\n\n\nclass DataLoader:\n <mask token>\n\n def main(self):\n choice = messagebox.askyesno('askquestion',\n 'Cliquer sur Oui pour charger les données en mode Trasactionnel')\n if choice:\n ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def multi_set_symmetric_difference(sets): return list(functools.reduce(lambda a, b: a ^ b, [set(s) for s in sets])) def flood_iteration_plaquettes(l, plaquettes): return set(plaquettes) | set(it.chain.from_iterable(l.plaquettes[p]. adjacent_plaquettes for p in plaquettes...
flexible
{ "blob_id": "d429f03c0f0c241166d6c0a5a45dc1101bcaec16", "index": 5878, "step-1": "<mask token>\n\n\ndef multi_set_symmetric_difference(sets):\n return list(functools.reduce(lambda a, b: a ^ b, [set(s) for s in sets]))\n\n\ndef flood_iteration_plaquettes(l, plaquettes):\n return set(plaquettes) | set(it.cha...
[ 3, 4, 5, 6, 7 ]
import os from flask import request, jsonify from flask_api import FlaskAPI from flask_api.exceptions import NotAcceptable from dotenv import load_dotenv load_dotenv(dotenv_path='./.env') from src.service.jira import jira from src.service.helper import helper application = FlaskAPI(__name__) jiraservice = jira() help...
normal
{ "blob_id": "72e03e7199044f3ed1d562db622a7b884fa186b0", "index": 2206, "step-1": "<mask token>\n\n\n@application.route('/')\ndef hello_world():\n return jsonify({'Hello': 'World'})\n\n\n<mask token>\n", "step-2": "<mask token>\nload_dotenv(dotenv_path='./.env')\n<mask token>\n\n\n@application.route('/')\nde...
[ 1, 3, 4, 5, 6 ]
import os import sys import random import string trainingData = open('./Data.txt').readlines() # Used for storing the Markov states table = {} # Stores all the words words = [] # The size of the tuple that represents the Markov State ChainLength = 2 # Length of hte output chain Size = int(sys.argv[1]) if(len(sys....
normal
{ "blob_id": "379ab72f5cc74cf6ed4319fff76437ce84aaca23", "index": 4185, "step-1": "import os\nimport sys\nimport random\nimport string\n\n\ntrainingData = open('./Data.txt').readlines()\n\n# Used for storing the Markov states\ntable = {} \n\n# Stores all the words\nwords = []\n\n# The size of the tuple that repre...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> cv2.putText(image, 'Hello World!', (75, 290), cv2.FONT_HERSHEY_COMPLEX, 2, (100, 170, 0), 3) cv2.imshow('Hello World!', image) cv2.imwrite('Text.jpg', image) cv2.waitKey(0) cv2.destroyAllWindows() <|reserved_special_token_1|...
flexible
{ "blob_id": "693f2a56578dfb1e4f9c73a0d33c5585070e9f9e", "index": 5371, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.putText(image, 'Hello World!', (75, 290), cv2.FONT_HERSHEY_COMPLEX, 2,\n (100, 170, 0), 3)\ncv2.imshow('Hello World!', image)\ncv2.imwrite('Text.jpg', image)\ncv2.waitKey(0)\ncv2.d...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class HandView: <|reserved_special_token_0|> def __init__(self, controller, display, ruleset): self.controller = controller self.display = display self.ruleset = ruleset self.Meld_Threshold = controller._state.rules.Meld_Threshold self.deal...
flexible
{ "blob_id": "1cdd315eec6792a8588dc2e6a221bc024be47078", "index": 7885, "step-1": "<mask token>\n\n\nclass HandView:\n <mask token>\n\n def __init__(self, controller, display, ruleset):\n self.controller = controller\n self.display = display\n self.ruleset = ruleset\n self.Meld_T...
[ 7, 9, 11, 12, 13 ]
#! /usr/bin/env python """ Normalizes a vidoe by dividing against it's background. See: BackgroundExtractor.py to get the background of a video. USING: As a command line utility: $ Normalizer.py input_video input_image output_video As a module: from Normalizer import Normalizer ...
normal
{ "blob_id": "141e0f20ce912ecf21940f78e9f40cb86b91dc2b", "index": 6121, "step-1": "<mask token>\n\n\nclass Normalizer:\n <mask token>\n\n def imageFromArg(self, image):\n if isinstance(image, (str, unicode)):\n return cv2.imread(image, 0)\n else:\n return image\n\n def...
[ 5, 7, 10, 11, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> import enter import loginout import roleinfo import zhanyi import package <|reserved_special_token_1|> import enter import loginout import roleinfo import zhanyi import package #import matrix
flexible
{ "blob_id": "de665735f02c7569ab382fdc3e910d5d3ac05bb5", "index": 9088, "step-1": "<mask token>\n", "step-2": "import enter\nimport loginout\nimport roleinfo\nimport zhanyi\nimport package\n", "step-3": "import enter\nimport loginout\nimport roleinfo\nimport zhanyi\nimport package\n#import matrix", "step-4"...
[ 0, 1, 2 ]
import librosa import soundfile import os, glob import numpy as np from sklearn.model_selection import train_test_split from sklearn.neural_network import MLPClassifier from sklearn.metrics import accuracy_score emotionsRavdessData = { '01': 'neutral', '02': 'calm', '03': 'happy', '04': 'sad', '05'...
normal
{ "blob_id": "8cd54362680aa3a96babe100b9231f6f16b3f577", "index": 6670, "step-1": "<mask token>\n\n\ndef extract_feature(file_name, mfcc, chroma, mel):\n with soundfile.SoundFile(file_name) as file:\n X = file.read(dtype='float32')\n sample_rate = file.samplerate\n if chroma:\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('^$', CommentListAPIView.as_view(), name='list'), url( '^(?P<pk>\\d+)/$', CommentDetailAPIView, name='detail')] <|reserved_special_token_1|> from django.conf.urls import url from django.contrib import adm...
flexible
{ "blob_id": "e08820ff4fb35a3770fcb110ef7181aad1abbae5", "index": 8778, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^$', CommentListAPIView.as_view(), name='list'), url(\n '^(?P<pk>\\\\d+)/$', CommentDetailAPIView, name='detail')]\n", "step-3": "from django.conf.urls import url...
[ 0, 1, 2, 3 ]
import os import config as cfg import numpy as np class lfwdata(): def __init__(self): self._pairs = [] pairs = open(os.path.join(cfg.LFW_IMAGEPATH, '../pairs.txt')) pairs.readline() for pair in pairs: pair = pair.split() if len(pair) == 3: ...
normal
{ "blob_id": "ccdd7a5e0a1de75762530a7cadd919a2ee753d18", "index": 1758, "step-1": "<mask token>\n\n\nclass lfwdata:\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass lfwdata:\n\n def __init__(self):\n self._pairs = []\n pairs = open(os.path.join(cfg.LFW_IMAGEPATH, '../p...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'Brice Chou' import os import lib import sys import time import getopt import training try: import cv2 import h5py except Exception as e: error_info = 'Please install h5py/cv2 tools first. Error: {}.\n'.format(e) print('\033[0;31m%s\033[0m' ...
normal
{ "blob_id": "398263b65fd98003f27020e46ae38e913dc5dd45", "index": 323, "step-1": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n__author__ = 'Brice Chou'\n\nimport os\nimport lib\nimport sys\nimport time\nimport getopt\nimport training\n\ntry:\n import cv2\n import h5py\nexcept Exception as e:\n err...
[ 0 ]
import csv import os from collections import namedtuple from typing import List, Dict from config import * HEADER = ['File', 'LKHContigs', 'LKHValue', 'LKHTime', 'APContigs', 'APValue', 'APTime', 'ActualObjectiveValue'] Assembly_Stats = namedtuple('Assembly_Stats', HEADER) dir = '/home/andreas/GDrive/workspace/spars...
normal
{ "blob_id": "edd98e3996b0fce46d33dd33340018ab5b029637", "index": 2333, "step-1": "<mask token>\n\n\ndef read_assembly_file(file: str) ->List:\n if not os.path.isfile(file):\n return [-1, -1, -1, -1, -1, -1]\n with open(file, 'r') as f:\n file_content_string = f.read()\n if 'LKH_Contigs...
[ 5, 7, 8, 9, 10 ]
<|reserved_special_token_0|> class UtilTestCase(TestCase): <|reserved_special_token_0|> def test_get_tree_queryset(self): qs = get_tree_queryset(Country) self.assertEqual(len(qs), 257) self.assertEqual(qs[0].name, 'root') qs = get_tree_queryset(Country, node_id=Country.objects...
flexible
{ "blob_id": "ac5c4edda8a5df7abc030fd637866fa4c8fc4bfc", "index": 1493, "step-1": "<mask token>\n\n\nclass UtilTestCase(TestCase):\n <mask token>\n\n def test_get_tree_queryset(self):\n qs = get_tree_queryset(Country)\n self.assertEqual(len(qs), 257)\n self.assertEqual(qs[0].name, 'root...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def program_skeleton(dictionary: dict): if dictionary['tasks']['environmental_vars']['run'] == True: dictionary['tasks']['environmental_vars']['log'][ 'environmental_vars_set'] = lv.set_environmental_vars...
flexible
{ "blob_id": "6a8007e44d2c4b56426cd49772cbc23df2eca49c", "index": 6917, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef program_skeleton(dictionary: dict):\n if dictionary['tasks']['environmental_vars']['run'] == True:\n dictionary['tasks']['environmental_vars']['log'][\n 'envi...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def decode_page(page_bytes, charsets=('utf-8',)): """通过指定的字符集对页面进行解码(不是每个网站都将字符集设置为utf-8)""" page_html = None for charset in charsets: try: page_html = page_bytes.decode(charset) break except UnicodeDecodeError: pass retu...
flexible
{ "blob_id": "53fae0103168f4074ba0645c33e4640fcefdfc96", "index": 731, "step-1": "<mask token>\n\n\ndef decode_page(page_bytes, charsets=('utf-8',)):\n \"\"\"通过指定的字符集对页面进行解码(不是每个网站都将字符集设置为utf-8)\"\"\"\n page_html = None\n for charset in charsets:\n try:\n page_html = page_bytes.decode(c...
[ 5, 6, 7, 8, 9 ]
import socket from threading import Thread from ast import literal_eval clients = {} addresses = {} host = '127.0.0.1' port = 5678 active = [] addr = (host, port) server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind(addr) groups = [] def broadcast(msg, prefix=""): # prefix is for name identificatio...
normal
{ "blob_id": "9f02313b6f91f83e3a8b4af8d9447b1d8f3558f6", "index": 4430, "step-1": "<mask token>\n\n\ndef broadcast(msg, prefix=''):\n \"\"\"Broadcasts a message to all the clients.\"\"\"\n for sock in clients:\n sock.send(bytes(prefix, 'utf8') + msg)\n\n\ndef broadcast_file(msg):\n for sock in cli...
[ 5, 6, 7, 8, 9 ]
import os bind = '0.0.0.0:8000' workers = os.environ['GET_KEYS_ACCOUNTS_WORKERS']
normal
{ "blob_id": "d84a7e16471c604283c81412653e037ecdb19102", "index": 3530, "step-1": "<mask token>\n", "step-2": "<mask token>\nbind = '0.0.0.0:8000'\nworkers = os.environ['GET_KEYS_ACCOUNTS_WORKERS']\n", "step-3": "import os\nbind = '0.0.0.0:8000'\nworkers = os.environ['GET_KEYS_ACCOUNTS_WORKERS']\n", "step-4...
[ 0, 1, 2 ]
""" Django settings for geobombay project. For more information on this file, see https://docs.djangoproject.com/en/1.7/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) ...
normal
{ "blob_id": "32ca107fde4c98b61d85f6648f30c7601b31c7f3", "index": 3182, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n SECRET_KEY\nexcept NameError:\n SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')\n try:\n SECRET_KEY = open(SECRET_FILE).read().strip()\n except IOError:\n ...
[ 0, 1, 2, 3, 4 ]
from flask_restful import Resource from flask import jsonify, make_response, request from ..models.Users import UsersModel from ..models.Incidents import IncidentsModel from app.api.validations.validations import Validations class UsersView(Resource): def __init__(self): self.db = UsersModel() def...
normal
{ "blob_id": "0188355f84054143bd4ff9da63f1128e9eb5b23b", "index": 2244, "step-1": "<mask token>\n\n\nclass LoginView(Resource):\n\n def __init__(self):\n self.db = UsersModel()\n self.user_db = IncidentsModel()\n\n def post(self):\n data = request.get_json()\n username = data['us...
[ 8, 10, 11, 12, 14 ]
import os.path as path from googleapiclient.discovery import build from google.oauth2 import service_account # If modifying these scopes, delete the file token.pickle. SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly'] # The ID and range of a sample spreadsheet. SAMPLE_SPREADSHEET_ID = '1FSMATLJUNCbV8...
normal
{ "blob_id": "f9261c1844cc629c91043d1221d0b76f6e22fef6", "index": 6157, "step-1": "<mask token>\n\n\ndef main():\n service_account_json = path.join(path.dirname(path.abspath(__file__)),\n 'service_account.json')\n credentials = service_account.Credentials.from_service_account_file(\n service_a...
[ 3, 5, 6, 7, 8 ]
import numpy as np import random import argparse import networkx as nx from gensim.models import Word2Vec from utils import read_node_label, plot_embeddings class node2vec_walk(): def __init__(self, nx_G, is_directed, p, q): self.G = nx_G self.is_directed = is_directed self.p = p ...
normal
{ "blob_id": "fc2748d766ebce8c9577f1eebc8435e2aa58ae25", "index": 8605, "step-1": "<mask token>\n\n\nclass node2vec_walk:\n\n def __init__(self, nx_G, is_directed, p, q):\n self.G = nx_G\n self.is_directed = is_directed\n self.p = p\n self.q = q\n\n def node2vec_walk(self, walk_l...
[ 7, 8, 12, 13, 15 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('IncomeHome/', views.IncomeHome, name='IncomeHome'), path('IncomeCreate/', views.IncomeCreate.as_view(), name='IncomeCreate' ), path('IncomeUpdate/<int:pk>', views.IncomeUpdate.as_view(), name= 'Inc...
flexible
{ "blob_id": "ad3a7221883a847fc9d26097c3801973cbbda38e", "index": 355, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('IncomeHome/', views.IncomeHome, name='IncomeHome'),\n path('IncomeCreate/', views.IncomeCreate.as_view(), name='IncomeCreate'\n ), path('IncomeUpdate/<int:pk>', ...
[ 0, 1, 2, 3 ]
providers = { 'provider-1': { 'name': 'provider-1', 'roles': ['licensor', 'producer'], 'description': 'This is a full description of the provider', 'url': 'https://www.provider.com' }, 'provider-2': { 'name': 'provider-2', 'roles': ['licensor'], 'descr...
normal
{ "blob_id": "7801676df91a7ded6f123113acc62f3955dfe6cb", "index": 7113, "step-1": "<mask token>\n", "step-2": "providers = {'provider-1': {'name': 'provider-1', 'roles': ['licensor',\n 'producer'], 'description':\n 'This is a full description of the provider', 'url':\n 'https://www.provider.com'}, 'pro...
[ 0, 1, 2 ]
# encoding=utf-8 ###### # 遗传算法应用于旅行商问题(TSP) # Python 3.6 # https://morvanzhou.github.io/tutorials/machine-learning/evolutionary-algorithm/2-03-genetic-algorithm-travel-sales-problem/ ######
normal
{ "blob_id": "e79e4eb1640d5ad6e360dfb18430fbf261cf9d3b", "index": 6675, "step-1": "# encoding=utf-8\n\n######\n# 遗传算法应用于旅行商问题(TSP)\n# Python 3.6\n# https://morvanzhou.github.io/tutorials/machine-learning/evolutionary-algorithm/2-03-genetic-algorithm-travel-sales-problem/\n######\n\n", "step-2": null, "step-3"...
[ 1 ]
#!/usr/bin/env python3 import sys class Parse: data = [] def __parseLine(line): """Parse the given line""" # extract name name_len = line.index(" ") name = line[:name_len] line = line[name_len + 3:] # array-ize 'electron' val elec_pos = line.index("e...
normal
{ "blob_id": "cb77696a90716acdee83a1cf6162a8f42c524e11", "index": 7612, "step-1": "<mask token>\n\n\nclass Write:\n\n def __writeHeader(fd):\n \"\"\"Write html header\"\"\"\n print('<!DOCTYPE html>', '<html>', ' <head>',\n ' <title>Super Tableau 3000</title>',\n \" <meta c...
[ 8, 11, 12, 13, 16 ]
from database import db from database import ma from datetime import datetime from sqlalchemy import ForeignKeyConstraint from models.admin import Admin, admin_limited_schema from models.event_status import EventStatus, event_status_schema from models.org_unit import org_unit_schema class Event(db.Model): # class ...
normal
{ "blob_id": "f3167d8f1a806c38fb10672605d8e94265d2fc9c", "index": 723, "step-1": "<mask token>\n\n\nclass Event(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask ...
[ 4, 6, 7, 8, 9 ]
#------------------------------------------------------------------------ # # @Author : EV2 CHEVALLIER # # @Date : 16.09.20 # @Location : École Navale / Chaire de Cyberdéfense des systèmes navals # @Project : Projet de Fin d'Études # @Subject : # Real time detection of cyber anomalies upon a NMEA network by using mach...
normal
{ "blob_id": "6726c8f1b3ef9a0df74c25c1921203af3aaacb12", "index": 8758, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef training(dict):\n model = {}\n model['µ'] = {}\n model['sigma'] = {}\n for x in dict:\n model['µ'][x] = {}\n model['sigma'][x] = {}\n for y in dic...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import json import os import io import shutil import pytest from chi_annotator.algo_factory.common import TrainingData from chi_annotator.task_center.config import AnnotatorConfig from chi_annotator.task_center.data_loader import load_local_data from chi_annotator.task_center.model import Inte...
normal
{ "blob_id": "192c44540018b9e1ab857bdbfba6fdb39bb74431", "index": 8769, "step-1": "<mask token>\n\n\nclass TestTrainer(object):\n <mask token>\n\n @classmethod\n def teardown_class(cls):\n \"\"\" teardown any state that was previously setup with a call to\n setup_class.\n \"\"\"\n ...
[ 10, 12, 13, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def euclidean(p, q): sumSq = 0.0 for i in range(len(p)): sumSq += (p[i] - q[i]) ** 2 return sumSq ** 0.5 <|reserved_special_token_1|> #!/usr/bin/env python # -*- coding: utf-8 -*- # ユークリッド距離 # http://en.wikipedia.org/wiki/Euclidean_spa...
flexible
{ "blob_id": "11a7ebac3dad1f91a6d46b62f557b51ded8e3d7a", "index": 1271, "step-1": "<mask token>\n", "step-2": "def euclidean(p, q):\n sumSq = 0.0\n for i in range(len(p)):\n sumSq += (p[i] - q[i]) ** 2\n return sumSq ** 0.5\n", "step-3": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# ユーク...
[ 0, 1, 2 ]
# coding: utf-8 from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome() driver.get("https://www.baidu.com") elem = driver.find_element_by_xpath('//*[@id="kw"]') elem.send_keys("python selenium", Keys.ENTER) print(driver.page_source)
normal
{ "blob_id": "3c8352ff2fc92ada1b58603df2a1a402e57842be", "index": 8606, "step-1": "<mask token>\n", "step-2": "<mask token>\ndriver.get('https://www.baidu.com')\n<mask token>\nelem.send_keys('python selenium', Keys.ENTER)\nprint(driver.page_source)\n", "step-3": "<mask token>\ndriver = webdriver.Chrome()\ndri...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> config = {'numIndividuals': 50, 'maxNumGen': 20, 'eliteProp': 0.1, 'mutantProp': 0.2, 'inheritanceProb': 0.7}
flexible
{ "blob_id": "85d1069d85e285bc5c36811f569dabd793b5064b", "index": 4460, "step-1": "<mask token>\n", "step-2": "config = {'numIndividuals': 50, 'maxNumGen': 20, 'eliteProp': 0.1,\n 'mutantProp': 0.2, 'inheritanceProb': 0.7}\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1...
[ 0, 1 ]
<|reserved_special_token_0|> class Book: def __init__(self, url): self.url = url self.title = '' self.category = '' self.upc = '' self.price_including_tax = '' self.price_excluding_tax = '' self.number_available = '' self.description = '' se...
flexible
{ "blob_id": "3dc83168264fbb4f9b0ab2980b845dffdc4417bb", "index": 7588, "step-1": "<mask token>\n\n\nclass Book:\n\n def __init__(self, url):\n self.url = url\n self.title = ''\n self.category = ''\n self.upc = ''\n self.price_including_tax = ''\n self.price_excluding_...
[ 11, 12, 13, 15, 16 ]
import numpy as np a = np.ones((3,4)) b = np.ones((4,1)) # a.shape = (3,4) # b.shape = (4,1) c = np.zeros_like(a) for i in range(3): for j in range(4): c[i][j] = a[i][j] + b[j] print(c) d = a+b.T print(d)
normal
{ "blob_id": "d6213698423902771011caf6b5206dd4e3b27450", "index": 5753, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(3):\n for j in range(4):\n c[i][j] = a[i][j] + b[j]\nprint(c)\n<mask token>\nprint(d)\n", "step-3": "<mask token>\na = np.ones((3, 4))\nb = np.ones((4, 1))\nc =...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class IndexSetter(BaseEstimator, TransformerMixin): """ Set index """ def __init__(self, index_cols, drop_existing): self.index_cols = index_cols self.drop_existing = drop_existing def fit(self, X, y=None): return self def transform(self, X): ...
flexible
{ "blob_id": "9f7b1cfcc3c20910201fc67b5a641a5a89908bd1", "index": 8980, "step-1": "<mask token>\n\n\nclass IndexSetter(BaseEstimator, TransformerMixin):\n \"\"\" Set index \"\"\"\n\n def __init__(self, index_cols, drop_existing):\n self.index_cols = index_cols\n self.drop_existing = drop_exist...
[ 41, 44, 52, 56, 62 ]
from django.apps import AppConfig class AttendaceConfig(AppConfig): name = 'attendace'
normal
{ "blob_id": "d5d61b23dc14ffdfe7fe6f983164916863928eaf", "index": 3685, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AttendaceConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AttendaceConfig(AppConfig):\n name = 'attendace'\n", "step-4": "from django.apps impo...
[ 0, 1, 2, 3 ]
from celery_app import celery_app @celery_app.task def demo_celery_run(): return 'result is ok'
normal
{ "blob_id": "4bb973b598a9c35394a0cd78ed9ba807f3a595d7", "index": 2323, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@celery_app.task\ndef demo_celery_run():\n return 'result is ok'\n", "step-3": "from celery_app import celery_app\n\n\n@celery_app.task\ndef demo_celery_run():\n return 'resul...
[ 0, 1, 2 ]
import glob import xarray as xr from model_diagnostics import * data_root = '../data/synthetic/standard/' var_list = ['hs', 'dp', 'spr', 'fp', 'dir', 't0m1'] eke = 0.01 ########################## output = [] diagnostic_functions = [basic_stats] for var in var_list: grid_files = glob.glob(data_root+'gridded/*%s*%s...
normal
{ "blob_id": "6b727cdfc684db4ba919cd5390fe45de43a806fe", "index": 309, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor var in var_list:\n grid_files = glob.glob(data_root + 'gridded/*%s*%s.nc' % (eke, var))\n for f in grid_files:\n output.append(analize_member(f, var, diagnostic_functions)...
[ 0, 1, 2, 3, 4 ]
""" Interfaces to Juju API ModelManager """ from conjureup import juju @juju.requires_login def list_models(user='user-admin'): """ Lists Juju Models Arguments: user: Name of user to list models for. Returns: Dictionary of known Juju Models (default: user-admin) """ models = juju.CLIENT...
normal
{ "blob_id": "11045cffc6d47902be7236e1d684422317f2c5f9", "index": 1444, "step-1": "<mask token>\n\n\n@juju.requires_login\ndef list_models(user='user-admin'):\n \"\"\" Lists Juju Models\n\n Arguments:\n user: Name of user to list models for.\n\n Returns:\n Dictionary of known Juju Models (default: ...
[ 1, 2, 3, 4, 5 ]
# Imports from __future__ import print_function import numpy from numpy.random import randint from enum import Enum __all__ = ["common", "plot"] class result(Enum): CRIT = 16 HIT = 8 EVADE = 4 FOCUS = 2 BLANK = 1 def result_str(res): str = "" if res & result.BLANK: str += "BLANK" i...
normal
{ "blob_id": "5261346f96e7520b6ef75a292b3d44a6f00d868c", "index": 5566, "step-1": "<mask token>\n\n\nclass result(Enum):\n CRIT = 16\n HIT = 8\n EVADE = 4\n FOCUS = 2\n BLANK = 1\n\n\n<mask token>\n\n\nclass die:\n\n def __init__(self):\n self.rerolled = False\n\n def __str__(self):\n ...
[ 24, 26, 29, 33, 38 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('\n'.join(re.findall( 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+' , sys.stdin.read()))) <|reserved_special_token_1|> import sys, re print('\n'.join(re.findall( 'http[s]?:...
flexible
{ "blob_id": "4cefaa964251e77a05066af1f61f9fd2a4350d38", "index": 7622, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('\\n'.join(re.findall(\n 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\\\(\\\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'\n , sys.stdin.read())))\n", "step-3": "import sys, re\nprint(...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ConcatZeroPadding(OptimizeRule): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ConcatZeroPadding(OptimizeRule): def optimize(self, graph: Graph) ->Tuple[Graph, b...
flexible
{ "blob_id": "687f7f4908e8a5448335f636edf74a627f03c306", "index": 9110, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ConcatZeroPadding(OptimizeRule):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ConcatZeroPadding(OptimizeRule):\n\n def optimize(self, graph: Graph) ->Tuple[Grap...
[ 0, 1, 2, 3, 4 ]
from . import * from module import * from transfer import * from dataset import *
normal
{ "blob_id": "94d992ef4b9015aa8f42071bb1409703d509c313", "index": 9810, "step-1": "<mask token>\n", "step-2": "from . import *\nfrom module import *\nfrom transfer import *\nfrom dataset import *\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
import pydgm import numpy as np import sys class XS(): # Hold the cross section values with routines for outputting to txt file def __init__(self, sig_t, sig_f, chi, sig_s, mu=None): self.sig_t = sig_t self.sig_f = sig_f self.chi = chi self.sig_s = sig_s self.mu = mu i...
normal
{ "blob_id": "1358adc3b2b3ffe72c0ed87fb0024f1079ca7d04", "index": 1710, "step-1": "<mask token>\n\n\nclass DGMSOLVER:\n\n def __init__(self, G, fname, fm, cm, mm, nPin, norm=None, mapping=None,\n vacuum=False, k=None, phi=None, psi=None):\n \"\"\"\n Inputs:\n G - Number of e...
[ 6, 8, 9, 11, 13 ]
# -*- coding: utf-8 -*- import sys #from Constants import * # start import CrudMatrixDao class CrudAccessValue: def __init__(self): self.crudAccessValue = {} self.__run() def __run(self): aCrudMatrixDao = CrudMatrixDao.CrudMatrixDao() # print aCrudMatrixDao.selectCrudAccessValueAction() ...
normal
{ "blob_id": "38e616e35f165d458d774dd0b6837a733b8402d7", "index": 1555, "step-1": "# -*- coding: utf-8 -*-\r\nimport sys\r\n#from Constants import *\r\n# start\r\nimport CrudMatrixDao\r\n\r\nclass CrudAccessValue:\r\n\tdef __init__(self):\r\n\t\tself.crudAccessValue = {}\r\n\t\tself.__run()\r\n\t\t\r\n\tdef __ru...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with onto: class Pizza(Thing): pass class MeatPizza(Pizza): pass class Topping(Thing): pass class has_Topping((Pizza >> Topping)): pass print(Pizza) <|reserved_special_token_...
flexible
{ "blob_id": "cc7f1f38efcd4d757c1d11e2bd53695fca44e15a", "index": 212, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith onto:\n\n\n class Pizza(Thing):\n pass\n\n\n class MeatPizza(Pizza):\n pass\n\n\n class Topping(Thing):\n pass\n\n\n class has_Topping((Pizza >> Toppi...
[ 0, 1, 2, 3, 4 ]
import logging as log from time import monotonic import re from jmap.account import ImapAccount import jmap.core as core import jmap.mail as mail import jmap.submission as submission import jmap.vacationresponse as vacationresponse import jmap.contacts as contacts import jmap.calendars as calendars from jmap import er...
normal
{ "blob_id": "aac3b2478980d3a5453451cb848afcfd6aca1743", "index": 1680, "step-1": "<mask token>\n\n\ndef handle_request(user, data):\n results = []\n resultsByTag = {}\n api = Api(user, data.get('createdIds', None))\n for capability in data['using']:\n CAPABILITIES[capability].register_methods(...
[ 6, 7, 8, 9, 10 ]
#!/bin/python3 import socket HOST = '127.0.0.1' PORT= 4444 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST,PORT))
normal
{ "blob_id": "14a39b9aa56777c8198794fe2f51c9a068500743", "index": 4075, "step-1": "<mask token>\n", "step-2": "<mask token>\ns.connect((HOST, PORT))\n", "step-3": "<mask token>\nHOST = '127.0.0.1'\nPORT = 4444\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.connect((HOST, PORT))\n", "step-4": "imp...
[ 0, 1, 2, 3, 4 ]
#@@range_begin(list1) # ←この行は無視してください。本文に引用するためのものです。 #ファイル名 Chapter07/0703person.py # __metaclass__ = type #← python 2を使っている場合は行頭の「#」を取る class Person: def set_name(self, name): self.name = name def get_name(self): return self.name def greet(self): # あいさつをする print(f"こんにちは。私は{self...
normal
{ "blob_id": "321dc411b003949a6744216a13c59c70d919a675", "index": 8402, "step-1": "class Person:\n <mask token>\n\n def get_name(self):\n return self.name\n\n def greet(self):\n print(f'こんにちは。私は{self.name}です。')\n\n\n<mask token>\n", "step-2": "class Person:\n\n def set_name(self, name)...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- # упражнение выполнено на Python 3 manual_calc = 53 + 1.0/3 def trapezoidal(f, a, b, n): h = float(b - a)/n result = 0.5*(f(a) + f(b)) for i in range(1, n): result += f(a + i*h) result *= h return result def rectangular(f, a, b, n): h = float(b - a)/n result = f(a+0.5*h) for ...
normal
{ "blob_id": "4fbf5b4520aa4dca4c7cc80d56ba00f634d184bf", "index": 3405, "step-1": "<mask token>\n\n\ndef rectangular(f, a, b, n):\n h = float(b - a) / n\n result = f(a + 0.5 * h)\n for i in range(1, n):\n result += f(a + 0.5 * h + i * h)\n result *= h\n return result\n\n\n<mask token>\n", ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> janela.title('Teste de frame') janela.geometry('800x600') <|reserved_special_token_0|> Label(frame, text='lsdakçasd').grid(row=0, column=0) janela.mainloop() <|reserved_special_token_1|> <|reserved_special_token_0|> janela = Tk...
flexible
{ "blob_id": "4ae24d1e39bdcde3313a8a0c8029a331864ba40e", "index": 6985, "step-1": "<mask token>\n", "step-2": "<mask token>\njanela.title('Teste de frame')\njanela.geometry('800x600')\n<mask token>\nLabel(frame, text='lsdakçasd').grid(row=0, column=0)\njanela.mainloop()\n", "step-3": "<mask token>\njanela = T...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def load_data(data): temp = [] for i in range(len(data)): im = cv2.imread(data[i]) im = misc.imresize(im, size=DOWNSAMPLE_RATIO) im = crop(im) temp.append(im) return temp def normalize(data): a = -0.5 b = 0.5 greyscale_min = 0 ...
flexible
{ "blob_id": "b109568c4dba05b16cbed1759a2b9e0a99babc67", "index": 2982, "step-1": "<mask token>\n\n\ndef load_data(data):\n temp = []\n for i in range(len(data)):\n im = cv2.imread(data[i])\n im = misc.imresize(im, size=DOWNSAMPLE_RATIO)\n im = crop(im)\n temp.append(im)\n ret...
[ 8, 10, 12, 16, 19 ]
<|reserved_special_token_0|> class TestListDiff(TestCase): <|reserved_special_token_0|> def test_two(self): assert list_diff([1, 2, 2, 2, 3], [2]) == [1, 3] <|reserved_special_token_0|> <|reserved_special_token_0|> class TestDiffLR(TestCase): def test_one(self): assert list_diff_...
flexible
{ "blob_id": "76526bdff7418997ac90f761936abccbb3468499", "index": 6513, "step-1": "<mask token>\n\n\nclass TestListDiff(TestCase):\n <mask token>\n\n def test_two(self):\n assert list_diff([1, 2, 2, 2, 3], [2]) == [1, 3]\n <mask token>\n\n\n<mask token>\n\n\nclass TestDiffLR(TestCase):\n\n def ...
[ 6, 8, 9, 10, 12 ]
<|reserved_special_token_0|> class floatlayoutApp(App): def build(self): return LayoutWindow() <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class LayoutWindow(FloatLayout): pass class floatlayoutApp(App): def build(self): return LayoutWi...
flexible
{ "blob_id": "2af8677e76b77b9bfa579012a85ea331c0c7f390", "index": 136, "step-1": "<mask token>\n\n\nclass floatlayoutApp(App):\n\n def build(self):\n return LayoutWindow()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass LayoutWindow(FloatLayout):\n pass\n\n\nclass floatlayoutApp(App):\n\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(stevila) print(stevila[1]) <|reserved_special_token_1|> stevila = [5, 2, 8, 3] print(stevila) print(stevila[1]) <|reserved_special_token_1|> stevila = [5, 2, 8, 3] #Izpis vseh števil print(stevila) #Izpis števila na ...
flexible
{ "blob_id": "6e845f2543b548fb936cc3719eb150e530281945", "index": 9505, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(stevila)\nprint(stevila[1])\n", "step-3": "stevila = [5, 2, 8, 3]\nprint(stevila)\nprint(stevila[1])\n", "step-4": "stevila = [5, 2, 8, 3]\n\n#Izpis vseh števil\nprint(stevila)\...
[ 0, 1, 2, 3 ]
from django import forms class LoginForm(forms.Form): usuario=forms.CharField(label="Usuario",max_length=20, required=True, widget=forms.TextInput( attrs={'class':'form-control'} )) contraseña=forms.CharField(label="Contraseña",max_length=20, widget=forms.PasswordInput( attrs={'class':'for...
normal
{ "blob_id": "7da5a7476c807619bed805cb892774c23c04c6f7", "index": 4917, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LoginForm(forms.Form):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LoginForm(forms.Form):\n usuario = forms.CharField(label='Usuario', max_le...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(volume, surface_area) <|reserved_special_token_1|> <|reserved_special_token_0|> pi = 3.14159 r = 3.14 h = 5 volume = pi * r ** 2 * h surface_area = 2 * pi * r ** 2 + r * h print(volume, surface_area) <|reserved_special_...
flexible
{ "blob_id": "d04e69c234f2887f5301e4348b4c4ec2ad3af7a2", "index": 2623, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(volume, surface_area)\n", "step-3": "<mask token>\npi = 3.14159\nr = 3.14\nh = 5\nvolume = pi * r ** 2 * h\nsurface_area = 2 * pi * r ** 2 + r * h\nprint(volume, surface_area)\n",...
[ 0, 1, 2, 3 ]
import collections import inspect import struct from pygments.token import * import decompil.builder import decompil.disassemblers import decompil.ir class Context(decompil.ir.Context): def __init__(self): super(Context, self).__init__(16) self.pointer_type = self.create_pointer_type(self.half_...
normal
{ "blob_id": "865d7c606b287dbce158f721c6cf768cd078eb48", "index": 9231, "step-1": "<mask token>\n\n\nclass Register(decompil.ir.Register):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass BaseDecoder:\n name = None\n opcode = None\n op...
[ 18, 24, 25, 29, 33 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def reverse(string): if len(string) == 0: return temp = string[0] reverse(string[1:]) print(temp, end='') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def ...
flexible
{ "blob_id": "d1ee33ce6fb071aae800b0597a09e7039a209ec8", "index": 2574, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef reverse(string):\n if len(string) == 0:\n return\n temp = string[0]\n reverse(string[1:])\n print(temp, end='')\n\n\n<mask token>\n", "step-3": "<mask token>\...
[ 0, 1, 2, 3, 4 ]
# data={ # "name":"Alby", # "age":23 # } # print (data['age']) # def foo(): # print("Hellow world") # return 1 # print (foo()) a="aa" def add(): print(a) add()
normal
{ "blob_id": "97857c1c5468a96187d44abc23ffaaf2a7ead1a6", "index": 1869, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef add():\n print(a)\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef add():\n print(a)\n\n\nadd()\n", "step-4": "a = 'aa'\n\n\ndef add():\n print(a)\n\n\nadd()\n"...
[ 0, 1, 2, 3, 4 ]
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 django import forms from django.contrib.auth.forms import UserCreationForm from .models import AuthUser class SignUpForm(forms.Form): username = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'})) email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-...
normal
{ "blob_id": "7644dcd956e1ad179f42e44870864386744c6cdf", "index": 2553, "step-1": "<mask token>\n\n\nclass LoginForm(forms.Form):\n username = forms.CharField(widget=forms.TextInput(attrs={'class':\n 'form-control'}))\n password = forms.CharField(widget=forms.PasswordInput(attrs={'class':\n 'f...
[ 2, 3, 4, 5 ]
a = [1, 1, 2, 3, 4, 4, 5, 7, 12, 30, 49] for i in range(0, len(a)): if a[i] < 5: print(str(a[i]) + " ") i += 1 else: i += 1
normal
{ "blob_id": "24635989ccdb0f35f1e618dd8dc07f2cf84faddb", "index": 6621, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(0, len(a)):\n if a[i] < 5:\n print(str(a[i]) + ' ')\n i += 1\n else:\n i += 1\n", "step-3": "a = [1, 1, 2, 3, 4, 4, 5, 7, 12, 30, 49]\nfor i in...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def pre_proc(INP_DIR): INP_DIR = INP_DIR + '/' NONE_DIR = os.path.dirname(INP_DIR) + '_none' SQUARE_DIR = os.path.dirname(INP_DIR) + '_square' CROP_DIR = os.path.dirname(INP_DIR) + '_cropped' os.makedirs(NONE_DIR, exist_ok=True) os.makedirs(SQUARE_DIR, exist_ok=Tru...
flexible
{ "blob_id": "4ad4cf46be735c6ac26b5b0953d4c2458f37496a", "index": 9372, "step-1": "<mask token>\n\n\ndef pre_proc(INP_DIR):\n INP_DIR = INP_DIR + '/'\n NONE_DIR = os.path.dirname(INP_DIR) + '_none'\n SQUARE_DIR = os.path.dirname(INP_DIR) + '_square'\n CROP_DIR = os.path.dirname(INP_DIR) + '_cropped'\n...
[ 1, 2, 3, 4, 5 ]
# Python 2.7 Doritobot Vision System # EECS 498 Purple Team, 2014 # Written by Cody Hyman (hymanc@umich.edu) # Written against OpenCV 3.0.0-alpha import sys import os import cv2 import numpy as np from uvcinterface import UVCInterface as uvc from visionUtil import VisionUtil as vu from collections import deque from ...
normal
{ "blob_id": "324030a976af29dc93fdb637583bfaab93671cc2", "index": 8515, "step-1": "# Python 2.7 Doritobot Vision System\n# EECS 498 Purple Team, 2014\n# Written by Cody Hyman (hymanc@umich.edu)\n# Written against OpenCV 3.0.0-alpha\n\nimport sys\nimport os\n\nimport cv2\nimport numpy as np\n\nfrom uvcinterface im...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @es_bot.event async def on_ready(): print('es started') @nas_bot.event async def on_ready(): print('nas started') @dow_bot.event async def on_ready(): print('dow started') @silver_bot.event async def on_ready()...
flexible
{ "blob_id": "e57109f1c5c2e1468ef1cf9f10fba743633ca150", "index": 8094, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@es_bot.event\nasync def on_ready():\n print('es started')\n\n\n@nas_bot.event\nasync def on_ready():\n print('nas started')\n\n\n@dow_bot.event\nasync def on_ready():\n prin...
[ 0, 1, 2, 3, 4 ]
import re text = 'Macademia nuts, Honey tuile, Cocoa powder, Pistachio nuts' search_pattern = re.compile('nuts') search_match_object = search_pattern.search(text) if search_match_object: print(search_match_object.span()) print(search_match_object.start()) print(search_match_object.end()) print(search_...
normal
{ "blob_id": "ef5d235f09eea827b240290218c397f880f1046d", "index": 4433, "step-1": "<mask token>\n", "step-2": "<mask token>\nif search_match_object:\n print(search_match_object.span())\n print(search_match_object.start())\n print(search_match_object.end())\n print(search_match_object.group())\nprint...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(getsizeof(a)) <|reserved_special_token_0|> print(getsizeof(c)) for b in a: print(b) print(sum(a)) <|reserved_special_token_1|> <|reserved_special_token_0|> a = (b for b in range(10)) print(getsizeof(a)) c = [b for b i...
flexible
{ "blob_id": "2ee4b31f880441e87c437d7cc4601f260f34ae24", "index": 6574, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(getsizeof(a))\n<mask token>\nprint(getsizeof(c))\nfor b in a:\n print(b)\nprint(sum(a))\n", "step-3": "<mask token>\na = (b for b in range(10))\nprint(getsizeof(a))\nc = [b for...
[ 0, 1, 2, 3, 4 ]
import json import yaml import argparse import sys def json2yaml(json_input, yaml_input): json_data = json.load(open(json_input, 'r')) yaml_file = open(yaml_input, 'w') yaml.safe_dump(json_data, yaml_file, allow_unicode=True, default_flow_style=False) yaml_data = yaml.load_all(open(yaml_input, 'r'), L...
normal
{ "blob_id": "5c15252611bee9cd9fbb5d91a19850c242bb51f1", "index": 4940, "step-1": "<mask token>\n\n\ndef json2yaml(json_input, yaml_input):\n json_data = json.load(open(json_input, 'r'))\n yaml_file = open(yaml_input, 'w')\n yaml.safe_dump(json_data, yaml_file, allow_unicode=True,\n default_flow_s...
[ 2, 3, 4, 5, 6 ]
import datetime import os # os.getcwd() class LMS: # This class is used to keep records of the books in the Library def __init__(self, list_of_books, library_name): self.list_of_books = "List_of_books.txt" self.library_name = library_name self.books_dict = {} Id = 101 w...
normal
{ "blob_id": "1a2616472c8d432c91e2b48260cbae61d3ecfd90", "index": 1746, "step-1": "<mask token>\n\n\nclass LMS:\n <mask token>\n <mask token>\n\n def issue_books(self):\n books_id = input(\"Enter book's ID: \")\n current_date = datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')\n ...
[ 4, 5, 6, 7, 9 ]
<|reserved_special_token_0|> class BinarySearchTree: <|reserved_special_token_0|> def __init__(self): self._root = None def __str__(self): """ yield 迭代器 """ tree2list = [x.data for x in self._generate_node()] return 'the BinarySearchTree is %s' % tree2list def __bool...
flexible
{ "blob_id": "fa46bd784dcfeee4f9012ffb6ab6731d2764c9fa", "index": 8484, "step-1": "<mask token>\n\n\nclass BinarySearchTree:\n <mask token>\n\n def __init__(self):\n self._root = None\n\n def __str__(self):\n \"\"\" yield 迭代器 \"\"\"\n tree2list = [x.data for x in self._generate_node(...
[ 15, 19, 26, 31, 34 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def home_admin(request): """ :view home_admin: Menu principale des Administrateurs :template home_admin.html: """ if not request.user.is_authenticated(): return redirect('login') title = 'Accueil'...
flexible
{ "blob_id": "b453c8e9cc50066d1b5811493a89de384a000f37", "index": 4929, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef home_admin(request):\n \"\"\"\n :view home_admin: Menu principale des Administrateurs\n :template home_admin.html:\n \"\"\"\n if not request.user.is_authenticated()...
[ 0, 1, 2, 3 ]
# # cuneiform_python.py # # Example showing how to create a custom Unicode set for parsing # # Copyright Paul McGuire, 2021 # from typing import List, Tuple import pyparsing as pp class Cuneiform(pp.unicode_set): """Unicode set for Cuneiform Character Range""" _ranges: List[Tuple[int, ...]] = [ (0x10...
normal
{ "blob_id": "bc1aefd0b0a87b80a10cecf00407b4608a6902b5", "index": 3897, "step-1": "<mask token>\n\n\nclass Cuneiform(pp.unicode_set):\n <mask token>\n _ranges: List[Tuple[int, ...]] = [(66432, 66517), (73728, 74751), (\n 74752, 74879)]\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Cuneif...
[ 1, 3, 4, 5, 6 ]
import numpy as np import cv2 from camera import load_K, load_camera_dist, load_camera_ret def undistort_img(img): ''' Return an undistorted image given previous calibrated parameters References from OpenCV docs ''' ret = load_camera_ret() K = load_K() dist = load_camera_dist() h,w = img.sha...
normal
{ "blob_id": "844c630d3fe2dda833064556228b524608cfece9", "index": 4671, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef undistort_img(img):\n \"\"\"\n Return an undistorted image given previous calibrated parameters \n References from OpenCV docs\n \"\"\"\n ret = load_camera_ret()\n K =...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def main(): num = int(input('dia: ')) dia(num) <|reserved_special_token_0|> <|reserved_special_token_1|> def main(): num = int(input('dia: ')) dia(num) def dia(a): if a == 1: print('Domingo !') elif a == 2: print...
flexible
{ "blob_id": "07332e2da5458fda2112de2507037a759d3c62db", "index": 3382, "step-1": "<mask token>\n", "step-2": "def main():\n num = int(input('dia: '))\n dia(num)\n\n\n<mask token>\n", "step-3": "def main():\n num = int(input('dia: '))\n dia(num)\n\n\ndef dia(a):\n if a == 1:\n print('Dom...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def asymmetric_extend(q1, q2, extend_fn, backward=False): if backward and ASYMETRIC: return reversed(list(extend_fn(q2, q1))) return extend_fn(q1, q2) <|reserved_special_token_0|> def calculate_radius(d=2): interval = 1 - 0 vol_free = interval ** d radius =...
flexible
{ "blob_id": "84febcc599aa97858ded3b6f803b6b76960878d4", "index": 7188, "step-1": "<mask token>\n\n\ndef asymmetric_extend(q1, q2, extend_fn, backward=False):\n if backward and ASYMETRIC:\n return reversed(list(extend_fn(q2, q1)))\n return extend_fn(q1, q2)\n\n\n<mask token>\n\n\ndef calculate_radius...
[ 7, 8, 10, 12, 13 ]
#!/usr/bin/env python """Server that accepts and executes control-type commands on the bot.""" import sys import os from inspect import getmembers, ismethod from simplejson.decoder import JSONDecodeError import zmq import signal # This is required to make imports work sys.path = [os.getcwd()] + sys.path import bot.l...
normal
{ "blob_id": "ddb81e3ce0df44ee503c558b68b41c35935358a0", "index": 8663, "step-1": "<mask token>\n\n\nclass CtrlServer(object):\n <mask token>\n <mask token>\n <mask token>\n\n def assign_subsystems(self):\n \"\"\"Instantiates and stores references to bot subsystems.\n\n :returns: Dict of...
[ 10, 13, 16, 18, 19 ]
from dataclasses import dataclass, field from typing import List @dataclass class Root: a: List[object] = field( default_factory=list, metadata={ "type": "Element", "namespace": "", "min_occurs": 2, "max_occurs": 4, "sequence": 1, ...
normal
{ "blob_id": "7e318ae7317eac90d6ce9a6b1d0dcc8ff65abef0", "index": 9430, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@dataclass\nclass Root:\n a: List[object] = field(default_factory=list, metadata={'type':\n 'Element', 'namespace': '', 'min_occurs': 2, 'max_occurs': 4,\n 'sequence'...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> torch.manual_seed(1) if use_cuda: torch.cuda.manual_seed(1) np.random.seed(1) <|reserved_special_token_0|> print('DCCNet training script') <|reserved_special_token_0|> parser.add_argument('--checkpoint', type=str, default='') ...
flexible
{ "blob_id": "0c97569c77fb3598d83eba607960328bb2134dd2", "index": 333, "step-1": "<mask token>\n", "step-2": "<mask token>\ntorch.manual_seed(1)\nif use_cuda:\n torch.cuda.manual_seed(1)\nnp.random.seed(1)\n<mask token>\nprint('DCCNet training script')\n<mask token>\nparser.add_argument('--checkpoint', type=...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class ScannerTests(unittest.TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def testPricingSingleItems(self): scanner = Scanner(self.singleItemListOneDiscount) groceryList = ['Apple', 'Orange', 'Tomato', 'A...
flexible
{ "blob_id": "fc2a123f8a86d149af9fc73baa360a029fcde574", "index": 6316, "step-1": "<mask token>\n\n\nclass ScannerTests(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def testPricingSingleItems(self):\n scanner = Scanner(self.singleItemListOneDiscount)\n groceryList...
[ 5, 7, 8, 11, 14 ]
from rest_framework import serializers from .models import Backend class BackendSerializer(serializers.ModelSerializer): class Meta: model = Backend fields = '__all__'
normal
{ "blob_id": "b4787d65fb8adf5dc6a99c1a13922c8f9acc2087", "index": 1971, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BackendSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Backend\n fields = '__all__'\n", "step-3": "from rest_framework import serializers...
[ 0, 1, 2 ]
f = open("resources/yesterday.txt", 'r') yesterday_lyric = "" while 1 : line = f.readline() if not line : break yesterday_lyric = yesterday_lyric + line.strip() + "\n" f.close() # 대소문자 구분없이 yesterday 단어의 개수 세기 : 대문자로 또는 소문자로 만들고 카운드 세기 num_of_yesterday = yesterday_lyric.upper().count("YESTERDAY") ...
normal
{ "blob_id": "8559448822b3d3989a9795e7b497a2791588c327", "index": 9539, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile 1:\n line = f.readline()\n if not line:\n break\n yesterday_lyric = yesterday_lyric + line.strip() + '\\n'\nf.close()\n<mask token>\nprint(\"Number of a Word 'YESTER...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def get_Userid(path): path_Divided = path.split('\\') get_id = path_Divided[6].split('.') get_id = get_id[0] return get_id def compose_Json_Path_ToRead(path_json_source, get_id): json_path_to_read = path_json_source + '\\' + str(get_id) + '.json' return json_path...
flexible
{ "blob_id": "2e5dbd84eb1f9cc09602df8ef8d7bdd30e1b2f26", "index": 7119, "step-1": "<mask token>\n\n\ndef get_Userid(path):\n path_Divided = path.split('\\\\')\n get_id = path_Divided[6].split('.')\n get_id = get_id[0]\n return get_id\n\n\ndef compose_Json_Path_ToRead(path_json_source, get_id):\n js...
[ 5, 6, 7, 8, 9 ]
# coding: UTF-8 -*- import os.path PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) EMOTICONS = { "O:)": "angel", "o:)": "angel", "O:-)": "angel", "o:-)": "angel", "o:-3": "angel", "o:3": "angel", "O;^)": "angel", ">:[": "annoyed/disappointed", ":-(": "annoyed/disappointed...
normal
{ "blob_id": "3f3ed0165120dc135a4ce1f282dbdf9dad57adf8", "index": 980, "step-1": "<mask token>\n", "step-2": "<mask token>\nPROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))\nEMOTICONS = {'O:)': 'angel', 'o:)': 'angel', 'O:-)': 'angel', 'o:-)':\n 'angel', 'o:-3': 'angel', 'o:3': 'angel', 'O;^)': 'ang...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class GraphWalkAgent(nn.Module): def __init__(self, args): super(GraphWalkAgent, self).__init__() self.model = args.model self.relation_only = args.relation_only self.history_dim = args.history_dim self.history_num_layers = args.history_num_lay...
flexible
{ "blob_id": "4a892c3532a3e3ddcd54705336dce820ff49b91b", "index": 6289, "step-1": "<mask token>\n\n\nclass GraphWalkAgent(nn.Module):\n\n def __init__(self, args):\n super(GraphWalkAgent, self).__init__()\n self.model = args.model\n self.relation_only = args.relation_only\n self.his...
[ 10, 13, 16, 18, 20 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_data_dir_register(): register = register_path.DataDirRegister(namespace_to_data_dirs={'ns1': [epath.Path('/path/ns1')]}) assert {'ns1'} == register.namespaces <|reserved_special_token_1|> <|reserved_s...
flexible
{ "blob_id": "ed65d7e0de3fc792753e34b77254bccc8cee6d66", "index": 3657, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_data_dir_register():\n register = register_path.DataDirRegister(namespace_to_data_dirs={'ns1':\n [epath.Path('/path/ns1')]})\n assert {'ns1'} == register.namespa...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(TSA, V) <|reserved_special_token_1|> l, w, h = map(int, input().split()) TSA = 2 * (l * w + w * h + h * l) V = l * w * h print(TSA, V)
flexible
{ "blob_id": "d3382ead1d98ba2fb15fe3ea277430f1bb07131c", "index": 2544, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(TSA, V)\n", "step-3": "l, w, h = map(int, input().split())\nTSA = 2 * (l * w + w * h + h * l)\nV = l * w * h\nprint(TSA, V)\n", "step-4": null, "step-5": null, "step-ids": [...
[ 0, 1, 2 ]
''' Created on 4 Oct 2016 @author: MetalInvest ''' def isHammerHangman(high, low, open, close): body = abs(open - close) leg = min(open, close) - low return leg / body >= 2.0 and high/max(open, close) <= 1.08 def isEngulfing(df, bottom = True): open_0 = df['open'][-1] close_0 = d...
normal
{ "blob_id": "6e739c30b3e7c15bd90b74cfd5a1d6827e863a44", "index": 4413, "step-1": "<mask token>\n\n\ndef isHammerHangman(high, low, open, close):\n body = abs(open - close)\n leg = min(open, close) - low\n return leg / body >= 2.0 and high / max(open, close) <= 1.08\n\n\ndef isEngulfing(df, bottom=True):...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/7/14 下午6:06 # @Author : Huang HUi # @Site : # @File : Longest Common Prefix.py # @Software: PyCharm class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ ...
normal
{ "blob_id": "1aed8e92a31ee42a3a609123af927f7074598ec1", "index": 1820, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution(object):\n\n def longestCommonPrefix(self, strs):\n \"\"\"\n :type strs: List[str]\n ...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.1.5 on 2019-01-21 22:51 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] ope...
normal
{ "blob_id": "a6cb7a134fb8480d344743bcb7bc8766146d256f", "index": 8238, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def test_read_from_file(): """ Test of function of reading data from file. :return: """ reading_file = d.read_code_from_file() assert type(reading_file) == list assert len(reading_file) == 7 assert '\n' not in d.read_code_from_file() def test_decode_from...
flexible
{ "blob_id": "8cfab525ab3a86dd6964475d5621fdc7c6413e38", "index": 8019, "step-1": "<mask token>\n\n\ndef test_read_from_file():\n \"\"\"\n Test of function of reading data from file.\n\n :return:\n \"\"\"\n reading_file = d.read_code_from_file()\n assert type(reading_file) == list\n assert le...
[ 5, 6, 7, 8, 9 ]