code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
# Copyright 2017 Battelle Energy Alliance, LLC # # 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 required by applicable law or agreed t...
normal
{ "blob_id": "5456fb2938ae4d0f69414c153390f86437088114", "index": 4475, "step-1": "<mask token>\n\n\nclass Metric(utils.metaclass_insert(abc.ABCMeta, BaseType)):\n <mask token>\n\n def __init__(self):\n \"\"\"\n This is the basic method initialize the metric object\n @ In, none\n @ Out...
[ 4, 5, 6, 8, 9 ]
<|reserved_special_token_0|> def convert_pos_MSD_to_Universal(pos): if pos.startswith('A'): return 'ADJ' elif pos.startswith('C'): return 'CCONJ' elif pos.startswith('I'): return 'INTJ' elif pos.startswith('M'): return 'NUM' elif pos.startswith('Nc'): return...
flexible
{ "blob_id": "b2a2e06c5db8b12acbc852bafc4ea869b006c1c8", "index": 9722, "step-1": "<mask token>\n\n\ndef convert_pos_MSD_to_Universal(pos):\n if pos.startswith('A'):\n return 'ADJ'\n elif pos.startswith('C'):\n return 'CCONJ'\n elif pos.startswith('I'):\n return 'INTJ'\n elif pos....
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class CustomLogger(logging.Logger): <|reserved_special_token_0|> @staticmethod def format_message(message): return json.dumps(message, **_beautiful_json) if isinstance(message, (dict, list, tuple)) else str(message) def subdebug(self, message, *args, ...
flexible
{ "blob_id": "37fdfddb471e2eec9e5867d685c7c56fc38c5ae7", "index": 8363, "step-1": "<mask token>\n\n\nclass CustomLogger(logging.Logger):\n <mask token>\n\n @staticmethod\n def format_message(message):\n return json.dumps(message, **_beautiful_json) if isinstance(message,\n (dict, list, ...
[ 10, 13, 14, 15, 16 ]
#/usr/bin/env python #v0.2 import random, time mapHeight = 30 mapWidth = 30 fillPercent = 45 def generateNoise(): #generate a grid of cells with height = mapHeight and width = mapWidth with each cell either "walls" (true) or "floors" (false) #border is guaranteed to be walls and all other spaces have a fi...
normal
{ "blob_id": "7feac838f17ef1e4338190c0e8c284ed99369693", "index": 1628, "step-1": "<mask token>\n\n\ndef generateNoise():\n caveMap = []\n column = 1\n row = 1\n while column <= mapWidth:\n while row <= mapHeight:\n if (column == 1 or column == mapWidth or row == 1 or row ==\n ...
[ 5, 6, 8, 9, 11 ]
<|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": "f15f49a29f91181d0aaf66b19ce9616dc7576be8", "index": 6740, "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 = [('Checkbook',...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def upload_file(file_name, object_name=None): RESULT_BUCKET_NAME = 'worm4047bucket2' s3_client = get_client('s3') max_retries = 5 while max_retries > 0: try: response = s3_client.upload_file(file_name, RESULT_BUCKET_NAME, object_name, Ca...
flexible
{ "blob_id": "f405a3e9ccabbba6719f632eb9c51809b8deb319", "index": 999, "step-1": "<mask token>\n\n\ndef upload_file(file_name, object_name=None):\n RESULT_BUCKET_NAME = 'worm4047bucket2'\n s3_client = get_client('s3')\n max_retries = 5\n while max_retries > 0:\n try:\n response = s3_...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class TestGroceryFuncs(unittest.TestCase): def test_getRecipeNames(self): recipe_names = grocery_functions.get_recipe_names('test-recipes') self.assertTrue(recipe_names[0] == 'Cajun Chicken & Rice') self.assertTrue(recipe_names[1] == 'Chicken Curry in a Hurry'...
flexible
{ "blob_id": "c4fbf206482a04f3e2d2aa98a0dbf525a176c4e7", "index": 1087, "step-1": "<mask token>\n\n\nclass TestGroceryFuncs(unittest.TestCase):\n\n def test_getRecipeNames(self):\n recipe_names = grocery_functions.get_recipe_names('test-recipes')\n self.assertTrue(recipe_names[0] == 'Cajun Chicke...
[ 4, 8, 12, 14, 15 ]
#!/usr/bin/env python3 #coding=utf-8 """ dfsbuild.py 单Git仓库多Dockerfile构建工具,提高了构建效率 快速使用: chmod +x ./dfsbuild.py 只构建Git最近一次修改的Dockerfile ./dfsbuild.py -a auto -r registry.cn-shanghai.aliyuncs.com/userename 构建所有的Dockerfile ./dfsbuild.py -a all -r registry.cn-shanghai.aliyuncs.com/userename 构建特定的Dockerfile ./dfsbuil...
normal
{ "blob_id": "400f9b6fb0ab73a920e6b73373615b2f8d1103bb", "index": 2301, "step-1": "<mask token>\n\n\ndef walkDockerfiles(path, splitFirt=True):\n \"\"\" 遍历目录中的所有dockerfile\n \n Arguments:\n path {string} -- 目录路径\n \n Keyword Arguments:\n splitFirt {bool} -- 去除文件开头的path (default: {True...
[ 3, 8, 9, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ProductStore(Store): <|reserved_special_token_0|> def add_product(self, product): try: c = self.conn.cursor() c.execute( 'INSERT INTO product (`name`,customerId,is_e...
flexible
{ "blob_id": "963499e071873083dc942486b9a5b094393cd99e", "index": 4458, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ProductStore(Store):\n <mask token>\n\n def add_product(self, product):\n try:\n c = self.conn.cursor()\n c.execute(\n 'INSERT ...
[ 0, 2, 3, 4 ]
<|reserved_special_token_0|> class Subscribe(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> class Meta: verbose_name = 'підписку' verbose_name_plural = 'Підписки' <|reserved_special_token_1|> <|reserved_special_token_0|> class Subscribe(models.Model): <...
flexible
{ "blob_id": "3c22b187f8538e16c0105706e6aac2875ea3a25c", "index": 6162, "step-1": "<mask token>\n\n\nclass Subscribe(models.Model):\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name = 'підписку'\n verbose_name_plural = 'Підписки'\n", "step-2": "<mask token>\n\n\nclass Subscri...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> def main(argnum, kmin): z_weighted, p = ARGS[argnum] kws = {} kws['version'] = 'v1.9f' kws['krange'] = '%s-0.3' % kmin kws['params'] = 'basemodel-N-fnl' kws['zrange'] = '0.8-2.2' kws['z_weighted'] = z_weighted kws['p'] = p kws['ells'] = [0] hashstr ...
flexible
{ "blob_id": "a40c87fe4b805495e5bd30155faa861cbe16c368", "index": 6123, "step-1": "<mask token>\n\n\ndef main(argnum, kmin):\n z_weighted, p = ARGS[argnum]\n kws = {}\n kws['version'] = 'v1.9f'\n kws['krange'] = '%s-0.3' % kmin\n kws['params'] = 'basemodel-N-fnl'\n kws['zrange'] = '0.8-2.2'\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Environment(tk.Tk, object): def __init__(self): super(Environment, self).__init__() self.action_space = ['g', 'b'] self.num_actions = len(self.action_space) self.title('Environment') self.geometry('{0}x{1}'.format(WIDTH, HEIGHT)) ...
flexible
{ "blob_id": "ee272fe1a023d85d818a8532055dcb5dbcb6a707", "index": 4799, "step-1": "<mask token>\n\n\nclass Environment(tk.Tk, object):\n\n def __init__(self):\n super(Environment, self).__init__()\n self.action_space = ['g', 'b']\n self.num_actions = len(self.action_space)\n self.ti...
[ 4, 5, 6, 8, 10 ]
import numpy as np import matplotlib.pyplot as plt from matplotlib.image import imread X = np.array([[51, 55], [14, 19], [0, 4]]) print(X) A = np.array([[1, 2], [3, 4]]) B = np.array([10, 20]) print(A * B) print(X[0]) print(X[0][1]) for row in X: print(row) newX = X.flatten() print(newX) print(X > 15) # 데이터 ...
normal
{ "blob_id": "ba702a9c5d9d31e48b047c106d77cf1707031d70", "index": 1795, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(X)\n<mask token>\nprint(A * B)\nprint(X[0])\nprint(X[0][1])\nfor row in X:\n print(row)\n<mask token>\nprint(newX)\nprint(X > 15)\n<mask token>\nplt.plot(x, y)\nplt.show()\n<mask...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ScambioConfig(AppConfig): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ScambioConfig(AppConfig): name = 'scambio' <|reserved_special_token_1|> from django.app...
flexible
{ "blob_id": "b091d00f5b5e997de87b36adbe9ce603a36ca49c", "index": 3347, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ScambioConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ScambioConfig(AppConfig):\n name = 'scambio'\n", "step-4": "from django.apps import App...
[ 0, 1, 2, 3 ]
import os import sys import glob import argparse import shutil import subprocess import numpy as np from PIL import Image import torch import torch.backends.cudnn as cudnn import torch.nn.functional as F from torch.autograd import Variable from torchvision.utils import save_image sys.path.append(os.pardir) from model...
normal
{ "blob_id": "d6c06a465c36430e4f2d355450dc495061913d77", "index": 5357, "step-1": "<mask token>\n\n\ndef main():\n global device\n args = parse_args()\n cfg = Config.from_file(args.config)\n out = cfg.train.out\n if not os.path.exists(out):\n os.makedirs(out)\n cuda = torch.cuda.is_availa...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def RMSE(min_y, max_y, yhat, y): yhat = descale(yhat, min_y, max_y) y = descale(y, min_y, max_y) return np.mean(np.power(np.subtract(yhat, y), 2)) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def RMSE(min_y, max_y, yhat, y): ...
flexible
{ "blob_id": "4fd4c9cf3bdb73a003ce860bf2ee0ccab01f0009", "index": 4646, "step-1": "<mask token>\n\n\ndef RMSE(min_y, max_y, yhat, y):\n yhat = descale(yhat, min_y, max_y)\n y = descale(y, min_y, max_y)\n return np.mean(np.power(np.subtract(yhat, y), 2))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n...
[ 1, 2, 3, 4, 5 ]
""" Unit test for the Supermarket checkout exercise """ import unittest from decimal import * from ShoppingCart import * # Unit tests ----- class ScannerTests(unittest.TestCase): def setUp(self): pricingRulesWithSingleDiscount = { 'Apple': { 1 : '0.50' , 3 : '1.30' }, 'Orange'...
normal
{ "blob_id": "fc2a123f8a86d149af9fc73baa360a029fcde574", "index": 6316, "step-1": "<mask token>\n\n\nclass ScannerTests(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def testPricingSingleItems(self):\n scanner = Scanner(self.singleItemListOneDiscount)\n groceryList...
[ 5, 7, 8, 11, 14 ]
# !/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 # -*- coding:utf-8 -*- # @Author : Jiazhixiang import requests from bs4 import BeautifulSoup headers = { "User-Agent": "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.65 Safari/535.11" } # start_url = "htt...
normal
{ "blob_id": "9833af7f5f740e18cbd4d16f59474b4bacaf070c", "index": 2026, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(response.status_code)\nprint(response.apparent_encoding)\n<mask token>\nfor music in list_music:\n print(music['name'])\n print('所属专辑:' + music['album']['name'])\n print('歌...
[ 0, 1, 2, 3, 4 ]
# 作者:西岛闲鱼 # https://github.com/globien/easy-python # https://gitee.com/globien/easy-python # 用蒙特卡洛法计算圆周率,即,往一个正方形里扔豆子,计算有多少比例的豆子扔在了该正方形的内切圆中 import random num_all = 0 #随机点总计数器 num_cir = 0 #随机点在圆内的计数器 num_halt = 10000000 #每产生这么多个随机点后,计算并打印一次目前的结果 print("将进行无限计算,请用Ctrl_C或其他方式强制退出!!!") input("按回车(Enter...
normal
{ "blob_id": "5d9afef2a748782659b82b329ea08d5815162cbc", "index": 3744, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('将进行无限计算,请用Ctrl_C或其他方式强制退出!!!')\ninput('按回车(Enter)键开始...')\nprint('开始计算...,退出请用Ctrl_C或其他强制退出方式...')\nprint(\"\"\"\n实验次数 计算结果\"\"\")\nwhile 1:\n for i in range(num_halt):\n...
[ 0, 1, 2, 3, 4 ]
""" Password Requirements """ # Write a Python program called "pw_validator" to validate a password based on the security requirements outlined below. # VALIDATION REQUIREMENTS: ## At least 1 lowercase letter [a-z] ## At least 1 uppercase letter [A-Z]. ## At least 1 number [0-9]. ## At least 1 special character [~!@#...
normal
{ "blob_id": "d72f9d521613accfd93e6de25a71d188626a0952", "index": 4807, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef pw_validator(pw):\n pw = list(pw)\n if len(pw) < 6 or len(pw) > 16:\n return 'Please enter a valid password.'\n num_count = 0\n lower_count = 0\n upper_count...
[ 0, 1, 2, 3, 4 ]
<|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": "289aa48b4433be533c3916dd039136df45e0ac0b", "index": 1073, "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 = [('student', '...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('parcours par élément') for e in L: print('caractere : *' + e + '*') <|reserved_special_token_1|> L = 'chaine de caractere' print('parcours par élément') for e in L: print('caractere : *' + e + '*') <|reserved_s...
flexible
{ "blob_id": "cdc9bc97332a3914415b16f00bc098acc7a02863", "index": 5020, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('parcours par élément')\nfor e in L:\n print('caractere : *' + e + '*')\n", "step-3": "L = 'chaine de caractere'\nprint('parcours par élément')\nfor e in L:\n print('caracte...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class AssessmentList(ListView): model = Assessment class AssessmentDetail(DetailView): model = Assessment class AnswerQuestions(ListView): model = Question def post(self, request): company, mine, assessment = self.get_assessment(request) for key, value...
flexible
{ "blob_id": "d296e528d399ee772039777d139a1d8271711ee9", "index": 2146, "step-1": "<mask token>\n\n\nclass AssessmentList(ListView):\n model = Assessment\n\n\nclass AssessmentDetail(DetailView):\n model = Assessment\n\n\nclass AnswerQuestions(ListView):\n model = Question\n\n def post(self, request):\...
[ 11, 14, 16, 17, 20 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def delete_sort_array(origin_list): if len(origin_list) == 0: return 0 elif len(origin_list) == 1: return 1 else: for index, item in enumerate(origin_list[:]): if index + 1 < len(o...
flexible
{ "blob_id": "ac0f0fbb9bcb450ac24198069ef8bea8b049ef47", "index": 5824, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef delete_sort_array(origin_list):\n if len(origin_list) == 0:\n return 0\n elif len(origin_list) == 1:\n return 1\n else:\n for index, item in enumerat...
[ 0, 1, 2, 3 ]
# take any non-negative and non-zero integer number and name it c0;if it's even, evaluate a new c0 as c0 ÷ 2; # otherwise, if it's odd, evaluate a new c0 as 3 × c0 + 1; # if c0 ≠ 1, skip to point 2. # The hypothesis says that regardless of the initial value of c0,it will always go to 1. # Write a program which reads on...
normal
{ "blob_id": "e7db3390d30f86e19eee930c48e5f848f41cc579", "index": 645, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n if c0 % 2 == 0:\n c0 //= 2\n if c0 != 1:\n step += 1\n print(' New value is ', c0, ':', 'step', step)\n continue\n el...
[ 0, 1, 2, 3 ]
from django.db import models from django.contrib import admin from django.utils import timezone class Libros(models.Model): ISBN = models.CharField(max_length=13,primary_key=True) Titulo = models.CharField(max_length=15) # Portada = models.ImageField(upload_to='imagen/') Autor = models.CharField(max_le...
normal
{ "blob_id": "86fdea2ae8e253aa4639bb3114de70c693536760", "index": 1046, "step-1": "<mask token>\n\n\nclass Prestamo(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass PrestamoInLine(admin.TabularInline):\n model = Prestamo\n extra = 1\n\n\ncla...
[ 7, 8, 12, 13, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def register(): Pool.register(MyInvoiceReport, module='cooperar-reporte-factura', type_ ='report') <|reserved_special_token_1|> from trytond.pool import Pool from .reporte import MyInvoiceReport def register(): ...
flexible
{ "blob_id": "a52e0dde47d7df1b7b30887a690b201733ac7592", "index": 4473, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef register():\n Pool.register(MyInvoiceReport, module='cooperar-reporte-factura', type_\n ='report')\n", "step-3": "from trytond.pool import Pool\nfrom .reporte import M...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append('/usr/local/anaconda3/lib/python3.6/site-packages') <|reserved_special_token_0|> plt.grid() plt.xlabel('x') plt.ylabel('f(x)') plt.title('Funkcija $sin(x)$ un tās izvitzījums rindā') plt.plot(x, y2) plt.plot(x, y2,...
flexible
{ "blob_id": "1dcea61908753777604d99235407981e89c3b9d4", "index": 4452, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('/usr/local/anaconda3/lib/python3.6/site-packages')\n<mask token>\nplt.grid()\nplt.xlabel('x')\nplt.ylabel('f(x)')\nplt.title('Funkcija $sin(x)$ un tās izvitzījums rindā')...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class GenericBreeder(object): <|reserved_special_token_0|> def __init__(self, nlifesize, nparentsize, nlowestscore): self.Reset(nlifesize, nparentsize, nlowestscore) def Reset(self, nlifesize, nparentsize, nlowestscore): self.life = [self.CreateLife() for i i...
flexible
{ "blob_id": "753617c189a88adee8430e994aa597c9db9410fe", "index": 6143, "step-1": "<mask token>\n\n\nclass GenericBreeder(object):\n <mask token>\n\n def __init__(self, nlifesize, nparentsize, nlowestscore):\n self.Reset(nlifesize, nparentsize, nlowestscore)\n\n def Reset(self, nlifesize, nparents...
[ 8, 10, 13, 14, 15 ]
<|reserved_special_token_0|> class TestKubeFetchContainers(KubeTestBase): class DummyConfig(object): def __init__(self, _environment): self.environment = _environment <|reserved_special_token_0|> <|reserved_special_token_0|> def test_get_flannel(self): self.fetcher.conf...
flexible
{ "blob_id": "d60810ea0b19cc9163ce526e6a5a54da9c8b3f68", "index": 3595, "step-1": "<mask token>\n\n\nclass TestKubeFetchContainers(KubeTestBase):\n\n\n class DummyConfig(object):\n\n def __init__(self, _environment):\n self.environment = _environment\n <mask token>\n <mask token>\n\n ...
[ 5, 6, 7, 8, 10 ]
<|reserved_special_token_0|> class ReportPdfView(ApiView): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ReportPdfView(ApiView): <|reserved_special_token_0|> def post(self, request, *args, **kwargs): data = json....
flexible
{ "blob_id": "789f95095346262a04e7de0f9f9c5df6177e8fbc", "index": 5114, "step-1": "<mask token>\n\n\nclass ReportPdfView(ApiView):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ReportPdfView(ApiView):\n <mask token>\n\n def post(self, request, *args, **kwargs):\n data =...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def find_version(): with open('pytest_defer.py') as fp: for line in fp: if '__version__' in line: version = line.split('=')[-1].strip() return version[1:-1] <|reserved_sp...
flexible
{ "blob_id": "7903484b4a36d4b6ea03b9eaf3bf2b2e056baad8", "index": 8148, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_version():\n with open('pytest_defer.py') as fp:\n for line in fp:\n if '__version__' in line:\n version = line.split('=')[-1].strip()\n ...
[ 0, 1, 2, 3, 4 ]
import unittest import hospital.employee.nurse as n class TestNurse(unittest.TestCase): @classmethod def setUpClass(cls): print('Start testing nurse') def setUp(self): self.n1 = n.Nurse('Tess',18,"5436890982",3200,25) self.n2 = n.Nurse('Melissa',40,"8920953924",9000,5) def...
normal
{ "blob_id": "f24075ea70851ce95bb6b3cd87b6417f8141d546", "index": 9112, "step-1": "<mask token>\n\n\nclass TestNurse(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n self.n1 = n.Nurse('Tess', 18, '5436890982', 3200, 25)\n self.n2 = n.Nurse('Melissa', 40, '8920953924', 9000, 5)\n <m...
[ 7, 8, 9, 11, 13 ]
# -*- coding: utf-8 -*- """ Created on Thu Jul 27 18:34:40 2017 @author: Peiyong Jiang :jiangpeiyong@impcas.ac.cn Wangsheng Wang : wwshunan@impcas.ac.cn Chi Feng : fengchi@impcas.ac.cn supervised by Zhijun Wang & Yuan He """ import os from ...
normal
{ "blob_id": "67f09cd8b41c7a4fe457766dfed916aaf71cc20d", "index": 9489, "step-1": "<mask token>\n\n\ndef GetPage5Docx(fileNameWithPath):\n word = Dispatch('Word.Application')\n word.Visible = False\n word = word.Documents.Open(fileNameWithPath)\n word.Repaginate()\n num_of_sheets = word.ComputeStat...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(a + b) print('hello') <|reserved_special_token_0|> for i in list: if i % 2 != 0: print(i) print('branch') <|reserved_special_token_1|> a = 1 b = 2 print(a + b) print('hello') list = [1, 2, 3, 4, 5] for i in li...
flexible
{ "blob_id": "03b325094bd3e77f467e17ce54deb95bf2b5c727", "index": 1724, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a + b)\nprint('hello')\n<mask token>\nfor i in list:\n if i % 2 != 0:\n print(i)\nprint('branch')\n", "step-3": "a = 1\nb = 2\nprint(a + b)\nprint('hello')\nlist = [1, 2...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def searchBeginAndEndStm(transFileName): fileName = path.splitext(path.basename(transFileName))[0] if path.isfile(path.dirname(transFileName) + '/encoding.txt'): e = open(path.dirname(transFileName) + '/encoding.txt', 'r') encod = e.readline() f = open(tran...
flexible
{ "blob_id": "77531233219b76be51aed86536e4d92b8dc5ccad", "index": 5494, "step-1": "<mask token>\n\n\ndef searchBeginAndEndStm(transFileName):\n fileName = path.splitext(path.basename(transFileName))[0]\n if path.isfile(path.dirname(transFileName) + '/encoding.txt'):\n e = open(path.dirname(transFileN...
[ 4, 5, 6, 7, 8 ]
#!/usr/bin/env python def main(): import sys from pyramid.paster import get_appsettings from sqlalchemy import engine_from_config from pyvideohub.models import ScopedSession, Base config_file = sys.argv[1] settings = get_appsettings(config_file) engine = engine_from_config(settings, 's...
normal
{ "blob_id": "dbb66930edd70729e4df7d3023e83a6eae65cccd", "index": 1030, "step-1": "<mask token>\n", "step-2": "def main():\n import sys\n from pyramid.paster import get_appsettings\n from sqlalchemy import engine_from_config\n from pyvideohub.models import ScopedSession, Base\n config_file = sys....
[ 0, 1, 2, 3 ]
#!/bin/python import sys arr = map(int, raw_input().strip().split(' ')) smallest = 1000000001 largest = 0 smi = -1 lri = -1 for i, num in enumerate(arr): if num < smallest: smallest = num smi = i if num > largest: largest = num lri = i smsum = 0 lrsum = 0 for i in range(len(a...
normal
{ "blob_id": "164665c7d037f1e4128d8227d5fc148940d5c2b8", "index": 6235, "step-1": "#!/bin/python\n\nimport sys\n\narr = map(int, raw_input().strip().split(' '))\n\nsmallest = 1000000001\nlargest = 0\nsmi = -1\nlri = -1\nfor i, num in enumerate(arr):\n if num < smallest:\n smallest = num\n smi = i...
[ 0 ]
# The purpose of this module is essentially to subclass the basic SWIG generated # pynewton classes and add a bit of functionality to them (mostly callback related # stuff). This could be done in the SWIG interface file, but it's easier to do it # here since it makes adding python-specific extensions to newton easier. ...
normal
{ "blob_id": "90d792fe18e589a0d74d36797b46c6ac1d7946be", "index": 4303, "step-1": "<mask token>\n\n\nclass ChamferCylinder(pynewton.ChamferCylinder):\n pass\n\n\nclass ConvexHull(pynewton.ConvexHull):\n pass\n\n\nclass ConvexHullModifier(pynewton.ConvexHullModifier):\n pass\n\n\nclass NullCollider(pynewt...
[ 33, 52, 66, 68, 76 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def label_modes(trip_list, silent=True): """Labels trip segments by likely mode of travel. Labels are "chilling" if traveler is stationary, "walking" if slow, "driving" if fast, and "bogus" if too fast to be real. trip_list [list]: a lis...
flexible
{ "blob_id": "3f4e8402bbd096a33ed159ca0fed250c74c2f876", "index": 4833, "step-1": "<mask token>\n", "step-2": "def label_modes(trip_list, silent=True):\n \"\"\"Labels trip segments by likely mode of travel.\n\n Labels are \"chilling\" if traveler is stationary, \"walking\" if slow,\n \"driving\" if...
[ 0, 1, 2 ]
import arcade WINDOW_WIDTH = 740 WINDOW_HEIGHT = 740 dark_green = (170, 216, 81) light_green = (162, 210, 73) snake_color = (72, 118, 235) def square(square_x, square_y, square_width, square_height, square_color): """ Code that sets up the squares for generation """ arcade.draw_rectangle_filled(square_x, squ...
normal
{ "blob_id": "fbe091b1cf3ecc2f69d34e3b1c399314b38ebc4a", "index": 5656, "step-1": "<mask token>\n\n\ndef generate_grid():\n \"\"\" Code that generates the grid \"\"\"\n y_offset = -10\n for a in range(20):\n x_offset = 10\n for b in range(1):\n y_offset += 20\n for c in ra...
[ 5, 7, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "9cab749b915dbb808ac105caa5287b50729f5fd9", "index": 111, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = Tr...
[ 0, 1, 2, 3, 4 ]
# Given a stream of numbers, print average (or mean) of the stream at every point. def getAverage(prev_avg, val, n): return ((prev_avg * n) + val) / (n + 1) def findAndPrintMovingAvgs(arr): cur_avg = 0 for i in range(len(arr)): cur_avg = getAverage(cur_avg, arr[i], i) print "Avg at", i, "i...
normal
{ "blob_id": "3f4b484f435936137cb8511ec6e0aa89efb267c4", "index": 2480, "step-1": "# Given a stream of numbers, print average (or mean) of the stream at every point.\n\ndef getAverage(prev_avg, val, n):\n return ((prev_avg * n) + val) / (n + 1)\n\ndef findAndPrintMovingAvgs(arr):\n cur_avg = 0\n for i in...
[ 0 ]
# MÁSTER EN BIG DATA Y BUSINESS ANALYTICS # MOD 1 - FINAL EVALUATION - EX. 2: dado un archivo que contiene en cada línea # una palabra o conjunto de palabras seguido de un valor numérico denominado # “sentimiento” y un conjunto de tweets, se pide calcular el sentimiento de # aquellas palabras o conjunto de palabras que...
normal
{ "blob_id": "acd2d84529e197d6f9d134e8d7e25a51a442f3ae", "index": 8615, "step-1": "<mask token>\n\n\ndef get_tweets(filename):\n \"\"\" Process a json formatted file with tweets using pandas read_json \"\"\"\n try:\n tweets = []\n pd_tweets = pd.read_json(filename, lines=True)\n pd_twee...
[ 2, 3, 4, 5, 6 ]
# Write a program to accept a no & count number of zeros in it.(int=32bits) def countOfZeros(num): cnt = 0 while(num!=0): cnt+=1 num = num&(num-1) return (32-cnt) def main(): num = eval(input('Enter number to count zeros in it\'s binary: ')) print('Assumung int...
normal
{ "blob_id": "7affd79fb0bb47283bbd9a7fbcaa0ba43aa8e6a6", "index": 106, "step-1": "<mask token>\n", "step-2": "def countOfZeros(num):\n cnt = 0\n while num != 0:\n cnt += 1\n num = num & num - 1\n return 32 - cnt\n\n\n<mask token>\n", "step-3": "def countOfZeros(num):\n cnt = 0\n w...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class AbstractTensorboardExportService(ABC): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class AbstractTensorboardExportService(ABC): <|reserved_special_token_0|> @abstractmethod def save_ten...
flexible
{ "blob_id": "08c3155a5fbf6c94f5885c12cfc7c917313ae9c7", "index": 5929, "step-1": "<mask token>\n\n\nclass AbstractTensorboardExportService(ABC):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass AbstractTensorboardExportService(ABC):\n <mask token>\n\n @abstractmethod\n def sa...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> def recvall(sock): BUFF_SIZE = 4096 data = b'' while True: part = sock.recv(BUFF_SIZE) data += part if len(part) < BUFF_SIZE: break return data <|reserved_special_token_0|> def extract_start(data): i = 0 while True: i...
flexible
{ "blob_id": "aa13278a4686e9bab7948c2f212f87f9bd6eee00", "index": 969, "step-1": "<mask token>\n\n\ndef recvall(sock):\n BUFF_SIZE = 4096\n data = b''\n while True:\n part = sock.recv(BUFF_SIZE)\n data += part\n if len(part) < BUFF_SIZE:\n break\n return data\n\n\n<mask...
[ 5, 6, 8, 9, 10 ]
<|reserved_special_token_0|> class Vector(object): <|reserved_special_token_0|> def __init__(self, coordinates): try: if not coordinates: raise ValueError self.coordinates = tuple([Decimal(x) for x in coordinates]) self.dimension = len(coordinates) ...
flexible
{ "blob_id": "1253e052865860a6895f91204a70152745b04652", "index": 8498, "step-1": "<mask token>\n\n\nclass Vector(object):\n <mask token>\n\n def __init__(self, coordinates):\n try:\n if not coordinates:\n raise ValueError\n self.coordinates = tuple([Decimal(x) fo...
[ 15, 17, 23, 27, 29 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_model(network, data, labels, verbose=True): """A Function that tests a neural network""" return network.evaluate(x=data, y=labels, verbose=verbose) <|reserved_special_token_1|> <|reserved_special_token_0|...
flexible
{ "blob_id": "39643454cbef9e6fa7979d0f660f54e07d155bc7", "index": 7690, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_model(network, data, labels, verbose=True):\n \"\"\"A Function that tests\n a neural network\"\"\"\n return network.evaluate(x=data, y=labels, verbose=verbose)\n", ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(tf.__version__) <|reserved_special_token_0|> for s, l in train_data: training_sentences.append(str(s.numpy())) training_labels.append(l.numpy()) for s, l in test_data: testing_sentences.append(str(s.numpy())) ...
flexible
{ "blob_id": "921c45af3ba34a1b12657bf4189fc8dd66fa44a6", "index": 3860, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(tf.__version__)\n<mask token>\nfor s, l in train_data:\n training_sentences.append(str(s.numpy()))\n training_labels.append(l.numpy())\nfor s, l in test_data:\n testing_sen...
[ 0, 1, 2, 3, 4 ]
from sklearn.model_selection import train_test_split from sklearn.metrics import silhouette_samples, silhouette_score from sklearn.metrics.cluster import homogeneity_score, completeness_score, v_measure_score from sklearn import datasets from random import shuffle import os import matplotlib matplotlib.use('Agg') imp...
normal
{ "blob_id": "fe63d9b0939bc91d2da14e4d966b33575eab5394", "index": 2531, "step-1": "<mask token>\n\n\ndef v_measure(cluster_labels, true_labels):\n h_score = homogeneity_score(true_labels, cluster_labels)\n c_score = completeness_score(true_labels, cluster_labels)\n v_score = v_measure_score(true_labels, ...
[ 8, 10, 12, 13, 14 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(jsondata) <|reserved_special_token_1|> <|reserved_special_token_0|> r = requests.get('http://pythonspot.com/') jsondata = str(r.headers).replace("'", '"') print(jsondata) <|reserved_special_token_1|> import requests im...
flexible
{ "blob_id": "7404dd324d54bb072e56985716bbae746b4dd219", "index": 1395, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(jsondata)\n", "step-3": "<mask token>\nr = requests.get('http://pythonspot.com/')\njsondata = str(r.headers).replace(\"'\", '\"')\nprint(jsondata)\n", "step-4": "import requests...
[ 0, 1, 2, 3, 4 ]
# ****************************************************************************** # main.py # # Date Name Description # ======== ========= ======================================================== # 6/5/19 Paudel Initial version, # ***********************************************************************...
normal
{ "blob_id": "1490fecd6e983c0e3093a45d77d6fb8afdb54718", "index": 203, "step-1": "<mask token>\n\n\ndef parse_args():\n \"\"\"\n Usual pythonic way of parsing command line arguments\n :return: all command line arguments read\n \"\"\"\n args = argparse.ArgumentParser('GODIT')\n args.add_argument(...
[ 5, 6, 7, 8, 10 ]
import os import pandas as pd import time import sys from tqdm import tqdm sys.path.append(os.path.join(os.environ['HOME'],'Working/interaction/')) from src.make import exec_gjf from src.vdw import vdw_R, get_c_vec_vdw from src.utils import get_E import argparse import numpy as np from scipy import signal i...
normal
{ "blob_id": "961bda96e433bb66d592ad1e99c92db0a9ab9fe9", "index": 8545, "step-1": "<mask token>\n\n\ndef init_process(args):\n auto_dir = args.auto_dir\n monomer_name = args.monomer_name\n os.makedirs(os.path.join(auto_dir, 'gaussian'), exist_ok=True)\n os.makedirs(os.path.join(auto_dir, 'gaussview'),...
[ 3, 7, 9, 10, 12 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('get_img_api$', router.get_img_api), url('add_book$', views.add_book), url('show_books$', views.show_books), url('add_story$', story.add_story), url('show_storys$', story.show_storys), url( 'add_comm...
flexible
{ "blob_id": "373c102018fdcc5211263304c368c2e8beef3257", "index": 720, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('get_img_api$', router.get_img_api), url('add_book$',\n views.add_book), url('show_books$', views.show_books), url('add_story$',\n story.add_story), url('show_stor...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class BinarySearchTree: def __init__(self): self.root = None def create(self, val): if self.root == None: self.root = Node(val) else: current = self.root while True: if val < current.info: ...
flexible
{ "blob_id": "6ee36994f63d64e35c4e76f65e9c4f09797a161e", "index": 511, "step-1": "<mask token>\n\n\nclass BinarySearchTree:\n\n def __init__(self):\n self.root = None\n\n def create(self, val):\n if self.root == None:\n self.root = Node(val)\n else:\n current = sel...
[ 3, 4, 5, 8, 9 ]
from trytond.pool import Pool from .reporte import MyInvoiceReport def register(): Pool.register(MyInvoiceReport, module='cooperar-reporte-factura', type_ ='report')
normal
{ "blob_id": "a52e0dde47d7df1b7b30887a690b201733ac7592", "index": 4473, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef register():\n Pool.register(MyInvoiceReport, module='cooperar-reporte-factura', type_\n ='report')\n", "step-3": "from trytond.pool import Pool\nfrom .reporte import M...
[ 0, 1, 2 ]
import numpy as np from math import inf """ Strategy made by duckboycool for carykh's Prisoner's Dilemma Tournament. (https://youtu.be/r2Fw_rms-mA) It is a nice Tit for Tat based strategy that attempts to detect when the opponent is not changing their actions based off of ours so we can maximize with defects, and att...
normal
{ "blob_id": "8ae6630ccd2f2b5a10401cadb4574772f6ecbc4a", "index": 4478, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef strategy(history, memory):\n if not history.size:\n counts.clear()\n for x in patterns:\n counts.append(0)\n if memory:\n return memory.pop(0...
[ 0, 1, 2, 3, 4 ]
#これは明日20200106に走らせましょう! import numpy as np import sys,os import config2 CONSUMER_KEY = config2.CONSUMER_KEY CONSUMER_SECRET = config2.CONSUMER_SECRET ACCESS_TOKEN = config2.ACCESS_TOKEN ACCESS_TOKEN_SECRET = config2.ACCESS_TOKEN_SECRET import tweepy auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_...
normal
{ "blob_id": "8fac4571a3a1559e297754e89375be06d6c45c2d", "index": 4795, "step-1": "<mask token>\n\n\ndef skip_func(list):\n cnt = 0\n for i in list:\n padd = [0] * 200\n try:\n got = api.friends_ids(i, count=200)\n except:\n print('========NG=============', cnt)\n ...
[ 1, 2, 3, 4, 5 ]
# https://docs.python.org/3/library/math.html # https://metanit.com/python/tutorial/6.2.php # https://habr.com/ru/post/337260/ # https://habr.com/ru/post/112953/ import math num = 8 float_num = 2.5 power = 8 rad = 0.5 grad = 90 n = 16 n10 = 1000 base = 2 print("math.pow:", math.pow(num, power)) # проблема точности ...
normal
{ "blob_id": "17db8f7a35004a1f2bd8d098aff39928d20511da", "index": 7026, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('math.pow:', math.pow(num, power))\nprint('pow:', pow(num, power))\nprint('pow:', pow(num, power, 100))\nprint('fmod:', math.fmod(5, 3))\nprint('fmod:', math.fmod(-1e-100, 1e+100))\...
[ 0, 1, 2, 3, 4 ]
class CUtil: # Returns a dictionary containing the cell UID as they key and the data for the cell as the value # Ex: 'AA': 2, 'AB': 4 .... @staticmethod def generate_board(initial_board, grid_size): board_dictionary = dict() iterator = 0 board_identifiers = CUtil.__generate_boar...
normal
{ "blob_id": "929e6deeb017fd338c63439f689d05331b016d0f", "index": 1951, "step-1": "class CUtil:\n\n @staticmethod\n def generate_board(initial_board, grid_size):\n board_dictionary = dict()\n iterator = 0\n board_identifiers = CUtil.__generate_board_identifiers(grid_size)\n for r...
[ 6, 7, 8, 10, 11 ]
# # Copyright (c) 2011-2014 The developers of Aqualid project - http://aqualid.googlecode.com # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and # associated documentation files (the "Software"), to deal in the Software without restriction, # including without limitati...
normal
{ "blob_id": "cbfccffce2884e1cbebe21daf7792eebc1f88571", "index": 6864, "step-1": "<mask token>\n\n\nclass _NodesTree(object):\n <mask token>\n <mask token>\n <mask token>\n\n def __hasCycle(self, node, new_deps):\n if node in new_deps:\n return True\n deps = set(new_deps)\n ...
[ 68, 84, 88, 95, 105 ]
import sys import time import math from neopixel import * count = int(sys.argv[1]) percent = int(sys.argv[2]) # LED strip configuration: LED_COUNT = count # Number of LED pixels. LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!). LED_FREQ_HZ = 800000 # LED signal frequency in he...
normal
{ "blob_id": "5ff7a3843314dfd3914c5e96164385d61fbe7fa5", "index": 684, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef setPixel(strip):\n for i in range(count):\n if i < lightUp:\n strip.setPixelColor(i, Color(0, 255, 0))\n strip.show()\n else:\n st...
[ 0, 2, 3, 4, 5 ]
import json from bokeh.plotting import figure, output_file from bokeh.io import show from bokeh.palettes import inferno from bokeh.models import ColumnDataSource, FactorRange from bokeh.transform import factor_cmap from bokeh.models import HoverTool # from bokeh.io import export_svgs def read_summary(summary_file): ...
normal
{ "blob_id": "7036ae5f74e6cb04518c20bb52122a1dfae76f23", "index": 712, "step-1": "<mask token>\n\n\ndef read_summary(summary_file):\n return json.loads(open(summary_file, 'r').read())\n\n\ndef get_descriptions(summary):\n d = {}\n for o in summary['ontology_events']:\n print(o)\n d[o] = sum...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while tn <= a + (n - 1) * d: print(tn, end=' ') tn += d <|reserved_special_token_1|> a = int(input('Enter first number: ')) d = int(input('Enter common difference: ')) n = int(input('Number of term: ')) tn = a while tn ...
flexible
{ "blob_id": "e748261d1e5fd7921a022afefe5a5bea1fbfc67c", "index": 9095, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile tn <= a + (n - 1) * d:\n print(tn, end=' ')\n tn += d\n", "step-3": "a = int(input('Enter first number: '))\nd = int(input('Enter common difference: '))\nn = int(input('Numb...
[ 0, 1, 2, 3 ]
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, DATE from sqlalchemy.orm import relationship from database import Base class User(Base): __tablename__ = "users" username = Column(String, primary_key=True, index=True) email = Column(String, unique=True, index=True) name = Column(...
normal
{ "blob_id": "acf69cd714f04aeceb4be39b8a7b2bc5d77cd69f", "index": 3307, "step-1": "<mask token>\n\n\nclass Documents(Base):\n __tablename__ = 'documents'\n id = Column(Integer, primary_key=True, index=True)\n name_doc = Column(String, index=True)\n exp = Column(DATE, index=True)\n notif = Column(In...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': tree = etree.parse('./data.html') result = tree.xpath('//div[@id="p"]//li') for r in result: print('--------', etree.tostring(r, encoding='utf-8').decode('utf-8')) <|reserved_specia...
flexible
{ "blob_id": "52c356b903b1fbb8cbf24c899ed86d7bf134a821", "index": 6387, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n tree = etree.parse('./data.html')\n result = tree.xpath('//div[@id=\"p\"]//li')\n for r in result:\n print('--------', etree.tostring(r, encod...
[ 0, 1, 2, 3 ]
class Solution(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ ...
flexible
{ "blob_id": "66f60eb86137203a74656be13b631384eba30c84", "index": 1681, "step-1": "class Solution(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Solution(object):\n\n def getIntersectionNode(self, headA, headB):\n \"\"\"\n :type head1, head1: ListNode\n ...
[ 1, 2, 3, 4, 5 ]
from .exceptions import InvalidUsage class HTTPMethodView: """ Simple class based implementation of view for the sanic. You should implement methods (get, post, put, patch, delete) for the class to every HTTP method you want to support. For example: class DummyView(HTTPMethodView): ...
normal
{ "blob_id": "4948fd2062bdbd32bfa32d2b0e24587f0872132d", "index": 4686, "step-1": "<mask token>\n\n\nclass HTTPMethodView:\n <mask token>\n <mask token>\n\n def dispatch_request(self, request, *args, **kwargs):\n handler = getattr(self, request.method.lower(), None)\n if handler:\n ...
[ 2, 4, 5, 6 ]
from PyQt4.QtGui import QSystemTrayIcon, QApplication, QMenu, QIcon class SystemTrayIcon(QSystemTrayIcon): def __init__(self, parent=None): super(SystemTrayIcon, self).__init__(parent) self.set_icon_state(QIcon.Disabled) menu = QMenu(parent) self.exit_action = menu.addAction('E&xi...
normal
{ "blob_id": "c6e315d7dd44b998f64eee079f2d8455ffecdc30", "index": 9931, "step-1": "<mask token>\n\n\nclass SystemTrayIcon(QSystemTrayIcon):\n <mask token>\n <mask token>\n\n def set_icon_state(self, state):\n pixmap = QApplication.instance().windowIcon().pixmap(256, 256, state)\n self.setIc...
[ 2, 3, 4, 5 ]
# # Copyright (C) 2005-2006 Rational Discovery LLC # # @@ All Rights Reserved @@ # This file is part of the RDKit. # The contents are covered by the terms of the BSD license # which is included in the file license.txt, found at the root # of the RDKit source tree. # import argparse import re import os from rd...
normal
{ "blob_id": "4b63df35b36b35f1b886b8981519921a9e697a42", "index": 4840, "step-1": "<mask token>\n\n\ndef GetAtomFeatInfo(factory, mol):\n res = [None] * mol.GetNumAtoms()\n feats = factory.GetFeaturesForMol(mol)\n for feat in feats:\n ids = feat.GetAtomIds()\n feature = '%s-%s' % (feat.GetF...
[ 5, 6, 7, 8, 9 ]
# Generated by Django 2.2.14 on 2020-08-25 17:00 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('blog', '0004_auto_20200825_1318'), ] operations = [ migrations.RenameField( model_name='cv', old_name='additionalskills_tex...
normal
{ "blob_id": "e296a5bea5465c2b84e37c7d83922adb01feab70", "index": 9828, "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 = [('blog', '000...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import csv import sys import os.path #Versao 2 do gerador das RawZones #global DIR_PYGEN = "/bid/_temporario_/pythonGeneration/" DIR_INTGR_PAR = "/bid/integration_layer/par/" DIR_INTGR_JOB = "/bid/integration_layer/job/" def Sqoop(filename,source_database,source_table, split_field, sourcesystem, ta...
normal
{ "blob_id": "aa817b86e26cf8cd9771aeb276914a1f5869c737", "index": 1849, "step-1": "#!/usr/bin/python\nimport csv\nimport sys\nimport os.path\n\n#Versao 2 do gerador das RawZones\n\n#global\nDIR_PYGEN = \"/bid/_temporario_/pythonGeneration/\"\nDIR_INTGR_PAR = \"/bid/integration_layer/par/\"\nDIR_INTGR_JOB = \"/bid...
[ 0 ]
<|reserved_special_token_0|> class TestFormation(unittest.TestCase): <|reserved_special_token_0|> def test_formation_with_more_than_three_cards_is_considered_invalid(self): self.assertRaisesRegexp(FormationInvalidError, 'Formation must have 3 cards', Formation, [(1, 'R'), (2, 'Y'), ...
flexible
{ "blob_id": "0ce69b7ce99b9c01892c240d5b268a9510af4503", "index": 1648, "step-1": "<mask token>\n\n\nclass TestFormation(unittest.TestCase):\n <mask token>\n\n def test_formation_with_more_than_three_cards_is_considered_invalid(self):\n self.assertRaisesRegexp(FormationInvalidError,\n 'For...
[ 18, 21, 22, 25, 26 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> __all__ = ['VERSION'] <|reserved_special_token_1|> from .version import VERSION __all__ = ['VERSION'] <|reserved_special_token_1|> #!/usr/bin/env python # -*- coding: utf-8 -*- # =============================================...
flexible
{ "blob_id": "d815c6e233d81dfb144442a83e6006aa4e29bfce", "index": 100, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['VERSION']\n", "step-3": "from .version import VERSION\n__all__ = ['VERSION']\n", "step-4": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# ==============================...
[ 0, 1, 2, 3 ]
import sys def ReadFile(array, fileName): with open(fileName, 'r') as f: if f.readline().rstrip() != 'MS': print("prosze podac macierz sasiedztwa") for i in f: el = list(map(int, i.rstrip().split())) if len(el) > 1: array.append(el) def Prim(mat...
normal
{ "blob_id": "56b8b9884b8500ff70f59058484c4a351b709311", "index": 3517, "step-1": "<mask token>\n\n\ndef main():\n if len(sys.argv) < 2:\n print('prosze podac plik')\n sys.exit()\n fileName = sys.argv[1]\n matrix = []\n ReadFile(matrix, fileName)\n Prim(matrix, 0)\n\n\n<mask token>\n"...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class Obstacle(pygame.sprite.Sprite): def __init__(self, game_params, game_speed): self.obs_type = random.randrange(0, 3) if self.obs_type == 0: self.create_pterodactyl(game_params) elif self.obs_type == 1: self.create_lg_cacti(game_par...
flexible
{ "blob_id": "09dac7bfe98a15b3e79edcb0d0a53c0ab4d771ca", "index": 7053, "step-1": "<mask token>\n\n\nclass Obstacle(pygame.sprite.Sprite):\n\n def __init__(self, game_params, game_speed):\n self.obs_type = random.randrange(0, 3)\n if self.obs_type == 0:\n self.create_pterodactyl(game_p...
[ 7, 8, 9, 10, 11 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import tornado.web from sqlalchemy import desc from sqlalchemy.orm import contains_eager from main_app.models.post import Post from main_app.models.thread import PostThread, User2Thread from main_app.handlers.base_handler import BaseHandler class API_Comments(BaseHan...
normal
{ "blob_id": "5186400c9b3463d6be19e73de665f8792d8d68c7", "index": 6982, "step-1": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport tornado.web\n\nfrom sqlalchemy import desc\nfrom sqlalchemy.orm import contains_eager\n\nfrom main_app.models.post import Post\nfrom main_app.models.thread import PostThread...
[ 0 ]
<|reserved_special_token_0|> class TestTestHelper(TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> def test_assertAnyIn_suceeds(self): """ Make sure assertInAny succeeds :return: """ test_case = AuthHelperTestCase('assertAnyIn') ...
flexible
{ "blob_id": "ae1aab7563443db3a31fe98b5b26b32944d57c9d", "index": 1473, "step-1": "<mask token>\n\n\nclass TestTestHelper(TestCase):\n <mask token>\n <mask token>\n\n def test_assertAnyIn_suceeds(self):\n \"\"\"\n Make sure assertInAny succeeds\n \n :return: \n \"\"\"\n...
[ 2, 3, 4, 5 ]
from django.conf import settings from django.urls import resolve from django.urls import reverse from django.shortcuts import render, redirect, get_object_or_404 from django.http import HttpResponse, JsonResponse, HttpResponseNotFound from django.template.loader import get_template, render_to_string from django.views.g...
normal
{ "blob_id": "55cf99e3493c9c94955fc7e75ac428cbd88ac5cf", "index": 2453, "step-1": "<mask token>\n\n\ndef preProcesar(request):\n id_archivo = request.GET.get('id_archivo')\n archivo = DataArchivoCargueProcesar.objects.filter(id=id_archivo).last()\n valores, columnas = iniPreviw(id_archivo, archivo.\n ...
[ 8, 11, 12, 14, 15 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_metadata(file_id, user_settings=None): """ Obtains the metadata of a file :param str file_id: the identifier of the file whose metadata is needed :param dict user_settings: optional, A dictionary of sett...
flexible
{ "blob_id": "033719313f92aaf3c62eb1b07a9aa08f13c7bb6e", "index": 2600, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_metadata(file_id, user_settings=None):\n \"\"\"\n Obtains the metadata of a file\n\n :param str file_id: the identifier of the file whose metadata is needed\n :par...
[ 0, 2, 3, 4, 5 ]
from nltk.corpus import stopwords from nltk.stem import WordNetLemmatizer from nltk.stem import SnowballStemmer import pandas as pd from sklearn.feature_selection import SelectKBest from sklearn.feature_selection import chi2 from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.feature_extraction.tex...
normal
{ "blob_id": "658532e1b81b025b8295bbf468dc01ecf12b922a", "index": 6463, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef process_review(review):\n review = re.sub('[^a-zA-Z]', ' ', review)\n review = review.lower()\n texts = [wnl.lemmatize(word) for word in review.lower().split() if word\n ...
[ 0, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Created on Wed Mar 24 20:59:36 2021 @author: Abeg """ #factorial using recursion """def factorial(n): if n==0 or n==1: return 1 elif n==2: return n else: return n*factorial(n-1) n=int(input("enter the no")) print(factorial(n))""" #fibonancci using recursi...
normal
{ "blob_id": "d1ee33ce6fb071aae800b0597a09e7039a209ec8", "index": 2574, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef reverse(string):\n if len(string) == 0:\n return\n temp = string[0]\n reverse(string[1:])\n print(temp, end='')\n\n\n<mask token>\n", "step-3": "<mask token>\...
[ 0, 1, 2, 3, 4 ]
LOGIN_USERNAME = 'YOUR_USERNAME' LOGIN_PASSWORD = 'YOUR_PASSWORD'
normal
{ "blob_id": "5a092150896e4082431849828793f86adcd2211c", "index": 8202, "step-1": "<mask token>\n", "step-2": "LOGIN_USERNAME = 'YOUR_USERNAME'\nLOGIN_PASSWORD = 'YOUR_PASSWORD'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> class JobManager: <|reserved_special_token_0|> def __init__(self, environment: 'Environment'): self.foreground_job: Optional[Job] = None self.background_jobs: list[Optional[Job]] = [None] self.environment = environment async def execute(self, s: str):...
flexible
{ "blob_id": "e09f914f00e59124ef7d8a8f183bff3f7f74b826", "index": 5869, "step-1": "<mask token>\n\n\nclass JobManager:\n <mask token>\n\n def __init__(self, environment: 'Environment'):\n self.foreground_job: Optional[Job] = None\n self.background_jobs: list[Optional[Job]] = [None]\n se...
[ 11, 12, 14, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def read_tags(filename): """Reads values of "magic tags" defined in the given Python file. :param filename: Python filename to read the tags from :return: Dictionary of tags """ with open(filename) as f: ...
flexible
{ "blob_id": "9d1b795b561a26ae28e82833485ca6034438e78b", "index": 8491, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef read_tags(filename):\n \"\"\"Reads values of \"magic tags\" defined in the given Python file.\n\n :param filename: Python filename to read the tags from\n :return: Dictio...
[ 0, 2, 3, 4, 5 ]
from Logic.ProperLogic.helper_classes.reducer import MaxReducer from Logic.ProperLogic.misc_helpers import log_error import torch from itertools import count import logging logging.basicConfig(level=logging.INFO) class Cluster: metric = 2 def __init__(self, cluster_id, embeddings=None, embeddings_ids=None,...
normal
{ "blob_id": "265c594b12ea45a2dda12e1157e5ea040f4d6ce4", "index": 9021, "step-1": "<mask token>\n\n\nclass Cluster:\n <mask token>\n <mask token>\n\n def __len__(self):\n return len(self.embeddings_dict)\n\n def set_label(self, label):\n self.label = label\n <mask token>\n <mask to...
[ 7, 17, 20, 21, 22 ]
<|reserved_special_token_0|> def lossFun(inputs, targets, hprev): x, h, yprime = {}, {}, {} h[-1] = np.copy(hprev) loss = 0 for t in range(len(inputs)): x[t] = np.zeros((vocab_size, 1)) x[t][inputs[t]] = 1 h[t] = np.tanh(np.dot(U, x[t]) + np.dot(W, h[t - 1]) + bh) temp ...
flexible
{ "blob_id": "d988cfebeec37df700f46bbb027a4980ba624d30", "index": 6639, "step-1": "<mask token>\n\n\ndef lossFun(inputs, targets, hprev):\n x, h, yprime = {}, {}, {}\n h[-1] = np.copy(hprev)\n loss = 0\n for t in range(len(inputs)):\n x[t] = np.zeros((vocab_size, 1))\n x[t][inputs[t]] = ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> L = [['0', '0', '00'], ['..0', '000'], ['00', '.0', '.0'], ['000', '0']] J = [['.0', '.0', '00'], ['0..', '000'], ['00', '0', '0'], ['000', '..0']] O = [['00', '00']] T = [['000', '.0'], ['0', '00', '0'], ['.0', '000'], ['.0', '00', '.0']] I = [['0000'], ['0'...
flexible
{ "blob_id": "5718eab8c5fac4cb7bfa1b049b63ca1e30610247", "index": 9554, "step-1": "<mask token>\n", "step-2": "L = [['0', '0', '00'], ['..0', '000'], ['00', '.0', '.0'], ['000', '0']]\nJ = [['.0', '.0', '00'], ['0..', '000'], ['00', '0', '0'], ['000', '..0']]\nO = [['00', '00']]\nT = [['000', '.0'], ['0', '00',...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for j in range(0, len(x)): for k in range(0, len(x[j, :])): phikprime[j, k] = np.complex(np.cos(x[j, k]), np.sin(x[j, k])) phikprimebar[j] = np.sum(phikprime[j, :]) / s[1] phikbar[j] = np.angle(phikprimebar[j])...
flexible
{ "blob_id": "c35ecad842477fc8501a763f7eb972f6e7fc13e1", "index": 7525, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor j in range(0, len(x)):\n for k in range(0, len(x[j, :])):\n phikprime[j, k] = np.complex(np.cos(x[j, k]), np.sin(x[j, k]))\n phikprimebar[j] = np.sum(phikprime[j, :]) / s...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> auth.set_access_token(TC.ACCESS_TOKEN, TC.ACCESS_TOKEN_SECRET) <|reserved_special_token_0|> for tweet in tweepy.Cursor(api.search, q='Indiana OR Weather').items(50): print(str(count) + '. ' + tweet.text) count += 1 <|res...
flexible
{ "blob_id": "4da1a97c2144c9aaf96e5fe6508f8b4532b082d4", "index": 7861, "step-1": "<mask token>\n", "step-2": "<mask token>\nauth.set_access_token(TC.ACCESS_TOKEN, TC.ACCESS_TOKEN_SECRET)\n<mask token>\nfor tweet in tweepy.Cursor(api.search, q='Indiana OR Weather').items(50):\n print(str(count) + '. ' + twee...
[ 0, 1, 2, 3, 4 ]
def pantip(k, n, arr, path,len): if len == 0: if sum(path)==k: path.reverse() print(path) return path.append(arr[len-1]) pantip(k,n,arr,path,len-1) path.pop() #backtrack pantip(k,n,arr,path,len-1) inp = input('Enter Input (Money, Product) : ')....
normal
{ "blob_id": "6cdaf89d97be8f5ef37ab35f2916a36b4c75ddbe", "index": 7513, "step-1": "<mask token>\n", "step-2": "def pantip(k, n, arr, path, len):\n if len == 0:\n if sum(path) == k:\n path.reverse()\n print(path)\n return\n path.append(arr[len - 1])\n pantip(k, n, arr...
[ 0, 1, 2, 3, 4 ]
import sys import os import logging import sh from ..util.path import SmartTempDir, replace_path logger = logging.getLogger('pyrsss.gps.teqc') def rinex_info(rinex_fname, nav_fname, work_path=None): """ Query RINEX file *rinex_fname* and RINEX nav file *nav_fname* for usef...
normal
{ "blob_id": "ec19567b49f686f613308d79e439f6ff9053fa40", "index": 5064, "step-1": "<mask token>\n\n\ndef rinex_merge(output_fname, rinex_fnames, _err=sys.stderr):\n \"\"\"\n Using teqc, merge *rinex_fnames* and store to the file\n *output_fname*. Returns *output_fname*. Redirect error output to\n *_er...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ascii_handler(port_handler): <|reserved_special_token_0|> def handle_data(self): """ Show a nicely formatted server list and immediately close connection """ self.ls.log.info('Sendi...
flexible
{ "blob_id": "cbf93eb96f40ff0aedc4b8d9238669da72934b27", "index": 2400, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ascii_handler(port_handler):\n <mask token>\n\n def handle_data(self):\n \"\"\"\n Show a nicely formatted server list and immediately close connection\n ...
[ 0, 2, 3, 4, 5 ]
import os from CTFd.utils.encoding import hexencode def generate_nonce(): return hexencode(os.urandom(32))
normal
{ "blob_id": "4f91c57ad42759654a87328d5c92de8da14ca5ea", "index": 2966, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_nonce():\n return hexencode(os.urandom(32))\n", "step-3": "import os\nfrom CTFd.utils.encoding import hexencode\n\n\ndef generate_nonce():\n return hexencode(os.u...
[ 0, 1, 2 ]
from foods.fruits import * orange.eat() apple.eat()
normal
{ "blob_id": "ad84a5bfcf82dff1f4a7e8f08f3c4243ad24de52", "index": 7318, "step-1": "<mask token>\n", "step-2": "<mask token>\norange.eat()\napple.eat()\n", "step-3": "from foods.fruits import *\norange.eat()\napple.eat()\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> results_dir.mkdir(parents=True, exist_ok=True) <|reserved_special_token_0|> print(data.shape) <|reserved_special_token_0|> print(""" DataFrame Shape :""", shape) print(""" Number of rows :""", shape[0]) print(""" Number of columns...
flexible
{ "blob_id": "b9678b447bc6e7c4e928ffa6b8cd58639e41a801", "index": 2688, "step-1": "<mask token>\n", "step-2": "<mask token>\nresults_dir.mkdir(parents=True, exist_ok=True)\n<mask token>\nprint(data.shape)\n<mask token>\nprint(\"\"\"\nDataFrame Shape :\"\"\", shape)\nprint(\"\"\"\nNumber of rows :\"\"\", shape[0...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class A: <|reserved_special_token_0|> class B: def __init__(self) ->None: self.alpha: str = '' self.C: C = None class C: def __init__(self) ->None: self.alpha: str = '' self.beta: str = '' self.gamma: str = '' self.delta: s...
flexible
{ "blob_id": "0926606a222e1277935a48ba7f0ea886fb4e298a", "index": 5234, "step-1": "<mask token>\n\n\nclass A:\n <mask token>\n\n\nclass B:\n\n def __init__(self) ->None:\n self.alpha: str = ''\n self.C: C = None\n\n\nclass C:\n\n def __init__(self) ->None:\n self.alpha: str = ''\n ...
[ 5, 6, 7, 8, 9 ]
import logging from bson import ObjectId from typing import Union from app.helper import parseControllerResponse from models.members import Member from schema.members import ( CreateMemberSchema, MemberInDBSchema, UpdateMemberSchema, memberHelper, ) def getAllMembersFromDB(**kwargs): """Finds an...
normal
{ "blob_id": "95f9e9a8f681679f56c3755199fba7d654af85e8", "index": 1937, "step-1": "<mask token>\n\n\ndef getAllMembersFromDB(**kwargs):\n \"\"\"Finds and returns all the registered members\"\"\"\n isResponseParsed = kwargs.get('isParsed', False)\n logging.info('Trying to find all the users')\n try:\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class SelectIndexHandler(AskUserEventHandler): <|reserved_special_token_0|> <|reserved_special_token_0|> def on_render(self, console): """ Highlight the tile under the cursor. """ super().on_render(console) x, y = self.engine.mouse_loca...
flexible
{ "blob_id": "8c7dcff80eeb8d7d425cfb25da8a30fc15daf5f9", "index": 4872, "step-1": "<mask token>\n\n\nclass SelectIndexHandler(AskUserEventHandler):\n <mask token>\n <mask token>\n\n def on_render(self, console):\n \"\"\"\n Highlight the tile under the cursor.\n \"\"\"\n super(...
[ 3, 6, 7, 8, 9 ]