code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
import os import random readpath = './DBLP/' writepath = './DBLP/' dataname = 'dblp.txt' labelname = 'node2label.txt' testsetname = writepath + 'dblp_testset.txt' def run(save_rate): rdataname = readpath + dataname rlabelname = readpath + labelname wdataname = writepath + dataname wlabelname = writepath + labelna...
normal
{ "blob_id": "4bd6a7c7fc6a788b2cb010f6513872bd3e0d396c", "index": 5011, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run(save_rate):\n rdataname = readpath + dataname\n rlabelname = readpath + labelname\n wdataname = writepath + dataname\n wlabelname = writepath + labelname\n orda...
[ 0, 2, 3, 4, 5 ]
# obtain the dataset import pandas as pd titanic = pd.read_csv('http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic.txt') #titanic.info() print(titanic.head()) # preprocessing x = titanic.drop(['row.names', 'name', 'survived'], axis=1) y = titanic['survived'] x['age'].fillna(x['age'].mean(),...
normal
{ "blob_id": "f1475d651c3b52611657a9767ad62796b55d8711", "index": 3676, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(titanic.head())\n<mask token>\nx['age'].fillna(x['age'].mean(), inplace=True)\nx.fillna('UNKNOWN', inplace=True)\n<mask token>\ndtc.fit(x_train, y_train)\nprint(dtc.score(x_test, y_...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class RefrigeratorRaider: """Raid a refrigerator""" def open(self): print('Open fridge door.') def take(self, food): print('Finding {}...'.format(food)) if food == 'deep fried pizza': raise RuntimeError('Health warning!') print('Ta...
flexible
{ "blob_id": "7455eb670c2c019b8d066fcc6f2878a2136b7fd0", "index": 5051, "step-1": "<mask token>\n\n\nclass RefrigeratorRaider:\n \"\"\"Raid a refrigerator\"\"\"\n\n def open(self):\n print('Open fridge door.')\n\n def take(self, food):\n print('Finding {}...'.format(food))\n if food ...
[ 6, 7, 8, 9, 10 ]
#!/usr/bin/env python # # Copyright 2017-2021 University Of Southern California # # 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...
normal
{ "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 ]
from torchvision import datasets, transforms import torch def load_data(data_folder, batch_size, train, num_workers=0, **kwargs): transform = { 'train': transforms.Compose( [transforms.Resize([256, 256]), transforms.RandomCrop(224), transforms.RandomHorizontalFli...
normal
{ "blob_id": "d99fd3dc63f6a40dde5a6230111b9f3598d3c5fd", "index": 7830, "step-1": "<mask token>\n\n\nclass _InfiniteSampler(torch.utils.data.Sampler):\n \"\"\"Wraps another Sampler to yield an infinite stream.\"\"\"\n\n def __init__(self, sampler):\n self.sampler = sampler\n\n def __iter__(self):\...
[ 8, 9, 10, 11, 12 ]
import SimpleITK as sitk import numpy as np from sklearn.ensemble import RandomForestClassifier # # Estimation function # # # --------------------------- # # Linear registration function # --------------------------- # # --- Input --- # # im_ref : The common image [numpy.ndarray] # im_mov : The group ima...
normal
{ "blob_id": "2b7d9ded82fa980eeae06beb2d84d89612d53df1", "index": 821, "step-1": "<mask token>\n\n\ndef est_lin_transf(im_ref, im_mov, mov_mask=None, show_parameters=False):\n initial_transform = sitk.CenteredTransformInitializer(im_ref, im_mov,\n sitk.ScaleSkewVersor3DTransform(), sitk.\n Center...
[ 5, 6, 7, 8, 9 ]
<|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": "61484d9a08f2e3fcd15573ce89be4118a442dc2e", "index": 6062, "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 = [('bcs', '0002...
[ 0, 1, 2, 3, 4 ]
import cv2 import numpy as np import show_imgs as si IMG_PATH = "../sample_imgs" def blur(): image = cv2.imread(IMG_PATH + "/jjang.jpg") kernel_sizes = [(1, 1), (3, 3), (5, 5), (7, 7), (7, 1), (1, 7)] filter_imgs = {} blur_imgs = {} for ksize in kernel_sizes: title = f"ksize: {ksize}" ...
normal
{ "blob_id": "8e5d05d925d47a85ad7c211f26af7951be048d32", "index": 9351, "step-1": "<mask token>\n\n\ndef blur():\n image = cv2.imread(IMG_PATH + '/jjang.jpg')\n kernel_sizes = [(1, 1), (3, 3), (5, 5), (7, 7), (7, 1), (1, 7)]\n filter_imgs = {}\n blur_imgs = {}\n for ksize in kernel_sizes:\n ...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> help_txt = """ :help, show this help menu. :help [command] for detail :dict [word], only find translation on dict.cn :google [sentence], only find translation on google api :lan2lan [sentence], translate from one language to another language :add [word], add ...
flexible
{ "blob_id": "3fadb91bd2367819a540f687530f4b48ed878423", "index": 9149, "step-1": "<mask token>\n", "step-2": "help_txt = \"\"\"\n:help, show this help menu. :help [command] for detail\n:dict [word], only find translation on dict.cn\n:google [sentence], only find translation on google api\n:lan2lan [sentence], ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class colour: purple = '\x1b[95m' cyan = '\x1b[96m' darkcyan = '\x1b[36m' blue = '\x1b[94m' green = '\x1b[92m' yellow = '\x1b[93m' red = '\x1b[91m' bold = '\x1b[1m' underline = '\x1b[4m' end = '\x1b[0m' <|reserved_special_token_1|> <|reserved_spe...
flexible
{ "blob_id": "4e9fd3ee2a78fae164d9f38704443ac5b2f4c11c", "index": 1189, "step-1": "<mask token>\n\n\nclass colour:\n purple = '\\x1b[95m'\n cyan = '\\x1b[96m'\n darkcyan = '\\x1b[36m'\n blue = '\\x1b[94m'\n green = '\\x1b[92m'\n yellow = '\\x1b[93m'\n red = '\\x1b[91m'\n bold = '\\x1b[1m'\...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python # -*- coding: utf-8 -* #Perso from signalManipulation import * from manipulateData import * #Module import pickle from sklearn import svm, grid_search from sklearn.linear_model import ElasticNetCV, ElasticNet, RidgeClassifier from sklearn.metrics import confusion_matrix, f1_score, accuracy_score...
normal
{ "blob_id": "d8e8ecbf77828e875082abf8dcbfbc2c29564e20", "index": 4892, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*\n#Perso\nfrom signalManipulation import *\nfrom manipulateData import *\n\n#Module\nimport pickle\n\nfrom sklearn import svm, grid_search\nfrom sklearn.linear_model import ElasticNetCV,...
[ 0 ]
import pygame, states, events from settings import all as settings import gui def handleInput(world, event): if event == events.btnSelectOn or event == events.btnEscapeOn: bwd(world) if event%10 == 0: world.sounds['uiaction'].play(0) # world.shouldRedraw = True def bwd(world): if wor...
normal
{ "blob_id": "8650e0f1e7f2ac42c3c78191f79810f5befc9f41", "index": 3298, "step-1": "<mask token>\n\n\ndef bwd(world):\n if world.state >= states.Config:\n return left(world)\n world.shouldRedraw = True\n world.state = states.Intro\n\n\ndef draw(world):\n if not world.shouldRedraw:\n retur...
[ 2, 3, 4, 5, 6 ]
import json from constants import * from coattention_layer import * from prepare_generator import * from tensorflow.keras.layers import Input from tensorflow.keras.models import Model from tensorflow.keras.optimizers import Adam from tensorflow.keras.callbacks import LearningRateScheduler, ModelCheckpoint, Early...
normal
{ "blob_id": "a8d52d81ef6538e9cb8a0a9cab7cd0a778454c8e", "index": 6424, "step-1": "<mask token>\n\n\ndef coattention(num_embeddings):\n image_input = Input(shape=(196, 512))\n question_input = Input(shape=(SEQ_LENGTH,))\n output = CoattentionModel(num_embeddings)(question_input, image_input)\n model =...
[ 3, 4, 5, 6, 7 ]
from flask import Flask, jsonify, request import requests, json, random from bs4 import BeautifulSoup import gspread import pandas as pd import dataservices as dss from oauth2client.service_account import ServiceAccountCredentials # page = requests.get("https://www.worldometers.info/coronavirus/") # soup = BeautifulSou...
normal
{ "blob_id": "267cb37f2ccad5b02a809d9b85327eacd9a49515", "index": 1061, "step-1": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return 'Flask setup'\n\n\ndef sheets_row_writer(data_list):\n print('sheets method invoked')\n credentials = ServiceAccountCredentials.from_json_keyfile_name(\n 'mec...
[ 5, 6, 9, 10, 11 ]
import numpy as np import mysql.connector from mysql.connector import Error import matplotlib.pyplot as plt def readData(): connection = mysql.connector.connect(host='localhost',database='cad_ultrasound',user='root',password='') sql_select_Query = "SELECT id_pasien,nama,pathdata FROM datasets" cu...
normal
{ "blob_id": "4d7696c832f9255fbc68040b61fde12e057c06fa", "index": 3899, "step-1": "<mask token>\n\n\ndef getFiturEkstraksi():\n connection = mysql.connector.connect(host='localhost', database=\n 'cad_ultrasound', user='root', password='')\n cursor = connection.cursor()\n sql_select_Query = 'SELECT...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class GeneralizedQSamplingModel(OdfModel, Cache): def __init__(self, gtab, method='gqi2', sampling_length=1.2, normalize_peaks=False): """ Generalized Q-Sampling Imaging [1]_ This model has the same assumptions as the DSI method i.e. Cartesian grid sa...
flexible
{ "blob_id": "2f193cb1eaf7b5e99d20025716a248144af90b92", "index": 1925, "step-1": "<mask token>\n\n\nclass GeneralizedQSamplingModel(OdfModel, Cache):\n\n def __init__(self, gtab, method='gqi2', sampling_length=1.2,\n normalize_peaks=False):\n \"\"\" Generalized Q-Sampling Imaging [1]_\n\n ...
[ 14, 16, 17, 19, 20 ]
import docker import logging import sys if __name__ == '__main__': # setting up logger logging.basicConfig(stream=sys.stdout, format='[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s', level=logging.DEBUG) # get the docker client clie...
normal
{ "blob_id": "a5c9ff1fe250310216e2eaa7a6ff5cc76fc10f94", "index": 4324, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n logging.basicConfig(stream=sys.stdout, format=\n '[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s',\n level=logging.DEBUG...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Images(models.Model): wordroot_text = models.CharField(max_length=255, verbose_name='词根') wordroot_id = models.IntegerField(default=0, null=True, blank=True, verbose_name='词根id, 可空') url = models.CharField(max_length=255, null=True, blank=True, verbose_na...
flexible
{ "blob_id": "512a13084a860e2784020664a3d5824d9dace6db", "index": 7764, "step-1": "<mask token>\n\n\nclass Images(models.Model):\n wordroot_text = models.CharField(max_length=255, verbose_name='词根')\n wordroot_id = models.IntegerField(default=0, null=True, blank=True,\n verbose_name='词根id, 可空')\n ...
[ 14, 20, 22, 26, 27 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=True) <|reserved_special_token_1|> <|reserved_special_token_0|> app = create_app(Config) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, ...
flexible
{ "blob_id": "bea90bbcd4d34b64c21f022b6f3af2bee2d978e4", "index": 1123, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n app.run(host='0.0.0.0', port=5000, debug=True)\n", "step-3": "<mask token>\napp = create_app(Config)\nif __name__ == '__main__':\n app.run(host='0.0.0...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.2.6 on 2020-06-18 14:16 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('gestionadmin', '0133_auto_20200618_1339'), ] operations = [ migrations.RemoveField( model_name='comprasenc', name='empleado'...
normal
{ "blob_id": "f96a7bef48e7df2899343029a2fae9697125a5b2", "index": 5203, "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 = [('gestionadmi...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def save2txt(songname, lyric, path): print('歌词下载完成:' + songname) lyric_path = path + '\\' + songname + '.txt' with open(lyric_path, 'a', encoding='utf-8') as f: f.write(lyric) <|reserved_special_token_0|> def get_lyrics(songids): url = 'http://music.163.com/api...
flexible
{ "blob_id": "3b11d514b15775e4c818a7a2adf9a80e89dca968", "index": 5801, "step-1": "<mask token>\n\n\ndef save2txt(songname, lyric, path):\n print('歌词下载完成:' + songname)\n lyric_path = path + '\\\\' + songname + '.txt'\n with open(lyric_path, 'a', encoding='utf-8') as f:\n f.write(lyric)\n\n\n<mask ...
[ 17, 20, 21, 24, 33 ]
class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: ''' ans = set() n = len(nums) for x, val in enumerate(nums): for y in range(x + 1, n + 1): ans.add(frozenset(nums[x:y])) for u in range(0, x + 1): fo...
normal
{ "blob_id": "7d873ed216355d1688ec79ff337304d8ebfd2754", "index": 7625, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def subsets(self, nums: List[int]) ->List[List[int]]:\n \"\"\"\n ans = set()\n n = len(nums)\n for ...
[ 0, 1, 2, 3 ]
import requests from bs4 import BeautifulSoup import json headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'} url = 'http://api.tvmaze.com/singlesearch/shows?q=game+of+throne&embed=episodes' response = requests.get(url, headers = hea...
normal
{ "blob_id": "d625e6724a3fe077a6f80b6de6b1f5bb0b95d47d", "index": 4612, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('got_info.json', 'w') as f:\n f.write(x)\n", "step-3": "<mask token>\nheaders = {'User-Agent':\n 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gec...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def solve(n, seq): flag = True freq = defaultdict() i = 1 p = len(seq) j = 0 while j < p: c = seq[j] if i > n: flag = False break if c in freq.keys(): ...
flexible
{ "blob_id": "89b03bb5ca86e426459e23866f86f8770e4a1613", "index": 3420, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solve(n, seq):\n flag = True\n freq = defaultdict()\n i = 1\n p = len(seq)\n j = 0\n while j < p:\n c = seq[j]\n if i > n:\n flag = Fals...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def Preprocessing(instancia): instancia = re.sub('#\\S+', '', instancia) instancia = re.sub('@\\S+', '', instancia).lower().replace('.', '' ).replace(';', '').replace('-', '').replace(':', '').replace(')', '' ...
flexible
{ "blob_id": "bffd211a2d2dc3dd9b596f69909be7f0437ab0c8", "index": 9322, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Preprocessing(instancia):\n instancia = re.sub('#\\\\S+', '', instancia)\n instancia = re.sub('@\\\\S+', '', instancia).lower().replace('.', ''\n ).replace(';', '').r...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class PriorityQueue: pq = [] elements = {} task = 0 def insert(self, priority, x_val, y_val): entry = [priority, self.task, x_val, y_val] self.elements[self.task] = entry heapq.heappush(self.pq, entry) self.task += 1 def delete(self, t...
flexible
{ "blob_id": "6192099bdecffd9ce3576f4034567478145115a0", "index": 1291, "step-1": "<mask token>\n\n\nclass PriorityQueue:\n pq = []\n elements = {}\n task = 0\n\n def insert(self, priority, x_val, y_val):\n entry = [priority, self.task, x_val, y_val]\n self.elements[self.task] = entry\n ...
[ 12, 17, 18, 23, 25 ]
import json # numbers=[2,3,5,7,11,13] filename='numbers.json' with open(filename) as f: numbers=json.load(f) print(numbers)
normal
{ "blob_id": "8da775bd87bfeab5e30956e62bcdba6c04e26b27", "index": 6720, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(filename) as f:\n numbers = json.load(f)\nprint(numbers)\n", "step-3": "<mask token>\nfilename = 'numbers.json'\nwith open(filename) as f:\n numbers = json.load(f)\nprin...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @udf(returnType=BooleanType()) def filter_host(item): for i in filter_hosts: if item.find(i) != -1: return False return True <|reserved_special_token_0|> @udf(returnType=BooleanType()) def contains_host(item): for i in contains_hosts: if item.fi...
flexible
{ "blob_id": "e7d63c3b56459297eb67c56e93a3c640d93e5f6d", "index": 8683, "step-1": "<mask token>\n\n\n@udf(returnType=BooleanType())\ndef filter_host(item):\n for i in filter_hosts:\n if item.find(i) != -1:\n return False\n return True\n\n\n<mask token>\n\n\n@udf(returnType=BooleanType())\n...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def reverse(text): """将字符串翻转""" return text[::-1] def is_palindrome(text): print(e for e in text if e.isalnum()) m = ''.join(e for e in text if e.isalnum()) print(m) """是否是回文数""" return m == reverse(m) <|reserved_special_token_0|> <|reserved_special_token...
flexible
{ "blob_id": "03a1f9f533f7550db32fa25578ef2f7f4c741510", "index": 8583, "step-1": "<mask token>\n\n\ndef reverse(text):\n \"\"\"将字符串翻转\"\"\"\n return text[::-1]\n\n\ndef is_palindrome(text):\n print(e for e in text if e.isalnum())\n m = ''.join(e for e in text if e.isalnum())\n print(m)\n \"\"\"...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def action_scaling(env, action_scaler): """ This is actually going to just be "action scaling". Because, it's all about the ratio, and the ratio doesn't change! """ try: state_dim = len(env.observation_space.low) except AttributeError: print('Using ...
flexible
{ "blob_id": "5529813e10e4a30a60c28242be9d1a8822fb58af", "index": 9685, "step-1": "<mask token>\n\n\ndef action_scaling(env, action_scaler):\n \"\"\"\n This is actually going to just be \"action scaling\". Because,\n it's all about the ratio, and the ratio doesn't change!\n \"\"\"\n try:\n s...
[ 3, 4, 6, 7, 8 ]
from selenium import webdriver import time with webdriver.Chrome() as browser: browser.get("http://suninjuly.github.io/selects1.html") time.sleep(1) x = int(browser.find_element_by_id("num1").text) y = int(browser.find_element_by_id("num2").text) sum_xy = str(int(x)+int(y)) browser.find_element...
normal
{ "blob_id": "42be9077ec51a9be1d4923011a38cd64d829f876", "index": 1529, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith webdriver.Chrome() as browser:\n browser.get('http://suninjuly.github.io/selects1.html')\n time.sleep(1)\n x = int(browser.find_element_by_id('num1').text)\n y = int(brow...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def maths(num): int(num) if num % 5 == 0 and num % 3 == 0: print('bizzfizz') elif num % 3 == 0: print('fizz') elif num % 5 == 0: print('bizz') else: print(num) <|reserved_special_token_0|> <|reserved_spe...
flexible
{ "blob_id": "91f83adbe01e2d8070f9286031b77eae71beb83e", "index": 1107, "step-1": "<mask token>\n", "step-2": "def maths(num):\n int(num)\n if num % 5 == 0 and num % 3 == 0:\n print('bizzfizz')\n elif num % 3 == 0:\n print('fizz')\n elif num % 5 == 0:\n print('bizz')\n else:\...
[ 0, 1, 2, 3, 4 ]
# encoding: utf-8 import paramiko import select import os import sys ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) host = "47.107.229.100" user = "root" pwd = "aliyun1996874353...A" class SSH: def __init__(self, host, user, pwd, port=22): self.host = host sel...
normal
{ "blob_id": "2342a651ec45623b887c4bc1168adb0731ba5ff6", "index": 8443, "step-1": "<mask token>\n\n\nclass SSH:\n <mask token>\n\n def exec_cmd(self, cmd):\n stdin, stdout, stderr = self.client.exec_command(cmd)\n res, err = stdout.read(), stderr.read()\n result = res if res else err\n ...
[ 5, 6, 8, 11, 12 ]
import math import numpy as np import basis.robot_math as rm import grasping.annotation.utils as gu from scipy.spatial import cKDTree def plan_contact_pairs(objcm, max_samples=100, min_dist_between_sampled_contact_points=.005, angle_between_contact_...
normal
{ "blob_id": "738e6d4d608aa977094420a432cbd8a05ea8a1b5", "index": 4384, "step-1": "<mask token>\n\n\ndef plan_grasps(hnd_s, objcm, angle_between_contact_normals=math.radians(\n 160), openning_direction='loc_x', rotation_interval=math.radians(22.5),\n max_samples=100, min_dist_between_sampled_contact_points=...
[ 3, 4, 5, 6, 7 ]
import mxnet as mx import numpy as np import cv2 import random class Even_iterator(mx.io.DataIter): ''' data iterator, shuffle data but always make pairs as neighbors for verification and triplet loss ''' def __init__(self, lst_name, batch_size, aug_params=dict(), shuffle=False): super(Eve...
normal
{ "blob_id": "a824bd7577134227f5c136f2a4382c056f1175be", "index": 9663, "step-1": "import mxnet as mx\nimport numpy as np\nimport cv2\nimport random\n\n\nclass Even_iterator(mx.io.DataIter):\n '''\n data iterator, shuffle data but always make pairs as neighbors\n for verification and triplet loss\n ''...
[ 0 ]
Ylist = ['yes', 'Yes', 'Y', 'y'] Nlist = ['no', 'No', 'N', 'n'] America = ['America', 'america', 'amer', 'rica'] TRW = ['1775', 'The Revolutionary war', 'the Revolutionary war', 'the revolutionary war', 'The Revolutionary War', 'trw', 'Trw', 'TRW'] TCW = ['1861', 'The civil war', 'The civil War', 'The Civil...
normal
{ "blob_id": "6e07dcc3f3b8c7fbf8ce8d481b9612e7496967bd", "index": 8316, "step-1": "<mask token>\n", "step-2": "Ylist = ['yes', 'Yes', 'Y', 'y']\nNlist = ['no', 'No', 'N', 'n']\nAmerica = ['America', 'america', 'amer', 'rica']\nTRW = ['1775', 'The Revolutionary war', 'the Revolutionary war',\n 'the revolution...
[ 0, 1, 2 ]
def patternCount(dnaText, pattern): count = 0 for i in range(0, len(dnaText) - len(pattern)): word = dnaText[i:i+len(pattern)] if (word == pattern): count = count + 1 return count def freqWordProblem(text, k): countWords = [] for i in range(0, len(text) - k): pa...
normal
{ "blob_id": "29c1a989365408bf5c3d6196f7afc969be63df85", "index": 5942, "step-1": "<mask token>\n\n\ndef complimentDNA(text):\n result = ''\n for letter in text:\n result = result + mapDNA[letter]\n return result[::-1]\n\n\ndef patternFind(text, pattern):\n index = []\n for i in range(0, len...
[ 2, 4, 5, 6, 7 ]
# https://www.acmicpc.net/problem/3584 import sys, collections input = sys.stdin.readline N = int(input()) for _ in range(N): n = int(input()) arr = collections.defaultdict(list) parent = [i for i in range(n + 1)] for i in range(n - 1): a, b = map(int, input().split()) arr[a].append(b) ...
normal
{ "blob_id": "d60a2d4c819f701e8e439b8839415aa2838df185", "index": 6415, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(N):\n n = int(input())\n arr = collections.defaultdict(list)\n parent = [i for i in range(n + 1)]\n for i in range(n - 1):\n a, b = map(int, input().spli...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def walk2(dirname): """Prints the names of all files in dirname and its subdirectories. dirname: string name of directory """ for root, dirs, files in os.walk(dirname): for filename in files: print(os.path.join(root, filename)) <|reserved_specia...
flexible
{ "blob_id": "de1262da699a18266ad8673597391f625783a44d", "index": 5721, "step-1": "<mask token>\n\n\ndef walk2(dirname):\n \"\"\"Prints the names of all files in \n dirname and its subdirectories.\n\n dirname: string name of directory\n \"\"\"\n for root, dirs, files in os.walk(dirname):\n f...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def merge_sort(merged_arr: list): """ функция делит поданный на вход массив, и рекурсивно все сортирует слиянием :param merged_arr: - список на входе :return: - список отсортированный слиянием на выходе """ if len(merged_arr) <= 1: return middle = l...
flexible
{ "blob_id": "cd1987f09ca3e09ac251b1ebdec4168fd5dbdd0e", "index": 7607, "step-1": "<mask token>\n\n\ndef merge_sort(merged_arr: list):\n \"\"\"\n функция делит поданный на вход массив,\n и рекурсивно все сортирует слиянием\n :param merged_arr: - список на входе\n :return: - список отсортированный с...
[ 2, 3, 4, 5, 6 ]
import cv2 as cv import numpy as np import sys from meio_tom_lib import * imgname = sys.argv[1] imgpath = "img/" + imgname try: img = cv.imread(imgpath) newimg1 = jarvis_judice_ninke_1(img)*255 newimg2 = jarvis_judice_ninke_2(img)*255 cv.imshow("Imagem original",img) cv.imshow("Jarvis, Judice e...
normal
{ "blob_id": "bf764457e6af25d2d9406b18af51f63b36ab823a", "index": 8564, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n img = cv.imread(imgpath)\n newimg1 = jarvis_judice_ninke_1(img) * 255\n newimg2 = jarvis_judice_ninke_2(img) * 255\n cv.imshow('Imagem original', img)\n cv.imshow('J...
[ 0, 1, 2, 3, 4 ]
# Given an unsorted integer array nums, find the smallest missing positive integer. class Solution: def firstMissingPositive(self, nums: List[int]) -> int: # if nums is emtpy, first pos int is 1 if not nums: return 1 maxnum = max(nums) # for speed we assign max of nums to var max...
normal
{ "blob_id": "09905d4b5ad2e59578d874db171aafb6c42db105", "index": 8609, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def firstMissingPositive(self, nums: List[int]) ->int:\n if not nums:\n return 1\n maxnum = max(nums)\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from .chair_model import run_chair_simulation, init_omega_t, JumpingModel, H_to_L from .utils import load_hcp_peaks, Condition, average_peak_counts <|reserved_special_token_1|> from .chair_model import run_chair_simulation, init_omega_t, \ JumpingM...
flexible
{ "blob_id": "9087a7bf42070fdb8639c616fdf7f09ad3903656", "index": 6755, "step-1": "<mask token>\n", "step-2": "from .chair_model import run_chair_simulation, init_omega_t, JumpingModel, H_to_L\nfrom .utils import load_hcp_peaks, Condition, average_peak_counts\n", "step-3": "from .chair_model import run_chair_...
[ 0, 1, 2 ]
from source.ga.population import create_population, random_genome def test_create_population(race_example): population = create_population(race_example, 20) assert population def test_random_genome(race_basic): genome = random_genome(race_basic) assert genome def test_random_genome_example(race_ex...
normal
{ "blob_id": "0802aac57cd28104cdb6ff45d993aa224f80b830", "index": 2877, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_random_genome(race_basic):\n genome = random_genome(race_basic)\n assert genome\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef test_create_population(race_exa...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from .signals import get_restaurant_coordinates, count_average_price, count_total_calories from .dish import Dish from .ingredients import Ingredient from .restaurants import Restaurant
flexible
{ "blob_id": "1935cab249bf559aeadf785ce7abcecb03344c04", "index": 6058, "step-1": "<mask token>\n", "step-2": "from .signals import get_restaurant_coordinates, count_average_price, count_total_calories\nfrom .dish import Dish\nfrom .ingredients import Ingredient\nfrom .restaurants import Restaurant\n", "step-...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('Convertidor de pies y pulgadas a centímetros') <|reserved_special_token_0|> print('{} pies y {} pulgadas son {} cm'.format(pies, pulgadas, cm)) <|reserved_special_token_1|> print('Convertidor de pies y pulgadas a centímetros') pies = float(input('Es...
flexible
{ "blob_id": "b0ab97f5c05cdeee4c01460109a76cef75ac72ce", "index": 5342, "step-1": "<mask token>\n", "step-2": "print('Convertidor de pies y pulgadas a centímetros')\n<mask token>\nprint('{} pies y {} pulgadas son {} cm'.format(pies, pulgadas, cm))\n", "step-3": "print('Convertidor de pies y pulgadas a centíme...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while True: url = raw_input('Enter URL: ') if len(url) < 1: break print('Retrieving', url) connection = urllib.urlopen(url) data = connection.read() print('Retrieved', len(data), 'characters') t...
flexible
{ "blob_id": "4cdd5fc15096aac01ad6d97d38ef7397859de18b", "index": 5470, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n url = raw_input('Enter URL: ')\n if len(url) < 1:\n break\n print('Retrieving', url)\n connection = urllib.urlopen(url)\n data = connection.read()\n ...
[ 0, 1, 2, 3 ]
import pysftp import time import threading def sftp_connection(): while True: cnopts = pysftp.CnOpts() cnopts.hostkeys = None try: with pysftp.Connection('sb-emea.avl.com', username='abhishek.hingwasia@avl.com', password='AvlAvl2931!!', ...
normal
{ "blob_id": "676ccbac9385a4b63d599c3f85f16e28d839e9b8", "index": 3731, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sftp_connection():\n while True:\n cnopts = pysftp.CnOpts()\n cnopts.hostkeys = None\n try:\n with pysftp.Connection('sb-emea.avl.com', username...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python2.7 '''USAGE: completeness.py BLAST_output (tab formatted) Prints % completeness based on marker gene BLAST of caled genes from a genome Markers from Lan et al. (2016) ''' import sys with open(sys.argv[1],'r') as blastOut: geneHits = [] orgHits = [] hits = 0.0 for line in blastOut: hits += 1.0 ...
normal
{ "blob_id": "a8659ca7d7a5870fc6f62b3dfee1779e33373e7b", "index": 8388, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(sys.argv[1], 'r') as blastOut:\n geneHits = []\n orgHits = []\n hits = 0.0\n for line in blastOut:\n hits += 1.0\n currHit = line.split()[1]\n c...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(100, 1000): for j in range(100, 1000): s = str(i * j) if s[::-1] == s: pal.append(int(s)) print(max(pal)) <|reserved_special_token_1|> pal = [] for i in range(100, 1000): for j...
flexible
{ "blob_id": "179a9cf0713001e361f39aa30192618b392c78c7", "index": 6972, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(100, 1000):\n for j in range(100, 1000):\n s = str(i * j)\n if s[::-1] == s:\n pal.append(int(s))\nprint(max(pal))\n", "step-3": "pal = []\nfo...
[ 0, 1, 2 ]
import os, sys, shutil import fnmatch, logging, zipfile logging.basicConfig(format='%(asctime)s [%(levelname)s] %(message)s', datefmt='%Y-%m-%d,%H:%M:%S', level=logging.DEBUG) def scan_files(dir, pattern): fileList = [] for root, subFolders, files in os.walk(dir): for file in files: ...
normal
{ "blob_id": "187c2a56ba9360b89c8ded09861091e2deedf32e", "index": 7783, "step-1": "<mask token>\n\n\ndef scan_files(dir, pattern):\n fileList = []\n for root, subFolders, files in os.walk(dir):\n for file in files:\n if fnmatch.fnmatch(file, pattern):\n fileList.append(os.pa...
[ 1, 2, 3, 4, 5 ]
from .plutotv_html import PlutoTV_HTML class Plugin_OBJ(): def __init__(self, fhdhr, plugin_utils): self.fhdhr = fhdhr self.plugin_utils = plugin_utils self.plutotv_html = PlutoTV_HTML(fhdhr, plugin_utils)
normal
{ "blob_id": "ee0cf2325c94821fa9f5115e8848c71143eabdbf", "index": 4775, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Plugin_OBJ:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Plugin_OBJ:\n\n def __init__(self, fhdhr, plugin_utils):\n self.fhdhr = fhdhr\n self.plug...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> nx.draw(g) nx.draw(h) plt.show() nx.write_gexf(g, 'test.gexf') <|reserved_special_token_1|> <|reserved_special_token_0|> g = nx.Graph() g = nx.complete_graph(10) h = nx.gnp_random_graph(10, 0.5) nx.draw(g) nx.draw(h) plt.show()...
flexible
{ "blob_id": "3bfa9d42e3fd61cf6b7ffaac687f66c2f4bc073e", "index": 3906, "step-1": "<mask token>\n", "step-2": "<mask token>\nnx.draw(g)\nnx.draw(h)\nplt.show()\nnx.write_gexf(g, 'test.gexf')\n", "step-3": "<mask token>\ng = nx.Graph()\ng = nx.complete_graph(10)\nh = nx.gnp_random_graph(10, 0.5)\nnx.draw(g)\nn...
[ 0, 1, 2, 3, 4 ]
from django.db import models class ScggjyList(models.Model): title = models.CharField(max_length=255) pubData = models.CharField(db_column='pubData', max_length=255) detailLink = models.CharField(db_column='detailLink', max_length=255) detailTitle = models.CharField(db_column='detailTitle', max_length...
normal
{ "blob_id": "951fafe9f1b9a3273f30d101831d1e59e26fe85d", "index": 1535, "step-1": "<mask token>\n\n\nclass ZakerNewsTab(models.Model):\n code = models.IntegerField(blank=True, null=True)\n tabName = models.CharField(db_column='tabName', max_length=20, blank=\n True, null=True)\n\n\n class Meta:\n ...
[ 4, 7, 8, 9, 10 ]
""" Декоратор parser_stop - парсер результата вывода комманды docker stop. """ from functools import wraps def parser_stop(func): @wraps(func) def wrapper(*args, **kwargs): result = func(*args, **kwargs) stdout = result['stdout'] """ stdout: строки разделены \n """ ...
normal
{ "blob_id": "4af573fa17f86ee067b870dce1f6ee482d1b14ff", "index": 8281, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parser_stop(func):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n result = func(*args, **kwargs)\n stdout = result['stdout']\n \"\"\"\n stdou...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('^add/$', views.cart_add, name='add'), url('^count/$', views.cart_count, name='count'), url('^del/$', views.cart_del, name= 'delete'), url('update/$', views.cart_update, name='update'), url('^&', vie...
flexible
{ "blob_id": "5b3a6b44bd9ea80da1983d8254c73bba3e2338e1", "index": 5166, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^add/$', views.cart_add, name='add'), url('^count/$',\n views.cart_count, name='count'), url('^del/$', views.cart_del, name=\n 'delete'), url('update/$', views.c...
[ 0, 1, 2, 3 ]
with open('rosalind_ba3d.txt','r') as f: kmer_length = int(f.readline().strip()) seq = f.readline().strip() dict = {} for offset in range(len(seq)-kmer_length+1): prefix = seq[offset:offset+kmer_length-1] suffix = seq[offset+1:offset+kmer_length] if prefix in dict: dict[prefix].append(suffix) else: ...
normal
{ "blob_id": "050f060bb9d3d46f8b87c9802356bd0da8f926f8", "index": 6244, "step-1": "<mask token>\n", "step-2": "with open('rosalind_ba3d.txt', 'r') as f:\n kmer_length = int(f.readline().strip())\n seq = f.readline().strip()\n<mask token>\nfor offset in range(len(seq) - kmer_length + 1):\n prefix = seq[...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for name in lst: name = name.strip().upper() rname = name[::-1] if name == rname: print(name) <|reserved_special_token_0|> print('-' * 20) <|reserved_special_token_0|> for name in names: name = name.upper()...
flexible
{ "blob_id": "622b388beb56eba85bbb08510c2bcea55f23da9a", "index": 721, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor name in lst:\n name = name.strip().upper()\n rname = name[::-1]\n if name == rname:\n print(name)\n<mask token>\nprint('-' * 20)\n<mask token>\nfor name in names:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def train_once(): os.system('xterm -e "pwd ; cd ~ ; torcs -r ~/quickrace.xml " &') os.system('xterm -e "pwd ; ./start.sh " &') return True <|reserved_special_token_1|> import os import time def train_once(): ...
flexible
{ "blob_id": "c2cf74893c7f7515a95141bb10be6a446b45a0cc", "index": 1447, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef train_once():\n os.system('xterm -e \"pwd ; cd ~ ; torcs -r ~/quickrace.xml \" &')\n os.system('xterm -e \"pwd ; ./start.sh \" &')\n return True\n", "step-3": "import...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Stack(object): def __init__(self): self.items = [] def is_empty(self): return self.items == [] def clear(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() ...
flexible
{ "blob_id": "6fa9dfadc60108e1718c6688f07de877b0ac0afd", "index": 5885, "step-1": "<mask token>\n\n\nclass Stack(object):\n\n def __init__(self):\n self.items = []\n\n def is_empty(self):\n return self.items == []\n\n def clear(self):\n self.items = []\n\n def push(self, item):\n ...
[ 7, 8, 9, 10, 11 ]
<|reserved_special_token_0|> def parseSexLabel(string): if string.startswith('male'): return 0 if string.startswith('female'): return 1 print('ERROR parsing sex from ' + string) <|reserved_special_token_0|> def parseExpLabel(string): if string.startswith('serious'): return ...
flexible
{ "blob_id": "6822a0a194e8b401fecfed2b617ddd5489302389", "index": 4718, "step-1": "<mask token>\n\n\ndef parseSexLabel(string):\n if string.startswith('male'):\n return 0\n if string.startswith('female'):\n return 1\n print('ERROR parsing sex from ' + string)\n\n\n<mask token>\n\n\ndef pars...
[ 2, 3, 4, 5, 7 ]
"""Step (with Warm up) learning rate scheduler module.""" from typing import Union import torch from torch.optim.lr_scheduler import _LRScheduler from typeguard import check_argument_types from espnet2.schedulers.abs_scheduler import AbsBatchStepScheduler class WarmupStepLR(_LRScheduler, AbsBatchStepScheduler): ...
normal
{ "blob_id": "bce16762c0739087a8309872da4ac04298c50893", "index": 7695, "step-1": "<mask token>\n\n\nclass WarmupStepLR(_LRScheduler, AbsBatchStepScheduler):\n <mask token>\n <mask token>\n\n def __repr__(self):\n return (\n f'{self.__class__.__name__}(warmup_steps={self.warmup_steps}, ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(k): l, r = map(int, input().split()) k_list.append([l, r]) <|reserved_special_token_0|> for i in range(1, n): dpsum[i] = dp[i] + dpsum[i - 1] for j in range(k): l, r = k_list[j] li = ...
flexible
{ "blob_id": "97720baab961d50ceae832d52350b9871c552c84", "index": 9071, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(k):\n l, r = map(int, input().split())\n k_list.append([l, r])\n<mask token>\nfor i in range(1, n):\n dpsum[i] = dp[i] + dpsum[i - 1]\n for j in range(k):\n ...
[ 0, 1, 2 ]
"""TcEx Framework Key Value Redis Module""" class KeyValueRedis: """TcEx Key Value Redis Module. Args: context (str): The Redis context (hash) for hashed based operations. redis_client (redis.Client): An instance of redis client. """ def __init__(self, context, redis_client): ...
normal
{ "blob_id": "a5b74c31aed103b55404afc538af60c3eb18cb1b", "index": 9738, "step-1": "<mask token>\n\n\nclass KeyValueRedis:\n <mask token>\n\n def __init__(self, context, redis_client):\n \"\"\"Initialize the Class properties.\"\"\"\n self._context = context\n self._redis_client = redis_c...
[ 5, 6, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('C:\\some\name') print('C:\\some\\name') print('C:\\some\\name') <|reserved_special_token_0|> print(s) <|reserved_special_token_0|> print(s) <|reserved_special_token_1|> x = '我是一个字符串' y = '我也是一个字符串' z = '我还是一个字符串' s = "Ye...
flexible
{ "blob_id": "8fe9d21bb65b795a6633ab390f7f5d24a90146d5", "index": 6774, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('C:\\\\some\\name')\nprint('C:\\\\some\\\\name')\nprint('C:\\\\some\\\\name')\n<mask token>\nprint(s)\n<mask token>\nprint(s)\n", "step-3": "x = '我是一个字符串'\ny = '我也是一个字符串'\nz = '我还...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def gen(task_id): while True: print('Thread runned ' + str(task_id)) img = Cameras[task_id].getImg() ret, jpeg = cv2.imencode('.jpg', img) frame = jpeg.tobytes() yield b'--frame\r\nContent-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n' @restA...
flexible
{ "blob_id": "5cdedce5f984f53b8e26d1580a9040b26023f247", "index": 2910, "step-1": "<mask token>\n\n\ndef gen(task_id):\n while True:\n print('Thread runned ' + str(task_id))\n img = Cameras[task_id].getImg()\n ret, jpeg = cv2.imencode('.jpg', img)\n frame = jpeg.tobytes()\n y...
[ 6, 7, 8, 9, 10 ]
<|reserved_special_token_0|> def validate_email(value, row_number): error_message = _(u'Invalid e-mail address on "%d" line.') return validators.EmailValidator(validators.email_re, unicode( error_message % row_number), 'invalid')(value) <|reserved_special_token_0|> def get_externalsubscribers(file...
flexible
{ "blob_id": "2ec41e02c95a270455c096e85829b7220eeda0c7", "index": 1317, "step-1": "<mask token>\n\n\ndef validate_email(value, row_number):\n error_message = _(u'Invalid e-mail address on \"%d\" line.')\n return validators.EmailValidator(validators.email_re, unicode(\n error_message % row_number), 'i...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> @app.route('/') def root(): return render_template('index.html') @app.route('/api') def index(): return render_template('index.html') @app.route('/api/total/counties') def total_counties(): return process_counties_total(read_macro('county'), get_args()) @app.route('/api/...
flexible
{ "blob_id": "af00c6f443426b1f61e1816d7d14ebc7e6871a82", "index": 5562, "step-1": "<mask token>\n\n\n@app.route('/')\ndef root():\n return render_template('index.html')\n\n\n@app.route('/api')\ndef index():\n return render_template('index.html')\n\n\n@app.route('/api/total/counties')\ndef total_counties():\...
[ 34, 39, 40, 41, 42 ]
import os import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy import stats # prevent numpy exponential # notation on print, default False np.set_printoptions(suppress=True) y_cord_df = pd.DataFrame(data=None, columns=['Time', 'Orien']) list_no = np.arange(0.0, 108000.0, 1.0) y_cord_df['...
normal
{ "blob_id": "ba5171d3de87ec01770a7174d9783d5058b0fced", "index": 9896, "step-1": "<mask token>\n\n\ndef vel_det(file, legend_label, line_color):\n fps = 60\n data_df = pd.read_hdf(path_or_buf=file)\n bodyparts = data_df.columns.get_level_values(1)\n coords = data_df.columns.get_level_values(2)\n b...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('admin/', admin.site.urls), path('post/', post_views. post_list, nam...
flexible
{ "blob_id": "63c0786d277c5576822d6e521f65850762ab5eb0", "index": 9198, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n", "step-3": "<mask token>\nurlpatterns = [path('admin/', admin.site.urls), path('post/', post_views.\n ...
[ 0, 1, 2, 3, 4 ]
import requests from requests import Response from auditlogging.Trail import Trail from utils.Utils import is_empty from auditlogging.agents.AuditAgent import AuditAgent class APIAuditAgent(AuditAgent): """ Captures the audit trail using a REST endpoint URL (POST) Add this agent to Auditor in order to cap...
normal
{ "blob_id": "45a57fac564f23253f9d9cd5d0fd820e559c15b9", "index": 1212, "step-1": "<mask token>\n\n\nclass APIAuditAgent(AuditAgent):\n <mask token>\n\n def __init__(self):\n self._url = 'http://localhost:3000/auditlogs/create'\n self._resp = None\n\n def change_endpoint(self, url: str):\n ...
[ 8, 9, 10, 11 ]
<|reserved_special_token_0|> def explore_cartpole(): for i_episode in range(2): observation = env.reset() for t in range(100): env.render() print(observation) action = env.action_space.sample() observation, reward, done, info = env.step(action) ...
flexible
{ "blob_id": "7789e54acc02fe0277ff80ce14efbcdc4ee6e7f1", "index": 8009, "step-1": "<mask token>\n\n\ndef explore_cartpole():\n for i_episode in range(2):\n observation = env.reset()\n for t in range(100):\n env.render()\n print(observation)\n action = env.action_s...
[ 2, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def load_img(path_to_img): img = tf.io.read_file(path_to_img) img = tf.io.decode_image(img, channels=3) img = tf.image.convert_image_dtype(img, tf.float32) img = img[tf.newaxis, :] return img def preprocess_image(image, target_dim): shape = tf.cast(tf.shape(image...
flexible
{ "blob_id": "36ce0de4cb760632959392a9f982532436bd37b0", "index": 7272, "step-1": "<mask token>\n\n\ndef load_img(path_to_img):\n img = tf.io.read_file(path_to_img)\n img = tf.io.decode_image(img, channels=3)\n img = tf.image.convert_image_dtype(img, tf.float32)\n img = img[tf.newaxis, :]\n return ...
[ 4, 5, 7, 8, 9 ]
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ProcessPoolExecutor import ATLAS1 import ATLAS_v2 from atlas.config import dbConfig import pandas as pd import ContentCategories import NgramMapping import SentimentAnalysis_2 import TrigDriv_2 import TopicModeling import logging import tr...
normal
{ "blob_id": "41698e9d8349ddf3f42aa3d4fc405c69077d1aa3", "index": 3160, "step-1": "from concurrent.futures import ThreadPoolExecutor\nfrom concurrent.futures import ProcessPoolExecutor\nimport ATLAS1\nimport ATLAS_v2\nfrom atlas.config import dbConfig\nimport pandas as pd\nimport ContentCategories\nimport NgramMa...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def roles_required(roles): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): print(roles, 'required') print(args, kwargs, 'provided') if kwargs['role']: ...
flexible
{ "blob_id": "1adaca88cf41d4e4d3a55996022278102887be07", "index": 3707, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef roles_required(roles):\n\n def decorator(func):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n print(roles, 'required')\n print(args, kw...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def perm(n, inc): perm_set = set(map(lambda x: int(''.join(x)), permutations(str(n)))) perms = n, n + inc, n + inc * 2 if any(map(lambda x: x not in prime_set or x not in perm_set, perms)): return None else: return perms <|reserved_special_token_0|> <|r...
flexible
{ "blob_id": "e03290746d6520fde63836e917f6af0c76596704", "index": 3816, "step-1": "<mask token>\n\n\ndef perm(n, inc):\n perm_set = set(map(lambda x: int(''.join(x)), permutations(str(n))))\n perms = n, n + inc, n + inc * 2\n if any(map(lambda x: x not in prime_set or x not in perm_set, perms)):\n ...
[ 1, 2, 3, 4, 5 ]
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import padding import cryptography.hazmat.primitives.ciphers as ciphers import struct import secrets import random from typing import List LOCO_PUBLICKEY = serializ...
normal
{ "blob_id": "db9919ab15988828d24b4430a124841f225860cc", "index": 5764, "step-1": "<mask token>\n\n\nclass V2SLClient:\n <mask token>\n <mask token>\n\n def handshake(self):\n encrypted_key = LOCO_PUBLICKEY.encrypt(self._aeskey, padding.OAEP(\n padding.MGF1(hashes.SHA1()), hashes.SHA1()...
[ 4, 5, 6, 8, 11 ]
import sys sys.path.append('preprocess') import matplotlib matplotlib.use("TkAgg") import matplotlib.pyplot as plt from matplotlib.pyplot import savefig import numpy as np import refit_cfg import os import random from sklearn.model_selection import train_test_split name = ['WashingMachine', 'Kettle', 'Microwave', 'Fr...
normal
{ "blob_id": "30405a6f20a44b2252b6894ef6d0e818861702f8", "index": 9857, "step-1": "<mask token>\n\n\ndef align_process(house_id):\n data = np.load('data\\\\REFIT\\\\original_data\\\\%d.npy' % house_id)\n new_data = []\n current_index = 0\n current_time = int(data[0][0])\n end_time = int(data[-1][0]...
[ 14, 15, 22, 23, 26 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> admin.site.register(Leave) admin.site.register(EmployeeProfile) <|reserved_special_token_1|> from django.contrib import admin from employees.models import Leave, EmployeeProfile admin.site.register(Leave) admin.site.register(Em...
flexible
{ "blob_id": "77ea670b537e9ff7082aeb9ed54b011fa8e3a035", "index": 6328, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Leave)\nadmin.site.register(EmployeeProfile)\n", "step-3": "from django.contrib import admin\nfrom employees.models import Leave, EmployeeProfile\nadmin.site.registe...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class testsolution(TestCase): def setUp(self): self.solution = Solution() self.inout = [([1, 2, 3, 4], [24, 12, 8, 6]), ([4, 5, 1, 8, 2], [80, 64, 320, 40, 160])] def test_productExceptSelf(self): for p1, p2 in self.inout: with sel...
flexible
{ "blob_id": "9e34fcec3af746af37cb68fd8617c706cc1066f6", "index": 1743, "step-1": "<mask token>\n\n\nclass testsolution(TestCase):\n\n def setUp(self):\n self.solution = Solution()\n self.inout = [([1, 2, 3, 4], [24, 12, 8, 6]), ([4, 5, 1, 8, 2], [80,\n 64, 320, 40, 160])]\n\n def t...
[ 3, 4, 5, 6, 8 ]
<|reserved_special_token_0|> def plan_grasps(hnd_s, objcm, angle_between_contact_normals=math.radians( 160), openning_direction='loc_x', rotation_interval=math.radians(22.5), max_samples=100, min_dist_between_sampled_contact_points=0.005, contact_offset=0.002): """ :param objcm: :param hnd_s:...
flexible
{ "blob_id": "738e6d4d608aa977094420a432cbd8a05ea8a1b5", "index": 4384, "step-1": "<mask token>\n\n\ndef plan_grasps(hnd_s, objcm, angle_between_contact_normals=math.radians(\n 160), openning_direction='loc_x', rotation_interval=math.radians(22.5),\n max_samples=100, min_dist_between_sampled_contact_points=...
[ 3, 4, 5, 6, 7 ]
# Import the SDK import json import boto3 from botocore.exceptions import ClientError import uuid #dbclient = boto3.client('dynamodb') dbresource = boto3.resource('dynamodb', region_name='eu-west-1') rekclient = boto3.client('rekognition','eu-west-1') collection_name = 'swiftarycelebrity' ScannedFacestable = dbresour...
normal
{ "blob_id": "6369c692e358c0dfd1193c6e961ecf9b521ea9ba", "index": 4649, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor Images in Faces:\n lv_FaceId = Images['FaceId']\n lv_ImageId = Images['ImageId']\n lv_ExternalImageId = Images['ExternalImageId'],\n lv_Names = ExternalImageId.split('_')\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def publish_data_on_redis(data, channel): redis_client.publish(channel, json.dumps(data)) <|reserved_special_token_1|> <|reserved_special_token_0|> redis_client = redis.StrictRedis(host='redis', port=6379, db=1, password=...
flexible
{ "blob_id": "d61024ecbd092852fc3396e6919d6d3c8aa554db", "index": 6178, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef publish_data_on_redis(data, channel):\n redis_client.publish(channel, json.dumps(data))\n", "step-3": "<mask token>\nredis_client = redis.StrictRedis(host='redis', port=6379,...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for _ in range(tot): id, pw = map(str, input().split()) ID_dict[id] = pw for _ in range(inp): print(ID_dict[input()]) <|reserved_special_token_1|> tot, inp = map(int, input().split()) ID_dict = {} for _ in range(tot...
flexible
{ "blob_id": "cf7556034020d88ddb6b71b9f908c905e2f03cdb", "index": 4076, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(tot):\n id, pw = map(str, input().split())\n ID_dict[id] = pw\nfor _ in range(inp):\n print(ID_dict[input()])\n", "step-3": "tot, inp = map(int, input().split())...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> @api.route('/depthinthewild/transform') @api.expect(upload_parser) class DepthInTheWildDepthTransform(Resource): <|reserved_special_token_0|> @api.route('/depthinthewild/transform_raw') @api.expect(upload_parser) class DepthInTheWildDepthTransformRaw(Resource): def post(self): ...
flexible
{ "blob_id": "acf409f2e56cd16b7dc07476b49b9c18675f7775", "index": 5540, "step-1": "<mask token>\n\n\n@api.route('/depthinthewild/transform')\n@api.expect(upload_parser)\nclass DepthInTheWildDepthTransform(Resource):\n <mask token>\n\n\n@api.route('/depthinthewild/transform_raw')\n@api.expect(upload_parser)\ncl...
[ 3, 5, 6, 7 ]
<|reserved_special_token_0|> def process_corpus(lcount, text, language, corpus, child, utts, owus, pdict, bdict): owu = owus / utts lineout1 = [language, corpus, child, utts, owu] ordered = sorted(pdict.items(), key=lambda pair: pair[1], reverse=True) tokencount = sum(pdict.values()) lineout1....
flexible
{ "blob_id": "4ba0affd3cbdc2652274213a8d410b541fb3edb4", "index": 4584, "step-1": "<mask token>\n\n\ndef process_corpus(lcount, text, language, corpus, child, utts, owus, pdict,\n bdict):\n owu = owus / utts\n lineout1 = [language, corpus, child, utts, owu]\n ordered = sorted(pdict.items(), key=lambda...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def random(): """Return a random parameter set for the model.""" radius = 10 ** np.random.uniform(1.3, 4) d_factor = 10 ** np.random.uniform(-2, -0.7) dnn_fraction = np.random.beta(a=10, b=1) dnn = radius * 4...
flexible
{ "blob_id": "7ccaa15f025b2c1ba560d07c1a30b06c9ebf9ad1", "index": 1927, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef random():\n \"\"\"Return a random parameter set for the model.\"\"\"\n radius = 10 ** np.random.uniform(1.3, 4)\n d_factor = 10 ** np.random.uniform(-2, -0.7)\n dnn_fr...
[ 0, 1, 2, 3, 4 ]
def favorite_book(name): print(f"One of my favorite books is {name}...") favorite_book("Alice in Wonderland")
normal
{ "blob_id": "08848e51d5564bad927607be3fa3c86f2c1212c5", "index": 9668, "step-1": "<mask token>\n", "step-2": "def favorite_book(name):\n print(f'One of my favorite books is {name}...')\n\n\n<mask token>\n", "step-3": "def favorite_book(name):\n print(f'One of my favorite books is {name}...')\n\n\nfavor...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def start(): username = browser.find_element_by_name('username') username.send_keys('Username') password = browser.find_element_by_name('password') password.send_keys('Password') nextButton = browser.find_element_by_xpath("//button[@type='submit']") nextButton.clic...
flexible
{ "blob_id": "6d18aa585c656b244d1e4272caa8419c04b20b6c", "index": 2363, "step-1": "<mask token>\n\n\ndef start():\n username = browser.find_element_by_name('username')\n username.send_keys('Username')\n password = browser.find_element_by_name('password')\n password.send_keys('Password')\n nextButto...
[ 1, 3, 4, 5, 6 ]
import argparse import pandas as pd import random import time class Deck: def __init__(self, num_cols, front, back): self.flashcards = [] self.num_cols = num_cols self.front = front self.back = back class Flashcard: def __init__(self, deck, front, back, column, row): self.deck = deck self.front = front ...
normal
{ "blob_id": "d5903698eb8ed6be531b0cc522d4feff6b79da4e", "index": 954, "step-1": "<mask token>\n\n\nclass Deck:\n\n def __init__(self, num_cols, front, back):\n self.flashcards = []\n self.num_cols = num_cols\n self.front = front\n self.back = back\n\n\nclass Flashcard:\n\n def _...
[ 8, 17, 18, 19, 20 ]
<|reserved_special_token_0|> @Interface.staticderived class Plugin(PluginBase): <|reserved_special_token_0|> <|reserved_special_token_0|> @staticmethod @Interface.override def Generate(open_file_func, global_custom_structs, global_custom_enums, data, output_dir, status_stream): re...
flexible
{ "blob_id": "d8befc4a79176aefcccd3dceddf04ca965601e5c", "index": 2856, "step-1": "<mask token>\n\n\n@Interface.staticderived\nclass Plugin(PluginBase):\n <mask token>\n <mask token>\n\n @staticmethod\n @Interface.override\n def Generate(open_file_func, global_custom_structs, global_custom_enums,\n...
[ 8, 9, 10, 11, 15 ]
import logging from unittest.mock import patch, Mock from intake.tests.base_testcases import ExternalNotificationsPatchTestCase from intake.tests import mock, factories from intake.tests.mock_org_answers import get_answers_for_orgs from intake.management.commands import send_followups from user_accounts.models import O...
normal
{ "blob_id": "5cb67e5fcedafca4ce124e4094cbd8e1e9d95bb4", "index": 3740, "step-1": "<mask token>\n\n\nclass TestCommand(ExternalNotificationsPatchTestCase):\n <mask token>\n\n @patch('intake.management.commands.send_followups.is_the_weekend')\n @patch('intake.management.commands.send_followups.FollowupsSe...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- """ Created on Sun Apr 19 12:28:39 2020 @author: Ксения """ import serial import time import serial.tools.list_ports as lp def get_comports_list(): ports=list(lp.comports(include_links=False)) for p in ports: print(p.device) return ports def read_while_LF(com, timeout...
normal
{ "blob_id": "e08fddefabf1b92aa97b939e05bb31d888df4e6a", "index": 2241, "step-1": "<mask token>\n\n\ndef get_comports_list():\n ports = list(lp.comports(include_links=False))\n for p in ports:\n print(p.device)\n return ports\n\n\ndef read_while_LF(com, timeout_ms=500):\n read_data = ''\n de...
[ 3, 4, 5, 6, 7 ]
""" @author Lucas @date 2019/3/29 21:46 """ # 二分查找 def search(nums, target): left = 0 right = len(nums) - 1 while left <= right: mid = int((left + right)/2) if target > nums[mid]: left = mid + 1 elif target < nums[mid]: right = mid - 1 else: ...
normal
{ "blob_id": "3eeed39bf775e2ac1900142b348f20d15907c6e6", "index": 4972, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef search(nums, target):\n left = 0\n right = len(nums) - 1\n while left <= right:\n mid = int((left + right) / 2)\n if target > nums[mid]:\n left =...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'src/ui_LibraryTab.ui' # # Created: Tue Jun 9 21:46:41 2015 # by: PyQt5 UI code generator 5.4 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Tab(object): def setupUi(se...
normal
{ "blob_id": "ef85f94282bfd7c9491c4e28bab61aaab5c792a5", "index": 232, "step-1": "<mask token>\n\n\nclass Ui_Tab(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Ui_Tab(object):\n <mask token>\n\n def retranslateUi(self, Tab):\n _translate = QtCore.QCoreApplicatio...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Test_is_palindrome(TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Test_is_palindrome(TestCase): def test_is_palindrome(self): from identif...
flexible
{ "blob_id": "785b54dce76d6906df513a8bde0110ab6fd63357", "index": 7083, "step-1": "<mask token>\n\n\nclass Test_is_palindrome(TestCase):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Test_is_palindrome(TestCase):\n\n def test_is_palindrome(self):\n from i...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append(os.environ['raco']) sys.path.append(os.environ['rapl']) sys.path.append(os.environ['rapl'] + '/timetrace') <|reserved_special_token_0|> kwargs_default.update(plot_timey_kwargs_default) find_bad_keys(kwargs_default,...
flexible
{ "blob_id": "97a059d6d34b924a0512ebe6ff5ab1d5ccc072d5", "index": 8966, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.environ['raco'])\nsys.path.append(os.environ['rapl'])\nsys.path.append(os.environ['rapl'] + '/timetrace')\n<mask token>\nkwargs_default.update(plot_timey_kwargs_default...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> async def sound(cube): sound = bytearray() sound.append(2) sound.append(9) sound.append(255) await cube.write_gatt_char(TOIO_SOUND_UUID, sound) async def motor(cube): motor = bytearray() motor.appen...
flexible
{ "blob_id": "923a433a3a04a8538b43d162d17d379daab4698a", "index": 7753, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nasync def sound(cube):\n sound = bytearray()\n sound.append(2)\n sound.append(9)\n sound.append(255)\n await cube.write_gatt_char(TOIO_SOUND_UUID, sound)\n\n\nasync def...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in stringy: if ord(i) >= 65 and ord(i) <= 90: temp = (ord(i) + k - 65) % 26 s += chr(temp + 65) elif ord(i) >= 97 and ord(i) <= 122: temp = (ord(i) + k - 97) % 26 s += chr(temp + 97) ...
flexible
{ "blob_id": "acf787885834961a71fb2655b9d8a1eb026942c7", "index": 4089, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in stringy:\n if ord(i) >= 65 and ord(i) <= 90:\n temp = (ord(i) + k - 65) % 26\n s += chr(temp + 65)\n elif ord(i) >= 97 and ord(i) <= 122:\n temp = (ord...
[ 0, 1, 2, 3 ]
from threading import Thread import time def sleeping(): time.sleep(5) print('Ended') Thread(target=sleeping, daemon=True).start() print('Hello world') time.sleep(5.5)
normal
{ "blob_id": "628fdf848079d0ecf5bf4f5bd46e07ad6cd10358", "index": 5070, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sleeping():\n time.sleep(5)\n print('Ended')\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef sleeping():\n time.sleep(5)\n print('Ended')\n\n\nThread(target=s...
[ 0, 1, 2, 3 ]