code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os.path import re import sys import tarfile import numpy as np from six.moves import urllib import tensorflow as tf from sklearn.model_selection import train_test_split from sklearn import datasets fro...
normal
{ "blob_id": "8ef20a7a93d6affabe88dad4e5d19613fe47dd0f", "index": 5399, "step-1": "<mask token>\n\n\ndef create_graph():\n \"\"\"Creates a graph from saved GraphDef file and returns a saver.\"\"\"\n with tf.gfile.FastGFile(os.path.join('/home/ubuntu/hdd/tensorFlowDic/',\n 'classify_image_graph_def.pb...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python3 # coding=utf-8 # title :paramiko_sftp.py # description : # author :JackieTsui # organization :pytoday.org # date :1/16/18 9:22 PM # email :jackietsui72@gmail.com # notes : # ================================================== # Import the module n...
normal
{ "blob_id": "64cf6b03fb68be8a23c6e87c8d68d0a42db0eb54", "index": 6451, "step-1": "<mask token>\n", "step-2": "<mask token>\nparamiko.util.log_to_file('syslogin.log')\n<mask token>\nt.connect(username=jumpuser, password=jumppass)\n<mask token>\nsftp.put(localpath, remotepath)\nsftp.close()\n<mask token>\nssh.se...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # !/usr/bin/python import re import sys import xlwt import os ''' python logcat_time.py config_file logcat_file ''' config_file = sys.argv[1] logcat_file = sys.argv[2] turns_time = 0 turn_compelete_flag = 0 def get_filePath_fileName_fileExt(filename): (filepath, tempfilename) = os.path.s...
normal
{ "blob_id": "585c0f89605f1d791b449f42412174f06d0c5db5", "index": 5163, "step-1": "# -*- coding: utf-8 -*-\n# !/usr/bin/python\nimport re\nimport sys\nimport xlwt\nimport os\n\n'''\npython logcat_time.py config_file logcat_file\n'''\n\nconfig_file = sys.argv[1]\nlogcat_file = sys.argv[2]\n\nturns_time = 0\nturn_c...
[ 0 ]
from django.contrib import admin from django.contrib.staticfiles.urls import static # 本Ch11.1 from django.urls import path, include from . import settings_common, settings_dev # 本Ch11.1 import debug_toolbar urlpatterns = [ path('admin/', admin.site.urls), path('', include('login_test_app.urls')), path('...
normal
{ "blob_id": "ce626afa7c0fd2e190afd92b57a0ebebf19f9e9b", "index": 6842, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns += static(settings_common.MEDIA_URL, document_root=settings_dev\n .MEDIA_ROOT)\n", "step-3": "<mask token>\nurlpatterns = [path('admin/', admin.site.urls), path('', inclu...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class GetCollectionItemidsTest(TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class GetCollectionItemAssetURLsTest(TestCase): def setUp(self): """ Setting up the required test data input for importer tas...
flexible
{ "blob_id": "b131107d2161634e2c09e0b3ab80dd322d13fbc2", "index": 2881, "step-1": "<mask token>\n\n\nclass GetCollectionItemidsTest(TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass GetCollectionItemAssetURLsTest(TestCase):\n\n def setUp(self):\n \"\"\"\n Setting up the ...
[ 16, 25, 31, 33, 38 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def upgrade(migrate_engine): meta.bind = migrate_engine table.create() def downgrade(migrate_engine): meta.bind = migrate_engine table.drop() <|reserved_special_token_1|> <|reserved_special_token_0|> meta = ...
flexible
{ "blob_id": "6154979cd2853dd2bd26d1ae5df7365efa0141c2", "index": 441, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef upgrade(migrate_engine):\n meta.bind = migrate_engine\n table.create()\n\n\ndef downgrade(migrate_engine):\n meta.bind = migrate_engine\n table.drop()\n", "step-3": "...
[ 0, 2, 3, 4, 5 ]
from flask import Flask, jsonify, request, send_file, render_template from flask_cors import CORS from twilio.rest import Client import autocomplete from gtts import gTTS import os # Set up the model. autocomplete.load() app = Flask(__name__) CORS(app) # The application @app.route("/") def index(): return render_tem...
normal
{ "blob_id": "8980ac4db2657d3dbd2b70b33a4d13a077d4590e", "index": 2266, "step-1": "<mask token>\n\n\nclass InvalidUsage(Exception):\n status_code = 400\n\n def __init__(self, message, status_code=None, payload=None):\n Exception.__init__(self)\n self.message = message\n if status_code i...
[ 7, 9, 10, 11, 13 ]
import logging import os import logzero from gunicorn.glogging import Logger _log_level = os.environ.get("LOG_LEVEL", "info").upper() log_level = getattr(logging, _log_level) log_format = "%(color)s[%(levelname)1.1s %(asctime)s %(name)s]%(end_color)s %(message)s" formatter = logzero.LogFormatter(fmt=log_format) logg...
normal
{ "blob_id": "b8b50ef021c4b25edbab355e1db5d62d3c5a28ad", "index": 7257, "step-1": "<mask token>\n\n\nclass GunicornLogger(Logger):\n <mask token>\n", "step-2": "<mask token>\nlogzero.setup_logger(**logger_args)\nlogzero.setup_default_logger(**logger_args)\n<mask token>\n\n\nclass GunicornLogger(Logger):\n\n ...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def run(): mod = 1000000007 N, *AB = map(int, read().split()) A_B = [] INF = float('inf') zerozero = 0 for i in range(N): a = AB[2 * i] b = AB[2 * i + 1] if a == 0 and b == 0: zerozero += 1 elif b == 0: A_B.ap...
flexible
{ "blob_id": "f73a3bd7665ac9cc90085fcac2530c93bef69d3d", "index": 6705, "step-1": "<mask token>\n\n\ndef run():\n mod = 1000000007\n N, *AB = map(int, read().split())\n A_B = []\n INF = float('inf')\n zerozero = 0\n for i in range(N):\n a = AB[2 * i]\n b = AB[2 * i + 1]\n if...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(name[0], name[2]) print(name[1:3]) print(name[:3]) print(name[0:3]) print(name[-2:]) name.append('666') name.insert(1, '999') print(name) <|reserved_special_token_0|> print(name) name.pop() print(name) name.pop(2) print(name...
flexible
{ "blob_id": "d517c1e2eb4d37a2584f1603c704efce6834df92", "index": 7443, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(name[0], name[2])\nprint(name[1:3])\nprint(name[:3])\nprint(name[0:3])\nprint(name[-2:])\nname.append('666')\nname.insert(1, '999')\nprint(name)\n<mask token>\nprint(name)\nname.pop...
[ 0, 1, 2, 3, 4 ]
count=0 def merge(a, b): global count c = [] h = j = 0 while j < len(a) and h < len(b): if a[j] <= b[h]: c.append(a[j]) j += 1 else: count+=(len(a[j:])) c.append(b[h]) h += 1 if j == len(a): for i in b[h:]: ...
normal
{ "blob_id": "cf3b66a635c6549553af738f263b035217e75a7a", "index": 903, "step-1": "<mask token>\n\n\ndef merge_sort(lists):\n if len(lists) <= 1:\n return lists\n middle = len(lists) // 2\n left = merge_sort(lists[:middle])\n right = merge_sort(lists[middle:])\n return merge(left, right)\n\n\...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python #coding=utf-8 """ __init__.py :license: BSD, see LICENSE for more details. """ import os import logging import sys from logging.handlers import SMTPHandler, RotatingFileHandler from flask import Flask, g, session, request, flash, redirect, jsonify, url_for from flaskext.babel import Ba...
normal
{ "blob_id": "ef124e8c15ef347efd709a5e3fb104c7fd1bccde", "index": 2753, "step-1": "<mask token>\n\n\ndef on_identity_changed(app, identity):\n g.identity = identity\n session['identity'] = identity\n\n\ndef configure_signals(app):\n identity_changed.connect(on_identity_changed, app)\n\n\n<mask token>\n\n...
[ 6, 8, 9, 10, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> if sm.hasItem(4310100, 1): sm.setSpeakerID(9390220) sm.sendSayOkay( "You can't start your voyage until you finish the tutorial quest!") else: sm.setSpeakerID(9390220) sm.sendNext( 'What? You threw away the coins without finishi...
flexible
{ "blob_id": "c4b9fdba9e9eeccc52999dab9232302f159c882a", "index": 588, "step-1": "<mask token>\n", "step-2": "if sm.hasItem(4310100, 1):\n sm.setSpeakerID(9390220)\n sm.sendSayOkay(\n \"You can't start your voyage until you finish the tutorial quest!\")\nelse:\n sm.setSpeakerID(9390220)\n sm....
[ 0, 1, 2 ]
from collections import deque n = -1 D = [(-1 , 0) , (0 , 1) , (1 , 0) , (0 , -1)] B = -1 up = 0 right = 1 down = 2 left = 3 dic = {} dic[0] = 'up' dic[1] = 'right' dic[2] = 'down' dic[3] = 'left' def possi(y , x): global n if y < 0 or y >= n or x < 0 or x >= n or B[y][x]: return False return True ...
normal
{ "blob_id": "feb912ac899208618f00c894458c1fda7a402652", "index": 1452, "step-1": "<mask token>\n\n\ndef possi(y, x):\n global n\n if y < 0 or y >= n or x < 0 or x >= n or B[y][x]:\n return False\n return True\n\n\ndef move(d, ay, ax, by, bx):\n ay += D[d][0]\n by += D[d][0]\n ax += D[d][...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def index(request, err_msg=None): """ Renders the index page. """ template = loader.get_template('aimodel/index.html') context = {} context['err_msg'] = err_msg return HttpResponse(template.render(context, request)) <|reserved_special_token_0|> @require_POS...
flexible
{ "blob_id": "41ca762fe6865613ae4ef2f657f86b516353676f", "index": 9784, "step-1": "<mask token>\n\n\ndef index(request, err_msg=None):\n \"\"\"\n Renders the index page.\n \"\"\"\n template = loader.get_template('aimodel/index.html')\n context = {}\n context['err_msg'] = err_msg\n return Http...
[ 13, 16, 17, 19, 22 ]
import matplotlib.pyplot as plt file_list = ["Quantification_comet_fdr.csv", "Quantification_crux_fdr.csv", "Quantification_msfg_fdr.csv", "Quantification_msfg_percolator.csv"] file_titles = ["Comet", "Crux", "MSGFPlus", "MSGFPlus + Pe...
normal
{ "blob_id": "e08159a51b611ce6d0ca354a4fe6759d00af2cb7", "index": 660, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor file_name in file_list:\n proteins = 0\n peptides = 0\n for line_index, line in enumerate(open(file_name, 'r')):\n if line_index > 3:\n proteins += 1\n ...
[ 0, 1, 2, 3, 4 ]
from __future__ import annotations from abc import ABC, abstractmethod class AbstractMoviment(ABC): @abstractmethod def move(self, dt) -> None: pass class Mov_LinearFall(AbstractMoviment): def move(self, coordinates, speed, lastcoordinate, dt): coordinates[1] = round(coordinates[1] + spe...
normal
{ "blob_id": "57935b560108ef0db59de9eee59aa0c908c58b8f", "index": 2348, "step-1": "<mask token>\n\n\nclass Mov_ZigZag(AbstractMoviment):\n <mask token>\n\n def move(self, coordinates, speed, startcoordinate, dt):\n ZigZageamento = 100\n coordinates[1] = round(coordinates[1] + speed * dt)\n ...
[ 8, 9, 11, 12, 15 ]
from django import forms from django.forms import ModelForm from .models import Noticia class NoticiaForm(ModelForm): class Meta: model = Noticia fields = ['idNoticia', 'resumen', 'titulo', 'categoria']
normal
{ "blob_id": "e7a283e0e0e16e9adb415b26d724b2ee84c4f4f8", "index": 1547, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass NoticiaForm(ModelForm):\n\n\n class Meta:\n model = Noticia\n fields = ['idNoticia', 'resumen', 'titulo', 'categoria']\n", "step-3": "from django import forms...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> try: print(int(s) + 1) print(int(s) / 1) except ValueError as ve: print('ValueError occurs!!!', ve) except ZeroDivisionError as e: print('ValueError occurs!!!', e) except: print('Error occurs!!!') else: pri...
flexible
{ "blob_id": "1bf79319613ca1454f3a9ed21068bd899616395c", "index": 624, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n print(int(s) + 1)\n print(int(s) / 1)\nexcept ValueError as ve:\n print('ValueError occurs!!!', ve)\nexcept ZeroDivisionError as e:\n print('ValueError occurs!!!', e)\ne...
[ 0, 1, 2, 3 ]
import smtplib import subprocess import time class NotifyError(Exception): def __init__(self, message): self.message = message class Notification(object): def __init__(self, config, dry_run): self.dry_run = dry_run self.notifications = {} def submit(self, recipient, message): ...
normal
{ "blob_id": "01849a6bf5ce5eb75c549af28312f61711ad2494", "index": 4425, "step-1": "<mask token>\n\n\nclass Notification(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass SendMail(Notification):\n\n def __init__(self, config, dry_run)...
[ 11, 12, 15, 20, 21 ]
import logging from typing import List, Optional import uuid from pydantic import BaseModel from obsei.payload import TextPayload from obsei.preprocessor.base_preprocessor import ( BaseTextPreprocessor, BaseTextProcessorConfig, ) logger = logging.getLogger(__name__) class TextSplitterPayload(BaseModel): ...
normal
{ "blob_id": "151cc71ff1a63897238e2cc55269bd20cc6ee577", "index": 2336, "step-1": "<mask token>\n\n\nclass TextSplitterConfig(BaseTextProcessorConfig):\n max_split_length: int = 512\n split_stride: int = 0\n document_id_key: Optional[str]\n\n\nclass TextSplitter(BaseTextPreprocessor):\n\n def preproce...
[ 4, 5, 6, 7, 8 ]
from elasticsearch import Elasticsearch, helpers from bso.server.main.config import ES_LOGIN_BSO_BACK, ES_PASSWORD_BSO_BACK, ES_URL from bso.server.main.decorator import exception_handler from bso.server.main.logger import get_logger client = None logger = get_logger(__name__) @exception_handler def get_client(): ...
normal
{ "blob_id": "9f760c0cf2afc746a1fc19ac68d1b2f406c7efe1", "index": 5767, "step-1": "<mask token>\n\n\n@exception_handler\ndef get_doi_not_in_index(index, dois):\n es = get_client()\n results = es.search(index=index, body={'query': {'bool': {'filter': [{\n 'terms': {'doi.keyword': dois}}]}}, 'fields': ...
[ 7, 8, 9, 11, 13 ]
# -*- coding: utf-8 -*- import unittest import torch from pythainlp.transliterate import romanize, transliterate, pronunciate, puan from pythainlp.transliterate.ipa import trans_list, xsampa_list from pythainlp.transliterate.thai2rom import ThaiTransliterator from pythainlp.corpus import remove _BASIC_TESTS = { ...
normal
{ "blob_id": "486cfc4bb4b46d78715b11cba44656e8ba077c9b", "index": 2551, "step-1": "<mask token>\n\n\nclass TestTransliteratePackage(unittest.TestCase):\n <mask token>\n\n def test_romanize_royin_basic(self):\n for word in _BASIC_TESTS:\n expect = _BASIC_TESTS[word]\n self.assert...
[ 6, 8, 10, 11, 12 ]
<|reserved_special_token_0|> class ParticipantAdmin(admin.ModelAdmin): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ParticipantAdmin(admin.ModelAdmin): fieldset...
flexible
{ "blob_id": "c43b899234ffff09225153dcaf097591c7176430", "index": 841, "step-1": "<mask token>\n\n\nclass ParticipantAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass ParticipantAdmin(admin.ModelAdmin):\n fieldsets = [('Per...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Tue May 19 17:27:57 2020 @author: li """ import numpy as np from opendr.renderer import ColoredRenderer from opendr.lighting import LambertianPointLight from opendr.camera import ProjectPoints import cPickle as pkl from models.smpl import Smpl, copy_smpl,...
normal
{ "blob_id": "2540e2752edaedbf2a011a25cb90f220ae770757", "index": 7611, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(model_file, 'rb') as fp:\n model_data = pkl.load(fp)\n<mask token>\nfor i in range(70563, 70564):\n imgname = mpi_inf_valid['imgname'][i]\n rgb_img = cv2.imread(join(RO...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def pagination(request, queryset, display_amount=15, after_range_num=5, bevor_range_num=4): paginator = Paginator(queryset, display_amount) try: page = int(request.GET['page']) except: page = 1 ...
flexible
{ "blob_id": "7a2b33d1763e66335c6a72a35082e20725cab03d", "index": 3318, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef pagination(request, queryset, display_amount=15, after_range_num=5,\n bevor_range_num=4):\n paginator = Paginator(queryset, display_amount)\n try:\n page = int(req...
[ 0, 1, 2, 3 ]
from quiz.schema.base import Schema from quiz.schema.schemas import UserSchemas class RegisterSchema(Schema): """ 注册 """ _schema = UserSchemas.REG_SCHEMA.value class LoginSchema(Schema): """ 登录 """ _schema = UserSchemas.LOGIN_SCHEMA.value
normal
{ "blob_id": "e0d7fb8a9799c91dca0ca0827a5149804c9efabb", "index": 7082, "step-1": "<mask token>\n\n\nclass RegisterSchema(Schema):\n <mask token>\n <mask token>\n\n\nclass LoginSchema(Schema):\n \"\"\"\n 登录\n \"\"\"\n _schema = UserSchemas.LOGIN_SCHEMA.value\n", "step-2": "<mask token>\n\n\ncl...
[ 4, 5, 6, 7 ]
from cancion import * class NodoLista: def __init__(self, cancion, s, a): self.elemento = cancion self.siguiente = s self.anterior = a
normal
{ "blob_id": "1fb3904d48905ade8f83b6e052057e80302ec5a7", "index": 4253, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass NodoLista:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass NodoLista:\n\n def __init__(self, cancion, s, a):\n self.elemento = cancion\n self.siguien...
[ 0, 1, 2, 3 ]
############################################################################## # # Copyright (c) 2003 Zope Foundation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOF...
normal
{ "blob_id": "13c0af340c4fff815919d7cbb1cfd3116be13771", "index": 7907, "step-1": "<mask token>\n\n\nclass PyHookableTests(PyHookableMixin, unittest.TestCase):\n\n def test_pure_python(self):\n from zope.hookable import _PURE_PYTHON\n from zope.hookable import _c_hookable\n from zope.hooka...
[ 20, 24, 28, 30, 35 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if exists(filename): f = open(filename) footprint = f.read() f.close() headerEndIndex = footprint.find('(pad ') header = footprint[:headerEndIndex] lastPadIndex = headerEndIndex while footprint.find('(p...
flexible
{ "blob_id": "c71e367ad320d7eadabbbfda728d94448db6441d", "index": 2109, "step-1": "<mask token>\n", "step-2": "<mask token>\nif exists(filename):\n f = open(filename)\n footprint = f.read()\n f.close()\n headerEndIndex = footprint.find('(pad ')\n header = footprint[:headerEndIndex]\n lastPadIn...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import urllib from urllib2 import HTTPError from datetime import datetime from flask.views import MethodView from flask.ext.login import current_user, login_required from flask.ext.paginate import Pagination as PaginationBar from flask import render_template, redirect, url_for, request, jsonify...
normal
{ "blob_id": "1a561ca0268d084c8fdde5de65ce0c7e68154eec", "index": 4993, "step-1": "<mask token>\n\n\nclass OperationLog(MethodView):\n decorators = [login_required, admin_required]\n\n def get(self, page):\n per_page = 10\n count = UserOperation.query.count()\n query = UserOperation.que...
[ 17, 24, 27, 37, 47 ]
<|reserved_special_token_0|> def read_atomic_data(path): if not path or not os.path.exists(path) or not os.path.isfile(path): print('To begin with, your path to data should be proper!') sys.exit(1) df = pd.read_csv(path) columns = df.columns.tolist() columns = columns[:-1] df = pd....
flexible
{ "blob_id": "1e34087719f6fd0456d2722edbd0a7af68d37e4c", "index": 1577, "step-1": "<mask token>\n\n\ndef read_atomic_data(path):\n if not path or not os.path.exists(path) or not os.path.isfile(path):\n print('To begin with, your path to data should be proper!')\n sys.exit(1)\n df = pd.read_csv...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def swap_dns(live_alias, future_value, alias_dns_name, zone, records): """ :description: Changes alias (blue.<domain> or green.<domain>) that is behind live url. :param live_alias: Your external DNS record pointing to live web server. future_alias: blue.<domain...
flexible
{ "blob_id": "dc928da92dc7e8a37a7f32dd4a579fd09b89eb01", "index": 4955, "step-1": "<mask token>\n\n\ndef swap_dns(live_alias, future_value, alias_dns_name, zone, records):\n \"\"\"\n :description: Changes alias (blue.<domain> or green.<domain>) that is behind live url.\n :param\n live_alias: Your ...
[ 1, 10, 14, 15, 23 ]
<|reserved_special_token_0|> class MyModel: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|rese...
flexible
{ "blob_id": "48270f70a9d69d15f808f22ec2d11d337b2c4845", "index": 7414, "step-1": "<mask token>\n\n\nclass MyModel:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<...
[ 1, 2, 3, 5, 6 ]
# Author: Andreas Francois Vermeulen print("CrawlerSlaveYoke") print("CSY-000000023.py")
normal
{ "blob_id": "322795bce189428823c45a26477555052c7d5022", "index": 8933, "step-1": "<mask token>\n", "step-2": "print('CrawlerSlaveYoke')\nprint('CSY-000000023.py')\n", "step-3": "# Author: Andreas Francois Vermeulen\nprint(\"CrawlerSlaveYoke\")\nprint(\"CSY-000000023.py\")\n", "step-4": null, "step-5": nu...
[ 0, 1, 2 ]
from tkinter import * from tkinter import messagebox from tkinter import ttk from PIL import Image, ImageTk import time import socket import threading root = Tk() root.title("Tic-Tac-Toe") root.geometry('600x600') winner = False def start_thread(target): thread = threading.Thread(target=target) ...
normal
{ "blob_id": "cc924892afe179e55166ea9b237b2bfe8ea900df", "index": 2120, "step-1": "<mask token>\n\n\ndef start_thread(target):\n thread = threading.Thread(target=target)\n thread.daemon = True\n thread.start()\n\n\n<mask token>\n\n\ndef receive_data():\n while True:\n data = sock.recv(1024).dec...
[ 5, 6, 7, 8, 9 ]
# ELABORE UM PROGRAMA QUE CALCULE O A SER PAGO POR UM PRODUTO CONSIDERANDO O PRECO NORMAL E A FORMA DE PAGAMENTO # a vista dinehiro ou cheque: 10% # a vista no cartao: 5% # 2x: preco normal # 3x ou mais: 20% de juros
normal
{ "blob_id": "fa271d3888dc60582fa0883eaf9f9ebbdffeed9d", "index": 3064, "step-1": "# ELABORE UM PROGRAMA QUE CALCULE O A SER PAGO POR UM PRODUTO CONSIDERANDO O PRECO NORMAL E A FORMA DE PAGAMENTO\n# a vista dinehiro ou cheque: 10%\n# a vista no cartao: 5%\n# 2x: preco normal\n# 3x ou mais: 20% de juros", "step-...
[ 1 ]
#!/usr/bin/env python import rospy import cv2 import numpy as np from cv_bridge import CvBridge from matplotlib import pyplot as plt from sensor_msgs.msg import Image from drone_app_msgs.msg import BBox, Drone, DroneArray from rospy.numpy_msg import numpy_msg # --------------------------------------- # This is an impl...
normal
{ "blob_id": "e864dad3f46fc9c6c472823bd06ce74fb5cb3f41", "index": 462, "step-1": "<mask token>\n\n\ndef processFrame(image_message):\n frame = CvBridge().imgmsg_to_cv2(image_message)\n frame_hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)\n mask = cv2.inRange(frame_hsv, (0, 0, 0, 0), (180, 255, 30, 0))\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Task(object): <|reserved_special_token_0|> <|reserved_special_token_0|> @staticmethod def rotate_file(input_file, output_dir, degrees, expand): output_file_name = os.path.basename(input_file) output_file = os.path.join(output_dir, output_file_name) ...
flexible
{ "blob_id": "df3208a00f7a5dd1ddd76542ac0de85762cc45ab", "index": 7236, "step-1": "<mask token>\n\n\nclass Task(object):\n <mask token>\n <mask token>\n\n @staticmethod\n def rotate_file(input_file, output_dir, degrees, expand):\n output_file_name = os.path.basename(input_file)\n output_...
[ 2, 3, 4, 6, 7 ]
from Crypto.PublicKey import DSA from Crypto.Signature import DSS from Crypto.Hash import SHA256 import os import time kB = 1024 # 1kB with open('small_file.txt', 'wb') as f: f.write(os.urandom(kB)) mB = 10485760 # 1GB with open('large_file.txt', 'wb') as f: f.write(os.urandom(mB)) Begin = time.time() key = ...
normal
{ "blob_id": "d24bbfc3587a2a79891a11e00ec865498c01c286", "index": 2101, "step-1": "<mask token>\n\n\ndef DSA_2048(filename, key):\n with open(filename, 'rb') as f:\n message = f.read()\n hash_obj = SHA256.new(message)\n signer = DSS.new(key, 'fips-186-3')\n signature = signer.sign(h...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class Reader: <|reserved_special_token_0|> <|reserved_special_token_1|> class Reader: @staticmethod def read_file(file_path): return ''
flexible
{ "blob_id": "8c51b2c06f971c92e30d6b2d668fdd2fd75142d2", "index": 4846, "step-1": "<mask token>\n", "step-2": "class Reader:\n <mask token>\n", "step-3": "class Reader:\n\n @staticmethod\n def read_file(file_path):\n return ''\n", "step-4": null, "step-5": null, "step-ids": [ 0, ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def saveImg(imgurl, downLoadType): fileLocation = directoryLocation + '\\' + downLoadType + '\\' + title if not os.path.exists(fileLocation): os.makedirs(fileLocation) file = fileLocation + '\\' + str(count + 1) + '.png' urlretrieve(imgurl, filename=file) retur...
flexible
{ "blob_id": "7bcdd6c5c6e41b076e476e1db35b663e34d74a67", "index": 1885, "step-1": "<mask token>\n\n\ndef saveImg(imgurl, downLoadType):\n fileLocation = directoryLocation + '\\\\' + downLoadType + '\\\\' + title\n if not os.path.exists(fileLocation):\n os.makedirs(fileLocation)\n file = fileLocati...
[ 3, 4, 5, 6, 7 ]
""" Created on Fri Jan 07 20:53:58 2022 @author: Ankit Bharti """ from unittest import TestCase, main from cuboid_volume import * class TestCuboid(TestCase): def test_volume(self): self.assertAlmostEqual(cuboid_volume(2), 8) self.assertAlmostEqual(cuboid_volume(1), 1) self.assertAlmostE...
normal
{ "blob_id": "394f835064d070a30040b6f01b25b6f0e005827d", "index": 5010, "step-1": "<mask token>\n\n\nclass TestCuboid(TestCase):\n <mask token>\n\n def test_input_value(self):\n self.assertRaises(TypeError, cuboid_volume, 'ank')\n <mask token>\n\n def test_addition_input_value(self):\n s...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class Subjects(object): def __init__(self): self.store = list() def add(self, subjects): if isinstance(subjects, (list, tuple)): self.store.extend(subjects) elif isinstance(subjects, str): self.store.append(subjects) else: ...
flexible
{ "blob_id": "8787126e654808a5fec52283780d9b4f668fa50f", "index": 8593, "step-1": "<mask token>\n\n\nclass Subjects(object):\n\n def __init__(self):\n self.store = list()\n\n def add(self, subjects):\n if isinstance(subjects, (list, tuple)):\n self.store.extend(subjects)\n el...
[ 9, 10, 12, 13, 15 ]
<|reserved_special_token_0|> class Scatter: <|reserved_special_token_0|> <|reserved_special_token_0|> class Pie: def __init__(self, values, labels, title): self.style = 'fivethirtyeight' self.values = values self.labels = labels self.explode = [(0) for i in range(len(val...
flexible
{ "blob_id": "58385a7713a8f88925ced714d25f1522bc7e39d8", "index": 1181, "step-1": "<mask token>\n\n\nclass Scatter:\n <mask token>\n <mask token>\n\n\nclass Pie:\n\n def __init__(self, values, labels, title):\n self.style = 'fivethirtyeight'\n self.values = values\n self.labels = lab...
[ 5, 6, 7, 8, 9 ]
#!/usr/bin/python # # # This is the Hydra slave module
normal
{ "blob_id": "95cdf6a22655d500c2838899ec9dfbff637a5969", "index": 2097, "step-1": "#!/usr/bin/python\n#\n#\n\n# This is the Hydra slave module\n\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 1 ] }
[ 1 ]
import pandas as pd import os import openpyxl from collections import defaultdict,deque # 調節用パラメータ filename = 'kaito7.xlsx' # 入力ファイル名 Output = 'output7.xlsx' # 出力ディレクトリ wb = openpyxl.load_workbook(filename) sheets = wb.sheetnames days = [] names = [] dict = defaultdict(dict) for sheet in sheets: sh = wb[sheet] ...
normal
{ "blob_id": "37d5696c402737bfafe21b20b90a49e2753fdc4f", "index": 7287, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor sheet in sheets:\n sh = wb[sheet]\n i = 3\n while True:\n tmp = sh.cell(row=1, column=i).value\n if tmp:\n days.append(tmp)\n else:\n ...
[ 0, 2, 3, 4, 5 ]
#!/usr/bin/env python3 # Script qui permet de couper au début ou à la fin d'un fichier audio (.wav) # un silence ou un passage musical à partir d'un fichier de transcription correspondant. # Supporte uniquement l'extension audio .wav. # Supporte les formats de transcriptions suivants : # - .stm # - .mlfmanu...
normal
{ "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 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while count < total: webbrowser.open('https://www.youtube.com/watch?v=GoSBNNgf_Vc') time.sleep(5 * 60 * 60) count += 1 <|reserved_special_token_1|> <|reserved_special_token_0|> total = 3 count = 0 while count < tota...
flexible
{ "blob_id": "e11a04cad967ae377449aab8b12bfde23e403335", "index": 8391, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile count < total:\n webbrowser.open('https://www.youtube.com/watch?v=GoSBNNgf_Vc')\n time.sleep(5 * 60 * 60)\n count += 1\n", "step-3": "<mask token>\ntotal = 3\ncount = 0\n...
[ 0, 1, 2, 3 ]
import scraperwiki import xlrd xlbin = scraperwiki.scrape("http://www.whatdotheyknow.com/request/82804/response/208592/attach/2/ACCIDENTS%20TRAMS%20Laurderdale.xls") book = xlrd.open_workbook(file_contents=xlbin) sheet = book.sheet_by_index(0) for n, s in enumerate(book.sheets()): print "Sheet %d is called %s and...
normal
{ "blob_id": "86ec33393bb19ee432c30834ea7983b11f4d1234", "index": 5169, "step-1": "import scraperwiki\nimport xlrd\nxlbin = scraperwiki.scrape(\"http://www.whatdotheyknow.com/request/82804/response/208592/attach/2/ACCIDENTS%20TRAMS%20Laurderdale.xls\")\nbook = xlrd.open_workbook(file_contents=xlbin)\n\nsheet = bo...
[ 0 ]
import pygame from clobber.constants import GREY, ROWS, WHITE, SQUARE_SIZE, COLS, YELLOW, BLACK from clobber.piece import Piece class Board: def __init__(self): self.board = [] self.selected_piece = None self.create_board() def draw_squares(self, win): win.fill(GREY) ...
normal
{ "blob_id": "b80b997f802c7ed4f0a838030703a314f2383c9d", "index": 5226, "step-1": "<mask token>\n\n\nclass Board:\n <mask token>\n\n def draw_squares(self, win):\n win.fill(GREY)\n for row in range(ROWS):\n for col in range(row % 2, COLS, 2):\n pygame.draw.rect(win, W...
[ 8, 9, 11, 13, 14 ]
my_list = [1, 2, 4, 0, 4, 0, 10, 20, 0, 1] new_list = list(filter(lambda x: x != 0, my_list)) try: new = list(map(lambda x: 2 / x, new_list)) except ZeroDivisionError: pass print(new) # def devis(n, list): # new_list = [] # for i, m_list in enumerate(list): # try: # new_list.a...
normal
{ "blob_id": "46f3d3681343d96889ddb073f17ff7f225486f35", "index": 8005, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n new = list(map(lambda x: 2 / x, new_list))\nexcept ZeroDivisionError:\n pass\nprint(new)\n", "step-3": "my_list = [1, 2, 4, 0, 4, 0, 10, 20, 0, 1]\nnew_list = list(filter(l...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.route('/comments/new/') @login_required(role='ANY') def comments_form(): return render_template('comments/new.html', form=CommentForm()) <|reserved_special_token_1|> from flask import render_template, request, redire...
flexible
{ "blob_id": "fe1d47b63e88935f8b2eb4bac883f3028d6f560b", "index": 4515, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/comments/new/')\n@login_required(role='ANY')\ndef comments_form():\n return render_template('comments/new.html', form=CommentForm())\n", "step-3": "from flask import...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def login_limit_user(): """ 登录函数 """ try: login_info = dict_queue.get(block=False) except Exception as e: print('[Error] {0}'.format(repr(e))) return username = login_info[0] if username in success_username: return password =...
flexible
{ "blob_id": "94286fc36e06598b9faa65d9e5759f9518e436c6", "index": 7979, "step-1": "<mask token>\n\n\ndef login_limit_user():\n \"\"\"\n 登录函数\n \"\"\"\n try:\n login_info = dict_queue.get(block=False)\n except Exception as e:\n print('[Error] {0}'.format(repr(e)))\n return\n ...
[ 4, 5, 6, 7, 8 ]
#!/usr/bin/env python # Copyright (c) 2018, University of Stuttgart # All rights reserved. # # Permission to use, copy, modify, and distribute this software for any purpose # with or without fee is hereby granted, provided that the above copyright # notice and this permission notice appear in all copies. # # THE ...
normal
{ "blob_id": "0d6177660a9b9c22bcf6eb11763e7fe1ee03b46a", "index": 3454, "step-1": "<mask token>\n", "step-2": "<mask token>\nworkspace.obstacles.append(box)\nworkspace.obstacles.append(segment)\nworkspace.obstacles.append(circle)\n<mask token>\nviewer.draw_ws_img(signed_distance_field)\nviewer.draw_ws_obstacles...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in yeongil_MBTI: print(MBTI_reverse_index[i], end='') <|reserved_special_token_1|> MBTI_reverse_index = {'E': 'I', 'I': 'E', 'S': 'N', 'N': 'S', 'T': 'F', 'F': 'T', 'J': 'P', 'P': 'J'} yeongil_MBTI = input() for i...
flexible
{ "blob_id": "c247b218267fc7c2bee93053dd90b2806572eaf2", "index": 4234, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in yeongil_MBTI:\n print(MBTI_reverse_index[i], end='')\n", "step-3": "MBTI_reverse_index = {'E': 'I', 'I': 'E', 'S': 'N', 'N': 'S', 'T': 'F', 'F':\n 'T', 'J': 'P', 'P': 'J'...
[ 0, 1, 2, 3 ]
# dg_kernel plots import os import re import numpy as np import matplotlib.pyplot as plt import matplotlib.colors as mcolors import csv import sys NE_SIZE = 128 TITLE_SIZE = 35 TEXT_SIZE = 30 MARKER_SIZE = 10 LINE_WIDTH = 5 colors = { idx:cname for idx, cname in enumerate(mcolors.cnames) } eventname = 'L1_DCM' cal...
normal
{ "blob_id": "872b13a93c9aba55c143ee9891543f059c070a36", "index": 4631, "step-1": "# dg_kernel plots\n\nimport os\nimport re\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.colors as mcolors\nimport csv\nimport sys\n\nNE_SIZE = 128\nTITLE_SIZE = 35 \nTEXT_SIZE = 30 \nMARKER_SIZE = 10\nLINE...
[ 0 ]
<|reserved_special_token_0|> def key_func(entry): return entry[0], entry[1] def make_pair(entry): key = entry[FIRST_KEY], entry[SECOND_KEY] return key, entry def unpair(entry): return entry[0][0], entry[1][0], entry[1][1] <|reserved_special_token_0|> def sorted_group(lines): return itertoo...
flexible
{ "blob_id": "05d6f15102be41937febeb63ed66a77d3b0a678e", "index": 8517, "step-1": "<mask token>\n\n\ndef key_func(entry):\n return entry[0], entry[1]\n\n\ndef make_pair(entry):\n key = entry[FIRST_KEY], entry[SECOND_KEY]\n return key, entry\n\n\ndef unpair(entry):\n return entry[0][0], entry[1][0], en...
[ 5, 6, 8, 10, 11 ]
<|reserved_special_token_0|> class ProductSpider(scrapy.Spider): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self): options = webdriver.ChromeOptions() options.add_argument('--start-maximized') self.driver = webdriver.Chr...
flexible
{ "blob_id": "237a93ff73cb98fd9d4006f14d3cadbdc09259a4", "index": 9885, "step-1": "<mask token>\n\n\nclass ProductSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self):\n options = webdriver.ChromeOptions()\n options.add_argument('--start-maximized')\...
[ 2, 3, 5, 6, 7 ]
import pandas as pd import numpy as np import sys #Best Mean Test if len(sys.argv) <= 3: print("Not enough args usage: anova.py <*.csv> <rv1,rv2> <target to beat>") print("ex: best-mean.py testdata.csv nicdrop 95000") print("<rv> is response variable") exit() target_to_beat = int(sys.argv[3]) #factors rv = sys.ar...
normal
{ "blob_id": "b9e78629fe094d933fdc0ffa2f9d9d1880e78c12", "index": 9078, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv) <= 3:\n print('Not enough args usage: anova.py <*.csv> <rv1,rv2> <target to beat>')\n print('ex: best-mean.py testdata.csv nicdrop 95000')\n print('<rv> is respo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> engine = create_engine('sqlite:///app/databases/fays-web-dev.db', connect_args={'check_same_thread': False}) Session = sessionmaker(bind=engine) session = Session() Base = declarative_base() <|reserved_special_token_1|> fro...
flexible
{ "blob_id": "3d2b8730953e9c2801eebc23b6fb56a1b5a55e3c", "index": 6156, "step-1": "<mask token>\n", "step-2": "<mask token>\nengine = create_engine('sqlite:///app/databases/fays-web-dev.db',\n connect_args={'check_same_thread': False})\nSession = sessionmaker(bind=engine)\nsession = Session()\nBase = declara...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def outlier_thresholds(dataframe, variable, low_quantile=0.05, up_quantile=0.95 ): quantile_one = dataframe[variable].quantile(low_quantile) quantile_three = dataframe[variable].quantile(up_quantile) interquantile_range = quantile_three - quantile_one up_limit = quanti...
flexible
{ "blob_id": "9e01ba8c489791ec35b86dffe12d0cedb5f09004", "index": 3919, "step-1": "<mask token>\n\n\ndef outlier_thresholds(dataframe, variable, low_quantile=0.05, up_quantile=0.95\n ):\n quantile_one = dataframe[variable].quantile(low_quantile)\n quantile_three = dataframe[variable].quantile(up_quantile...
[ 2, 3, 4, 5, 6 ]
import cv2 import numpy as np import os from tqdm import tqdm DIR = '/home/nghiatruong/Desktop' INPUT_1 = os.path.join(DIR, 'GOPR1806.MP4') INPUT_2 = os.path.join(DIR, '20190715_180940.mp4') INPUT_3 = os.path.join(DIR, '20190715_181200.mp4') RIGHT_SYNC_1 = 1965 LEFT_SYNC_1 = 1700 RIGHT_SYNC_2 = 5765 LEFT_SYNC_2 = 128...
normal
{ "blob_id": "f8f538773693b9d9530775094d9948626247a3bb", "index": 6950, "step-1": "<mask token>\n\n\ndef add_frame_id(video, output_dir):\n reader = cv2.VideoCapture(video)\n if not reader.isOpened():\n return -1\n os.makedirs(output_dir, exist_ok=True)\n frame_count = int(reader.get(cv2.CAP_PR...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class JSONStoreTest(TestCase): def setUp(self): self.experiment = get_experiment_with_batch_and_single_trial() def testJSONEncodeFailure(self): self.assertRaises(JSONEncodeError, object_to_json, RuntimeError( 'foobar')) def testJSONDecodeFailure(...
flexible
{ "blob_id": "52eec56f7f5da8356f61301994f846ef7769f73b", "index": 6189, "step-1": "<mask token>\n\n\nclass JSONStoreTest(TestCase):\n\n def setUp(self):\n self.experiment = get_experiment_with_batch_and_single_trial()\n\n def testJSONEncodeFailure(self):\n self.assertRaises(JSONEncodeError, ob...
[ 7, 10, 12, 14, 18 ]
from bs4 import BeautifulSoup import urllib2 def get_begin_data(url): headers = { 'ser-Agent': '', 'Cookie': '' } request = urllib2.Request(url, headers=headers) web_data = urllib2.urlopen(request) soup = BeautifulSoup(web_data, 'html.parser') results = soup.select('tab...
normal
{ "blob_id": "790110a8cba960eb19593e816b579080dfc46a4e", "index": 4572, "step-1": "<mask token>\n\n\ndef get_begin_data(url):\n headers = {'ser-Agent': '', 'Cookie': ''}\n request = urllib2.Request(url, headers=headers)\n web_data = urllib2.urlopen(request)\n soup = BeautifulSoup(web_data, 'html.parse...
[ 2, 3, 4, 5, 6 ]
from django.db import models class faculdades(models.Model): codigo = models.IntegerField(primary_key = True) nome = models.CharField(max_length=50) cidade = models.CharField(max_length=30) estado = models.CharField(max_length=20) pais = models.CharField(max_length=20) def __str__(self): ...
normal
{ "blob_id": "20e5220ce23aaaedbfafe599b352f5d3a220e82e", "index": 6687, "step-1": "<mask token>\n\n\nclass cursos(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.nome\n\n\n class Meta:\n managed = False\n db_tab...
[ 11, 13, 14, 16, 17 ]
import torch.nn as nn import torch from torch.distributions.categorical import Categorical import torch.nn.functional as F from torch.optim import Adam import gym import numpy as np Device = torch.device("cuda:0") class ActorCriticNet(nn.Module): def __init__(self, observation_space, action_space, ...
normal
{ "blob_id": "e1ab4b034c949b8158c6ccc1e8e3f4a960a38c72", "index": 4382, "step-1": "<mask token>\n\n\nclass Agent(object):\n\n def __init__(self, model=None, lr=0.01, gamma=0.99):\n self.gamma = gamma\n self.AC = model\n self.optimizer = Adam(AC.parameters(), lr=lr)\n self.logp_as = ...
[ 4, 7, 8, 10, 11 ]
<|reserved_special_token_0|> class LampViewSet(viewsets.ModelViewSet): serializer_class = LampSerializer queryset = Lamp.objects.all() <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class LampSerializer(serializers.HyperlinkedModelSerializer): class Meta: ...
flexible
{ "blob_id": "aff1d702e591efcfc0fc93150a3fbec532408137", "index": 55, "step-1": "<mask token>\n\n\nclass LampViewSet(viewsets.ModelViewSet):\n serializer_class = LampSerializer\n queryset = Lamp.objects.all()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass LampSerializer(serializers.HyperlinkedMo...
[ 2, 3, 5, 6, 7 ]
<|reserved_special_token_0|> class Datalayer(BaseDataLayer): <|reserved_special_token_0|> <|reserved_special_token_0|> def __getitem__(self, item): if np.random.random() > 0.5 and len(self.bg_masks_path) > 0: random_id_bg = np.random.randint(0, len(self.bg_imgs_path)) img_...
flexible
{ "blob_id": "9928eaa32468453f405d8bb650f3e0e85a7933bf", "index": 5514, "step-1": "<mask token>\n\n\nclass Datalayer(BaseDataLayer):\n <mask token>\n <mask token>\n\n def __getitem__(self, item):\n if np.random.random() > 0.5 and len(self.bg_masks_path) > 0:\n random_id_bg = np.random.r...
[ 2, 3, 4, 5, 6 ]
from platform_class import * from player_class import * from functions import * delay = 3000 startOfGame = False # def keyPressed(): # startOfGame = True # print(startOfGame) # if (keyCode == 'B'): # print("I am pressed") # startOfGame = True def mousePressed(): global platforms ...
normal
{ "blob_id": "850251338e8af841a5214b37610d1b6fba572aa5", "index": 1138, "step-1": "<mask token>\n\n\ndef setup():\n size(500, 800)\n rectMode(CENTER)\n global atStartUp\n atStartUp = True\n global startTimeMs\n startTimeMs = millis()\n global bg, go, sb\n bg = loadImage('assets\\\\backgrou...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for name, hexcode in zip(cs.colornames, cs.colors): print('%s: %s' % (hexcode, name)) <|reserved_special_token_0|> cs.example_plot(ax) fig.savefig('latest.png', dpi=200, bbox_inches='tight') <|reserved_special_token_1|> <|r...
flexible
{ "blob_id": "7106a8ddbec60ce4b7d9e8e5ce8d7df02e5f7222", "index": 6854, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor name, hexcode in zip(cs.colornames, cs.colors):\n print('%s: %s' % (hexcode, name))\n<mask token>\ncs.example_plot(ax)\nfig.savefig('latest.png', dpi=200, bbox_inches='tight')\n", ...
[ 0, 1, 2, 3 ]
import argparse import gc import gcsfs import nibabel as nib import nilearn import nobrainer import numpy as np import os import os.path as op import pandas as pd import tensorflow as tf def interpolate_images(baseline, image, alphas): alphas_x = alphas[:, tf.newaxis, tf.newaxis, tf.newaxis, tf.newaxis] basel...
normal
{ "blob_id": "848e4abcd0b4f118030fc62f1272a19bfce9db4e", "index": 178, "step-1": "<mask token>\n\n\ndef interpolate_images(baseline, image, alphas):\n alphas_x = alphas[:, tf.newaxis, tf.newaxis, tf.newaxis, tf.newaxis]\n baseline_x = tf.expand_dims(baseline, axis=0)\n input_x = tf.expand_dims(image, axi...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def insert_category(conn): """将商品的种类插入数据库 """ categories_dict = {(66): '手机', (327): '腕表配饰', (65): '电脑办公', (67): '相机单反', (217): '平板数码', (179): '运动户外', (255): '家电家居', (1000): '其他'} with conn.cursor() as cursor: for category_id, category_name in categories_dict.it...
flexible
{ "blob_id": "b69e3f5e57adc8e89b6ff22fb4a10d2539e13ca3", "index": 7200, "step-1": "<mask token>\n\n\ndef insert_category(conn):\n \"\"\"将商品的种类插入数据库 \"\"\"\n categories_dict = {(66): '手机', (327): '腕表配饰', (65): '电脑办公', (67):\n '相机单反', (217): '平板数码', (179): '运动户外', (255): '家电家居', (1000): '其他'}\n with...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def get_all_lefts(word, substring): if len(substring) == 0: yield (len(word), word), elif substring[0] not in word: yield -1, else: for i in range(len(word)): if word[i] == substring[0]: for sub_...
flexible
{ "blob_id": "8c0377b70b902e6e61351869a4378b4c2c50a3a7", "index": 2478, "step-1": "<mask token>\n", "step-2": "def get_all_lefts(word, substring):\n if len(substring) == 0:\n yield (len(word), word),\n elif substring[0] not in word:\n yield -1,\n else:\n for i in range(len(word)):\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if os.path.exists(Result_File): os.remove(Result_File) <|reserved_special_token_0|> with open(Result_File, 'w') as r: r.write( 'OI_CE|Chng_in_OI_CE |Volume_CE|IV_CE|LTP_CE|NetChng_CE|Bid_Qty_CE|Bid_Price_CE|Ask_Pri...
flexible
{ "blob_id": "869bbc8da8cdb5de0bcaf5664b5482814daae53a", "index": 6212, "step-1": "<mask token>\n", "step-2": "<mask token>\nif os.path.exists(Result_File):\n os.remove(Result_File)\n<mask token>\nwith open(Result_File, 'w') as r:\n r.write(\n 'OI_CE|Chng_in_OI_CE |Volume_CE|IV_CE|LTP_CE|NetChng_CE...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def read_incremental_factors(): import csv inc_file = open(incremental_factors_file, 'r') reader = csv.reader(inc_file) increment_map = dict() funding_code_map = dict() this_trn_code = '' for row in r...
flexible
{ "blob_id": "18dae039f6455f944cbaa97bcb9c36ed29ac9a21", "index": 867, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef read_incremental_factors():\n import csv\n inc_file = open(incremental_factors_file, 'r')\n reader = csv.reader(inc_file)\n increment_map = dict()\n funding_code_map...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def http_request(url, data, token=None, method='post'): header = {'X-Lemonban-Media-Type': 'lemonban.v2', 'Authorization': token} if method == 'get': result = requests.get(url, json=data, headers=header) else...
flexible
{ "blob_id": "dd7c7fa6493a43988e1c8079797f6ff9b4d239dd", "index": 4672, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef http_request(url, data, token=None, method='post'):\n header = {'X-Lemonban-Media-Type': 'lemonban.v2', 'Authorization': token}\n if method == 'get':\n result = reque...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class BackGround: def __init__(self, x, y): self.y = y self.x = x <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class BackGround: def __init__(self, x, y): self.y = y ...
flexible
{ "blob_id": "071e3cf6b4337e0079bbb2c7694fff2468142070", "index": 6505, "step-1": "<mask token>\n\n\nclass BackGround:\n\n def __init__(self, x, y):\n self.y = y\n self.x = x\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass BackGround:\n\n def __init__(self, x, y):\...
[ 2, 3, 4, 5 ]
class Robot: def __init__(self, name): self.name = name def say_hi(self): print("Hi, I'm from class Robot") print("Hi, Ich bin " + self.name) def say_hi_to_everybody(self): print("Hi to all objects :-)") class PhysicianRobot(Robot): def say_hi_again(self): pr...
normal
{ "blob_id": "6b24c438ca7bb4c37ae356c18c562831767f0569", "index": 9961, "step-1": "<mask token>\n\n\nclass PhysicianRobot(Robot):\n <mask token>\n\n\n<mask token>\n", "step-2": "class Robot:\n\n def __init__(self, name):\n self.name = name\n\n def say_hi(self):\n print(\"Hi, I'm from clas...
[ 1, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> [(x * x) for x in a] <|reserved_special_token_1|> a = range(10) [(x * x) for x in a] <|reserved_special_token_1|> a = range(10) [x*x for x in a]
flexible
{ "blob_id": "018b9533074d2766dc5010ff9c5e70888d249b45", "index": 1832, "step-1": "<mask token>\n", "step-2": "<mask token>\n[(x * x) for x in a]\n", "step-3": "a = range(10)\n[(x * x) for x in a]\n", "step-4": "a = range(10)\n[x*x for x in a]\n", "step-5": null, "step-ids": [ 0, 1, 2, 3...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> roslib.load_manifest('learning_tf') <|reserved_special_token_0|> if __name__ == '__main__': rospy.init_node('move_client') client = actionlib.SimpleActionClient('moveTo', turtlesim_) client.wait_for_server() goal =...
flexible
{ "blob_id": "791935f63f7a0ab2755ad33369d2afa8c10dffbb", "index": 4708, "step-1": "<mask token>\n", "step-2": "<mask token>\nroslib.load_manifest('learning_tf')\n<mask token>\nif __name__ == '__main__':\n rospy.init_node('move_client')\n client = actionlib.SimpleActionClient('moveTo', turtlesim_)\n cli...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def EuclidGCD(a, b): if b == 0: return a else: a = a % b return EuclidGCD(b, a) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def EuclidGCD(a, b): ...
flexible
{ "blob_id": "39d82267f966ca106ee384e540c31a3e5e433318", "index": 2248, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef EuclidGCD(a, b):\n if b == 0:\n return a\n else:\n a = a % b\n return EuclidGCD(b, a)\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef EuclidGCD...
[ 0, 1, 2, 3, 4 ]
import math import pendulum from none import * @on_command('yearprogress') async def year_progress(session: CommandSession): await session.send(get_year_progress()) def get_year_progress(): dt = pendulum.now() percent = year_progress(dt) year = dt.year return f'你的 {year} 使用进度:{percent}%\n' \ ...
normal
{ "blob_id": "f54d0eeffa140af9c16a1fedb8dcd7d06ced29f2", "index": 2395, "step-1": "<mask token>\n\n\ndef get_year_progress():\n dt = pendulum.now()\n percent = year_progress(dt)\n year = dt.year\n return f'你的 {year} 使用进度:{percent}%\\n\\n\\n{make_progress_string(percent)}'\n\n\ndef year_progress(dt):\n...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Products(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "5b0252dd862fe1e46c0c1df41935db16ae691dff", "index": 7277, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Products(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Prod...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class A_Scroller(Scene): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class A_Scroller(Scene): <|reserved_special_token_0|> def construct(self): text_1 = Text('3493', color='#DC3832') ...
flexible
{ "blob_id": "97c97f18d1b93dc54538a0df7badafd961fdcb9c", "index": 3588, "step-1": "<mask token>\n\n\nclass A_Scroller(Scene):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass A_Scroller(Scene):\n <mask token>\n\n def construct(self):\n text_1 = Text('3493', color='#DC3832'...
[ 1, 2, 3, 4, 5 ]
import generic name = __name__ def options(opt): generic._options(opt, name) def configure(cfg): generic._configure(cfg, name, incs=('czmq.h',), libs=('czmq',), pcname= name.lower(), uses='LIBZMQ', mandatory=True)
normal
{ "blob_id": "9e511c769f6ccedc06845a382171fb3729913d05", "index": 9767, "step-1": "<mask token>\n\n\ndef options(opt):\n generic._options(opt, name)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef options(opt):\n generic._options(opt, name)\n\n\ndef configure(cfg):\n generic._configure(cfg, name...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def DIXMAAN(type): def DIXMAAN_(n): name = 'DIXMAAN%c function (CUTE)' % type alpha, beta, gamma, sigma, k1, k2, k3, k4 = table_DIXMAAN[type] m = n // 3 sm = lambda i: alpha * xi(i) ** 2 * (i...
flexible
{ "blob_id": "7026f4549019c25cb736af556fe46fd360fba46f", "index": 2238, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef DIXMAAN(type):\n\n def DIXMAAN_(n):\n name = 'DIXMAAN%c function (CUTE)' % type\n alpha, beta, gamma, sigma, k1, k2, k3, k4 = table_DIXMAAN[type]\n m = n /...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class RatingBlock(InclusionTag): name = 'rating' template = 'ratings/rating.html' options = Options(Argument('obj', required=True)) def get_context(self, context, obj): if not hasattr(obj, '_meta') or not hasattr(obj, 'pk'): raise ValueError( ...
flexible
{ "blob_id": "1a05817c4c16f2d9234e504b0c98f9c9ae2dc3f7", "index": 1525, "step-1": "<mask token>\n\n\nclass RatingBlock(InclusionTag):\n name = 'rating'\n template = 'ratings/rating.html'\n options = Options(Argument('obj', required=True))\n\n def get_context(self, context, obj):\n if not hasatt...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def urlShortner(): if clip.paste(): text = clip.paste() o = urlparse(text) if not (o.scheme == 'http' or o.scheme == 'https'): print('This is not url.') return 1 newUrl = '...
flexible
{ "blob_id": "c3c82b9ba198b7818cc8e63710140bbb6e28a9ea", "index": 6628, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef urlShortner():\n if clip.paste():\n text = clip.paste()\n o = urlparse(text)\n if not (o.scheme == 'http' or o.scheme == 'https'):\n print('This...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> api.add_resource(StoreList, '/stores') api.add_resource(Store, '/store/<string:name>') api.add_resource(ItemList, '/items') api.add_resource(Item, '/item/<string:name>') api.add_resource(UserRegister, '/register') if __name__ == '...
flexible
{ "blob_id": "bf8f7b51b685f0e9131cb4d8a0bfc16ee5ad1263", "index": 3281, "step-1": "<mask token>\n", "step-2": "<mask token>\napi.add_resource(StoreList, '/stores')\napi.add_resource(Store, '/store/<string:name>')\napi.add_resource(ItemList, '/items')\napi.add_resource(Item, '/item/<string:name>')\napi.add_resou...
[ 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_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "cdd929ee041c485d2a6c1149ea1b1ced92d7b7ab", "index": 5972, "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 ]
# coding: utf-8 from openerp import SUPERUSER_ID from openerp.osv import osv, fields from openerp.addons.ud.ud import _TIPOS_BOLSA TIPOS_BOLSA = dict(_TIPOS_BOLSA) def get_banco(cls, cr, browse_record, usuario_id, context=None): dados_bancarios_model = cls.pool.get("ud.dados.bancarios") args = [("banco_id", ...
normal
{ "blob_id": "fd877f5952c1fc0b2115d0950a066501ee7545f8", "index": 4150, "step-1": "<mask token>\n\n\nclass AdicionarBolsaWizard(osv.TransientModel):\n <mask token>\n <mask token>\n <mask token>\n\n def _bolsas(self, cr, uid, ids, campos, args, context=None):\n oferta_model = self.pool.get('ud.m...
[ 18, 20, 22, 24, 26 ]
from django.contrib import admin from .models import Spot from leaflet.admin import LeafletGeoAdmin class SpotAdmin(LeafletGeoAdmin): pass admin.site.register(Spot, SpotAdmin)
normal
{ "blob_id": "7633944366c6655306bc41087b19a474e9c414b5", "index": 7688, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SpotAdmin(LeafletGeoAdmin):\n pass\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass SpotAdmin(LeafletGeoAdmin):\n pass\n\n\nadmin.site.register(Spot, SpotAdmin)\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def run(path, output): for xml_file in glob.glob(path + '/*.xml'): tree = ET.parse(xml_file) root = tree.getroot() base_file, ext = os.path.splitext(root.find('filename').text) txtFileName = os.path.join(output, base_file + '.txt') l = [] ...
flexible
{ "blob_id": "26d14bc74d893f6f14ee7405280f4af41854c544", "index": 141, "step-1": "<mask token>\n\n\ndef run(path, output):\n for xml_file in glob.glob(path + '/*.xml'):\n tree = ET.parse(xml_file)\n root = tree.getroot()\n base_file, ext = os.path.splitext(root.find('filename').text)\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class InventoryAsyncPlugin(SqPlugin): <|reserved_special_token_0|> async def run(self): """Background task to launch in order to execute the plugin""" try: await self._execute() final...
flexible
{ "blob_id": "8b49aa63cc6e4490b7b22cd304dbba132962c870", "index": 9049, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass InventoryAsyncPlugin(SqPlugin):\n <mask token>\n\n async def run(self):\n \"\"\"Background task to launch in order to execute the plugin\"\"\"\n try:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def test_number(): pass
flexible
{ "blob_id": "687ab41e9ce94c8d14154a941504845a8fa9f2d9", "index": 8660, "step-1": "<mask token>\n", "step-2": "def test_number():\n pass\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
import numpy as np import matplotlib.pyplot as plt ########################################## # line plot ######################################### # x축 생략시 x축은 0, 1, 2, 3이 됨 """ plt.plot([1, 4, 9, 16]) plt.show() """ # x축과 y축 지정 """ plt.plot([10, 20, 30, 40], [1, 4, 9, 16]) plt.show() """ # 스타일지정 # 색깔, 마커, 선 순서로 ...
normal
{ "blob_id": "89ffb2da456d2edf15fde8adc01615a277c6caa1", "index": 8522, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith plt.xkcd():\n plt.title('XKCD style plot!!!')\n plt.plot(X, C, label='cosine')\n t = 2 * np.pi / 3\n plt.scatter(t, np.cos(t), 50, color='blue')\n plt.annotate('0.5 He...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def est_lin_transf(im_ref, im_mov, mov_mask=None, show_parameters=False): initial_transform = sitk.CenteredTransformInitializer(im_ref, im_mov, sitk.ScaleSkewVersor3DTransform(), sitk. CenteredTransformInitializerFilter.MOMENTS) lin_transformation = sitk.ImageRegis...
flexible
{ "blob_id": "2b7d9ded82fa980eeae06beb2d84d89612d53df1", "index": 821, "step-1": "<mask token>\n\n\ndef est_lin_transf(im_ref, im_mov, mov_mask=None, show_parameters=False):\n initial_transform = sitk.CenteredTransformInitializer(im_ref, im_mov,\n sitk.ScaleSkewVersor3DTransform(), sitk.\n Center...
[ 5, 6, 7, 8, 9 ]
from pulp import * from collections import namedtuple import networkx as nx import itertools from mcfpox.controller.lib import Flow, Hop def get_host_from_ip(G, ip): return next((i for i in G.nodes() if G.node[i].get('ip') == str(ip)), None) # https://docs.python.org/2/library/itertools.html#recipes def pairwis...
normal
{ "blob_id": "65bcb4a2fbc05ee19c8a94811d369562ec5e72ff", "index": 9261, "step-1": "from pulp import *\nfrom collections import namedtuple\nimport networkx as nx\nimport itertools\nfrom mcfpox.controller.lib import Flow, Hop\n\n\ndef get_host_from_ip(G, ip):\n return next((i for i in G.nodes() if G.node[i].get(...
[ 0 ]
from django.apps import AppConfig class PersianConfig(AppConfig): name = 'persian'
normal
{ "blob_id": "6b0d1de4c77841f20670331db3332cf87be7ad84", "index": 3931, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PersianConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass PersianConfig(AppConfig):\n name = 'persian'\n", "step-4": "from django.apps import App...
[ 0, 1, 2, 3 ]