code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> class Array: def __init__(self, size, classname='org/python/Object', fill=None): self.size = size self.classname = classname self.fill = fill def process(self, context): context.add_opcodes(ICONST_val(self.size), JavaOpcodes.ANEWARRAY( ...
flexible
{ "blob_id": "67e0536dc9f38ab82fe30e715599fed93c5425a5", "index": 5142, "step-1": "<mask token>\n\n\nclass Array:\n\n def __init__(self, size, classname='org/python/Object', fill=None):\n self.size = size\n self.classname = classname\n self.fill = fill\n\n def process(self, context):\n ...
[ 12, 15, 16, 18, 23 ]
<|reserved_special_token_0|> @app.route('/publish', methods=['GET', 'POST']) def publish(): topic_user = request.args.get('touser') sub_user = request.args.get('fromuser') subscription_id = sub_user msg = request.args.get('msg') topic_id = topic_user publisher = pubsub_v1.PublisherClient() ...
flexible
{ "blob_id": "a76a0631c97ba539019790e35136f6fd7573e461", "index": 5469, "step-1": "<mask token>\n\n\n@app.route('/publish', methods=['GET', 'POST'])\ndef publish():\n topic_user = request.args.get('touser')\n sub_user = request.args.get('fromuser')\n subscription_id = sub_user\n msg = request.args.get...
[ 2, 3, 4, 5, 6 ]
##Problem 10 «The number of even elements of the sequence» (Medium) ##Statement ##Determine the number of even elements in the sequence ending with the number 0. a = True i = 0 while a is True:      x = int(input())      if x != 0:         if x%2 == 0:          i = i+1      else:         a =False print(i)
normal
{ "blob_id": "2eddd446dc59695b185be368b359bae78a868b90", "index": 9918, "step-1": "\n##Problem 10 «The number of even elements of the sequence» (Medium)\n##Statement\n##Determine the number of even elements in the sequence ending with the number 0. \n\n\na = True\ni = 0\nwhile a is True:\n     x = int(input())\n ...
[ 0 ]
import pynucastro as pyna rl = pyna.ReacLibLibrary() h_burn = rl.linking_nuclei(["h1", "he4", "c12", "c13", "n13", "n14", "n15", "o14", "o15", "o16","o17","o18", "f17", "f18","f19", ...
normal
{ "blob_id": "39b07f1a515787e80a1fb822e67e19e2301b894a", "index": 3285, "step-1": "<mask token>\n", "step-2": "<mask token>\nrc.write_network()\n<mask token>\ncomp.set_solar_like()\nrc.plot(outfile='cno_extras.png', rho=1000000.0, T=100000000.0, comp=comp,\n Z_range=[1, 13], N_range=[1, 13])\nrc.plot(outfile...
[ 0, 1, 2, 3, 4 ]
""" Python Challenge - Level 1 - What about making trans? """ import string #import requests #res = requests.get('http://www.pythonchallenge.com/pc/def/map.html') #res.raise_for_status() #print(res.text) INPUT_TEXT = string.ascii_lowercase # abcdefghijklmnopqrstuvwxyz OUTPUT_TEXT = INPUT_TEXT[2:]+INPUT_TEXT[:2...
normal
{ "blob_id": "3c03f71ef9de8825ecd7c89208c79f43c9fb7a56", "index": 9594, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('http://www.pythonchallenge.com/pc/def/ocr.html')\n", "step-3": "<mask token>\nINPUT_TEXT = string.ascii_lowercase\nOUTPUT_TEXT = INPUT_TEXT[2:] + INPUT_TEXT[:2]\nTRANSLATION_TABL...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Job: """ Job class which stores the attributes of the jobs """ def __init__(self, day, startTime, endTime, noOfChildren, hourlyRate): self.day = day self.startTime = startTime self.endTime = endTime self.noOfChildren = noOfChildren ...
flexible
{ "blob_id": "f57fa2787934dc2a002f82aa1af1f1d9a7f90da5", "index": 9947, "step-1": "<mask token>\n\n\nclass Job:\n \"\"\"\n Job class which stores the attributes of the jobs\n \"\"\"\n\n def __init__(self, day, startTime, endTime, noOfChildren, hourlyRate):\n self.day = day\n self.startTi...
[ 9, 11, 12, 13, 14 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(windowController, *args, **kwargs): textView = windowController.textView() document = windowController.document() if textView != None: dateFormat = time.strftime('%Y.%m.%d') textView.insertTe...
flexible
{ "blob_id": "e51ca78ca6751f8238a39d3eae55d6cc6ab65128", "index": 5797, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main(windowController, *args, **kwargs):\n textView = windowController.textView()\n document = windowController.document()\n if textView != None:\n dateFormat = ti...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def downgrade(): op.drop_index('ix_ballot_measure_tags_ballot_measure_id', 'ballot_measure_tags') op.drop_index('ix_ballot_measure_tags_tag_id', 'ballot_measure_tags') op.drop_table(u'ballot_measure_tags') op.drop_index('ix_stance_committee_id', 'stance') op.dr...
flexible
{ "blob_id": "7df55853d0f4f1bf56512c4427d7f91e9c1f2279", "index": 6524, "step-1": "<mask token>\n\n\ndef downgrade():\n op.drop_index('ix_ballot_measure_tags_ballot_measure_id',\n 'ballot_measure_tags')\n op.drop_index('ix_ballot_measure_tags_tag_id', 'ballot_measure_tags')\n op.drop_table(u'ballo...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> mpl.style.use('classic') <|reserved_special_token_0|> ax1.plot(chi2, color='r', linestyle='--', linewidth=2, markersize=5, label= '$\\chi^B_2$') ax1.axis([0, 300, -0.05, 0.2]) ax1.set_xlabel('$T\\,[\\mathrm{MeV}]$', fontsize=1...
flexible
{ "blob_id": "66904cbe3e57d9cc1ee385cd8a4c1ba3767626bd", "index": 923, "step-1": "<mask token>\n", "step-2": "<mask token>\nmpl.style.use('classic')\n<mask token>\nax1.plot(chi2, color='r', linestyle='--', linewidth=2, markersize=5, label=\n '$\\\\chi^B_2$')\nax1.axis([0, 300, -0.05, 0.2])\nax1.set_xlabel('$...
[ 0, 1, 2, 3, 4 ]
from discord.ext import commands import discord import os import random bot = commands.Bot(command_prefix="!") @bot.event async def on_ready(): print(f"Logged in as {bot.user.name}") @bot.command() async def ping(ctx): await ctx.send("pong") # Lucky command, it picks a number between 0-50 and spams your dm'...
normal
{ "blob_id": "b48bc9475a8dc593ba858af8ed4e930ae290fd69", "index": 6479, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@bot.event\nasync def on_ready():\n print(f'Logged in as {bot.user.name}')\n\n\n@bot.command()\nasync def ping(ctx):\n await ctx.send('pong')\n\n\n@bot.command()\nasync def luck...
[ 0, 1, 2, 3, 4 ]
from extras.plugins import PluginTemplateExtension from .models import BGPSession from .tables import BGPSessionTable class DeviceBGPSession(PluginTemplateExtension): model = 'dcim.device' def left_page(self): if self.context['config'].get('device_ext_page') == 'left': return self.x_page(...
normal
{ "blob_id": "be566041402dc1705aa9d644edc44de8792fbb3c", "index": 4850, "step-1": "<mask token>\n\n\nclass DeviceBGPSession(PluginTemplateExtension):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass DeviceBGPSessio...
[ 1, 4, 7, 8 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Oct 15 15:36:38 2021 @author: mav24 """ import pandas as pd import numpy as np from sklearn.preprocessing import QuantileTransformer, StandardScaler, PowerTransformer, MaxAbsScaler from sklearn.cross_decomposition import PLSRegression from sklearn.en...
normal
{ "blob_id": "4a17db6b65e1615b0d519581b3e63bc34ad16093", "index": 1288, "step-1": "<mask token>\n", "step-2": "<mask token>\ndata.drop(columns=drop, inplace=True)\n<mask token>\nmodel.fit(X_train, Y_train)\n<mask token>\nprint('With Standar Scaler')\nprint(f'The R2 accuracy is: {r2(Y_test, pred_test)}')\nprint(...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> if answ[1] == 'дата': apisay(datetime.date.today(), toho, torep)
flexible
{ "blob_id": "66444047f9e5eea845c8ac2dbaaf16fc2914d6ec", "index": 370, "step-1": "<mask token>\n", "step-2": "if answ[1] == 'дата':\n apisay(datetime.date.today(), toho, torep)\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
import multiprocessing import sys import warnings from pathlib import Path import attr import librosa import pandas as pd from rich.progress import BarColumn, Progress, TimeRemainingColumn from sklearn.preprocessing import LabelEncoder from tslearn.piecewise import SymbolicAggregateApproximation from tslearn.preproces...
normal
{ "blob_id": "0e57e25c11ba97aef5467f61d99065609e127f5b", "index": 2782, "step-1": "<mask token>\n\n\n@attr.s\nclass MusicDB(object):\n <mask token>\n <mask token>\n <mask token>\n\n @feat.default\n def _feat_default(self):\n our_feat = utils.load_tracks(givegenre=True, outliers=False, fill=F...
[ 4, 6, 8, 9, 11 ]
import sys import time import numpy import pb_robot import pyquaternion import pybullet as p from copy import deepcopy from actions import PlaceAction, make_platform_world from block_utils import get_adversarial_blocks, rotation_group, ZERO_POS, \ Quaternion, get_rotated_block, Pose, add_noise,...
normal
{ "blob_id": "5c1465bc70010ecabc156a04ec9877bbf66a229d", "index": 5150, "step-1": "<mask token>\n\n\nclass PandaAgent:\n\n def __init__(self, blocks, noise=5e-05, block_init_xy_poses=None,\n use_platform=False, use_vision=False, real=False,\n use_planning_server=False, use_learning_server=False,\...
[ 20, 22, 24, 25, 26 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from .models import CNNClassifier, load_weights, LastLayer_Alexnet, classes, MyResNet from .transforms import image_transforms, tensor_transform from .utils import newest_model, Dataset, load_data
flexible
{ "blob_id": "17781ae5e9c72232fbc11c7eda7daeaeb0fa3670", "index": 9277, "step-1": "<mask token>\n", "step-2": "from .models import CNNClassifier, load_weights, LastLayer_Alexnet, classes, MyResNet\nfrom .transforms import image_transforms, tensor_transform\nfrom .utils import newest_model, Dataset, load_data\n"...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while True: r, f = stream.read() cv2.imshow('IP Camera stream', f) if cv2.waitKey(1) & 255 == ord('q'): break cv2.destroyAllWindows() <|reserved_special_token_1|> <|reserved_special_token_0|> stream = cv2.Vi...
flexible
{ "blob_id": "f9db3c96bc3fd4911640d0428672c87072564b0d", "index": 710, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n r, f = stream.read()\n cv2.imshow('IP Camera stream', f)\n if cv2.waitKey(1) & 255 == ord('q'):\n break\ncv2.destroyAllWindows()\n", "step-3": "<mask token>...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- from sqlalchemy import or_ from ..extensions import db from .models import User def create_user(username): user = User(username) db.session.add(user) return user def get_user(user_id=None, **kwargs): if user_id is not None: return User.query.get(user_id) username ...
normal
{ "blob_id": "49c15f89225bb1dd1010510fe28dba34f6a8d085", "index": 4866, "step-1": "<mask token>\n\n\ndef get_user(user_id=None, **kwargs):\n if user_id is not None:\n return User.query.get(user_id)\n username = kwargs.pop('username')\n if username is not None:\n return User.query.filter_by(...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def strictly_greater_than(value): if value: return 'Greater than 100' elif value: return 'Greater than 10' else: return '10 or less' <|reserved_special_token_0|> <|reserved_special_token_1|> def strictly_greater_than(v...
flexible
{ "blob_id": "7620d76afc65ceb3b478f0b05339ace1f1531f7d", "index": 6708, "step-1": "<mask token>\n", "step-2": "def strictly_greater_than(value):\n if value:\n return 'Greater than 100'\n elif value:\n return 'Greater than 10'\n else:\n return '10 or less'\n\n\n<mask token>\n", "s...
[ 0, 1, 2, 3 ]
import tensorflow.keras from PIL import Image, ImageOps from os import listdir from os.path import isfile, join import numpy as np import glob import cv2 np.set_printoptions(suppress = True) # Load the model model = tensorflow.keras.models.load_model('./converted_keras/keras_model.h5') # Create the array of the righ...
normal
{ "blob_id": "13b69ec61d6b2129f1974ce7cae91c84100b3b58", "index": 449, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.set_printoptions(suppress=True)\n<mask token>\nfor image in path:\n n1 = cv2.imread(image)\n n2 = cv2.resize(n1, (244, 244))\n images.append(n2)\n print(image)\n<mask token>...
[ 0, 1, 2, 3, 4 ]
permissions = ('restart', ) commands = ('restart', ) def get_command(session, parsed_message): return 'stop', 'restart' def parse_response(permission, response): return response
normal
{ "blob_id": "acd5cf675522c90fc9fbc96bdeb52f66835626b4", "index": 3489, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_response(permission, response):\n return response\n", "step-3": "<mask token>\n\n\ndef get_command(session, parsed_message):\n return 'stop', 'restart'\n\n\ndef pars...
[ 0, 1, 2, 3, 4 ]
# This module is used to load pascalvoc datasets (2007 or 2012) import os import tensorflow as tf from configs.config_common import * from configs.config_train import * from configs.config_test import * import sys import random import numpy as np import xml.etree.ElementTree as ET # Original dataset organisation. DIR...
normal
{ "blob_id": "c33d625ebd6a40551d2ce0393fd78619601ea7ae", "index": 5834, "step-1": "<mask token>\n\n\nclass Dataset(object):\n\n def __init__(self):\n self.items_descriptions = {'image':\n 'A color image of varying height and width.', 'shape':\n 'Shape of the image', 'object/bbox':\...
[ 11, 12, 13, 14, 16 ]
<|reserved_special_token_0|> class VelocityLoss(nn.Module): def __init__(self, _mean, _std, config): super(VelocityLoss, self).__init__() self._mean = _mean self._std = _std self.device = config.device self.root_pos_dim = config.root_pos_dim self.pos_dim = config.p...
flexible
{ "blob_id": "edc66bdc365f9c40ee33249bd2d02c0c5f28256a", "index": 8386, "step-1": "<mask token>\n\n\nclass VelocityLoss(nn.Module):\n\n def __init__(self, _mean, _std, config):\n super(VelocityLoss, self).__init__()\n self._mean = _mean\n self._std = _std\n self.device = config.devi...
[ 14, 18, 19, 23, 24 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in red: turtle.forward(200) turtle.left(90) turtle.done() <|reserved_special_token_1|> <|reserved_special_token_0|> red = range(4) for i in red: turtle.forward(200) turtle.left(90) turtle.done() <|reserv...
flexible
{ "blob_id": "38fceb57977cb792be1a63e8571cd222facdf656", "index": 1142, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in red:\n turtle.forward(200)\n turtle.left(90)\nturtle.done()\n", "step-3": "<mask token>\nred = range(4)\nfor i in red:\n turtle.forward(200)\n turtle.left(90)\nturt...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Version(BaseVersion): def __init__(self, connection): super().__init__(connection) def update(self, force=False): """ :param force: :return: """ log.info('Updating to version %s' % DB_VERSION) try: log.in...
flexible
{ "blob_id": "12fd4e3bfb6821205a9b65b4d236b4158ec4ef1e", "index": 7345, "step-1": "<mask token>\n\n\nclass Version(BaseVersion):\n\n def __init__(self, connection):\n super().__init__(connection)\n\n def update(self, force=False):\n \"\"\"\n\n :param force:\n :return:\n \"...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "5485fe4f612ededc11e3a96dfd546e97a56cbe2a", "index": 3316, "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 ]
import os import sys import requests import urllib.parse import urllib.request import json from shutil import copyfile def sdssDownload(band, location, size, path): """ . sdssArchie populates a directory with links to raw images from the SDSS mission. These images are all in FITS format and su...
normal
{ "blob_id": "459bd36037158c9a6a38da6eadf45a3dc6f19e04", "index": 4405, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sdssDownload(band, location, size, path):\n \"\"\"\n .\n sdssArchie populates a directory with links to raw images \n from the SDSS mission. These images are all in F...
[ 0, 1, 2, 3 ]
from .most_serializers import *
normal
{ "blob_id": "a718949ed95b7d78f091b1e0f237eed151b102ae", "index": 2160, "step-1": "<mask token>\n", "step-2": "from .most_serializers import *\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#!/usr/bin/python3 import requests import urllib3 urllib3.disable_warnings() response = requests.get('https://freeaeskey.xyz', verify=False) data = response.text.encode('utf-8') key = data[data.index(b'<b>')+3:data.index(b'</b>')] print(key.decode('ascii'))
normal
{ "blob_id": "368e209f83cc0cade81791c8357e01e7e3f940c8", "index": 97, "step-1": "<mask token>\n", "step-2": "<mask token>\nurllib3.disable_warnings()\n<mask token>\nprint(key.decode('ascii'))\n", "step-3": "<mask token>\nurllib3.disable_warnings()\nresponse = requests.get('https://freeaeskey.xyz', verify=Fals...
[ 0, 1, 2, 3, 4 ]
# Copyright (C) 2020 Francis Sun, all rights reserved. """A copyright utility""" import datetime import argparse import os import os.path class Copyright: _file_type = { 'c/c++': ['h', 'c', 'cpp', 'cc'], 'python': ['py'], 'cmake': ['cmake'], 'vim': ['vim'], ...
normal
{ "blob_id": "dc05a441c21a67fbb3a1975b3fccb865a32731c8", "index": 4642, "step-1": "<mask token>\n\n\nclass Copyright:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def _c_cpp_formater(self):\n return '/* ' + self.declaration + ' */'\n for ft in _file_type['c/c++']:\n ...
[ 5, 7, 11, 12, 13 ]
import os import pandas as pd from tabulate import tabulate if __name__ == '__main__': bestPrecision = [0,0,0,0,0,0] bestPrecisionFile = ['','','','','',''] bestRecall = [0,0,0,0,0,0] bestRecallFile = ['','','','','',''] bestSupport = [0,0,0,0,0,0] bestSupportFile = ['','','','','',''] bes...
normal
{ "blob_id": "22c498d84f40455d89ed32ccf3bf8778cb159579", "index": 79, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n bestPrecision = [0, 0, 0, 0, 0, 0]\n bestPrecisionFile = ['', '', '', '', '', '']\n bestRecall = [0, 0, 0, 0, 0, 0]\n bestRecallFile = ['', '', '', ...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python #**************************************************************************** # fieldformat.py, provides non-GUI base classes for field formating # # TreeLine, an information storage program # Copyright (C) 2006, Douglas W. Bell # # This is free software; you can redistribute it and/or modify it ...
normal
{ "blob_id": "5e1398ed628917a42cc465e7cc2979601f0f4fbc", "index": 7865, "step-1": "<mask token>\n\n\nclass DateFormat(TextFormat):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, name, attrs={}):\n \"\"\...
[ 100, 168, 171, 173, 175 ]
<|reserved_special_token_0|> def _get_change_making_matrix(set_of_coins, r): matrix = [[(0) for _ in range(r + 1)] for _ in range(len(set_of_coins) + 1) ] for i in range(1, len(set_of_coins) + 1): matrix[i][0] = i return matrix def change_making(coins, target): """This function assum...
flexible
{ "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 ]
<|reserved_special_token_0|> class Category(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __str__(self): return self.category class Subcategory(models.Model): name = models.ForeignKey(Category, on_delete=models.CASCADE, null=Tr...
flexible
{ "blob_id": "a0dcfb738451c11ed4ff1428629c3f7bbf5c52c9", "index": 5649, "step-1": "<mask token>\n\n\nclass Category(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.category\n\n\nclass Subcategory(models.Model):\n name = models.ForeignKey(Categ...
[ 17, 20, 22, 24, 30 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Base: <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Base: def getTime(self): """ 获取时间戳 :return: """ return str(time.time...
flexible
{ "blob_id": "28a920072bad1b411d71f7f70cd991cb7dfbeb8c", "index": 8754, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Base:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Base:\n\n def getTime(self):\n \"\"\"\n 获取时间戳\n :return: \n \"\"\"\n retur...
[ 0, 1, 2, 3, 4 ]
from typing import List def uppercase_first_letter(string: str) ->str: return string[0:1].upper() + string[1:] string_list: List[str] = input('Please, input string: ').split(' ') result: str = '' for i, value in enumerate(string_list): result += (lambda index: '' if index == 0 else ' ')(i ) + upperc...
normal
{ "blob_id": "0555c577a8fb746cf2debb929d02b46cd3be4d7b", "index": 1062, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef uppercase_first_letter(string: str) ->str:\n return string[0:1].upper() + string[1:]\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef uppercase_first_letter(string: str...
[ 0, 1, 2, 3 ]
from interpreter import Interpreter from pretty_print import PrettyPrint from ast import Operator, Operation, Element class Token: operator = False empty = False def __init__(self, token): self.token = token if token == '+': self.operator = True elif token == '-': ...
normal
{ "blob_id": "0d6c1e74a274b3e8ad9c63ecaa125f79976db9b4", "index": 1734, "step-1": "<mask token>\n\n\nclass Token:\n operator = False\n empty = False\n\n def __init__(self, token):\n self.token = token\n if token == '+':\n self.operator = True\n elif token == '-':\n ...
[ 10, 11, 13, 15, 16 ]
from api.decidim_connector import DecidimConnector from api.participatory_processes_reader import ParticipatoryProcessesReader from api.version_reader import VersionReader API_URL = "https://meta.decidim.org/api" decidim_connector = DecidimConnector(API_URL) version_reader = VersionReader(decidim_connector) version = ...
normal
{ "blob_id": "88a469eba61fb6968db8cc5e1f93f12093b7f128", "index": 6973, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(version)\n<mask token>\n", "step-3": "<mask token>\nAPI_URL = 'https://meta.decidim.org/api'\ndecidim_connector = DecidimConnector(API_URL)\nversion_reader = VersionReader(decidim...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Tue Mar 16 16:11:46 2021 @author: Suman """ import numpy as np import cv2 rect = (0,0,0,0) startPoint = False endPoint = False def mark_object(event,x,y,flags,params): global rect,startPoint,endPoint # get mouse click if event == cv2.EVENT_LB...
normal
{ "blob_id": "0f3e19b02dbe508bc4e0ef7879af81a9eabfd8c9", "index": 6141, "step-1": "<mask token>\n\n\ndef mark_object(event, x, y, flags, params):\n global rect, startPoint, endPoint\n if event == cv2.EVENT_LBUTTONDOWN:\n if startPoint == True and endPoint == True:\n startPoint = False\n ...
[ 1, 2, 3, 4, 5 ]
from django.shortcuts import render from django.http import HttpResponse, HttpResponseRedirect from interface_app.models import TestTask, TestCase from interface_app.extend.task_run import run_cases import os import json from interface_app.apps import TASK_PATH, RUN_TASK_FILE """ 说明:接口任务文件,返回HTML页面 """ # 获取任务列表 def...
normal
{ "blob_id": "8be70543a7aa177d9ad48fb736228b1ffba5df16", "index": 6179, "step-1": "<mask token>\n\n\ndef run_task(request, tid):\n if request.method == 'GET':\n task_obj = TestTask.objects.get(id=tid)\n cases_list = task_obj.cases.split(',')\n cases_list.pop(-1)\n task_obj.status = ...
[ 1, 2, 3, 4, 5 ]
import reddit import tts import sys import praw import os #TODO: CENSOR CURSE WORDS,tag images that have curse words in them. strip punctuation from comment replies mp3 #TODO: pay for ads :thinking: buy views? #TODO: sort by top upvotes #todo: remove the formatting stuff #todo: redo ducking #todo quick scri...
normal
{ "blob_id": "fd57e13269ca00ed5eb05e00bd7999c041141187", "index": 4256, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f'NOW PROCESSING POST ID: {POST_ID}')\n<mask token>\ntts.comment_to_mp3(post_title, './quota.txt', 'titles', 0, randomize=True)\n<mask token>\nfor comment in comments_from_post:\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def _load_img(fp): img = cv2.imread(fp, cv2.IMREAD_UNCHANGED) if img.ndim == 3: img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) return img <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def _load_img(fp): img = cv2.imread(f...
flexible
{ "blob_id": "559e46aa4e9b55f8c01acf30fa01e106ab914116", "index": 5687, "step-1": "<mask token>\n\n\ndef _load_img(fp):\n img = cv2.imread(fp, cv2.IMREAD_UNCHANGED)\n if img.ndim == 3:\n img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n return img\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nde...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # coding: utf-8 # In[19]: import numpy as np import pandas as pd class simple_nn(): ''' This is simple nn class with 3 layers NN. In this class additional layer was added to the original layers from notebook given by Julian Stier and Sahib Julka. Moreover those functions were...
normal
{ "blob_id": "cdc32e7c767097a0eb0def71e55f0276982d6a96", "index": 5235, "step-1": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[19]:\n\n\nimport numpy as np\nimport pandas as pd\n\nclass simple_nn():\n '''\n This is simple nn class with 3 layers NN. In this class additional layer was added to the origin...
[ 0 ]
#!/usr/bin/env python3 import logging import datetime import os import time import json import prod import secret from logging.handlers import RotatingFileHandler import requests import sns from kafka import KafkaProducer logger = logging.getLogger() logger.setLevel('INFO') log_path = os.path.basename(__file__).split...
normal
{ "blob_id": "283b93437072f0fd75d75dab733ecab05dc9e1f3", "index": 3872, "step-1": "<mask token>\n\n\nclass Producer:\n\n def __init__(self, topic):\n kafka_uname = os.environ['KAFKA_USERNAME']\n kafka_pwd = os.environ['KAFKA_PASSWORD']\n kafka_hosts = os.environ['KAFKA_HOSTS']\n ssl...
[ 4, 7, 8, 9, 11 ]
# Generated by Django 3.0.4 on 2020-03-29 09:27 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('portfolio_app', '0008_feedback_product'), ] operations = [ migrations.RemoveField( model_name='feedback', name...
normal
{ "blob_id": "11ad3e1ab4ffd491e27998a7235b7e18857632ed", "index": 3141, "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 = [('portfolio_a...
[ 0, 1, 2, 3, 4 ]
from __future__ import print_function, unicode_literals import sys import ast import os import tokenize import warnings from io import StringIO def interleave(inter, f, seq): """Call f on each item in seq, calling inter() in between. """ seq = iter(seq) try: f(next(seq)) except StopIteratio...
normal
{ "blob_id": "8443d208a6a6bef82240235eeadbf6f8eaf77bcb", "index": 2995, "step-1": "<mask token>\n\n\nclass CodeGenerator:\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 t...
[ 43, 45, 82, 94, 103 ]
# 938. Range Sum of BST # Share # Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). # The binary search tree is guaranteed to have unique values. # Example 1: # Input: root = [10,5,15,3,7,null,18], L = 7, R = 15 # Output: 32 # Example 2: ...
normal
{ "blob_id": "8e1de62f2490d2276a834ae1ab0f1958649fa821", "index": 5503, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n <mask token>\n", "step-3": "class Solution:\n <mask token>\n\n def cal_sum(self, root, L, R, result):\n if not root:\n return result\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(ports) for p in ports: print(p[1]) if 'Arduino' in p[1]: ser = serial.Serial(port=p[0]) else: print('No Arduino Device was found connected to the computer') <|reserved_special_token_0|> while True...
flexible
{ "blob_id": "7c80c98e32f386362003ac3cd729fa9b279b8e8e", "index": 7316, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(ports)\nfor p in ports:\n print(p[1])\n if 'Arduino' in p[1]:\n ser = serial.Serial(port=p[0])\n else:\n print('No Arduino Device was found connected to the c...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for img in img_list: print(img['src']) <|reserved_special_token_1|> <|reserved_special_token_0|> url = 'http://www.pythonscraping.com/pages/page3.html' html = urlopen(url) html_data = BeautifulSoup(html.read(), 'lxml') img_...
flexible
{ "blob_id": "00609c4972269c36bbfcf5bec2a8648f812b6092", "index": 9422, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor img in img_list:\n print(img['src'])\n", "step-3": "<mask token>\nurl = 'http://www.pythonscraping.com/pages/page3.html'\nhtml = urlopen(url)\nhtml_data = BeautifulSoup(html.read...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """Utilities for reading BEL Script.""" import time from typing import Iterable, Mapping, Optional, Set from .constants import ( ANNOTATION_PATTERN_FMT, ANNOTATION_URL_FMT, NAMESPACE_PATTERN_FMT, NAMESPACE_URL_FMT, format_annotation_list, ) __all__ = [ 'make_knowledge_header', ] de...
normal
{ "blob_id": "46b8d0ba58d4bf17021b05fc03bd480802f65adf", "index": 6132, "step-1": "<mask token>\n\n\ndef make_knowledge_header(name: str, version: Optional[str]=None,\n description: Optional[str]=None, authors: Optional[str]=None, contact:\n Optional[str]=None, copyright: Optional[str]=None, licenses: Optio...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def K_step(x): if not x.shape: return S.One assert len(x.shape) == 1 n = x.shape[0] if n == 2: return x[1] return Piecewise((1, Equal(n, 1)), (x[1], Equal(n, 2)), (K(x[:n - 1]) * x[n - 1] + K(x[:n - 2]), True)) <|reserved_special_token_0|> @...
flexible
{ "blob_id": "b00c07ee3cdba55800c9701b7b8b0e3c9079e9f8", "index": 6272, "step-1": "<mask token>\n\n\ndef K_step(x):\n if not x.shape:\n return S.One\n assert len(x.shape) == 1\n n = x.shape[0]\n if n == 2:\n return x[1]\n return Piecewise((1, Equal(n, 1)), (x[1], Equal(n, 2)), (K(x[:n...
[ 3, 4, 5, 6, 7 ]
from golem import actions from projects.golem_integration.pages import golem_steps description = 'close_window_by_partial_title action' def test(data): actions.navigate(data.env.url + 'tabs/') actions.send_keys('#title', 'lorem ipsum') actions.click('#goButtonCustom') actions.assert_amount_of_windows(...
normal
{ "blob_id": "8fe45332ce09195beabb24c8cbb56868c564ded4", "index": 2132, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test(data):\n actions.navigate(data.env.url + 'tabs/')\n actions.send_keys('#title', 'lorem ipsum')\n actions.click('#goButtonCustom')\n actions.assert_amount_of_windo...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def get_human_choice(): print('(1) Rock\n(2) Paper\n(3) Scissors') return OPTIONS[int(input('Enter the number of your choice: ')) - 1] def get_computer_choice(): return random.choice(OPTIONS) def print_choices(human_choice, computer_choice): print(f'You chose {human_ch...
flexible
{ "blob_id": "2e6bce05c8ba21aa322e306d2cdb8871531d7341", "index": 5499, "step-1": "<mask token>\n\n\ndef get_human_choice():\n print('(1) Rock\\n(2) Paper\\n(3) Scissors')\n return OPTIONS[int(input('Enter the number of your choice: ')) - 1]\n\n\ndef get_computer_choice():\n return random.choice(OPTIONS)...
[ 6, 7, 8, 9 ]
<|reserved_special_token_0|> def maskRCNN_model(): config_file = ( '/home/raj/data/Raj/IndividualProject/maskRCNN/configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml' ) cfg.merge_from_file(config_file) cfg.merge_from_list(['MODEL.DEVICE', 'cpu']) coco_demo = COCODemo(cfg, min_image_si...
flexible
{ "blob_id": "2c8b8e9767ac8400fb6390e0851d9df10df7cd8c", "index": 8729, "step-1": "<mask token>\n\n\ndef maskRCNN_model():\n config_file = (\n '/home/raj/data/Raj/IndividualProject/maskRCNN/configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml'\n )\n cfg.merge_from_file(config_file)\n cfg.me...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(len(lines)): if i + 1 < len(lines): lines[i] = str("'") + str(lines[i]).replace('\r', '').replace('\n', '' ) + str("',") elif i + 1 == len(lines): lines[i] = str("'") + str(lines[...
flexible
{ "blob_id": "454fd88af552d7a46cb39167f21d641420973959", "index": 2312, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(lines)):\n if i + 1 < len(lines):\n lines[i] = str(\"'\") + str(lines[i]).replace('\\r', '').replace('\\n', ''\n ) + str(\"',\")\n elif i + 1 ==...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while True: elem = input('Enter a letter : (type quit to quit) ') if elem.lower() != 'quit': newList.append(elem) else: break for item in newList: if item not in noDuplicate: noDuplicate.app...
flexible
{ "blob_id": "7273592ab8fea10d9a3cde58690063690c74b746", "index": 4635, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n elem = input('Enter a letter : (type quit to quit) ')\n if elem.lower() != 'quit':\n newList.append(elem)\n else:\n break\nfor item in newList:\n i...
[ 0, 1, 2, 3 ]
from django.core.management.base import BaseCommand, CommandError from tasks.redisqueue import RedisQueue from django.conf import settings class Command(BaseCommand): def handle(self, *args, **options): rqueue = RedisQueue(settings.REDIS_URL) rqueue.worker()
normal
{ "blob_id": "cccf6ec50ae00d8e00a1a53ea06fa8b6d061b72e", "index": 8258, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Command(BaseCommand):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Command(BaseCommand):\n\n def handle(self, *args, **options):\n rqueue = RedisQueue(se...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- __author__ = 'tqs' from win32com.client import Dispatch import win32com.client import time import os import re import win32api ''' windows操作部分说明: 考试波及知识点: 1.删除文件及文件夹 2.复制文件及文件夹 3.移动文件及文件夹 4.文件及文件夹改名 5.文件属性 考试样例: 1、在“蕨类植物”文件夹中,新建一个子文件夹“薄囊蕨类”。 2、将文件“淡水藻.ddd”移动到“藻类植物”文件夹中。 3、设置“螺旋藻.aaa”文件属性为“只读”...
normal
{ "blob_id": "b453006b4d4c5f17bb58110fe8197d7796ca0c6c", "index": 467, "step-1": "<mask token>\n\n\nclass ExcelOperation:\n\n def __init__(self, filename=None):\n self.xlApp = win32com.client.Dispatch('Excel.Application')\n if filename:\n self.filename = filename\n self.xlBo...
[ 42, 52, 64, 71, 87 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class face_verifier: <|reserved_special_token_0|> def verify_person(self, f1, f2): batch_tensor = torch.cat([f1, f2], 0) output_feat = self.model(batch_tensor.cuda()) sim = torch.nn.CosineSimilar...
flexible
{ "blob_id": "0659df48bb150582917e333a7a25d2d25395dfda", "index": 1381, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass face_verifier:\n <mask token>\n\n def verify_person(self, f1, f2):\n batch_tensor = torch.cat([f1, f2], 0)\n output_feat = self.model(batch_tensor.cuda())\n ...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def EPGAD(ReportPath, Hi=None, GUi=None): if Hi == None: Hi = sha256(str(random()).encode()).hexdigest() jsn = open(ReportPath, 'rt').read() jsnld = loads(jsn) print('Report Loaded') print('Finding Subject Information') if 'subject' in jsnld.keys(): ...
flexible
{ "blob_id": "8f554166c28fe4c9a093568a97d39b6ba515241b", "index": 3196, "step-1": "<mask token>\n\n\ndef EPGAD(ReportPath, Hi=None, GUi=None):\n if Hi == None:\n Hi = sha256(str(random()).encode()).hexdigest()\n jsn = open(ReportPath, 'rt').read()\n jsnld = loads(jsn)\n print('Report Loaded')\n...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(was) <|reserved_special_token_1|> was = input() print(was)
flexible
{ "blob_id": "e12c411814efd7cc7417174b51f0f756589ca40b", "index": 3325, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(was)\n", "step-3": "was = input()\nprint(was)\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
""" ------------------------------------------------------- Stack utilities ------------------------------------------------------- Author: Evan Attfield ID: 180817010 Email: attf7010@mylaurier.ca __updated__ = "Jan 22, 2019" ------------------------------------------------------- """ from Stack_array...
normal
{ "blob_id": "dab9b58b08b562d902ee0ae1104198cb1ebbffe5", "index": 1928, "step-1": "<mask token>\n\n\ndef array_to_stack(stack, source):\n \"\"\"\n -------------------------------------------------------\n Pushes contents of source onto stack. At finish, source is empty.\n Last value in source is at bo...
[ 4, 9, 12, 13, 14 ]
from web3.auto.infura import w3 import json import os with open("contract_abi.json") as f: info_json = json.load(f) abi = info_json mycontract = w3.eth.contract(address='0x091FDeb7990D3E00d13c31b81841d56b33164AD7', abi=abi) myfilter = mycontract.events.currentResponderState.createFilter(fromBlock=16147303) #myfilt...
normal
{ "blob_id": "8921c0a17e90f7113d1e0be630a15fc9d74d1780", "index": 8519, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('contract_abi.json') as f:\n info_json = json.load(f)\n<mask token>\nprint(abi)\nprint(myfilter)\n", "step-3": "<mask token>\nwith open('contract_abi.json') as f:\n info...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def getworld_data(url, header): headers = header res = requests.get(url, headers=headers) res.encoding = 'UTF-8' pattern = re.compile( '(\'\\{"(\\w+)":{"active":(.*?),"confirmed":(.*?),"deaths":(.*?),"recovered":(.*?),"relative_active":(.*?),"relative_active_start_...
flexible
{ "blob_id": "0677e12bc9733c76bff7ed3fe83e3800e64e9a10", "index": 7633, "step-1": "<mask token>\n\n\ndef getworld_data(url, header):\n headers = header\n res = requests.get(url, headers=headers)\n res.encoding = 'UTF-8'\n pattern = re.compile(\n '(\\'\\\\{\"(\\\\w+)\":{\"active\":(.*?),\"confir...
[ 2, 3, 4, 5, 6 ]
# ---------------------MODULE 1 notes-------------------- # . # . # . # . # . # . # . # . # . # . # save as (file).py first if not it will not work print("Hello") # control s to save
normal
{ "blob_id": "bb64da929ff2e1e04267518ec93a28bedb5a4de5", "index": 7306, "step-1": "<mask token>\n", "step-2": "print('Hello')\n", "step-3": "# ---------------------MODULE 1 notes--------------------\r\n# .\r\n# .\r\n# .\r\n# .\r\n# .\r\n# .\r\n# .\r\n# .\r\n# .\r\n# .\r\n\r\n# save as (file).py first if not i...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from .data_processing import make_request_data, clear_request_data, get_token_from_text from .review import Review
flexible
{ "blob_id": "5d654c056e6ef01e72821427c4f8dcb285755ee9", "index": 2933, "step-1": "<mask token>\n", "step-2": "from .data_processing import make_request_data, clear_request_data, get_token_from_text\nfrom .review import Review\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, ...
[ 0, 1 ]
import numpy as np import scipy.sparse as sparse from .world import World from . import util from . import fem from . import linalg def solveFine(world, aFine, MbFine, AbFine, boundaryConditions): NWorldCoarse = world.NWorldCoarse NWorldFine = world.NWorldCoarse * world.NCoarseElement NpFine = np.prod(NWo...
normal
{ "blob_id": "1b3493322fa85c2fe26a7f308466c4a1c72d5b35", "index": 4637, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solveCoarse(world, aFine, MbFine, AbFine, boundaryConditions):\n NWorldCoarse = world.NWorldCoarse\n NWorldFine = world.NWorldCoarse * world.NCoarseElement\n NCoarseEleme...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python #coding=utf-8 #author:maohan #date:20160706 #decription:通过百度api获取相关信息,并保存为xls格式 #ver:1.0 import urllib2 import json import sys from pyExcelerator import * def bd_finder(qw,region,page_num): page_size='20' bd_ak='wkEmrv7B1l0KPpi30F1G2VMx10xEdeol' bd_url='http://api.map.baidu.com/place/v2/search?...
normal
{ "blob_id": "941a93c66a5131712f337ad055bbf2a93e6ec10d", "index": 1634, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bd_finder(qw, region, page_num):\n page_size = '20'\n bd_ak = 'wkEmrv7B1l0KPpi30F1G2VMx10xEdeol'\n bd_url = 'http://api.map.baidu.com/place/v2/search?'\n furl = (bd_ur...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class OrgStaff(db.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "b0f92b5e4cc972aca84a29b4568e85836f155273", "index": 3774, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass OrgStaff(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 to...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import wx class test(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,"TestFrame",size=(500,500)) if __name__ == '__main__': app = wx.PySimpleApp() frame = test(parent=None,id=-1,) frame.show() app.mainloop()
normal
{ "blob_id": "e204cbbf36ac180eba0e95916345088c77bca7c0", "index": 5001, "step-1": "<mask token>\n\n\nclass test(wx.Frame):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass test(wx.Frame):\n\n def __init__(self, parent, id):\n wx.Frame.__init__(self, parent, id, 'TestFrame', s...
[ 1, 2, 3, 4, 5 ]
for i in range(0, 20): if i % 20 == 0: print('Stop It') else: print('The For Loop Failed')
normal
{ "blob_id": "bfb2d7b811fd450b53493375fa130649349d308f", "index": 174, "step-1": "<mask token>\n", "step-2": "for i in range(0, 20):\n if i % 20 == 0:\n print('Stop It')\nelse:\n print('The For Loop Failed')\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] ...
[ 0, 1 ]
<|reserved_special_token_0|> class Net(nn.Module): <|reserved_special_token_0|> <|reserved_special_token_0|> def _initialize_weights(self): pass <|reserved_special_token_1|> <|reserved_special_token_0|> class Net(nn.Module): def __init__(self): super(Net, self).__init__() ...
flexible
{ "blob_id": "49cdeb59e75ed93122b3a62fbdc508b7d66166d6", "index": 2337, "step-1": "<mask token>\n\n\nclass Net(nn.Module):\n <mask token>\n <mask token>\n\n def _initialize_weights(self):\n pass\n", "step-2": "<mask token>\n\n\nclass Net(nn.Module):\n\n def __init__(self):\n super(Net,...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def get_U_S_T_from_WM(WM): U = {} S = {} T = {} for wm in WM.WM: U[str(wm.values)] = float(WM['TRANS'].sel(WM=wm).groupby( 'TIME.month').mean('TIME').mean(dim='month').values) S[str(wm.values)] = float(WM['PSAL'].sel(WM=wm).groupby( ...
flexible
{ "blob_id": "40b94a3be27ebb0d8e3e67fddabe1dc68646169c", "index": 9881, "step-1": "<mask token>\n\n\ndef get_U_S_T_from_WM(WM):\n U = {}\n S = {}\n T = {}\n for wm in WM.WM:\n U[str(wm.values)] = float(WM['TRANS'].sel(WM=wm).groupby(\n 'TIME.month').mean('TIME').mean(dim='month').val...
[ 10, 11, 13, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': ROOT_PATH = '/media/andreis/storage/datasets/pku-autonomous-driving/' df = pd.read_csv(ROOT_PATH + 'train.csv') df_test = pd.read_csv(ROOT_PATH + 'sample_submission.csv') train_images_dir...
flexible
{ "blob_id": "1861c394fb02643d2e6ac8362f3340f512ef6d72", "index": 6402, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n ROOT_PATH = '/media/andreis/storage/datasets/pku-autonomous-driving/'\n df = pd.read_csv(ROOT_PATH + 'train.csv')\n df_test = pd.read_csv(ROOT_PATH +...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def PMHD(p, chi, b): return b ** 2 / p * (1 + sin(chi) ** 2) def xMHD(p, chi, b): return -b ** 2 / p ** 2 * sin(chi) * cos(chi) <|reserved_special_token_0|> def xBGI(p, chi, b): Q = 0.7 * p / b ** 0.57 / sqrt(cos(chi)) if Q > 1: A = 1 else: A = Q ...
flexible
{ "blob_id": "660334be611c30397c2f33890e1bca1fc43bd01f", "index": 2420, "step-1": "<mask token>\n\n\ndef PMHD(p, chi, b):\n return b ** 2 / p * (1 + sin(chi) ** 2)\n\n\ndef xMHD(p, chi, b):\n return -b ** 2 / p ** 2 * sin(chi) * cos(chi)\n\n\n<mask token>\n\n\ndef xBGI(p, chi, b):\n Q = 0.7 * p / b ** 0....
[ 3, 5, 6, 7, 8 ]
class Enumerator(object): """For Python we just wrap the iterator""" def __init__(self, next): self.iterator = next def __next__(self): return next(self.iterator) # Python 2.7 next = __next__ def __iter__(self): return self
normal
{ "blob_id": "1ca20b0cd9217623ff039ab352acd09df8dfae1b", "index": 8235, "step-1": "class Enumerator(object):\n <mask token>\n <mask token>\n\n def __next__(self):\n return next(self.iterator)\n <mask token>\n\n def __iter__(self):\n return self\n", "step-2": "class Enumerator(object...
[ 3, 4, 5, 6, 7 ]
from django.contrib.auth.hashers import make_password from django.core import mail from rest_framework import status from django.contrib.auth.models import User import time from api.tests.api_test_case import CustomAPITestCase from core.models import Member, Community, LocalCommunity, TransportCommunity, Profile, Noti...
normal
{ "blob_id": "75c00eec7eacd37ff0b37d26163c2304620bb9db", "index": 5868, "step-1": "<mask token>\n\n\nclass MemberTests(CustomAPITestCase):\n\n def setUp(self):\n \"\"\"\n Make a user for authenticating and\n testing community actions\n \"\"\"\n owner = self.user_model.objects...
[ 23, 29, 33, 36, 38 ]
import turtle import random shaan = turtle.Turtle() #shaan.color(50,50,50) #shaan.begin_fill() for i in range (2): shaan.forward(200) shaan.right(90) shaan.forward(250) shaan.right(90) shaan.left(60) for i in range(4): shaan.forward(200) shaan.right(120) shaan.forward(100) shaan.left(150) shaan.forward(100)...
normal
{ "blob_id": "6f13ebe7355d530ba3403aab54b313ecf35b1261", "index": 4523, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(2):\n shaan.forward(200)\n shaan.right(90)\n shaan.forward(250)\n shaan.right(90)\nshaan.left(60)\nfor i in range(4):\n shaan.forward(200)\n shaan.right(1...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class CountedList(UserList): def Count(self): self.cnt = Counter(self.data) return self.cnt def append(self, item): super(CountedList, self).append(item) global y y = self.Count() <|reserved_special_token_0|> <|reserved_special_token_1...
flexible
{ "blob_id": "1cf4fc37e030a895cb36f537ce9e92df34acfb8b", "index": 7659, "step-1": "<mask token>\n\n\nclass CountedList(UserList):\n\n def Count(self):\n self.cnt = Counter(self.data)\n return self.cnt\n\n def append(self, item):\n super(CountedList, self).append(item)\n global y\...
[ 3, 4, 5, 6, 7 ]
import sys sys.setrecursionlimit(1000000) n, q = map(int, input().split()) graph = [set([]) for _ in range(n)] for _ in range(n - 1): a, b = map(int, input().split()) graph[a - 1].add(b - 1) graph[b - 1].add(a - 1) def dfs(i): if temp[i]: return temp[i] = True if i in odd: for...
normal
{ "blob_id": "bab6b9a0178da119f753deb6c626dd5c41db2bdd", "index": 2004, "step-1": "<mask token>\n\n\ndef dfs(i):\n if temp[i]:\n return\n temp[i] = True\n if i in odd:\n for j in graph[i]:\n even.add(j)\n dfs(j)\n else:\n for j in graph[i]:\n odd.a...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class SaveConfigFile: <|reserved_special_token_0|> def __init__(self, fileName='../conf/main.ini'): self.config = ConfigParser.ConfigParser() self.fileName = fileName def saveConfigFile(self, configMainName, configSubName, value): """ :param ...
flexible
{ "blob_id": "b61bb47f3e059c607447cea92ce1712825735822", "index": 2373, "step-1": "<mask token>\n\n\nclass SaveConfigFile:\n <mask token>\n\n def __init__(self, fileName='../conf/main.ini'):\n self.config = ConfigParser.ConfigParser()\n self.fileName = fileName\n\n def saveConfigFile(self, ...
[ 3, 4, 5, 6, 7 ]
""" Plot funcs Jan, 2018 Rose Yu @Caltech """ import matplotlib.pyplot as plt import seaborn as sns from util.matutil import * from util.batchutil import * def plot_img(): """ plot ground truth (left) and reconstruction (right) showing b/w image data of mnist """ plt.subplot(121) plt.imshow...
normal
{ "blob_id": "cca9d91fe20e58f233ccfc4100edb748356ed234", "index": 6311, "step-1": "<mask token>\n\n\ndef plot_img():\n \"\"\" \n plot ground truth (left) and reconstruction (right)\n showing b/w image data of mnist\n \"\"\"\n plt.subplot(121)\n plt.imshow(data.data.numpy()[0,].squeeze())\n pl...
[ 1, 2, 3, 4, 5 ]
import gdal import sys, gc sys.path.append("..") import getopt import redis import time import subprocess import numpy as np from os import listdir, makedirs from os.path import isfile, join, exists from operator import itemgetter from natsort import natsorted from config import DatasetConfig, RasterParams from datase...
normal
{ "blob_id": "2b82d66803ae0a0b03204318975d3c122f34f0cf", "index": 7003, "step-1": "<mask token>\n\n\ndef main(argv):\n \"\"\"\n Main function which shows the usage, retrieves the command line parameters and invokes the required functions to do\n the expected job.\n\n :param argv: (dictionary) options ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> @app.before_first_request def create_tables(): pass <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> db.init_app(app) <|reserved_special_token_0|> @app.before_first_request def create_tables(): pass add_module_gamma(api) <|reserved_...
flexible
{ "blob_id": "fbb081fd52b14336ab4537bb795105bcd6a03070", "index": 3045, "step-1": "<mask token>\n\n\n@app.before_first_request\ndef create_tables():\n pass\n\n\n<mask token>\n", "step-2": "<mask token>\ndb.init_app(app)\n<mask token>\n\n\n@app.before_first_request\ndef create_tables():\n pass\n\n\nadd_mod...
[ 1, 2, 3, 4, 5 ]
# -*- coding:utf-8 -*- ''' Created on 2016��4��8�� @author: liping ''' import sys from PyQt4 import QtGui,QtCore class QuitButton(QtGui.QWidget): def __init__(self,parent = None): QtGui.QWidget.__init__(self,parent) self.setGeometry(300,300,250,150) self.setWindowTitle('quitButto...
normal
{ "blob_id": "5a3431b79b8f42b3042bb27d787d0d92891a7415", "index": 3947, "step-1": "<mask token>\n\n\nclass QuitButton(QtGui.QWidget):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass QuitButton(QtGui.QWidget):\n\n def __init__(self, parent=None):\n QtGui.QWidget.__init__(self...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class Pastebin(models.Model): <|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 Pastebin(models.Model): <|reserved_special_token_0|> ...
flexible
{ "blob_id": "3badf65a5301cc9cf26811e3989631aec5d31910", "index": 2709, "step-1": "<mask token>\n\n\nclass Pastebin(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Pastebin(models.Model):\n <mask token>\n <mask token>\n <mask...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class LabeledEntry(sw.LabeledWidget): <|reserved_special_token_0|> @property def value(self): return self.get() <|reserved_special_token_0|> def show(self, *args): """Show only the specified subwidgets. 'all' or no arguments reverts to showing...
flexible
{ "blob_id": "111186f1d45b9cf3bf9065c7fa83a8f3f796bbe1", "index": 5841, "step-1": "<mask token>\n\n\nclass LabeledEntry(sw.LabeledWidget):\n <mask token>\n\n @property\n def value(self):\n return self.get()\n <mask token>\n\n def show(self, *args):\n \"\"\"Show only the specified subw...
[ 5, 6, 8, 9, 11 ]
class Client: def __init__(self, id, color): self.id = id self.arrival = {} self.leave = {} self.server = {} self.queue = 0 self.served = 0 self.color = color def set_arrival(self, arrival): self.arrival[self.queue] = arrival def set_leave(s...
flexible
{ "blob_id": "5dc201f743705d6a57dfb61ec2cc2a827db0ba25", "index": 7234, "step-1": "class Client:\n\n def __init__(self, id, color):\n self.id = id\n self.arrival = {}\n self.leave = {}\n self.server = {}\n self.queue = 0\n self.served = 0\n self.color = color\n\...
[ 5, 6, 7, 8, 9 ]
# -*- coding:utf-8 -*- import math r = float(input()) print("{0:f} {1:f}".format(r*r*math.pi,2*r*math.pi))
normal
{ "blob_id": "e28cca2273e1c3ad4b8a955843e7dfb45c00694c", "index": 3246, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('{0:f} {1:f}'.format(r * r * math.pi, 2 * r * math.pi))\n", "step-3": "<mask token>\nr = float(input())\nprint('{0:f} {1:f}'.format(r * r * math.pi, 2 * r * math.pi))\n", "step-...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> soup.find('td', {'style': 'color:red'}).text <|reserved_special_token_1|> <|reserved_special_token_0|> url = 'https://goodinfo.tw/StockInfo/StockDividendPolicy.asp?STOCK_ID=2002' headers = {'User-Agent': 'Mozilla/5.0 (Windo...
flexible
{ "blob_id": "a5918679b6e3a9bde54808264d9526c6a191578f", "index": 7737, "step-1": "<mask token>\n", "step-2": "<mask token>\nsoup.find('td', {'style': 'color:red'}).text\n", "step-3": "<mask token>\nurl = 'https://goodinfo.tw/StockInfo/StockDividendPolicy.asp?STOCK_ID=2002'\nheaders = {'User-Agent':\n 'Moz...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Callback(HCallback): def __init__(self): pass @staticmethod def run(drawable): drawable.anchorAt(H.CENTER).fill(choice([color1, color2])) HOscillator().target(drawable).property(H.ROTATION).range(-5, 5).speed( 1).freq(4).currentStep(...
flexible
{ "blob_id": "b8a41c56a31acab0181ec364f76010ac12119074", "index": 5489, "step-1": "<mask token>\n\n\nclass Callback(HCallback):\n\n def __init__(self):\n pass\n\n @staticmethod\n def run(drawable):\n drawable.anchorAt(H.CENTER).fill(choice([color1, color2]))\n HOscillator().target(dr...
[ 3, 5, 6, 7, 8 ]
#!/usr/bin/python3 ''' generator.py This program inputs a strings, and outputs the corresponding hex Creator: Ethan Knight Email: ethantknight@gmail.com Published: 20181116 ''' import sys import time import binascii def main(): print("\n", sys.version_info) try: while True: ...
normal
{ "blob_id": "a52cbe6dbf4b4fc82d09e5f34e6e135933f3af38", "index": 1418, "step-1": "<mask token>\n\n\ndef main():\n print('\\n', sys.version_info)\n try:\n while True:\n print('\\n\\nPress Ctrl+C to exit.')\n usr = test()\n out = binascii.hexlify(bytes(usr, encoding='u...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def square_root(n): start = 1 end = n if n == 0 or n == 1: return n while start <= end: mid = (start + end) // 2 if mid * mid == n: return mid elif mid * mid < n: ...
flexible
{ "blob_id": "f9b53df799b3e6b71282c84a625ea5915ccb8014", "index": 1966, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef square_root(n):\n start = 1\n end = n\n if n == 0 or n == 1:\n return n\n while start <= end:\n mid = (start + end) // 2\n if mid * mid == n:\n ...
[ 0, 1, 2 ]
from django.contrib import admin from mptt.admin import MPTTModelAdmin from product.models import Item,Product,Category # Register your models here. admin.site.register(Category,MPTTModelAdmin) admin.site.register(Item) admin.site.register(Product)
normal
{ "blob_id": "fcd3e4c0d42649833e6c5ff6414c993654691d16", "index": 188, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Category, MPTTModelAdmin)\nadmin.site.register(Item)\nadmin.site.register(Product)\n", "step-3": "from django.contrib import admin\nfrom mptt.admin import MPTTModelAd...
[ 0, 1, 2, 3 ]
import csv, io from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.decorators import permission_required from django.views import generic from itertools import chain from .models import Player, League, Team class IndexView(generic.ListView): templ...
normal
{ "blob_id": "bce794616889b80c152a8ebec8d02e49a96684e9", "index": 2955, "step-1": "<mask token>\n\n\nclass IndexView(generic.ListView):\n template_name = 'players/players.html'\n context_object_name = 'players'\n\n def get_queryset(self):\n return list(chain(Player.objects.all(), Player._meta.get_...
[ 4, 7, 8, 9, 10 ]
#Max Low #9-25-17 #quiz2.py -- numbers , bigger smaller same, divisible by 3, product and correct person numone = int(input('Enter a number: ')) numtwo = int(input('Enter a 2nd number: ')) if numone > numtwo: print('The first number is bigger') elif numtwo > numone: print('The second number is bigger') else: ...
normal
{ "blob_id": "a67612e8301728d1fb366d7c8909fa830f04bf45", "index": 9739, "step-1": "<mask token>\n", "step-2": "<mask token>\nif numone > numtwo:\n print('The first number is bigger')\nelif numtwo > numone:\n print('The second number is bigger')\nelse:\n print('The numbers are the same')\nif numone % 3 ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open('file.txt', 'w') as file: content = file.write('Tanyuhich') try: browser = webdriver.Chrome() browser.get('http://suninjuly.github.io/file_input.html') input1 = browser.find_element_by_name('firstname') ...
flexible
{ "blob_id": "03270285c6dc99d8dcb9804270421f36b573048c", "index": 2863, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('file.txt', 'w') as file:\n content = file.write('Tanyuhich')\ntry:\n browser = webdriver.Chrome()\n browser.get('http://suninjuly.github.io/file_input.html')\n inpu...
[ 0, 1, 2, 3 ]
""" This module provides a script to extract data from all JSON files stored in a specific directory and create a HTML table for an better overview of the data. .. moduleauthor:: Maximilian Springenberg <mspringenberg@gmail.com> | """ from collections import defaultdict from argparse import ArgumentParser import os...
normal
{ "blob_id": "d6e836140b1f9c955711402111dc07e74b4a23b1", "index": 1621, "step-1": "<mask token>\n\n\ndef jsons_to_table(dir_jsons, dir_out, name, format='html'):\n \"\"\"\n Extracts the informations stored in the JSON files and stores creates an HTML-table for them.\n\n :param dir_jsons: directory of JS...
[ 3, 4, 5, 6, 7 ]
from django.shortcuts import render from .models import Votings from .serializers import VotingsSerializer from rest_framework.response import Response from rest_framework import status from rest_framework.decorators import api_view import requests, json @api_view(['GET']) def votings(request): votings = Votings....
normal
{ "blob_id": "c3ecac1c0facbf6f0905bb03fd337a7f4f5bbeff", "index": 4376, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@api_view(['GET'])\ndef votings(request):\n votings = Votings.objects.all()\n if votings:\n return Response({}, status=status.HTTP_404_NOT_FOUND)\n else:\n seri...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class ReportingDealer(game_dealer.GameDealer): <|reserved_special_token_0|> def Report(self): """For testing.""" return [p.hand for p in self.players] class TestPlayCards(unittest.TestCase): def testSmall(self): little = ReportingDealer(1, 1).Report...
flexible
{ "blob_id": "06a721c12e3140d4d1cf544a598f512595c4ab66", "index": 3013, "step-1": "<mask token>\n\n\nclass ReportingDealer(game_dealer.GameDealer):\n <mask token>\n\n def Report(self):\n \"\"\"For testing.\"\"\"\n return [p.hand for p in self.players]\n\n\nclass TestPlayCards(unittest.TestCase...
[ 8, 10, 11, 12, 13 ]