code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
from django.db import models from django.utils import timezone from accounts.models import AllUser from profiles.models import Profile ### MODEL HOLDING MEMBER TO CLIENT RELATIONSHIPS. ### class MemberClient(models.Model): created = models.DateTimeField(auto_now_add=timezone.now()) client = models.ForeignKey(...
normal
{ "blob_id": "b419e26cbf5bbb746f897367ddaa829773a6860c", "index": 7742, "step-1": "<mask token>\n\n\nclass MemberClient(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass MemberClient(models.Model):\n <mask token>\n ...
[ 1, 2, 3, 4, 5 ]
import numpy #Matrixmultiplikation #Matrixinvertierung #nicht p inv #selbst invertierbar machen import math import operator
normal
{ "blob_id": "ece20c8c8fae2225cbac3552e254314b7116057c", "index": 7095, "step-1": "<mask token>\n", "step-2": "import numpy\nimport math\nimport operator\n", "step-3": "import numpy\n#Matrixmultiplikation\n#Matrixinvertierung\n#nicht p inv\n#selbst invertierbar machen\n\nimport math\nimport operator", "step...
[ 0, 1, 2 ]
<|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": "1c1cd0eeea4dbf446aa4582f42ef1f3b5a4e8875", "index": 7452, "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 = [('meeting', '...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @register.filter def td_humanize(diff): if diff.total_seconds() < 0: return 'Meni jo!' days = diff.days if days >= 7: weeks, days = divmod(days, 7) result = str(weeks) + ' vk' if days: result += ' ' + str(days) + ' pv' return...
flexible
{ "blob_id": "43792a647243b9d667d6d98b62a086d742e8e910", "index": 6093, "step-1": "<mask token>\n\n\n@register.filter\ndef td_humanize(diff):\n if diff.total_seconds() < 0:\n return 'Meni jo!'\n days = diff.days\n if days >= 7:\n weeks, days = divmod(days, 7)\n result = str(weeks) + ...
[ 2, 7, 8, 9, 12 ]
# defining private variables class Privacy: def __init__(self, val): self.__val = 900; print("Private data member =",self.__val,"\n") value = Privacy(800); print("Value not changable\n") value.__val;
normal
{ "blob_id": "b767519229058b50183d78bb97121f050e5b6bad", "index": 423, "step-1": "class Privacy:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Privacy:\n\n def __init__(self, val):\n self.__val = 900\n print('Private data member =', self.__val, '\\n')\n\n\n<mask token>\n", "step-3"...
[ 1, 2, 3, 4, 5 ]
def ispalindrome(s): if len(s) <= 1: return True elif s[0] != s[-1]: return False else: return ispalindrome(s[1:-1])
normal
{ "blob_id": "c20a414f7f96a96f6e458fc27e5d2c7ac7ab05cf", "index": 8574, "step-1": "<mask token>\n", "step-2": "def ispalindrome(s):\n if len(s) <= 1:\n return True\n elif s[0] != s[-1]:\n return False\n else:\n return ispalindrome(s[1:-1])\n", "step-3": null, "step-4": null, ...
[ 0, 1 ]
<|reserved_special_token_0|> def patternToNumber(pattern): if len(pattern) == 0: return 0 return 4 * patternToNumber(pattern[0:-1]) + symbolToNumber(pattern[-1:]) def symbolToNumber(symbol): if symbol == 'A': return 0 if symbol == 'C': return 1 if symbol == 'G': r...
flexible
{ "blob_id": "51848a64102f7fe8272fcf56a9792ed50c430538", "index": 9115, "step-1": "<mask token>\n\n\ndef patternToNumber(pattern):\n if len(pattern) == 0:\n return 0\n return 4 * patternToNumber(pattern[0:-1]) + symbolToNumber(pattern[-1:])\n\n\ndef symbolToNumber(symbol):\n if symbol == 'A':\n ...
[ 8, 9, 11, 13, 15 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append(os.pardir) <|reserved_special_token_0|> for key in optimizers.keys(): networks[key] = MultiLayerNet(input_size=784, hidden_size_list=[100, 100, 100, 100], output_size=10) train_loss[key] = [] for i...
flexible
{ "blob_id": "85d40a49341c7bd7af7a5dc62e4bce0253eb25e6", "index": 9944, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.pardir)\n<mask token>\nfor key in optimizers.keys():\n networks[key] = MultiLayerNet(input_size=784, hidden_size_list=[100, \n 100, 100, 100], output_size=10)...
[ 0, 1, 2, 3, 4 ]
from models import Ban from django.shortcuts import render_to_response class IPBanMiddleware(object): """ Simple middleware for taking care of bans from specific IP's Redirects the banned user to a ban-page with an explanation """ def process_request(self, request): ip = request.META['REMOTE_ADDR'] # use...
normal
{ "blob_id": "9289eb32db145187c5b4140e32acff520be8366e", "index": 7620, "step-1": "<mask token>\n\n\nclass IPBanMiddleware(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass IPBanMiddleware(object):\n <mask token>\n\n def process_request(self, request):\n ip = reque...
[ 1, 2, 3, 4, 5 ]
import ray import os import sys import random path_join = os.path.join real_path = os.path.realpath perfd_dir = real_path(path_join(os.getcwd())) microps_dir = path_join(perfd_dir, "thirdparty", "microps") sys.path += [perfd_dir, microps_dir] from thirdparty.microps.oracle.experiments.spark_sql_perf.main import Spar...
normal
{ "blob_id": "25595b5f86a41fee1dc43f199f3bcff73f6d256b", "index": 9418, "step-1": "<mask token>\n\n\n@ray.remote\ndef run(run_config: dict, wrks: dict) ->dict:\n try:\n add_spk_role()\n except:\n print('run, spark: ignore')\n os.chdir(microps_dir)\n base_spk_config = spk.apps_config_map[...
[ 1, 2, 3, 4, 5 ]
<|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": "8b0eed6d1f24b5dd30726ce08c97354a5d5ab69b", "index": 7597, "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 = [('grafit', '0...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def main(): if len(sys.argv) != 3: sys.stderr.write('USAGE: %s input output\n' % sys.argv[0]) sys.stderr.flush() sys.exit(0) with open(sys.argv[1]) as inpt, open(sys.argv[2], 'w') as outp: process(inpt, outp) <|reserved_special_token_0|> <|reser...
flexible
{ "blob_id": "f819d1b1f2f6f3052247cda592007eac40aca37a", "index": 7927, "step-1": "<mask token>\n\n\ndef main():\n if len(sys.argv) != 3:\n sys.stderr.write('USAGE: %s input output\\n' % sys.argv[0])\n sys.stderr.flush()\n sys.exit(0)\n with open(sys.argv[1]) as inpt, open(sys.argv[2], ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class StardogGraphStore(GraphStore): <|reserved_special_token_0|> def check_whether_db_exists(self): logger.debug("Checking whether a triple store with db '{}' exists..." .format(self._node_ts_url)) url = self._get_ts_db_url() r = requests.get(...
flexible
{ "blob_id": "a42a94798d176e20646d41cf0f4b7e4f99e0790b", "index": 105, "step-1": "<mask token>\n\n\nclass StardogGraphStore(GraphStore):\n <mask token>\n\n def check_whether_db_exists(self):\n logger.debug(\"Checking whether a triple store with db '{}' exists...\"\n .format(self._node_ts_u...
[ 4, 5, 6, 7, 8 ]
from kivy.app import App from kivy.uix.floatlayout import FloatLayout class LayoutWindow(FloatLayout): pass class floatlayoutApp(App): def build(self): return LayoutWindow() if __name__== "__main__": display = floatlayoutApp() display.run()
normal
{ "blob_id": "2af8677e76b77b9bfa579012a85ea331c0c7f390", "index": 136, "step-1": "<mask token>\n\n\nclass floatlayoutApp(App):\n\n def build(self):\n return LayoutWindow()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass LayoutWindow(FloatLayout):\n pass\n\n\nclass floatlayoutApp(App):\n\n ...
[ 2, 3, 4, 5, 6 ]
class TflearnDataSourceExtraTemplate(object): """ Base class for TFLearn's DataSource (if we use wrapping). Parameters: ---------- rewrite_data_aug : bool use wrapper for data augmentation """ def __init__(self, rewrite_data_aug=False): self.rewrite_data_aug = rewrite_data_...
normal
{ "blob_id": "70c084dab8469ca34b0e3e5174101111e695f1ca", "index": 6638, "step-1": "<mask token>\n", "step-2": "class TflearnDataSourceExtraTemplate(object):\n <mask token>\n <mask token>\n", "step-3": "class TflearnDataSourceExtraTemplate(object):\n <mask token>\n\n def __init__(self, rewrite_data...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def downgrade(): op.drop_column('stakeholder', 'archived') <|reserved_special_token_1|> <|reserved_special_token_0|> def upgrade(): op.add_column('stakeholder', sa.Column('archived', sa.Boolean(), nullable=False, default=False, server_default='false')) def downgrade...
flexible
{ "blob_id": "42d9f40dd50056b1c258508a6cb3f9875680276a", "index": 3393, "step-1": "<mask token>\n\n\ndef downgrade():\n op.drop_column('stakeholder', 'archived')\n", "step-2": "<mask token>\n\n\ndef upgrade():\n op.add_column('stakeholder', sa.Column('archived', sa.Boolean(),\n nullable=False, defa...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : 河北雪域网络科技有限公司 A.Star # @contact: astar@snowland.ltd # @site: # @file: img_to_sketch.py # @time: 2018/8/6 1:15 # @Software: PyCharm from skimage.color import rgb2grey import numpy as np def sketch(img, threshold=15): """ 素描画生成 param img: Image实例  ...
normal
{ "blob_id": "065354d2a8fd8a75e16bf85f624b12641377029a", "index": 8568, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sketch(img, threshold=15):\n \"\"\"\n 素描画生成\n param img: Image实例\n  param threshold: 介于0到100\n :return:\n \"\"\"\n if threshold < 0:\n threshold = 0\n ...
[ 0, 1, 2, 3 ]
/Users/tanzy/anaconda3/lib/python3.6/_dummy_thread.py
normal
{ "blob_id": "08a5a903d3757f8821554aa3649ec2ac2b2995a5", "index": 911, "step-1": "/Users/tanzy/anaconda3/lib/python3.6/_dummy_thread.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
from math import ceil, log2, sqrt def constructST(s, start, end, st, i): if start == end: st[i] = 0 openst[i] = 1 if s[start] == '(' else 0 closedst[i] = 1 if s[start] == ')' else 0 return st[i], openst[i], closedst[i] else: mid = (start+end)//2 st[i], openst[i], closedst[i] = constructST(s, ...
normal
{ "blob_id": "ccc74f58eff3bb00f0be8c2c963de4208b7f0933", "index": 9125, "step-1": "<mask token>\n\n\ndef constructST(s, start, end, st, i):\n if start == end:\n st[i] = 0\n openst[i] = 1 if s[start] == '(' else 0\n closedst[i] = 1 if s[start] == ')' else 0\n return st[i], openst[i],...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if recipe not in recipes: user.add_recipes([recipe]) db.session.commit() <|reserved_special_token_1|> <|reserved_special_token_0|> user = User.query.filter_by(username='xiaofan').first() recipe = Recipe.query.filter_by(...
flexible
{ "blob_id": "07f8fd305e2311c0e37a785da0a826b8ea4e78ba", "index": 4154, "step-1": "<mask token>\n", "step-2": "<mask token>\nif recipe not in recipes:\n user.add_recipes([recipe])\n db.session.commit()\n", "step-3": "<mask token>\nuser = User.query.filter_by(username='xiaofan').first()\nrecipe = Recipe....
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def get_basename(name, split_num): return f'{name}.split{split_num:d}' <|reserved_special_token_0|> def maybe_load_model(name, split_num, checkpoint_dir, resume_from_epoch, batch_norm, l1_factor, l2_factor, optimizer): """ Attempt to load the specified model (including...
flexible
{ "blob_id": "6553312c9655c821444ff5f60e4d68c7fc08bd08", "index": 1118, "step-1": "<mask token>\n\n\ndef get_basename(name, split_num):\n return f'{name}.split{split_num:d}'\n\n\n<mask token>\n\n\ndef maybe_load_model(name, split_num, checkpoint_dir, resume_from_epoch,\n batch_norm, l1_factor, l2_factor, op...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class DensePoseConfig(ZambaBaseModel): <|reserved_special_token_0|> video_loader_config: VideoLoaderConfig output_type: DensePoseOutputEnum render_output: bool = False embeddings_in_json: bool = False data_dir: Path filepaths: Optional[Path] = None save_dir...
flexible
{ "blob_id": "9d8d8e97f7d3dbbb47dc6d4105f0f1ffb358fd2f", "index": 6977, "step-1": "<mask token>\n\n\nclass DensePoseConfig(ZambaBaseModel):\n <mask token>\n video_loader_config: VideoLoaderConfig\n output_type: DensePoseOutputEnum\n render_output: bool = False\n embeddings_in_json: bool = False\n ...
[ 4, 5, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def tetrahedron_filled(tetrahedrons, water): var = 0 br = 0 tetrahedrons.sort() for numbers in tetrahedrons: v = tetrahedrons[var] ** 3 * 2 ** 0.5 / 12000 if v < water: br = br + 1 water = water - v ...
flexible
{ "blob_id": "c926e16ef2daa5978b6c71e7794721d320bb9b1e", "index": 1224, "step-1": "<mask token>\n", "step-2": "def tetrahedron_filled(tetrahedrons, water):\n var = 0\n br = 0\n tetrahedrons.sort()\n for numbers in tetrahedrons:\n v = tetrahedrons[var] ** 3 * 2 ** 0.5 / 12000\n if v < w...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class InvoiceServiceTestCase(TestCase): <|reserved_special_token_0|> def test_create_invoice(self): invoice = self.invoice_service.create_invoice(amount=12.1, status= InvoiceStatusChoices.OVERDUE, due_date=date(2019, 4, 1), debtor =self.debtor_1) ...
flexible
{ "blob_id": "5f77e93d63c696363c30f019019acd22c694308b", "index": 4529, "step-1": "<mask token>\n\n\nclass InvoiceServiceTestCase(TestCase):\n <mask token>\n\n def test_create_invoice(self):\n invoice = self.invoice_service.create_invoice(amount=12.1, status=\n InvoiceStatusChoices.OVERDUE...
[ 3, 4, 5, 6 ]
#!/usr/bin/env python __author__ = "Maxime Beauchamp" __version__ = "0.1" __date__ = "2020-12-10" __email__ = "maxime.beauchamp@imt-atantique.fr" from graphics_OSSE import * # function to create recursive paths def mk_dir_recursive(dir_path): if os.path.isdir(dir_path): return h, t = os.path.split(di...
normal
{ "blob_id": "9f4cd9ed8aea03f5908aef4a154d964f0810619b", "index": 9820, "step-1": "<mask token>\n\n\ndef mk_dir_recursive(dir_path):\n if os.path.isdir(dir_path):\n return\n h, t = os.path.split(dir_path)\n if not os.path.isdir(h):\n mk_dir_recursive(h)\n new_path = join_paths(h, t)\n ...
[ 1, 2, 3, 4, 5 ]
from django.http import HttpResponse from polls.models import Pregunta from django.template import loader def index(request): preguntas = Pregunta.objects.order_by('-fecha')[:5] template = loader.get_template('polls/index.html') context = { 'listado': preguntas,} return HttpResponse(template.render(c...
normal
{ "blob_id": "07dc058ecef323ffd41299245e4fcafdc9e41506", "index": 2131, "step-1": "<mask token>\n\n\ndef resultados(request, total):\n latest_question_list = Pregunta.objects.order_by('fecha')[:total]\n output = ', '.join([q.descripcion for q in latest_question_list])\n return HttpResponse(output)\n\n\n<...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def f(x, y): return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def f(x, y): return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2) <|reserved_special_token_0|> ax...
flexible
{ "blob_id": "e9c439eafac8fd689980ffcb562f3b5ee903dd56", "index": 2604, "step-1": "<mask token>\n\n\ndef f(x, y):\n return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef f(x, y):\n return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y **...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Actor: def __init__(self): self.x = random.random() * sizex self.y = random.random() * sizey self.xn = self.x self.yn = self.y def step(self): t = getnoise(self.x, self.y) * 5 * math.pi self.x = self.xn self.y = self....
flexible
{ "blob_id": "68c9944c788b9976660384e5d1cd0a736c4cd0e6", "index": 3826, "step-1": "<mask token>\n\n\nclass Actor:\n\n def __init__(self):\n self.x = random.random() * sizex\n self.y = random.random() * sizey\n self.xn = self.x\n self.yn = self.y\n\n def step(self):\n t = g...
[ 3, 4, 6, 7 ]
<|reserved_special_token_0|> class TestComputeReverseDependencies(unittest.TestCase): def setUp(self): repo_0 = Repository(packages_from_definition(PACKAGE_DEF_0)) repo_1 = Repository(packages_from_definition(PACKAGE_DEF_1)) self.repos = [repo_0, repo_1] <|reserved_special_token_0|> ...
flexible
{ "blob_id": "fcf19c49bb161305eaa5ba8bc26e276a8e8db8ea", "index": 3925, "step-1": "<mask token>\n\n\nclass TestComputeReverseDependencies(unittest.TestCase):\n\n def setUp(self):\n repo_0 = Repository(packages_from_definition(PACKAGE_DEF_0))\n repo_1 = Repository(packages_from_definition(PACKAGE_...
[ 5, 12, 13, 14, 18 ]
# 1.- Crear una grafica que muestre la desviacion tipica de los datos cada dia para todos los pacientes # 2.- Crear una grafica que muestre a la vez la inflamacion maxima, media y minima para cada dia import numpy as np data = np.loadtxt(fname='inflammation-01.csv', delimiter=',') import matplotlib.pyplot as pl...
normal
{ "blob_id": "52064b518ad067c9906e7de8542d9a399076a0b5", "index": 4214, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.plot(data.std(axis=0))\nplt.show()\nplt.plot(data.max(axis=0))\nplt.plot(data.mean(axis=0))\nplt.plot(data.min(axis=0))\n", "step-3": "<mask token>\ndata = np.loadtxt(fname='inflamm...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class BaseCard(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __getattr__(self, item): """ 添加魔术方法 :param item: :return: """ operation = it...
flexible
{ "blob_id": "93e5852df00733c024a59d37699bae58bd893030", "index": 112, "step-1": "<mask token>\n\n\nclass BaseCard(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __getattr__(self, item):\n \"\"\"\n 添加魔术方法\n :param item:\n :return:\n \...
[ 2, 3, 4, 7, 9 ]
class Solution: def minimumDeletions(self, nums: List[int]) ->int: n = len(nums) a = nums.index(min(nums)) b = nums.index(max(nums)) if a > b: a, b = b, a return min(a + 1 + n - b, b + 1, n - a)
normal
{ "blob_id": "14f3c941856ddf6bd7b3e046f21072f0b5f7b036", "index": 5009, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def minimumDeletions(self, nums: List[int]) ->int:\n n = len(nums)\n a = nums.index(min(nums))\n b = nums....
[ 0, 1, 2 ]
# Copyright (c) 2023 Intel Corporation # 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 to in writ...
normal
{ "blob_id": "cd1ada2d7979fffc17f707ed113efde7aa134954", "index": 3036, "step-1": "<mask token>\n\n\n@api(canonical_alias='nncf.torch.create_compressed_model')\n@tracked_function(NNCF_PT_CATEGORY, [CompressionStartedFromConfig(argname=\n 'config')])\ndef create_compressed_model(model: Module, config: NNCFConfi...
[ 2, 3, 5, 6, 7 ]
n = int(input()) p = [220000] + list(map(int, input().split())) cnt = 0 m = 220000 for i in range(1, n + 1): now = p[i] m = min(m, now) if now == m: cnt += 1 print(cnt)
normal
{ "blob_id": "2a500968cf6786440c0d4240430433db90d1fc2f", "index": 5941, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(1, n + 1):\n now = p[i]\n m = min(m, now)\n if now == m:\n cnt += 1\nprint(cnt)\n", "step-3": "n = int(input())\np = [220000] + list(map(int, input().spli...
[ 0, 1, 2 ]
from itertools import groupby def solve(tribes): attacks = [] for t in tribes: D, N, W, E, S, DD, DP, DS = t for i in range(N): d = D + DD * i w = W + DP * i e = E + DP * i s = S + DS * i attacks.append((d, w, e, s)) attacks = sort...
normal
{ "blob_id": "362bfc5a35b09817ce071e71a72e574a28ea287d", "index": 3365, "step-1": "<mask token>\n\n\ndef line(f):\n return map(int, f.readline().split())\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef solve(tribes):\n attacks = []\n for t in tribes:\n D, N, W, E, S, DD, DP, DS = t\n ...
[ 1, 3, 4, 5, 6 ]
from . import resources from jsonschema import validate from jsonschema.exceptions import ValidationError import aiohttp_client import importlib.resources as pkg_resources import json import logging log = logging.getLogger("amplitude-client") API_URL = "https://api.amplitude.com/2/httpapi" class AmplitudeLogger: ...
normal
{ "blob_id": "d32f009f373249b7b602ac36f29982273a2ed192", "index": 2289, "step-1": "<mask token>\n\n\nclass AmplitudeLogger:\n <mask token>\n\n async def log_event(self, event):\n event = {'api_key': self.api_key, 'events': [event]}\n try:\n validate(instance=event, schema=self.api_s...
[ 1, 2, 3, 4, 5 ]
import pandas as pd import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import math from tkinter import * from tkinter.ttk import * from facedetectandtrack import * x_vals = [] root = Tk() counter=0 #def graph(): plt.style.use('seaborn') def animate(i): data = pd.read_csv('data.csv...
normal
{ "blob_id": "239f055fd76a3ecb5f384c256ad850ea42739b8f", "index": 9710, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.style.use('seaborn')\n\n\ndef animate(i):\n data = pd.read_csv('data.csv')\n global x_vals\n global counter\n x_vals.append(counter)\n try:\n x = data.iloc[x_val...
[ 0, 2, 3, 4, 5 ]
a=10 b=20 c=400 d=100 e=500 f=30 z=a+b+c+d+e+f print "The total sum is",z print "variable d added" print "Variable e added" print "Variable f is equal to 30" print "You are coming from test branch" print "Your are very new in this branch"
normal
{ "blob_id": "700d876dd45548b74b563ed86f8124fa666e1739", "index": 2588, "step-1": "a=10\nb=20\nc=400\nd=100\ne=500\nf=30\nz=a+b+c+d+e+f\nprint \"The total sum is\",z\nprint \"variable d added\"\nprint \"Variable e added\"\nprint \"Variable f is equal to 30\"\nprint \"You are coming from test branch\"\nprint \"You...
[ 0 ]
from QnA_processor.question_analysis.google_question_classifier import GoogleQuestionClassifier def classify_question(query): try: """ Get answer-type from google autoML classifier (by making POST requests with authorization key) """ question_c...
normal
{ "blob_id": "db231ea92319414dd10ca8dfbc14e5a70ed2fe44", "index": 7343, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef classify_question(query):\n try:\n \"\"\"\n Get answer-type from google autoML classifier \n (by making POST requests with authorization key)\n \"\"...
[ 0, 1, 2, 3 ]
import ssl import urllib from urllib import request, response, error, parse, robotparser context = ssl._create_unverified_context() url = 'https://oauth.51job.com/get_login.php?client_id=000001&redirect_uri=https%3A%2F%2Funion.yingjiesheng.com%2Fapi_login.php&from_domain=yjs_web&display=default&state=7c893ec1be7b355a91...
normal
{ "blob_id": "2a37d02c7a0840e855a80adced4794fd757e353a", "index": 2917, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(res.read().decode('utf-8'))\n", "step-3": "<mask token>\ncontext = ssl._create_unverified_context()\nurl = (\n 'https://oauth.51job.com/get_login.php?client_id=000001&redirect_...
[ 0, 1, 2, 3, 4 ]
# coding=utf-8 # Copyright 2022 The TensorFlow Datasets Authors. # # 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 appl...
normal
{ "blob_id": "ed65d7e0de3fc792753e34b77254bccc8cee6d66", "index": 3657, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_data_dir_register():\n register = register_path.DataDirRegister(namespace_to_data_dirs={'ns1':\n [epath.Path('/path/ns1')]})\n assert {'ns1'} == register.namespa...
[ 0, 1, 2, 3 ]
from django.apps import AppConfig class WebApiAppConfig(AppConfig): name = 'WebApiApp'
normal
{ "blob_id": "cc97f70b9d41357f020ea9c59d8b149392a336cc", "index": 9656, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass WebApiAppConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass WebApiAppConfig(AppConfig):\n name = 'WebApiApp'\n", "step-4": "from django.apps impo...
[ 0, 1, 2, 3 ]
import os, sys sys.path.append('./Pytorch-UNet/') import torch from torch import optim import torchvision.transforms as transforms import torchvision.datasets as dset import wandb from datasets import parse_dataset_args, create_dataset from wt_utils import wt, create_filters, load_checkpoint, load_weights from argumen...
normal
{ "blob_id": "fbd5c7fa335d6bde112e41a55d15aee31e3ebaf7", "index": 2759, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('./Pytorch-UNet/')\n<mask token>\nif __name__ == '__main__':\n logger = Logger()\n torch.backends.cudnn.benchmark = True\n args = parse_args()\n logger.update_...
[ 0, 1, 2, 3 ]
import cv2 import sys import online as API def demo(myAPI): myAPI.setAttr() video_capture = cv2.VideoCapture(0) print("Press q to quit: ") while True: # Capture frame-by-frame ret, frame = video_capture.read() #np.array frame = cv2.resize(frame, (320, 240)) key = cv2.w...
normal
{ "blob_id": "778ef68b5270657f75185b27dc8219b35847afa1", "index": 5829, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef demo(myAPI):\n myAPI.setAttr()\n video_capture = cv2.VideoCapture(0)\n print('Press q to quit: ')\n while True:\n ret, frame = video_capture.read()\n fra...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def f1(phi, phi_o, d): """sinusoidally growing function between (phi_o-d) to phi_o""" return 1 - sigmoid_decay(phi, phi_o, d) def f2(phi, sigma): """normal distribution""" return math.exp(-phi ** 2 / sigma ** 2) <|reserved_special_token_0|> <|reserved_special_token_1...
flexible
{ "blob_id": "19bb3cd0c7862f39a78479d9a9703ebef198fc73", "index": 3677, "step-1": "<mask token>\n\n\ndef f1(phi, phi_o, d):\n \"\"\"sinusoidally growing function between (phi_o-d) to phi_o\"\"\"\n return 1 - sigmoid_decay(phi, phi_o, d)\n\n\ndef f2(phi, sigma):\n \"\"\"normal distribution\"\"\"\n retu...
[ 2, 3, 4, 5, 6 ]
from django.contrib import admin from django.urls import path from . import views urlpatterns = [ path('', views.artifact, name="artifacts"), path('<int:artifact_id>', views.detail, name="detail"), path('register/', views.register, name="register") ]
normal
{ "blob_id": "9b73037e8af7d4f91261cebf895b68650182fcd5", "index": 2780, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.artifact, name='artifacts'), path(\n '<int:artifact_id>', views.detail, name='detail'), path('register/',\n views.register, name='register')]\n", "st...
[ 0, 1, 2, 3 ]
from collections import defaultdict, namedtuple from color import RGB, clamp import math import controls_model as controls from eyes import Eye, MutableEye from geom import ALL #from icicles.ice_geom import ALL def load_geometry(mapfile): """ Load sheep neighbor geometry Returns a map { panel: [(edge-ne...
normal
{ "blob_id": "fe01b78d29dc456f7a537dd5639bc658fc184e36", "index": 5035, "step-1": "from collections import defaultdict, namedtuple\nfrom color import RGB, clamp\n\nimport math\n\nimport controls_model as controls\nfrom eyes import Eye, MutableEye\n\nfrom geom import ALL\n#from icicles.ice_geom import ALL\n\ndef l...
[ 0 ]
import os from subprocess import Popen, PIPE from Bio import SeqIO from Bio.Align.Applications import ClustalOmegaCommandline from Bio import Phylo from io import StringIO # from ete3 import Tree, TreeStyle import pylab class TreeDrawer: def __init__(self, sequences=None): self.sequences = sequences ...
normal
{ "blob_id": "5adb16c654a4e747f803590c42328fa6ba642e95", "index": 7599, "step-1": "<mask token>\n\n\nclass TreeDrawer:\n <mask token>\n <mask token>\n\n def draw_tree(self, filename):\n tree_file = open('dnaml.tree')\n x = tree_file.read()\n tree = Phylo.read(StringIO(x[:-2]), 'newic...
[ 2, 3, 4, 5, 6 ]
# MINISTを読み込んでレイヤーAPIでCNNを構築するファイル import tensorflow as tf import numpy as np import os import tensorflow as tf import glob import numpy as np import config as cf from data_loader import DataLoader from PIL import Image from matplotlib import pylab as plt dl = DataLoader(phase='Train', shuffle=True) X...
normal
{ "blob_id": "a5559ff22776dee133f5398bae573f515efb8484", "index": 3820, "step-1": "<mask token>\n", "step-2": "<mask token>\ndl = DataLoader(phase='Train', shuffle=True)\nX_data, y_data = dl.shuffle_and_get()\nX_data = np.reshape(X_data, [-1, cf.Height, cf.Width])\nconfig = tf.ConfigProto()\nconfig.gpu_options....
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def plot_depth_slice(x, depth, fld, stretch_depth=-500, plot_type= 'pcolormesh', cmap='YlOrRd', title=None, cmin=None, cmax=None, dpi=100, show_colorbar=True): """2D plot of depth vs some other variable, stretching first 500m of depth. Parameters ---------- depth ...
flexible
{ "blob_id": "b039ed74e62f3a74e8506d4e14a3422499046c06", "index": 860, "step-1": "<mask token>\n\n\ndef plot_depth_slice(x, depth, fld, stretch_depth=-500, plot_type=\n 'pcolormesh', cmap='YlOrRd', title=None, cmin=None, cmax=None, dpi=100,\n show_colorbar=True):\n \"\"\"2D plot of depth vs some other va...
[ 1, 2, 3, 4, 5 ]
import sys if sys.version_info.major == 2: from itertools import izip else: izip = zip
normal
{ "blob_id": "88445d8466d7acbf29d2525c7e322611d66494cd", "index": 8315, "step-1": "<mask token>\n", "step-2": "<mask token>\nif sys.version_info.major == 2:\n from itertools import izip\nelse:\n izip = zip\n", "step-3": "import sys\nif sys.version_info.major == 2:\n from itertools import izip\nelse:\...
[ 0, 1, 2 ]
from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.QtSql import * from DatabaseHandler import send_answer class PW(QWidget): def __init__(self, index, question, pid): super().__init__() self.question = question self.pid = pid self.maxim = len(self.questi...
normal
{ "blob_id": "f35569e2d8d26f43d4b2395b5088902c6cd3b826", "index": 2232, "step-1": "<mask token>\n\n\nclass PW(QWidget):\n <mask token>\n <mask token>\n\n def ButtonNoAction(self):\n table = 'patient_' + str(self.pid)\n send_answer(self.question[self.index]['qid'], 'Нет', table)\n if ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> driver.maximize_window() driver.get('http://www.toolsqa.com/iframe-practice-page/') driver.switch_to.default_content() driver.find_element_by_xpath("//span[text()='VIDEOS']").click() <|reserved_special_token_1|> <|reserved_spec...
flexible
{ "blob_id": "53eb1dcd54ce43d9844c48eb1d79f122a87dca39", "index": 3831, "step-1": "<mask token>\n", "step-2": "<mask token>\ndriver.maximize_window()\ndriver.get('http://www.toolsqa.com/iframe-practice-page/')\ndriver.switch_to.default_content()\ndriver.find_element_by_xpath(\"//span[text()='VIDEOS']\").click()...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> send(ip / ack_packet) <|reserved_special_token_1|> <|reserved_special_token_0|> ip = IP(src=sys.argv[1], dst=sys.argv[2]) syn_packet = TCP(sport=52255, dport=1237, flags='S', seq=100, options=[( 'MSS', 689), ('WScale', 1)])...
flexible
{ "blob_id": "acd6197e60cf59ffcaa33bb50a60a03592bb3559", "index": 7169, "step-1": "<mask token>\n", "step-2": "<mask token>\nsend(ip / ack_packet)\n", "step-3": "<mask token>\nip = IP(src=sys.argv[1], dst=sys.argv[2])\nsyn_packet = TCP(sport=52255, dport=1237, flags='S', seq=100, options=[(\n 'MSS', 689), ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> KEYS = ['CM', 'GM'] NOTES_FOR_KEY = {'CM': [21, 23, 24, 26, 28, 29, 31, 33, 35, 36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 53, 55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72, 74, 76, 77, 79, 81, 83, 84, 86, 88, 89, 91, 93, 95, 96...
flexible
{ "blob_id": "dd7ade05ef912f7c094883507768cc21f95f31f6", "index": 533, "step-1": "<mask token>\n", "step-2": "<mask token>\nKEYS = ['CM', 'GM']\nNOTES_FOR_KEY = {'CM': [21, 23, 24, 26, 28, 29, 31, 33, 35, 36, 38, 40, 41,\n 43, 45, 47, 48, 50, 52, 53, 55, 57, 59, 60, 62, 64, 65, 67, 69, 71, 72,\n 74, 76, 7...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for line in file1: x_list.append(float(line)) <|reserved_special_token_0|> for line in file2: y_list.append(float(line)) file2.close file1.close <|reserved_special_token_0|> plt.plot(x_list, y_list, label='robot trajectory...
flexible
{ "blob_id": "d869aa32cb9793ce11a5b6a782cc66c2dd0be309", "index": 6176, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in file1:\n x_list.append(float(line))\n<mask token>\nfor line in file2:\n y_list.append(float(line))\nfile2.close\nfile1.close\n<mask token>\nplt.plot(x_list, y_list, labe...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def add_owner_mce(m) ->MetadataChangeEventClass: entity = m['Table'] schema = m['Schema'] dataset_name = f'{schema}.{entity}' owners = [OwnerClass(owner=owner, type=OwnershipTypeClass.DATAOWNER) for owner in m['Owner']] changed_snapshot = DatasetSnapshotClass(u...
flexible
{ "blob_id": "7ad5e803afa42790e878bfb923eddcfde2d21928", "index": 1501, "step-1": "<mask token>\n\n\ndef add_owner_mce(m) ->MetadataChangeEventClass:\n entity = m['Table']\n schema = m['Schema']\n dataset_name = f'{schema}.{entity}'\n owners = [OwnerClass(owner=owner, type=OwnershipTypeClass.DATAOWNER...
[ 2, 3, 4, 5, 6 ]
# -*- coding:utf-8 -*- #实现同义词词林的规格化 with open('C:\\Users\\lenovo\\Desktop\\哈工大社会计算与信息检索研究中心同义词词林扩展版.txt') as f: with open('convert.txt','a') as w: for line in f: data = line[8:-1].split() for item in data: tmp = data.copy() ...
normal
{ "blob_id": "9109e649a90730df022df898a7760140275ad724", "index": 4854, "step-1": "<mask token>\n", "step-2": "with open('C:\\\\Users\\\\lenovo\\\\Desktop\\\\哈工大社会计算与信息检索研究中心同义词词林扩展版.txt') as f:\n with open('convert.txt', 'a') as w:\n for line in f:\n data = line[8:-1].split()\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> res.read_rcf() res.read_his() <|reserved_special_token_0|> for kt, step in enumerate(res.steps): if step.conv_status in [-1]: if step.time in tx: tsteps.append(kt) <|reserved_special_token_0|> res.read_dat(...
flexible
{ "blob_id": "fb6dd9ec7d8dc80eace90dadc2112c7c27125efd", "index": 2055, "step-1": "<mask token>\n", "step-2": "<mask token>\nres.read_rcf()\nres.read_his()\n<mask token>\nfor kt, step in enumerate(res.steps):\n if step.conv_status in [-1]:\n if step.time in tx:\n tsteps.append(kt)\n<mask to...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def upload_to_s3(file_name, node_number): try: key_info_json = open('awsinfo.json').read() except FileNotFoundError: print('awsinfo.json is not exist in dir.') exit(-1) data = json.loads(key_i...
flexible
{ "blob_id": "2f0d611fecdb5717029938d2ec2cd2db345b8f3a", "index": 8176, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef upload_to_s3(file_name, node_number):\n try:\n key_info_json = open('awsinfo.json').read()\n except FileNotFoundError:\n print('awsinfo.json is not exist in di...
[ 0, 1, 2, 3 ]
from typing import Sequence import matplotlib.pyplot as plt import matplotlib.colors as colors import numpy as np def plot3D(X, Y, Z, proporcao=1, espelharZ = False): fig = plt.figure() ax = fig.gca(projection='3d') ax.set_xlabel('X ') ax.set_ylabel('Y ') ax.set_zlabel('Z ') np.floor col...
normal
{ "blob_id": "ff20b65f35614415ad786602c0fc2cabd08124fb", "index": 4065, "step-1": "<mask token>\n\n\ndef limitZ(Z, limit=10):\n for i in range(len(Z)):\n for j in range(len(Z[i])):\n if Z[i][j] > limit:\n Z[i][j] = np.inf\n if Z[i][j] < -limit:\n Z[i][...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def save_df_surnames_as_pickle(): df_surnames, df_categories = load_surnames() df = shuffle(df_surnames, random_state=sc.RANDOM_STATE) train_cnt = int(df['surname'].count() * sc.TRAIN_TEST_RATIO) train = df[0:train_cnt] test = df[train_cnt + 1:] df_surnames.to_pick...
flexible
{ "blob_id": "db46fbfb1acd855eebb5c9f557d70038b84e812d", "index": 8573, "step-1": "<mask token>\n\n\ndef save_df_surnames_as_pickle():\n df_surnames, df_categories = load_surnames()\n df = shuffle(df_surnames, random_state=sc.RANDOM_STATE)\n train_cnt = int(df['surname'].count() * sc.TRAIN_TEST_RATIO)\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open('txt.txt', 'r') as f: data = f.readlines() line = 0 for i in range(10, 110, 10): agg = 0 for j in range(num_tests): agg += int(data[line]) line += 1 res.append(...
flexible
{ "blob_id": "176ffac7ad47f5c43a24acc664631f8353ec5100", "index": 967, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('txt.txt', 'r') as f:\n data = f.readlines()\n line = 0\n for i in range(10, 110, 10):\n agg = 0\n for j in range(num_tests):\n agg += int(data[...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> marks = {'S': 'subject', 'O': 'object', 'A': 'attribute', 'C': 'clause'} marks_reverse = {'subject': 'S', 'object': 'O', 'attribute': 'A', 'clause': 'C' } <|reserved_special_token_1|> marks = { "S":"subject", "O":"object", "A":"attribute", ...
flexible
{ "blob_id": "c66b07c45f4a675a6c7fcec82048a3197910d0d8", "index": 3435, "step-1": "<mask token>\n", "step-2": "marks = {'S': 'subject', 'O': 'object', 'A': 'attribute', 'C': 'clause'}\nmarks_reverse = {'subject': 'S', 'object': 'O', 'attribute': 'A', 'clause': 'C'\n }\n", "step-3": "marks = {\n \"S\":\"...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class Profile(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Profile(models.Model): <|reserved_special_token_0|> def __str__(self): return f'{self.user.username} Profile...
flexible
{ "blob_id": "51ff1181f0ddac3a8f7cbd9f9d2eedae29a6c559", "index": 6654, "step-1": "<mask token>\n\n\nclass Profile(models.Model):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Profile(models.Model):\n <mask token>\n\n def __str__(self):\n return f'{self.user.username} P...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- ############################################################################## # # Copyright (C) 2011 Eficent (<http://www.eficent.com/>) # Jordi Ballester Alomar <jordi.ballester@eficent.com> # # This program is free software: you can redistribute it and/or modify # it und...
normal
{ "blob_id": "1ddec426e4ad50f1d0e8a57ed841fbdf8c51b00f", "index": 9871, "step-1": "<mask token>\n\n\nclass tax(osv.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass tax(osv.Model):\n _inherit = 'sgr.tax'\n\n def send_alerts(self, cr, uid...
[ 1, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def read_dataset(mode, args): def decode_example(protos, vocab_size): features = {'key': tf.FixedLenFeature(shape=[1], dtype=tf.int64), 'indices': tf.VarLenFeature(dtype=tf.int64), 'values': tf. VarLenFeature(dtype=tf.float32)} parsed_features ...
flexible
{ "blob_id": "fb9ae5b3cdeac0c254669e214779ad43a02bff6d", "index": 4596, "step-1": "<mask token>\n\n\ndef read_dataset(mode, args):\n\n def decode_example(protos, vocab_size):\n features = {'key': tf.FixedLenFeature(shape=[1], dtype=tf.int64),\n 'indices': tf.VarLenFeature(dtype=tf.int64), 'va...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append(os.path.dirname(os.path.abspath(__file__))) execute('scrapy crawl laptop'.split()) <|reserved_special_token_1|> import os, sys from scrapy.cmdline import execute sys.path.append(os.path.dirname(os.path.abspath(_...
flexible
{ "blob_id": "71ff8e8a62a3b2731071ed7a039b51c150ebaca4", "index": 3671, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.path.dirname(os.path.abspath(__file__)))\nexecute('scrapy crawl laptop'.split())\n", "step-3": "import os, sys\nfrom scrapy.cmdline import execute\nsys.path.append(os...
[ 0, 1, 2 ]
from django.contrib import admin from .models import User # Register your models here. @admin.register(User) class AuthorizationUserAdmin(admin.ModelAdmin): exclude = ['open_id'] pass
normal
{ "blob_id": "d3585e7b761fa7b2eeaacf09f84bb6a4abc1cf02", "index": 6806, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@admin.register(User)\nclass AuthorizationUserAdmin(admin.ModelAdmin):\n <mask token>\n pass\n", "step-3": "<mask token>\n\n\n@admin.register(User)\nclass AuthorizationUserAdm...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Imprimidor(Thread): def __init__(self, nombre, berlin, bolsa_dinero): super().__init__() pass <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ...
flexible
{ "blob_id": "ab79e2f9584dbbb526c62bde882a1bc9874b56f9", "index": 7903, "step-1": "<mask token>\n\n\nclass Imprimidor(Thread):\n\n def __init__(self, nombre, berlin, bolsa_dinero):\n super().__init__()\n pass\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\...
[ 2, 4, 5, 6, 7 ]
import cv2 import imutils import detect def detectByPathVideo(path, writer): video = cv2.VideoCapture(path) check, frame = video.read() if check == False: print('Video Not Found. Please Enter a Valid Path (Full path of Video Should be Provided).') return print('Detecting p...
normal
{ "blob_id": "5044b8bc8cabd7762df6a0327828df4546ab8d96", "index": 9000, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef detectByPathVideo(path, writer):\n video = cv2.VideoCapture(path)\n check, frame = video.read()\n if check == False:\n print(\n 'Video Not Found. Please...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def intersection(list1, list2): return set(list1).intersection(list2) def computeSteps(x, y, step, steps): curr = 0 if (x, y) in steps: curr = steps.get((x, y)) steps[x, y] = step + curr <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_sp...
flexible
{ "blob_id": "e9e119dd69f9416e007e748d7f494741140efc8e", "index": 8182, "step-1": "<mask token>\n\n\ndef intersection(list1, list2):\n return set(list1).intersection(list2)\n\n\ndef computeSteps(x, y, step, steps):\n curr = 0\n if (x, y) in steps:\n curr = steps.get((x, y))\n steps[x, y] = step...
[ 2, 4, 5, 6, 7 ]
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer from sklearn.feature_selection import SelectKBest, chi2 from sklearn import metrics, ensemble, linear_model, svm from numpy import log, ones, array, zeros, mean, std, repeat import numpy as np import scipy.sparse as sp import re import csv fro...
normal
{ "blob_id": "91eb0ae8e59f24aeefdabd46546bc8fb7a0b6f6c", "index": 3833, "step-1": "<mask token>\n\n\ndef normalize(f, lammatize=False):\n f = [x.lower() for x in f]\n f = [x.replace('\\\\n', ' ') for x in f]\n f = [x.replace('\\\\t', ' ') for x in f]\n f = [x.replace('\\\\xa0', ' ') for x in f]\n f...
[ 7, 8, 9, 10, 12 ]
<|reserved_special_token_0|> class ListVolumeType(command.Lister): <|reserved_special_token_0|> <|reserved_special_token_0|> class ShowVolumeType(command.ShowOne): def get_parser(self, prog_name): parser = super(ShowVolumeType, self).get_parser(prog_name) parser.add_argument('volume_typ...
flexible
{ "blob_id": "c73bea686786a30f298500968cfd01e2d5125d75", "index": 4013, "step-1": "<mask token>\n\n\nclass ListVolumeType(command.Lister):\n <mask token>\n <mask token>\n\n\nclass ShowVolumeType(command.ShowOne):\n\n def get_parser(self, prog_name):\n parser = super(ShowVolumeType, self).get_parse...
[ 4, 5, 6, 7, 8 ]
import os import shutil import json from django.shortcuts import render, HttpResponse from django.utils.encoding import escape_uri_path from django.db import transaction from web_pan.settings import files_folder from disk import models # Create your views here. def logined(func): def wrapper(request, *args, **k...
normal
{ "blob_id": "eeb87891d1a02484a61537745ec6f13387017929", "index": 705, "step-1": "<mask token>\n\n\ndef logined(func):\n\n def wrapper(request, *args, **kwargs):\n session = request.session.get('user')\n if not session:\n return render(request, 'login.html')\n else:\n ...
[ 9, 10, 12, 13, 14 ]
from functions.service_funcs.get_data import get_data_character def clean_room(update): char, db_sess = get_data_character(update, return_sess=True) # удаляем старую комнату и всю инфу о ней if char and char.room: if char.room.mobs: for mob in char.room.mobs: db_sess.de...
normal
{ "blob_id": "4d57fa22282d7b3f8adabedd7a04e32767181890", "index": 5693, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef clean_room(update):\n char, db_sess = get_data_character(update, return_sess=True)\n if char and char.room:\n if char.room.mobs:\n for mob in char.room.mob...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Comment(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __str__(self): return self.text class Rating(models.Model): rating = models.PositiveIntegerField() pr...
flexible
{ "blob_id": "052574be3f4a46bceefc0a54b1fe268a7cef18a9", "index": 3061, "step-1": "<mask token>\n\n\nclass Comment(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.text\n\n\nclass Rating(models.Model):\n rating = models.Positi...
[ 8, 9, 10, 13, 14 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-10-28 17:50 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ ] operations...
normal
{ "blob_id": "b0064a5cd494d5ad232f27c63a4df2c56a4c6a66", "index": 5241, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Favorits(QDialog, Ui_DialogFavorit): <|reserved_special_token_0|> def __init__(self): super(Favorits, self).__init__() self.setupUi(self) self.buttonBox.button(QDialogButtonBox.Save).setText('Сохранить') self.buttonBox.button(QDialogButtonBox...
flexible
{ "blob_id": "14023785983f493af57189b3d96254efef2e33ae", "index": 8180, "step-1": "<mask token>\n\n\nclass Favorits(QDialog, Ui_DialogFavorit):\n <mask token>\n\n def __init__(self):\n super(Favorits, self).__init__()\n self.setupUi(self)\n self.buttonBox.button(QDialogButtonBox.Save).s...
[ 4, 5, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> received_event = Event() leave_rooms_event = Event() exit_event = Event() output_message_queue = AGQueue() input_message_queue = AGQueue() matrix_to_aio_queue = AGQueue() aio_to_matrix_queue = AGQueue() sync_to_matrix_queue = Queu...
flexible
{ "blob_id": "af1a6c6009b21962228fbe737f27c22bf9460762", "index": 729, "step-1": "<mask token>\n", "step-2": "<mask token>\nreceived_event = Event()\nleave_rooms_event = Event()\nexit_event = Event()\noutput_message_queue = AGQueue()\ninput_message_queue = AGQueue()\nmatrix_to_aio_queue = AGQueue()\naio_to_matr...
[ 0, 1, 2, 3 ]
#header import matplotlib.pyplot as pmf import random p = 0.5 # Probablility of success for original system n = 18 # Number of trials Y = [] # Contains binomial RVs b = [0] * (n+1) # List of n + 1 zeroes N = 100 # Number of experiments performed for j in range(N): # Bernoulli random variable for i in ra...
normal
{ "blob_id": "9a1b268386b4652bf50af0365892ef7338329727", "index": 9631, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor j in range(N):\n for i in range(n):\n r = random.uniform(0, 1)\n if r < p:\n x = 1\n else:\n x = 0\n Y.append(x)\n outcome = su...
[ 0, 1, 2, 3, 4 ]
## ## Originally created by https://www.reddit.com/user/AlekseyP ## Seen at: https://www.reddit.com/r/technology/comments/43fi39/i_set_up_my_raspberry_pi_to_automatically_tweet ## #!/usr/bin/python import os import sys import csv import datetime import time import twitter #Configuration # Twitter ACCESS_TOKEN="" ACCE...
normal
{ "blob_id": "6492f1eda79fd3116058f29647dc5f09e903f637", "index": 7274, "step-1": "##\n## Originally created by https://www.reddit.com/user/AlekseyP\n## Seen at: https://www.reddit.com/r/technology/comments/43fi39/i_set_up_my_raspberry_pi_to_automatically_tweet\n##\n\n#!/usr/bin/python\nimport os\nimport sys\nimp...
[ 0 ]
<|reserved_special_token_0|> def get_text_from_image(imageName): img = preprocess(imageName) result = tes.image_to_string(img) return result <|reserved_special_token_0|> def find_receipt_box(image): """ Finds a contour around the receipt in the given image. Returns the bounding box and the...
flexible
{ "blob_id": "e480136aca96e45cc8a7ca34c1a9d09b96a5a4da", "index": 4152, "step-1": "<mask token>\n\n\ndef get_text_from_image(imageName):\n img = preprocess(imageName)\n result = tes.image_to_string(img)\n return result\n\n\n<mask token>\n\n\ndef find_receipt_box(image):\n \"\"\"\n Finds a contour a...
[ 5, 7, 8, 9, 10 ]
from packages import data as DATA from packages import plot as PLOT from packages import universal as UNIVERSAL from packages import currency_pair as CP import matplotlib.pyplot as plt import mpl_finance as mpf from packages import db as DB import CONSTANTS import datetime from matplotlib.pylab import date2num from mat...
normal
{ "blob_id": "9aaaa744780dbd32b14e09a34976a2a0a3ce34f7", "index": 7864, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor cnt in range(20, len(rows)):\n row_previous2 = rows[cnt - 2]\n row_previous1 = rows[cnt - 1]\n row = rows[cnt]\n open = row[2]\n high = row[3]\n low = row[4]\n cl...
[ 0, 1, 2, 3, 4 ]
import os import sqlite3 import datetime directory = 'C:\PyHelp' if not os.path.exists(directory): os.makedirs(directory) rand_facts = '''• Exception is used as a base class for all exceptions. It's strongly recommended (but not yet required) that user exceptions are derived from this class too. • System...
normal
{ "blob_id": "a2c93fd632a637d47f05e0a4fda851b465d03a31", "index": 4674, "step-1": "<mask token>\n", "step-2": "<mask token>\nif not os.path.exists(directory):\n os.makedirs(directory)\n<mask token>\nif not file_exists:\n x = open(op, 'w')\n x.write(rand_facts)\n", "step-3": "<mask token>\ndirectory =...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> year = datetime.datetime.now().year project = 'python201' copyright = f'2019-{year} Geoffrey Lentner, 2018 Ashwin Srinath' author = 'Geoffrey Lentner, Ashwin Srinath' version = '0.0.1' release = '0.0.1' extensions = ['sphinx.ext.i...
flexible
{ "blob_id": "1ead23c6ea4e66b24e60598ae20606e24fa41482", "index": 1024, "step-1": "<mask token>\n", "step-2": "<mask token>\nyear = datetime.datetime.now().year\nproject = 'python201'\ncopyright = f'2019-{year} Geoffrey Lentner, 2018 Ashwin Srinath'\nauthor = 'Geoffrey Lentner, Ashwin Srinath'\nversion = '0.0.1...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class ColorPoint(object): <|reserved_special_token_0|> <|reserved_special_token_0|> def __getitem__(self, item) ->float: """ >>> cp = ColorPoint(Color('#880073'), Color('white'), '') >>> cp[0] # hue 0.8590686274509803 >>> cp[1] # satu...
flexible
{ "blob_id": "e239c2089fc6d4ab646c490b6e3de8953cec5634", "index": 8093, "step-1": "<mask token>\n\n\nclass ColorPoint(object):\n <mask token>\n <mask token>\n\n def __getitem__(self, item) ->float:\n \"\"\"\n >>> cp = ColorPoint(Color('#880073'), Color('white'), '')\n >>> cp[0] # hu...
[ 7, 8, 9, 10, 12 ]
<|reserved_special_token_0|> @ddt.ddt class TestAddress(unittest.TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def test_02_check_address(self): url = 'http://ecshop.itsoso.cn/ECMobile/?url=/address/list' ...
flexible
{ "blob_id": "0f0b3eea9dc397d32e81749304041abaf6651e94", "index": 1873, "step-1": "<mask token>\n\n\n@ddt.ddt\nclass TestAddress(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def test_02_check_address(self):\n url = 'http://ecshop.itsoso.cn/ECMobile/?url...
[ 2, 8, 9, 10, 12 ]
<|reserved_special_token_0|> def write_csv(filename, data_list): """ 将python对象 [{}, {}. {}, {} ...] 写入到csv文件中 :param filename: 生成的csv文件名 :param data_list: [{}, {}. {}, {} ...] :return: None """ with open(filename, 'w') as f: dict_writer = csv.DictWriter(f, data_list[0].keys()) ...
flexible
{ "blob_id": "7531480f629c1b3d28210afac4ef84b06edcd420", "index": 3825, "step-1": "<mask token>\n\n\ndef write_csv(filename, data_list):\n \"\"\"\n 将python对象 [{}, {}. {}, {} ...] 写入到csv文件中\n :param filename: 生成的csv文件名\n :param data_list: [{}, {}. {}, {} ...]\n :return: None\n \"\"\"\n with ...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def sentiment(text): global url global headers body = {'text': text} try: r = requests.post(url, headers=headers, data=json.dumps(body)) dic = r.json() except Exception as e: print('分析失败') pass time.sleep(0.3) return dic['items']...
flexible
{ "blob_id": "a95e64877a1fc9f8109f1293b4ae9176f4f64647", "index": 3090, "step-1": "<mask token>\n\n\ndef sentiment(text):\n global url\n global headers\n body = {'text': text}\n try:\n r = requests.post(url, headers=headers, data=json.dumps(body))\n dic = r.json()\n except Exception a...
[ 1, 2, 3, 4, 5 ]
n, k = map(int, input().split()) k_list = [] for i in range(k): l, r = map(int, input().split()) k_list.append([l, r]) dp = [0] * (n + 1) dp[1] = 1 dpsum = [0] * (n + 1) dpsum[1] = 1 for i in range(1, n): dpsum[i] = dp[i] + dpsum[i - 1] for j in range(k): l, r = k_list[j] li = i + l ...
normal
{ "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 ]
import pymysql db = pymysql.connect( "localhost", "root", "", "order_db", use_unicode=True, charset="utf8") cursor = db.cursor() sql = "DROP TABLE custdetail" cursor.execute(sql) db.close()
normal
{ "blob_id": "1aa2bff245322a34438cc836e23f430926dfac6c", "index": 3414, "step-1": "<mask token>\n", "step-2": "<mask token>\ncursor.execute(sql)\ndb.close()\n", "step-3": "<mask token>\ndb = pymysql.connect('localhost', 'root', '', 'order_db', use_unicode=True,\n charset='utf8')\ncursor = db.cursor()\nsql ...
[ 0, 1, 2, 3, 4 ]
def mysum(*c): print(sum([x for x in c])) mysum(1,2,3,4,0xB)
normal
{ "blob_id": "2c4fa92b28fa46a26f21ada8826474baac204e00", "index": 1234, "step-1": "<mask token>\n", "step-2": "def mysum(*c):\n print(sum([x for x in c]))\n\n\n<mask token>\n", "step-3": "def mysum(*c):\n print(sum([x for x in c]))\n\n\nmysum(1, 2, 3, 4, 11)\n", "step-4": "def mysum(*c):\n print(su...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> parser.add_argument('nex', help='path of the .nex file to be launched') parser.add_argument('file', help='autoexec.bas file to be generated') <|reserved_special_token_0|> contents += bytearray((0, 10)) contents += struct.pack('<H'...
flexible
{ "blob_id": "0744ec646e7b9303c67c25dff2997568c6171b91", "index": 108, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('nex', help='path of the .nex file to be launched')\nparser.add_argument('file', help='autoexec.bas file to be generated')\n<mask token>\ncontents += bytearray((0, 10))...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def factor(n): result = [] d = 2 while d * d <= n: if n % d == 0: result.append(d) n //= d else: d += 1 if n > 1: result.append(n) return result def get_coeff(period): c = randint(0, period) while gc...
flexible
{ "blob_id": "11e9d25c30c8c9945cfa3c234ffa1aab98d1869e", "index": 8023, "step-1": "<mask token>\n\n\ndef factor(n):\n result = []\n d = 2\n while d * d <= n:\n if n % d == 0:\n result.append(d)\n n //= d\n else:\n d += 1\n if n > 1:\n result.append...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def GenTests(api): yield api.test('basic') <|reserved_special_token_1|> <|reserved_special_token_0|> def RunSteps(api): try: api.step('test step', [{}]) except AssertionError as e: assert str(e) ...
flexible
{ "blob_id": "25d210144ef209fd5e4ff7e4e4c2e77fd7eb79ac", "index": 3480, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef GenTests(api):\n yield api.test('basic')\n", "step-3": "<mask token>\n\n\ndef RunSteps(api):\n try:\n api.step('test step', [{}])\n except AssertionError as e:\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> pygame.init() <|reserved_special_token_0|> pygame.display.set_caption('Social Force Model - Crosswalk') <|reserved_special_token_0|> for line in open(WALLSFILE, newline='', encoding='utf-8-sig'): coords = line.split(',') w...
flexible
{ "blob_id": "00051a4087bfcf2e6826e9afa898830dc59aa5ab", "index": 5451, "step-1": "<mask token>\n", "step-2": "<mask token>\npygame.init()\n<mask token>\npygame.display.set_caption('Social Force Model - Crosswalk')\n<mask token>\nfor line in open(WALLSFILE, newline='', encoding='utf-8-sig'):\n coords = line....
[ 0, 1, 2, 3, 4 ]
def word_count(s): # Your code here cache = {} ignore = '":;,.-+=/\\|[]{}()*^&' lower = s.lower() for i in lower: if i in ignore: lower = lower.replace(i, '') words = lower.split() for j in words: if j not in cache: cache[j] = 1 else: ...
normal
{ "blob_id": "97d84f99264afa5e7df4b5d22cf4c49b2d14ff7a", "index": 8291, "step-1": "<mask token>\n", "step-2": "def word_count(s):\n cache = {}\n ignore = '\":;,.-+=/\\\\|[]{}()*^&'\n lower = s.lower()\n for i in lower:\n if i in ignore:\n lower = lower.replace(i, '')\n words = l...
[ 0, 1, 2, 3 ]
from django import forms from .models import File, Sample, Plate, Well, Machine, Project class MachineForm(forms.ModelForm): class Meta: model = Machine fields = ['name', 'author', 'status', 'comments'] class ProjectForm(forms.ModelForm): class Meta: model = Project field...
normal
{ "blob_id": "5bb894feaf9293bf70b3f831e33be555f74efde8", "index": 6901, "step-1": "<mask token>\n\n\nclass SampleForm(forms.ModelForm):\n\n\n class Meta:\n model = Sample\n fields = ['name', 'alias', 'sample_type', 'description', 'project',\n 'author', 'sequence', 'length', 'genbank', ...
[ 3, 5, 6, 7 ]
import math from chainer import cuda from chainer import function from chainer.functions import Sigmoid from chainer.utils import type_check import numpy def _as_mat(x): if x.ndim == 2: return x return x.reshape(len(x), -1) class Autoencoder(function.Function): def __init__(self, in_size, hidde...
normal
{ "blob_id": "97eb599ae8bf726d827d6f8313b7cf2838f9c125", "index": 4098, "step-1": "<mask token>\n\n\nclass Autoencoder(function.Function):\n <mask token>\n\n def hidden(self, x):\n h = _Encoder(self.W, self.b1)(x)\n if self.activation is not None:\n h = self.activation(h)\n h...
[ 11, 13, 14, 15, 17 ]