code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
# Unsolved:Didn't try coz of this warning: # If you use Python, then submit solutions on PyPy. Try to write an efficient solution. from sys import stdin from collections import defaultdict t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int, stdin.readline().strip().split())) d...
normal
{ "blob_id": "789f098fe9186d2fbda5417e9938930c44761b83", "index": 6760, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(t):\n n = int(input())\n arr = list(map(int, stdin.readline().strip().split()))\n d = defaultdict(int)\n maxnum = 0\n for num in arr:\n d[num] += 1\n ...
[ 0, 1, 2, 3, 4 ]
#题目014:将一个正整数分解质因数 #【编程思路】类似手算分解质因数的过程,找出因数后,原数字缩小 ''' 找出质因数并不难,把他们打印出来有点小烦 ''' num = int(input('请输入一个整数:')) original=num a= [] while num > 1: for i in range(2,num+1): if num%i == 0: a.append(i) num = num//i break print("%d ="%(original),end='') for i...
normal
{ "blob_id": "78e72bf3ac73113e2c71caf5aed70b53cafa9c46", "index": 3413, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile num > 1:\n for i in range(2, num + 1):\n if num % i == 0:\n a.append(i)\n num = num // i\n break\nprint('%d =' % original, end='')\nfor i ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class UserRegModel(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|...
flexible
{ "blob_id": "d0653dac8e7c8162070ed9fd191f7fb318f47c60", "index": 1719, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass UserRegModel(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass UserRegModel(model...
[ 0, 1, 2, 3, 4 ]
from enum import Enum class AggregationTypes(Enum): NO_AGG = 'NO-AGG' STATIC = 'STATIC' SUB_HOUR = 'SUB-HOUR' DYNAMIC = 'DYNAMIC'
normal
{ "blob_id": "436b89b91aed14525f847e6488b452b7ca0e1b70", "index": 5322, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AggregationTypes(Enum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AggregationTypes(Enum):\n NO_AGG = 'N...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def calculate_distance_for_tour(tour, node_id_to_location_dict): length = 0 num = 0 for i in tour: j = tour[num - 1] distance = np.linalg.norm(node_id_to_location_dict[i] - node_id_to_loca...
flexible
{ "blob_id": "67d79a5c9eceef9f1ed69f79d6a9d1f421f3246c", "index": 2757, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef calculate_distance_for_tour(tour, node_id_to_location_dict):\n length = 0\n num = 0\n for i in tour:\n j = tour[num - 1]\n distance = np.linalg.norm(node_id...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from . import by_trips from . import by_slope
flexible
{ "blob_id": "74fae3636b1c1b0b79d0c6bec8698581b063eb9c", "index": 8944, "step-1": "<mask token>\n", "step-2": "from . import by_trips\nfrom . import by_slope\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> class A31: def __init__(self, dict): self.dict = dict self.CID = self.dict['CID'] self.val = self.dict['values'] self.calc = self.val['calculated'] self.comp = self.val['component'] self.fluid = self.val['fluid'] self.calc['pres...
flexible
{ "blob_id": "4b8038ddea60f371aa8da168ea4456372d6f0388", "index": 2357, "step-1": "<mask token>\n\n\nclass A31:\n\n def __init__(self, dict):\n self.dict = dict\n self.CID = self.dict['CID']\n self.val = self.dict['values']\n self.calc = self.val['calculated']\n self.comp = s...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> __all__ = ['RepositoryMixin', 'LicenseMixin', 'RegistryMixin', 'CitationMixin', 'ChecklistMixin'] <|reserved_special_token_1|> from .checklist_mixin import ChecklistMixin from .citation_mixin import CitationMixin from .lice...
flexible
{ "blob_id": "bf8a524e54aa866c8293a93b2321335f2c7b0850", "index": 7419, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['RepositoryMixin', 'LicenseMixin', 'RegistryMixin',\n 'CitationMixin', 'ChecklistMixin']\n", "step-3": "from .checklist_mixin import ChecklistMixin\nfrom .citation_mixin i...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def tobin(n): bin = '' while n / 2 != 0: if n % 2 == 0: bin = bin + '0' else: bin = bin + '1' if n % 2 == 1: bin = bin + '1' return bin <|reserved_special_token_0|> <|reserved_special_token_1...
flexible
{ "blob_id": "1c5ca920fe1f116a5bc52c9e5c53c13b1e1c925f", "index": 2412, "step-1": "<mask token>\n", "step-2": "def tobin(n):\n bin = ''\n while n / 2 != 0:\n if n % 2 == 0:\n bin = bin + '0'\n else:\n bin = bin + '1'\n if n % 2 == 1:\n bin = bin + '1'\n ret...
[ 0, 1, 2, 3, 4 ]
s=input("enter a string") u=0 l=0 for i in s: if i.isupper(): u+=1 elif i.islower(): l+=1 print(u,l,end="")
normal
{ "blob_id": "bbb23d606b081d2591699cb6b9336c8766eea5b2", "index": 2436, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in s:\n if i.isupper():\n u += 1\n elif i.islower():\n l += 1\nprint(u, l, end='')\n", "step-3": "s = input('enter a string')\nu = 0\nl = 0\nfor i in s:\n i...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: print('{0}是润年'.format(year)) else: print('{0}不是润年'.format(year)) <|reserved_special_token_1|> year = int(input('请输入一个年份:')) <|reserved_special_token_0|> if year %...
flexible
{ "blob_id": "78178ec8474a3deb876ab7d3950cd427d7a795d5", "index": 2218, "step-1": "<mask token>\n", "step-2": "<mask token>\nif year % 4 == 0 and year % 100 != 0 or year % 400 == 0:\n print('{0}是润年'.format(year))\nelse:\n print('{0}不是润年'.format(year))\n", "step-3": "year = int(input('请输入一个年份:'))\n<mask ...
[ 0, 1, 2, 3 ]
# module for comparing stats and making recommendataions """ Read team names from user input, retrieve features of teams from MySQL DB, compute odds of winning and recommend features to care """ import numpy as np import pandas as pd import matplotlib.pyplot as plt import pymysql as mdb def FeatureImprove(tgtName, yo...
normal
{ "blob_id": "e5f8301ae22e99c967b2ff3d791379deba7d154a", "index": 2341, "step-1": "# module for comparing stats and making recommendataions\n\"\"\"\nRead team names from user input, retrieve features of teams from MySQL DB, compute odds of winning and recommend features to care\n\"\"\"\n\nimport numpy as np\nimpo...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(alien_0) <|reserved_special_token_0|> print(f""" The alien is {alien_0['color']}""") <|reserved_special_token_0|> print(f"The alien is now {alien_0['color']}") <|reserved_special_token_1|> alien_0 = {} alien_0['color'] = ...
flexible
{ "blob_id": "f4dd9500835cb22a859da8bd57487052522bb593", "index": 7697, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(alien_0)\n<mask token>\nprint(f\"\"\"\nThe alien is {alien_0['color']}\"\"\")\n<mask token>\nprint(f\"The alien is now {alien_0['color']}\")\n", "step-3": "alien_0 = {}\nalien_0['...
[ 0, 1, 2, 3 ]
import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): expansion = 1 def __init__(self, in_planes, planes, stride=1): super(BasicBlock, self).__init__() self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stri...
normal
{ "blob_id": "d3f42f329246164cdb6113df3da0eb2d3203b2a9", "index": 7114, "step-1": "<mask token>\n\n\nclass Bottleneck(nn.Module):\n expansion = 4\n\n def __init__(self, in_planes, planes, stride=1):\n super(Bottleneck, self).__init__()\n self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1,...
[ 13, 15, 18, 22, 25 ]
# -*- coding: utf-8; -*- import gherkin from gherkin import Lexer, Parser, Ast def test_lex_test_eof(): "lex_text() Should be able to find EOF" # Given a lexer that takes '' as the input string lexer = gherkin.Lexer('') # When we try to lex any text from '' new_state = lexer.lex_text() # T...
normal
{ "blob_id": "44649e44da4eb80e7f869ff906798d5db493b913", "index": 4415, "step-1": "<mask token>\n\n\ndef test_lex_comment_no_newline():\n lexer = gherkin.Lexer(' test comment')\n new_state = lexer.lex_comment_metadata_value()\n lexer.tokens.should.equal([(1, gherkin.TOKEN_META_VALUE, 'test comment')])\n ...
[ 23, 35, 36, 40, 42 ]
from flask import Flask, Blueprint, render_template, request, redirect from repositories import manufacturer_repository, product_repository from models.manufacturer import Manufacturer from models.product import Product manufacturers_blueprint = Blueprint("manufacturers", __name__) @manufacturers_blueprint.route("/ma...
normal
{ "blob_id": "841e859feff2151667d70e7bf1829129d1f92cf7", "index": 9889, "step-1": "<mask token>\n\n\n@manufacturers_blueprint.route('/manufacturers', methods=['GET'])\ndef manufacturers():\n manufacturers = manufacturer_repository.select_all()\n return render_template('manufacturers/index.html', manufacture...
[ 5, 6, 7, 9, 10 ]
<|reserved_special_token_0|> def create_graph(): """Creates a graph from saved GraphDef file and returns a saver.""" with tf.gfile.FastGFile(os.path.join('/home/ubuntu/hdd/tensorFlowDic/', 'classify_image_graph_def.pb'), 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f...
flexible
{ "blob_id": "8ef20a7a93d6affabe88dad4e5d19613fe47dd0f", "index": 5399, "step-1": "<mask token>\n\n\ndef create_graph():\n \"\"\"Creates a graph from saved GraphDef file and returns a saver.\"\"\"\n with tf.gfile.FastGFile(os.path.join('/home/ubuntu/hdd/tensorFlowDic/',\n 'classify_image_graph_def.pb...
[ 2, 3, 4, 5, 6 ]
class User: <|reserved_special_token_0|> def __init__(self, balance, int_rate): self.balance = balance self.int_rate = int_rate User.account.append(self) def dep(self, amount): self.balance += amount return self def make_withdrawal(self, amount): if sel...
flexible
{ "blob_id": "ff3f6d50498f58f3a340e2d690165efcc1a5fb1d", "index": 6000, "step-1": "class User:\n <mask token>\n\n def __init__(self, balance, int_rate):\n self.balance = balance\n self.int_rate = int_rate\n User.account.append(self)\n\n def dep(self, amount):\n self.balance +=...
[ 8, 10, 11, 12, 13 ]
#encoding=utf-8 import json import os def get_Userid(path): path_Divided = path.split('\\') #print(path_Divided) get_id= path_Divided[6].split('.') get_id = get_id[0] #print(get_id) return get_id def compose_Json_Path_ToRead(path_json_source,get_id): json_path_to_read = path...
normal
{ "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 ]
import numpy as np # Copyright 2011 University of Bonn # Author: Hannes Schulz def cnan(x): """ check for not-a-number in parameter x """ if np.isnan(x).sum()>0: import pdb pdb.set_trace() def get_curve_3D(eig, alpha=0.25,g23=0.5,g12=0.5): # renumerated according to sato et al: l3 is smallest...
normal
{ "blob_id": "2a19c2d6e51e9c123236c58f82de1a39e5db40f4", "index": 220, "step-1": "import numpy as np\n\n# Copyright 2011 University of Bonn\n# Author: Hannes Schulz\n\ndef cnan(x):\n \"\"\" check for not-a-number in parameter x \"\"\"\n if np.isnan(x).sum()>0:\n import pdb\n pdb.set_trace()\n\...
[ 0 ]
../PyFoam/bin/pyFoamPlotWatcher.py
normal
{ "blob_id": "ec2d3bbfce06c498790afd491931df3f391dafbe", "index": 8686, "step-1": "../PyFoam/bin/pyFoamPlotWatcher.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
from csv import reader, writer from collections import OrderedDict as OrdDic import sqlite3 from jsmin import jsmin from glob import glob from csscompressor import compress from threading import Timer from glob import glob import os import shutil import logging import json class MinifyFilesPre: def __init__(self, ...
normal
{ "blob_id": "38bd9e5b2147838b6061925d72b989c83343f1c2", "index": 9800, "step-1": "<mask token>\n\n\nclass DbManager:\n\n def __init__(self, fname=None, tname=None):\n if fname:\n self.FILE_NAME = fname\n else:\n self.FILE_NAME = 'resources/static/LOG_Temp.db'\n if tn...
[ 31, 37, 39, 44, 50 ]
<|reserved_special_token_0|> def loss_function(real, pred, loss_object, pad_token_id): """Calculates total loss containing cross entropy with padding ignored. Args: real: Tensor of size [batch_size, length_logits, vocab_size] pred: Tensor of size [batch_size, length_labels] loss_obje...
flexible
{ "blob_id": "7613dde4f49044fbca13acad2dd75587ef68f477", "index": 2903, "step-1": "<mask token>\n\n\ndef loss_function(real, pred, loss_object, pad_token_id):\n \"\"\"Calculates total loss containing cross entropy with padding ignored.\n Args:\n real: Tensor of size [batch_size, length_logits, voca...
[ 5, 6, 7, 8, 9 ]
from flask import Flask, jsonify, request, render_template from werkzeug import secure_filename import os from utils import allowed_file, convert_html_to_pdf, convert_doc_to_pdf app = Flask(__name__) @app.route('/', methods=['GET']) def index(): """ Renders Index.html """ try: return render_template...
normal
{ "blob_id": "860f77b031c815df40a16669dae8d32af4afa5bf", "index": 868, "step-1": "<mask token>\n\n\n@app.route('/', methods=['GET'])\ndef index():\n \"\"\" Renders Index.html \"\"\"\n try:\n return render_template('index.html')\n except Exception as e:\n print('Exception Occurred', e)\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class test_AppendAndDelete3(unittest.TestCase): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class test_AppendAndDelete3(unittest.TestCase): def test_hurdleRace(self): ...
flexible
{ "blob_id": "ea86a2a9068c316d3efcbcb165a8ef3d3516ba1b", "index": 4763, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass test_AppendAndDelete3(unittest.TestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass test_AppendAndDelete3(unittest.TestCase):\n\n def test_hurdleRace(self):\...
[ 0, 1, 2, 3 ]
import torch.nn as nn from transformers import BertModel class BertBasedTODModel(nn.Module): def __init__(self, bert_type, num_intent_labels, num_slot_labels): super(BertBasedTODModel, self).__init__() self.bert_model = BertModel.from_pretrained(bert_type) self.num_intent_labels = num_int...
normal
{ "blob_id": "74e70056ddfd8963a254f1a789a9058554c5489e", "index": 2586, "step-1": "<mask token>\n\n\nclass BertBasedTODModel(nn.Module):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass BertBasedTODModel(nn.Module):\n <mask token>\n\n def forward(self, input_ids, attention_mask, ...
[ 1, 2, 3, 4 ]
import argparse import json import os import warnings import numpy as np import pandas as pd import src.data_loaders as module_data import torch from sklearn.metrics import roc_auc_score from src.data_loaders import JigsawDataBias, JigsawDataMultilingual, JigsawDataOriginal from torch.utils.data import DataLoader from...
normal
{ "blob_id": "58c7e81d1b3cf1cff7d91bf40641e5a03b9f19ac", "index": 5730, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_classifier(config, dataset, checkpoint_path, device='cuda:0'):\n model = ToxicClassifier(config)\n checkpoint = torch.load(checkpoint_path, map_location=device)\n mo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def digital_root(n): if n < 10: return n return digital_root(digital_sum(n)) <|reserved_special_token_1|> def digital_sum(n): if n < 10: return n return n % 10 + digital_sum(n // 10) def digi...
flexible
{ "blob_id": "e3e6f1b6580a223558791cebfcb1a92d45553162", "index": 1823, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef digital_root(n):\n if n < 10:\n return n\n return digital_root(digital_sum(n))\n", "step-3": "def digital_sum(n):\n if n < 10:\n return n\n return n % ...
[ 0, 1, 2 ]
import itertools import math def score(stack): syrup = math.pi * max(x[0] for x in stack)**2 for item in stack: syrup += 2*math.pi*item[0]*item[1] return syrup def ring_score(item): return 2*math.pi*item[0]*item[1] def solve(pancakes, k): return max(itertools.combin...
normal
{ "blob_id": "31304c3b0f41b848a36115f1ef098a2104c170ac", "index": 5779, "step-1": "<mask token>\n\n\ndef ring_score(item):\n return 2 * math.pi * item[0] * item[1]\n\n\ndef solve(pancakes, k):\n return max(itertools.combinations(pancakes, k), key=score)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nd...
[ 2, 3, 4, 5, 6 ]
name_list =[ ] a = 1 for a in range(1,33): name = input("请输入要加入列表的名字:") name_list.append("name") print(name) print(list_ name)
normal
{ "blob_id": "3f7dddcfde9d33f30f00156fc41700da2692afc3", "index": 2006, "step-1": "name_list =[ ]\na = 1\nfor a in range(1,33):\n name = input(\"请输入要加入列表的名字:\")\n name_list.append(\"name\")\n print(name)\nprint(list_ name)\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "ste...
[ 0 ]
""" Kernel desnity estimation plots for geochemical data. """ import copy import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import MaxNLocator from ...comp.codata import close from ...util.log import Handle from ...util.meta import get_additional_params, subkwargs from ...util.plot.axes import...
normal
{ "blob_id": "ae475dc95c6a099270cf65d4b471b4b430f02303", "index": 8840, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef density(arr, ax=None, logx=False, logy=False, bins=25, mode='density',\n extent=None, contours=[], percentiles=True, relim=True, cmap=\n DEFAULT_CONT_COLORMAP, shading='auto...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def other_bot(bot_name): if bot_name == 'O': return 'B' else: return 'O' <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def solve_sequence(seq): O_init_walk_time = 0 B_init_walk_time = 0 try: O_init...
flexible
{ "blob_id": "d1944493b7f3e74462ca0163a8c0907e4976da06", "index": 4806, "step-1": "<mask token>\n\n\ndef other_bot(bot_name):\n if bot_name == 'O':\n return 'B'\n else:\n return 'O'\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef solve_sequence(seq):\n O_init_walk_time = 0\n B_i...
[ 1, 3, 4, 5, 6 ]
<|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_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): dependencies = [(...
flexible
{ "blob_id": "795f936423965063c44b347705c53fd1c306692f", "index": 4927, "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 = [('people', '0...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> parser.add_argument('config', help='train config file path') <|reserved_special_token_0|> if __name__ == '__main__': trainer = getattr(trainers, config.trainer.trainer_name)(config, args. config) trainer.run() <|...
flexible
{ "blob_id": "46e2955756cf1aea902f31685b258ffd14b2e62b", "index": 5291, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('config', help='train config file path')\n<mask token>\nif __name__ == '__main__':\n trainer = getattr(trainers, config.trainer.trainer_name)(config, args.\n ...
[ 0, 1, 2, 3, 4 ]
class StartStateImpl: start_message = "Для продолжения мне необходим ваш корпоративный E-mail"\ "Адрес вида: <адрес>@edu.hse.ru (без кавычек)" thank_you = "Спасибо за ваш адрес. Продолжаем." def __init__(self): pass def enter_state(self, message, user): user.send_message(StartS...
normal
{ "blob_id": "3741e44178375f351278cb17c2bf8f11c69e1262", "index": 4009, "step-1": "class StartStateImpl:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def exit_state(self, message, user):\n user.send_message(StartStateImpl.thank_you)\n <mask token>\n\n\nclass StartState(...
[ 5, 6, 7, 8, 10 ]
import uvicore from uvicore.support import module from uvicore.typing import Dict, List from uvicore.support.dumper import dump, dd from uvicore.contracts import Email @uvicore.service() class Mail: def __init__(self, *, mailer: str = None, mailer_options: Dict = None, to: List = [], ...
normal
{ "blob_id": "c87ede0e3c6d4cc305450f68b4cf61fb63986760", "index": 8676, "step-1": "<mask token>\n\n\n@uvicore.service()\nclass Mail:\n\n def __init__(self, *, mailer: str=None, mailer_options: Dict=None, to:\n List=[], cc: List=[], bcc: List=[], from_name: str=None,\n from_address: str=None, subj...
[ 6, 8, 9, 10, 15 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> if input is not None: element = S(input) if newChild is not None: newChild = S(newChild) element.replaceChild(existingChild, newChild)
flexible
{ "blob_id": "fdbb64159b72bf902efc3aa2eaa534e199dccf84", "index": 8442, "step-1": "<mask token>\n", "step-2": "if input is not None:\n element = S(input)\nif newChild is not None:\n newChild = S(newChild)\nelement.replaceChild(existingChild, newChild)\n", "step-3": null, "step-4": null, "step-5": nu...
[ 0, 1 ]
#coding: utf-8 from flask import Flask, redirect, url_for, request from werkzeug.utils import secure_filename import torch, torchvision # Setup detectron2 logger import detectron2 from detectron2.utils.logger import setup_logger setup_logger() # import some common libraries import numpy as np import os, json, cv2, ...
normal
{ "blob_id": "a18e98db417fe234e3d8d5d1321203fbac18751c", "index": 8174, "step-1": "<mask token>\n\n\ndef init_setup():\n cfg = get_cfg()\n cfg.merge_from_file(model_zoo.get_config_file(\n 'COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml'))\n cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5\n cf...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def bubbleSort(list): for num in range(len(list) - 1, 0, -1): for i in range(num): if list[i] > list[i + 1]: temp = list[i] list[i] = list[i + 1] list[i + 1...
flexible
{ "blob_id": "29c25721a4754650f0d5d63d6cc3215cb0ea1b3e", "index": 7849, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bubbleSort(list):\n for num in range(len(list) - 1, 0, -1):\n for i in range(num):\n if list[i] > list[i + 1]:\n temp = list[i]\n ...
[ 0, 1, 2, 3, 4 ]
#!/usr/local/autopkg/python """ JamfExtensionAttributeUploader processor for uploading extension attributes to Jamf Pro using AutoPkg by G Pugh """ import os import sys from time import sleep from xml.sax.saxutils import escape from autopkglib import ProcessorError # pylint: disable=import-error # to use a base...
normal
{ "blob_id": "31f91e67d0adde0a984a6d162ea5607f06e9208e", "index": 9876, "step-1": "<mask token>\n\n\nclass JamfExtensionAttributeUploader(JamfUploaderBase):\n description = (\n 'A processor for AutoPkg that will upload an Extension Attribute item to a Jamf Cloud or on-prem server.'\n )\n input...
[ 4, 5, 6, 7, 8 ]
"""Contains functionality for tokenizing, parsing, embedding language.""" from . import parsing from . import cleaning from .config import NATURAL_EMB_DIM
normal
{ "blob_id": "8a6c9fa67c02d69444c9c3a2e6811b982c49eb4e", "index": 5585, "step-1": "<mask token>\n", "step-2": "<mask token>\nfrom . import parsing\nfrom . import cleaning\nfrom .config import NATURAL_EMB_DIM\n", "step-3": "\"\"\"Contains functionality for tokenizing, parsing, embedding language.\"\"\"\n\nfrom...
[ 0, 1, 2 ]
import argparse from train import train from test import infer if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--mode', type=str, default='train', help='could be either infer or train') parser.add_argument('--model_dir', type=str, default='model', ...
normal
{ "blob_id": "f0fa85f240b74b003ade767ffe8642feacdfaa32", "index": 5807, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n parser = argparse.ArgumentParser()\n parser.add_argument('--mode', type=str, default='train', help=\n 'could be either infer or train')\n pars...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.4 on 2016-04-12 14:41 from __future__ import unicode_literals import datetime from django.db import migrations, models from django.utils.timezone import utc class Migration(migrations.Migration): dependencies = [ ('ashesiundergraduate', '0016_orphanage')...
normal
{ "blob_id": "5f2110bcab465a85ad7db1b0e01a882b3ed305a5", "index": 2876, "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 = [('ashesiunder...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_features(raw_data, raw_ids): """ Calculate the information gain of a dataset. This function takes three parameters: 1. data = The dataset for whose feature the IG should be calculated 2. split_attribute_n...
flexible
{ "blob_id": "ca403e8820a3e34e0eb11b2fdd5d0fc77e3ffdc4", "index": 9394, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_features(raw_data, raw_ids):\n \"\"\"\n Calculate the information gain of a dataset. This function takes three parameters:\n 1. data = The dataset for whose feature t...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ImageTaggingChoice(str, Enum): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|...
flexible
{ "blob_id": "e3fe77867926d9d82963c8125048148de6998e2b", "index": 4374, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ImageTaggingChoice(str, Enum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ImageTaggingChoice(str, Enum):\n ...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Wed May 8 15:05:51 2019 @author: Brian Heckman and Kyle Oprisko """ import csv """this file opens a csv file created in the csv creator class. The main purpose of this class is to normalize the data in the csv file, so that it can be read by the neural network. """ ...
normal
{ "blob_id": "ecbca04a58c19469e63ee2310e2b2f6b86c41199", "index": 1011, "step-1": "<mask token>\n\n\nclass CSV_Normalize:\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...
[ 11, 12, 19, 21, 23 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for file_name in file_list: proteins = 0 peptides = 0 for line_index, line in enumerate(open(file_name, 'r')): if line_index > 3: proteins += 1 peptides += int(line.split('\t')[3]) p...
flexible
{ "blob_id": "e08159a51b611ce6d0ca354a4fe6759d00af2cb7", "index": 660, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor file_name in file_list:\n proteins = 0\n peptides = 0\n for line_index, line in enumerate(open(file_name, 'r')):\n if line_index > 3:\n proteins += 1\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def fa(x): dict2 = {(1): 'one', (2): 'two', (3): 'three', (4): 'four', (5): 'five', (6): 'six', (7): 'seven', (8): 'eight', (9): 'nine', (0): 'zero'} return dict2[int(x)] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in r...
flexible
{ "blob_id": "af9adc0faad4fc1426a2bd75c1c77e23e37b60bf", "index": 2431, "step-1": "<mask token>\n\n\ndef fa(x):\n dict2 = {(1): 'one', (2): 'two', (3): 'three', (4): 'four', (5): 'five',\n (6): 'six', (7): 'seven', (8): 'eight', (9): 'nine', (0): 'zero'}\n return dict2[int(x)]\n\n\n<mask token>\n", ...
[ 1, 3, 4, 5, 6 ]
from Bio.PDB import * import urllib.request import numpy as np import pandas as pd from math import sqrt import time import os import heapq from datetime import datetime dir_path = os.getcwd() peptidasesList = pd.read_csv("./MCSA_EC3.4_peptidases.csv") peptidasesList = peptidasesList[peptidasesList.iloc[:, 4] == "res...
normal
{ "blob_id": "67b1cdfa514aac4fdac3804285ec8d0aebce944d", "index": 6068, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(len(peptidasesList))\n<mask token>\nfor i in range(len(peptidasesList)):\n if peptidasesList.loc[i, 'PDB'] not in bindingSiteDic:\n bindingSiteDic[peptidasesList.loc[i, 'P...
[ 0, 1, 2, 3, 4 ]
from pybrain3.datasets import SupervisedDataSet inputDataSet = SupervisedDataSet(35, 20) #Creating new DataSet #A inputDataSet.addSample(( #Adding first sample to dataset -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1,...
normal
{ "blob_id": "a2569ccd509fa755f4cad026f483bcf891c6fb41", "index": 8120, "step-1": "<mask token>\n", "step-2": "<mask token>\ninputDataSet.addSample((-1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1,\n 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1), (\n 1, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python import argparse import http.server import os class SimpleHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): def log_message(*args, **kwargs): pass parser = argparse.ArgumentParser() parser.add_argument('port', action='store', # default=8000, type=int, ...
normal
{ "blob_id": "e839eba2514c29a8cfec462f8d5f56d1d5712c34", "index": 7413, "step-1": "<mask token>\n\n\nclass SimpleHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):\n\n def log_message(*args, **kwargs):\n pass\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass SimpleHTTPRequestHandler(http...
[ 2, 3, 4, 5, 6 ]
""" 作用域 在Python中,当引用一个变量的时候,对这个【变量的搜索】是按照 本地作用域(Local)、 嵌套作用域(Enclosing function locals)、 全局作用域(Global)、 内置作用域(builtins模块) 的顺序来进行的, 即所谓的LEGB规则。 然而当在一个【函数内部为一个变量赋值】时,并不是按照上面所说LEGB规则来首先找到变量,之后为该变量赋值。在Python中,在函数中为一个变量赋值时,有下面这样一条规则 “当在函数中给一个变量名赋值是(而不是在一个表达式中对其进行引用),Python总是🔹创建或改变本地作用域的变量名🔹,除非它已经在那个函数中被声明为全局变量. ” """ ...
normal
{ "blob_id": "e98767fbac44f50f58c149e16124fef95b38cf71", "index": 8190, "step-1": "<mask token>\n\n\ndef func():\n x = 88\n\n\n<mask token>\n\n\ndef func_y():\n global y\n y = 101\n\n\n<mask token>\n\n\ndef func_e():\n count = 0\n\n def foo():\n nonlocal count\n count = 12\n foo()\...
[ 3, 4, 5, 6, 7 ]
def bullets(chunks): print("bullets") final_string = "Your list in latex can be created with the following command: \n" final_string += "> \\begin{itemize} \n" for e in chunks: print(final_string) final_string += f"> \item {e} \n" final_string += "> \end{itemize}" retur...
normal
{ "blob_id": "7a920b3609bb29cd26b159b48290fa6978839416", "index": 7377, "step-1": "<mask token>\n", "step-2": "def bullets(chunks):\n print('bullets')\n final_string = (\n 'Your list in latex can be created with the following command: \\n')\n final_string += '> \\\\begin{itemize} \\n'\n for e...
[ 0, 1, 2, 3, 4 ]
/home/co/Documents/ImageClassifier/tensorflow/tensorflow/contrib/rnn/python/ops/rnn_cell.py
normal
{ "blob_id": "8c4aacb0dfacac2cc3e6fa91397ddfed75923fd9", "index": 1721, "step-1": "/home/co/Documents/ImageClassifier/tensorflow/tensorflow/contrib/rnn/python/ops/rnn_cell.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
import sys from pprint import pprint sys.stdin = open("sample_input.txt", "r") test_case = int(input()) """ for test in range(test_case): nxn_array, palin_len = map(int, input().split()) ## 2차 배열 만들기 => 행스트링 리스트 order_2nd_array = [] for i in range(nxn_array): order_2nd_array.append(input()) ...
normal
{ "blob_id": "15fea8a84accdfc2dac87c111cbe8bfca61fe801", "index": 3482, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.stdin = open('sample_input.txt', 'r')\ntest_case = int(input())\n<mask token>\n", "step-3": "import sys\nfrom pprint import pprint\nsys.stdin = open('sample_input.txt', 'r')\ntest_c...
[ 0, 1, 2, 3 ]
""" Modulo collection - Counter Collections -> High-performance Container Datatypes Counter -> Recebe um interável como parametro e cria um objeto do tipo Collections Counter que é parecido com um dicionario, contendo como chave o elemento da lista passada como parametro e como valor a quantidade de ocorrencia...
normal
{ "blob_id": "4989d01f31ca034aacdda28eff56adb2e0bb15da", "index": 1889, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f'resultado: {resultado} || seu tipo: {type(resultado)}')\nprint('--------------\\n')\nprint(f\"\"\"Nasca de bacana: \n {Counter('Nasca de bacana')}\"\"\")\nprint('--------------\\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Net(nn.Module): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def create_depthwise_conv2d(self, in_channels, out_channels, kernel_size=(3, 3), dilation...
flexible
{ "blob_id": "f925b3b2f55c3f8daf57438d8d20b60446ae39af", "index": 6111, "step-1": "<mask token>\n\n\nclass Net(nn.Module):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def create_depthwise_conv2d(self, in_channels, out_channels,\n kernel_size=(3, 3), dila...
[ 6, 7, 11, 14, 17 ]
# RSA key modulus_size = 2048 (n, e) = (0, 0) # Not being initialize here # modulus size in bytes k = modulus_size // 8 # keep track of the oracle calls queries = 0 print_queries_every = 1 number_of_time_to_confirm_conforming = 10 # Choose to use OpenSSL encrypt function or our own implementations encrypt_openssl =...
normal
{ "blob_id": "415d58e502e8a33f7a37c4fb2da34e838246ea9c", "index": 2057, "step-1": "<mask token>\n", "step-2": "modulus_size = 2048\nn, e = 0, 0\nk = modulus_size // 8\nqueries = 0\nprint_queries_every = 1\nnumber_of_time_to_confirm_conforming = 10\nencrypt_openssl = True\nt_start = 0\ncwd = ''\nhost = '10.0.0.1...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}'.format(* argv[1:4]), pool_pre_ping=True) Base.metadata.create_all(engine) session = orm.sessionmaker(bind=engine)() fir...
flexible
{ "blob_id": "1f3e20e7fe597a88cddacf6813250f1ede6c6ee0", "index": 6595, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}'.format(*\n argv[1:4]), pool_pre_ping=True)\n Base.metadata.create_all(engine)\n se...
[ 0, 1, 2, 3 ]
def mais_populoso(dic): p = 0 sp = 0 for t, i in dic.items(): for m in dic[t].values(): p += m if p > sp: sp = p x = t return x
normal
{ "blob_id": "2cbce618d1ec617d1c7dc0e9792b6a49361ec5a4", "index": 13, "step-1": "<mask token>\n", "step-2": "def mais_populoso(dic):\n p = 0\n sp = 0\n for t, i in dic.items():\n for m in dic[t].values():\n p += m\n if p > sp:\n sp = p\n x = t\n return ...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> dic01 = {'name': 'seop', 'age': 48, 'address': 'seoul', 'birth': '730919', 'gender': True} dic02 = dict([('name', 'seop'), ('age', 48), ('address', 'seoul'), ('birth', '730919'), ('gender', True)]) dic03 = dict(name='seop', age=48, address='seoul', bi...
flexible
{ "blob_id": "d1077107a5cd3a9f489f74b030a698b0521841f3", "index": 7721, "step-1": "<mask token>\n", "step-2": "dic01 = {'name': 'seop', 'age': 48, 'address': 'seoul', 'birth': '730919',\n 'gender': True}\ndic02 = dict([('name', 'seop'), ('age', 48), ('address', 'seoul'), ('birth',\n '730919'), ('gender', ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if date == 'DEC 25' or date == 'OCT 31': print('yup') else: print('nope') <|reserved_special_token_1|> date = input() if date == 'DEC 25' or date == 'OCT 31': print('yup') else: print('nope') <|reserved_specia...
flexible
{ "blob_id": "bc5b368a710b8dfc4492b996c42c46638e1f538c", "index": 9811, "step-1": "<mask token>\n", "step-2": "<mask token>\nif date == 'DEC 25' or date == 'OCT 31':\n print('yup')\nelse:\n print('nope')\n", "step-3": "date = input()\nif date == 'DEC 25' or date == 'OCT 31':\n print('yup')\nelse:\n ...
[ 0, 1, 2, 3 ]
class Solution: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution: def isUgly(self, num): if num == 0: return False for n in [2, 3, 5]: while num % n == 0: num = num / n return num == 1 <|...
flexible
{ "blob_id": "d39cc2dbbc83869e559f8355ceba5cf420adea5e", "index": 1662, "step-1": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Solution:\n\n def isUgly(self, num):\n if num == 0:\n return False\n for n in [2, 3, 5]:\n while num % n == 0:\n ...
[ 1, 2, 3, 4 ]
from __future__ import annotations from collections import Counter from distribution import Distribution, Normal class GoodKind: """ The definition of a kind of good. "Vegtable" is a kind of good, as is "Iron Ore", "Rocket Fuel", and "Electic Motor" """ def __init__(self, name: str): as...
normal
{ "blob_id": "286801b69546046853d123c5708f24eaaa2e8cec", "index": 6044, "step-1": "<mask token>\n\n\nclass Recipe:\n <mask token>\n\n def __init__(self, labor_amount: float, required_goods: BagOfGoods,\n planet_variation: Distribution, person_variation: Distribution,\n labor_variation: Distrib...
[ 6, 9, 17, 23, 26 ]
# # @lc app=leetcode.cn id=2006 lang=python3 # # [2006] 差的绝对值为 K 的数对数目 # # @lc code=start class Solution: def countKDifference(self, nums: List[int], k: int) -> int: def abs(x,y): if(x-y>=0): return x-y else: return y-x ret = 0 for i...
normal
{ "blob_id": "351b2c2a18473e6ac541a96165c69c836ea101de", "index": 846, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def countKDifference(self, nums: List[int], k: int) ->int:\n\n def abs(x, y):\n if x - y >= 0:\n ...
[ 0, 1, 2, 3 ]
# -*- coding=utf-8 -*- # ! /usr/bin/env python3 """ 抽奖活动-摇一摇活动 """ import time import allure from libs.selenium_libs.common.base import Base from libs.selenium_libs.page_object.page_activity import PageActivity from libs.selenium_libs.page_object.page_personal_center import PagePersonalCenter class LuckDrawActivity...
normal
{ "blob_id": "6b1970ee2b0d24504f4dea1f2ad22a165101bfbe", "index": 8958, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LuckDrawActivity(Base):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LuckDrawActivity(Base):\n\n @allure.step('参加抽奖活动')\n def join_luck_draw_activity(self, d...
[ 0, 1, 2, 3, 4 ]
from __future__ import unicode_literals import requests try: import json except ImportError: import simplejson as json def main(app, data): MEDIUM_API_ENDPOINT = 'https://medium.com/{0}/latest?format=json' r = requests.get(MEDIUM_API_ENDPOINT.format(data.get('username'))) response_content = r.cont...
normal
{ "blob_id": "96936b7f6553bee06177eb66a2e63064c1bf51a6", "index": 8373, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main(app, data):\n MEDIUM_API_ENDPOINT = 'https://medium.com/{0}/latest?format=json'\n r = requests.get(MEDIUM_API_ENDPOINT.format(data.get('username')))\n response_conte...
[ 0, 1, 2, 3 ]
from ..utils import Object class ChatMembersFilterAdministrators(Object): """ Returns the owner and administrators Attributes: ID (:obj:`str`): ``ChatMembersFilterAdministrators`` No parameters required. Returns: ChatMembersFilter Raises: :class:`telegram.Error` ...
normal
{ "blob_id": "6dfd59bbab74a3a657d2200d62964578c296ee54", "index": 5713, "step-1": "<mask token>\n\n\nclass ChatMembersFilterAdministrators(Object):\n <mask token>\n <mask token>\n\n def __init__(self, **kwargs):\n pass\n\n @staticmethod\n def read(q: dict, *args) ->'ChatMembersFilterAdminist...
[ 3, 4, 5, 6, 7 ]
from flask_restful import Resource, reqparse import nltk from nltk.tokenize import sent_tokenize tokenizer = nltk.RegexpTokenizer(r"\w+") # CLASS DESCRIPTION: # Devides and clears the sentence of punctuation marks and builds a dependency tree on each sentence # Allocates its own names and verbs # added: Te...
normal
{ "blob_id": "6d042a2035eab579193452e4dc44c425125d9515", "index": 9402, "step-1": "<mask token>\n\n\nclass Chunk_CleanSentences(Resource):\n <mask token>\n parser.add_argument('text', type=str, required=True, help=\n 'გთხოვთ შეიყვანოთ სწორი წინადადება')\n\n def get(self):\n data = Chunk_Cle...
[ 2, 3, 4, 5, 6 ]
import xml.etree.ElementTree as ET from collections import OrderedDict import json import threading class MyThread(threading.Thread): def __init__(self, filenum): threading.Thread.__init__(self) self.filenum = filenum print('Inicio del thread:', str(self.filenum)) def run(self): ...
normal
{ "blob_id": "9150eb53d309e75299775cd9524a688e8dc2ff76", "index": 4210, "step-1": "<mask token>\n\n\nclass MyThread(threading.Thread):\n\n def __init__(self, filenum):\n threading.Thread.__init__(self)\n self.filenum = filenum\n print('Inicio del thread:', str(self.filenum))\n <mask tok...
[ 2, 3, 4, 5, 6 ]
import requests #try make the request try: r = requests.get('http://skitter.com') print(r) # see the results # catch a failue except (requests.ConnectionError, requests.Timeout) as x: pass
normal
{ "blob_id": "a26cab29f0777764f014eeff13745be60e55b62d", "index": 724, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n r = requests.get('http://skitter.com')\n print(r)\nexcept (requests.ConnectionError, requests.Timeout) as x:\n pass\n", "step-3": "import requests\ntry:\n r = requests...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 '''Глава 9. Распутываем Всемирную паутину''' '''1. Если вы еще не установили Flask, сделайте это сейчас. Это также установит werkzeug, jinja2 и, возможно, другие пакеты.''' # pip3 install flask print('\n================================ RESTART ================================\n') '''2. Созда...
normal
{ "blob_id": "664f9d5aa981c3590043fae1d0c80441bda4fbb1", "index": 2499, "step-1": "<mask token>\n\n\n@app.route('/')\ndef home():\n thing = request.args.get('thing')\n height = request.args.get('height')\n color = request.args.get('color')\n return render_template('home1.html', thing=thing, height=hei...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 22 13:19:51 2020 @author: Warren Script to check sdf file format for Fragalysis upload """ from rdkit import Chem import validators import numpy as np import os from viewer.models import Protein, CompoundSet import datetime # Set .sdf format versio...
normal
{ "blob_id": "0082f75332321dba498f06d4c4a99c9248829b59", "index": 654, "step-1": "<mask token>\n\n\ndef check_compound_set(description_mol, validate_dict):\n y_m_d = description_mol.GetProp('generation_date').split('-')\n submitter_dict = {'submitter__name': description_mol.GetProp(\n 'submitter_name...
[ 9, 10, 14, 16, 18 ]
def firstMissingPositive(nums): if len(nums) == 0: return 1 if len(nums) == 1: if nums[0] == 1: return 2 else: return 1 nums.sort() current = 1 nums = [ele for ele in nums if ele > 0] if len(nums) == 0: return 1 if len(nums) == 1: ...
normal
{ "blob_id": "89addbf2c49d568250cd5a48d3fdb73914ce50c4", "index": 2899, "step-1": "<mask token>\n", "step-2": "def firstMissingPositive(nums):\n if len(nums) == 0:\n return 1\n if len(nums) == 1:\n if nums[0] == 1:\n return 2\n else:\n return 1\n nums.sort()\n...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def request_id(): global req_c, pid if req_c is None: req_c = random.randint(1000 * 1000, 1000 * 1000 * 1000) if pid is None: pid = str(os.getpid()) req_id = req_c = req_c + 1 req_id = hex(req_id)[2:].zfill(8)[-8:] return pid + '-' + req_id <|rese...
flexible
{ "blob_id": "cdbf9427d48f0a5c53b6efe0de7dfea65a8afd83", "index": 87, "step-1": "<mask token>\n\n\ndef request_id():\n global req_c, pid\n if req_c is None:\n req_c = random.randint(1000 * 1000, 1000 * 1000 * 1000)\n if pid is None:\n pid = str(os.getpid())\n req_id = req_c = req_c + 1\n...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class openacademy_course_xls_parser(report_sxw.rml_parse): def __init__(self, cursor, uid, name, context): super(openacademy_course_xls_parser, self).__init__(cursor, uid, name, context=context) self.pool = pooler.get_pool(self.cr.dbname) self.curs...
flexible
{ "blob_id": "5c415d5bf9d6952863a662d300cb1f706ef02a8f", "index": 1048, "step-1": "<mask token>\n\n\nclass openacademy_course_xls_parser(report_sxw.rml_parse):\n\n def __init__(self, cursor, uid, name, context):\n super(openacademy_course_xls_parser, self).__init__(cursor, uid,\n name, contex...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> d.fillna(0, inplace=True) <|reserved_special_token_1|> <|reserved_special_token_0|> df = pd.read_csv('orb.csv') d = pd.pivot_table(df, index='col1', columns='col2', values='result') d.fillna(0, inplace=True) <|reserved_specia...
flexible
{ "blob_id": "ce65a672cae26bdb8ec8cb04eabfe1877f9cd7d4", "index": 9558, "step-1": "<mask token>\n", "step-2": "<mask token>\nd.fillna(0, inplace=True)\n", "step-3": "<mask token>\ndf = pd.read_csv('orb.csv')\nd = pd.pivot_table(df, index='col1', columns='col2', values='result')\nd.fillna(0, inplace=True)\n", ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('Reading labels') <|reserved_special_token_0|> with open('/home/xilinx/jupyter_notebooks/bnn/t10k-labels-idx1-ubyte', 'rb' ) as lbl_file: magicNum = int.from_bytes(lbl_file.read(4), byteorder='big') countLbl = in...
flexible
{ "blob_id": "da34eb25ec08c8311fa839a0cdcd164eff036a5d", "index": 942, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Reading labels')\n<mask token>\nwith open('/home/xilinx/jupyter_notebooks/bnn/t10k-labels-idx1-ubyte', 'rb'\n ) as lbl_file:\n magicNum = int.from_bytes(lbl_file.read(4), byte...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def grayscale(): maske = np.zeros((480, 640, 3)) a = freenect.sync_get_depth(format=freenect.DEPTH_MM)[0] mask = a == 0 a[mask] = 8000 mask1 = a > 1000 b = freenect.sync_get_video()[0] ab = cv2.cvtColor(b, cv2.COLOR_BGR2RGB) ab[mask1, :] = 0 return ab ...
flexible
{ "blob_id": "9540319cf192add1fb24375a35d70ea8e3031a72", "index": 7455, "step-1": "<mask token>\n\n\ndef grayscale():\n maske = np.zeros((480, 640, 3))\n a = freenect.sync_get_depth(format=freenect.DEPTH_MM)[0]\n mask = a == 0\n a[mask] = 8000\n mask1 = a > 1000\n b = freenect.sync_get_video()[0...
[ 1, 2, 3, 4, 5 ]
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns def distribution(): ##testing_results = pd.read_csv('https://raw.githubusercontent.com/dsfsi/covid19za/master/data/covid19za_timeline_testing.csv') confirmed_results = pd.read_csv('https://raw.githubusercontent.com/dsf...
normal
{ "blob_id": "38be4e75c2311a1e5a443d39a414058dc4d1879b", "index": 2320, "step-1": "<mask token>\n\n\ndef distribution_plot():\n confirmed_results = pd.read_csv(\n 'https://raw.githubusercontent.com/dsfsi/covid19za/master/data/covid19za_timeline_confirmed.csv'\n )\n trial = pd.notnull(confirmed...
[ 2, 3, 4, 5, 6 ]
from django.test import TestCase from .models import Seller, Product from rest_framework.test import APIClient import json class SellerModelTests(TestCase): def test_class_str(self): seller = Seller() seller.name = "Bruna" self.assertEquals(seller.__str__(), "Bruna") def test_to_dic...
normal
{ "blob_id": "71ab4ada4062ecde1463f2a766b5951860d0f2fb", "index": 7250, "step-1": "<mask token>\n\n\nclass ProductModelTests(TestCase):\n <mask token>\n <mask token>\n\n\nclass SellerViewTests(TestCase):\n\n @classmethod\n def setUpTestData(cls):\n Seller.objects.create(name='Bruna', email='bru...
[ 9, 10, 13, 16, 17 ]
#!/usr/bin/python3 """Prints the first State object from the database specified """ from sys import argv import sqlalchemy from sqlalchemy import create_engine, orm from model_state import Base, State if __name__ == "__main__": engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}' ...
normal
{ "blob_id": "1f3e20e7fe597a88cddacf6813250f1ede6c6ee0", "index": 6595, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}'.format(*\n argv[1:4]), pool_pre_ping=True)\n Base.metadata.create_all(engine)\n se...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def extract2(inp): two = 0 while inp % 2 == 0: inp //= 2 two += 1 return inp, two <|reserved_special_token_0|> def solve(): x = RSA.importKey(open('pub.pem', 'rb').read()) d0 = THE_LEAKED_PRIVATE_KEY % mod r = 304 mod = 2 ** r e = x.e ...
flexible
{ "blob_id": "b29f85ccf396640c2a63bf634b549a3eaa0dbb1b", "index": 1830, "step-1": "<mask token>\n\n\ndef extract2(inp):\n two = 0\n while inp % 2 == 0:\n inp //= 2\n two += 1\n return inp, two\n\n\n<mask token>\n\n\ndef solve():\n x = RSA.importKey(open('pub.pem', 'rb').read())\n d0 =...
[ 2, 3, 4, 5, 6 ]
from typing import Dict, Optional from collections import OrderedDict import torch import torch.nn as nn import torch.optim as optim import yaml def get_device() -> torch.device: if torch.cuda.is_available(): return torch.device("cuda") return torch.device("cpu") def load_yaml_config(config_path: s...
normal
{ "blob_id": "e8a36bd7826c5d71cf8012ea82df6c127dd858fc", "index": 549, "step-1": "<mask token>\n\n\ndef load_yaml_config(config_path: str) ->Dict:\n with open(config_path, 'r') as stream:\n return yaml.load(stream)\n\n\ndef get_optimizer(model: nn.Module, optim_config: Dict) ->optim.Optimizer:\n retu...
[ 4, 5, 6, 7, 8 ]
from __future__ import unicode_literals from django.db import models from django.db.models.signals import post_save from django.contrib.auth.models import User from django.dispatch import receiver PROFILE_PIC_PATH = 'users/profile_pic' class Profile(models.Model): user = models.OneToOneField(User, on_delete=model...
normal
{ "blob_id": "3e7df9a733c94b89d22d10883844c438444d5e2c", "index": 8010, "step-1": "<mask token>\n\n\nclass Profile(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Profile(models.Model):\n user = models.OneToOneField(User, on_delete...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> class NotSetTestCase(unittest.TestCase): <|reserved_special_token_0|> class _CachedPropertyHelper(object): def __init__(self, value): self.value = value @cached_property('_cached_value') def cached_value(self): return self.value class CachedPropertyTe...
flexible
{ "blob_id": "9189c1dd21b0858df3138bcf4fc7568b378e6271", "index": 885, "step-1": "<mask token>\n\n\nclass NotSetTestCase(unittest.TestCase):\n <mask token>\n\n\nclass _CachedPropertyHelper(object):\n\n def __init__(self, value):\n self.value = value\n\n @cached_property('_cached_value')\n def c...
[ 11, 12, 13, 18, 22 ]
<|reserved_special_token_0|> class User(AbstractUser): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def check_token(self, token...
flexible
{ "blob_id": "b7511c156c241accaf1668d83ee0a5263b41af0d", "index": 3465, "step-1": "<mask token>\n\n\nclass User(AbstractUser):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def check_token(self, token):\n \"\"\"\n ...
[ 8, 13, 15, 16, 18 ]
def K_Wilson(w, Tr, Pr): # Inserting necessary libraries import numpy as np # Calculating K-value using Wilson correlation K_value_Output = (1 / Pr) * np.exp(5.37 * (1 + w) * (1 - 1 / Tr)) # Returning output value return K_value_Output
normal
{ "blob_id": "0b42f458097d11d66160bcb8e706ccb9b5c4682a", "index": 5744, "step-1": "<mask token>\n", "step-2": "def K_Wilson(w, Tr, Pr):\n import numpy as np\n K_value_Output = 1 / Pr * np.exp(5.37 * (1 + w) * (1 - 1 / Tr))\n return K_value_Output\n", "step-3": "def K_Wilson(w, Tr, Pr):\r\n \r\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def bsigs(): S = lists(floats(allow_infinity=False, allow_nan=False), min_size=N_SIG, max_size=N_SIG) return S def sigs(): S = lists(bsigs(), min_size=1) return S <|reserved_special_token_0|> @given(space_configs()) def test_get_func_signature(api_config): ...
flexible
{ "blob_id": "64b254db6d8f352b2689385e70f2ea7d972c9191", "index": 4797, "step-1": "<mask token>\n\n\ndef bsigs():\n S = lists(floats(allow_infinity=False, allow_nan=False), min_size=N_SIG,\n max_size=N_SIG)\n return S\n\n\ndef sigs():\n S = lists(bsigs(), min_size=1)\n return S\n\n\n<mask token...
[ 4, 6, 7, 9, 10 ]
# Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file # for details. All rights reserved. Use of this source code is governed by a # BSD-style license that can be found in the LICENSE.md file. { 'variables': { 'mac_asan_dylib': '<(PRODUCT_DIR)/libclang_rt.asan_osx_dynamic.dylib', }, ...
normal
{ "blob_id": "84b98ebf6e44d03d16f792f3586be1248c1d0221", "index": 6957, "step-1": "<mask token>\n", "step-2": "{'variables': {'mac_asan_dylib':\n '<(PRODUCT_DIR)/libclang_rt.asan_osx_dynamic.dylib'}, 'targets': [{\n 'target_name': 'fletch-vm', 'type': 'none', 'dependencies': [\n 'src/vm/vm.gyp:fletch-v...
[ 0, 1, 2 ]
# -*- coding=UTF-8 -*- ''' Created on 20180127 @author: Harry ''' import datetime # today = datetime.date.today() # weekday = today.weekday() # # if weekday == 0: # print "周一" # else: # print "other days" nowtime=datetime.datetime.now() detaday = datetime.timedelta(days=-1) da_days= nowtime + detad...
normal
{ "blob_id": "662fc9d64b9046180cf70ce4b26ac2b9665dba0e", "index": 887, "step-1": "# -*- coding=UTF-8 -*-\n\n'''\nCreated on 20180127\n\n@author: Harry\n'''\n\nimport datetime\n \n# today = datetime.date.today() \n# weekday = today.weekday() \n# \n# if weekday == 0:\n# print \"周一\"\n# else:\n# print \"othe...
[ 0 ]
from lmfit import Parameters import numpy as np from cls.cls import * from reading.ellipseOutput import readEllipseOutput def readInputModel(txt, equivalentAxisFit, Settings): psfwing_02pxscale_datatab = None psfwing_logscale_datatab = None componentslist = [] params = Parameters() data = open(txt) for lin...
normal
{ "blob_id": "219b22b6ad685fc316b1df02cc924a1cfec89f5b", "index": 650, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef readInputModel(txt, equivalentAxisFit, Settings):\n psfwing_02pxscale_datatab = None\n psfwing_logscale_datatab = None\n componentslist = []\n params = Parameters()\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def detectByPathVideo(path, writer): video = cv2.VideoCapture(path) check, frame = video.read() if check == False: print( 'Video Not Found. Please Enter a Valid Path (Full path of Video Should be ...
flexible
{ "blob_id": "5044b8bc8cabd7762df6a0327828df4546ab8d96", "index": 9000, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef detectByPathVideo(path, writer):\n video = cv2.VideoCapture(path)\n check, frame = video.read()\n if check == False:\n print(\n 'Video Not Found. Please...
[ 0, 1, 2, 3, 4 ]
Max = 100010 a = [0 for i in range(Max)] p = [] for i in range(2,Max): if a[i ] == 0: p.append(i) j = i * i while j < Max: a[j ] = 1 j = j + i cnt,j = 0,1 n = int(input()) while p[j] <= n : if p[j ] - p[j-1] == 2: cnt = cnt + 1 j = j + 1 print(cnt)
normal
{ "blob_id": "e828c2792d508ba41c5dca3f4a255eee2611c333", "index": 3565, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(2, Max):\n if a[i] == 0:\n p.append(i)\n j = i * i\n while j < Max:\n a[j] = 1\n j = j + i\n<mask token>\nwhile p[j] <= n:\n ...
[ 0, 1, 2, 3 ]
from __future__ import print_function # Should comes first than torch import torch from torch.autograd import Variable ## ## Autograd.Variable is the central class of the package. It wraps a Tensor, and supports nearly all of operations defined on it. Once you finish your computation you can call .backward() and have ...
normal
{ "blob_id": "ba1648143d49110a163da02e60fb0fd024a10b79", "index": 5140, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('# ------------- Simple Variable ------------- #')\n<mask token>\nprint(x)\n<mask token>\nprint(y)\nprint(y.grad_fn)\n<mask token>\nprint('z = y * y * 3\\n', z, out)\nprint('# -----...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # # Copyright 2019 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requir...
normal
{ "blob_id": "d6a677ed537f6493bb43bd893f3096dc058e27da", "index": 507, "step-1": "<mask token>\n\n\n@base.ReleaseTracks(base.ReleaseTrack.ALPHA)\nclass Describe(base.DescribeCommand):\n <mask token>\n <mask token>\n\n def Run(self, args):\n guest_policy_ref = args.CONCEPTS.guest_policy.Parse()\n ...
[ 2, 3, 4, 5, 6 ]
# https://github.com/openai/gym/blob/master/gym/envs/__init__.py#L449 import gym import numpy as np from rl_main.conf.names import EnvironmentName, DeepLearningModelName from rl_main.environments.environment import Environment from rl_main.main_constants import DEEP_LEARNING_MODEL class BreakoutDeterministic_v4(Envi...
normal
{ "blob_id": "05e57ed95427f0de74ea5b0589c5cd56e4a96f73", "index": 8776, "step-1": "<mask token>\n\n\nclass BreakoutDeterministic_v4(Environment):\n\n def __init__(self):\n self.env = gym.make(EnvironmentName.BREAKOUT_DETERMINISTIC_V4.value)\n super(BreakoutDeterministic_v4, self).__init__()\n ...
[ 9, 11, 16, 17, 18 ]
from telegram.ext import Dispatcher,CommandHandler,CallbackQueryHandler import random from telegram import InlineKeyboardMarkup, InlineKeyboardButton gifGOODBOAT = 'https://media3.giphy.com/media/3oz8xRQiRlaS1XwnPW/giphy.gif' gifBADBOAT = 'https://media1.giphy.com/media/l2Je3n9VXC8z3baTe/giphy.gif' gifGOODMAN = 'https...
normal
{ "blob_id": "bc3e94c3fb8e563f62fcf0ca628d4aa73c668612", "index": 7097, "step-1": "<mask token>\n\n\ndef treasure(update, context):\n msg1 = \"\"\"\n 欢迎来到寻宝游戏!这是一场惊悚又危险追逐战,智慧,运气和勇气都是成功的关键!记得要避开海盗!读一读规则吧!\n 1. 系统会自动给你分配即将要发生的事,做好心理准备!\n 2. 好的外表不一定有好的结果...\n 3. 点击按钮开始寻宝!\n -----------------------\...
[ 2, 3, 4, 5, 6 ]
n, m = map(int, input().split()) li = list(map(int, input().split())) max = 0 for i in range(0, n): for j in range(i+1, n): for k in range(j+1, n): tmp = li[i] + li[j] + li[k] if(tmp <= m and max < tmp): max = tmp print(max)
normal
{ "blob_id": "83d0a32ef2d365d17caa9d311c367ed5828559ac", "index": 4153, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(0, n):\n for j in range(i + 1, n):\n for k in range(j + 1, n):\n tmp = li[i] + li[j] + li[k]\n if tmp <= m and max < tmp:\n m...
[ 0, 1, 2, 3 ]
# encoding=utf8 from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.common.exceptions import NoSuchElementException, ElementNotVisibleException from selenium.webdriver.support.select import Select import time import threading import random import ...
normal
{ "blob_id": "ae775e25179546156485e15d05491e010cf5daca", "index": 9360, "step-1": "<mask token>\n\n\nclass BookRoomThread(threading.Thread):\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 ...
[ 3, 8, 15, 17, 18 ]