code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
# @Time : 2019/12/12 15:54 # @Author : Libuda # @FileName: 远程服务器文件监控.py # @Software: PyCharm import itchat @itchat.msg_register(itchat.content.TEXT) def text_reply(msg): return msg.text itchat.auto_login() itchat.run()
normal
{ "blob_id": "2b87b8571664989e78790bd9df23eee9cbd44035", "index": 1363, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@itchat.msg_register(itchat.content.TEXT)\ndef text_reply(msg):\n return msg.text\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\n@itchat.msg_register(itchat.content.TEXT)\nde...
[ 0, 1, 2, 3, 4 ]
from paypalcheckoutsdk.core import PayPalHttpClient, SandboxEnvironment from paypalcheckoutsdk.orders import OrdersCaptureRequest, OrdersCreateRequest from django.conf import settings import sys class PayPalClient: def __init__(self): self.client_id = settings.PAYPAL_CLIENT_ID self.client_secret ...
normal
{ "blob_id": "542bd52e3d5bc79077277034234419983005f78e", "index": 2128, "step-1": "<mask token>\n\n\nclass OrderClient(PayPalClient):\n \"\"\" This is the sample function to create an order. It uses the\n JSON body returned by buildRequestBody() to create an order.\"\"\"\n\n def create_order(self, order_...
[ 4, 5, 6, 8, 11 ]
<|reserved_special_token_0|> class ConnTimeout(object): def __init__(self, timeout, function, servers=5, args=[], kwargs=[]): self.timeout = timeout self.timer = None self.count = 0 self.f = function self.servers = servers self.args = args self.kwargs = kwa...
flexible
{ "blob_id": "ed5ba72443b70c84941af3d112e0246cb3ae97d9", "index": 5337, "step-1": "<mask token>\n\n\nclass ConnTimeout(object):\n\n def __init__(self, timeout, function, servers=5, args=[], kwargs=[]):\n self.timeout = timeout\n self.timer = None\n self.count = 0\n self.f = function...
[ 5, 6, 7, 8, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_check_error_page_1(): try: link = 'http://suninjuly.github.io/registration1.html' browser = webdriver.Chrome() browser.get(link) field_text = browser.find_element_by_xpath( ...
flexible
{ "blob_id": "83ebebbb6191295adcb58b003bf1c3bcc6fb189f", "index": 7405, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_check_error_page_1():\n try:\n link = 'http://suninjuly.github.io/registration1.html'\n browser = webdriver.Chrome()\n browser.get(link)\n fiel...
[ 0, 1, 2, 3, 4 ]
from django.test import TestCase from django.core.files import File from ResearchManage.forms import ResearchFormMKI from django.test import Client from unittest import TestCase, mock from datetime import date, timedelta from django.core.files.uploadedfile import SimpleUploadedFile import os # Create your tests here. ...
normal
{ "blob_id": "c5d0b23396e084ad6ffade15b3aa3c59b6be3cc0", "index": 2706, "step-1": "<mask token>\n\n\nclass TestForms(TestCase):\n <mask token>\n\n def test_wrong_data_ResearchFormMKI_form(self):\n with open(os.path.abspath(os.curdir) + 'Test.txt', 'wb') as f:\n f.write(b'ABOBA')\n w...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> class DB: <|reserved_special_token_0|> def __enter__(self): return self <|reserved_special_token_0|> def write(self, data): sql = "INSERT INTO {}({}) VALUES ('%s')".format('data', 'a') % data self.cur.execute(sql) self.conn.commit() d...
flexible
{ "blob_id": "80ad4459436e2e1cc44509e7dae18d1539bf2bc0", "index": 8139, "step-1": "<mask token>\n\n\nclass DB:\n <mask token>\n\n def __enter__(self):\n return self\n <mask token>\n\n def write(self, data):\n sql = \"INSERT INTO {}({}) VALUES ('%s')\".format('data', 'a') % data\n ...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if not os.path.exists(app.config['CONFIG_PATH']): os.makedirs(app.config['CONFIG_PATH']) if not os.path.exists(app.config['SESSION_FILE_DIR']): os.makedirs(app.config['SESSION_FILE_DIR']) if not os.path.exists(app.config['...
flexible
{ "blob_id": "26fb607623fda333c37e254470ca6d07708671a8", "index": 5877, "step-1": "<mask token>\n", "step-2": "<mask token>\nif not os.path.exists(app.config['CONFIG_PATH']):\n os.makedirs(app.config['CONFIG_PATH'])\nif not os.path.exists(app.config['SESSION_FILE_DIR']):\n os.makedirs(app.config['SESSION_...
[ 0, 1, 2, 3, 4 ]
from flask_sqlalchemy import SQLAlchemy from flask_security import UserMixin, RoleMixin db = SQLAlchemy() roles_users = db.Table('roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('user.id')), db.Column('role_id', db.Integer(), db.ForeignKey('role.id'))) class Role(db.Model, RoleMixin): ...
normal
{ "blob_id": "f561846c943013629e417d16f4dae77df43b25c4", "index": 3806, "step-1": "<mask token>\n\n\nclass Role(db.Model, RoleMixin):\n <mask token>\n <mask token>\n <mask token>\n\n def __repr__(self):\n return f'<Role {self.name}'\n\n\nclass User(db.Model, UserMixin):\n id = db.Column(db.I...
[ 10, 11, 12, 13, 14 ]
a=int(raw_input()) if (a%2)==0: print("Even") else: print("Odd")
normal
{ "blob_id": "00b06b5e6465bae3eab336441b283a9831bb93c0", "index": 4531, "step-1": "<mask token>\n", "step-2": "<mask token>\nif a % 2 == 0:\n print('Even')\nelse:\n print('Odd')\n", "step-3": "a = int(raw_input())\nif a % 2 == 0:\n print('Even')\nelse:\n print('Odd')\n", "step-4": "a=int(raw_inp...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for row in data: cell_text.append([f'{x:1.2f}' for x in row]) <|reserved_special_token_0|> plt.figure(linewidth=2, edgecolor=fig_border, facecolor= fig_background_color, tight_layout={'pad': 1}, figsize=(4.5, 1.75)) <|rese...
flexible
{ "blob_id": "ba7db49ca7956fdc055702ffccba769485fd0046", "index": 8915, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor row in data:\n cell_text.append([f'{x:1.2f}' for x in row])\n<mask token>\nplt.figure(linewidth=2, edgecolor=fig_border, facecolor=\n fig_background_color, tight_layout={'pad': ...
[ 0, 1, 2, 3, 4 ]
# funkcja usuwająca zera z listy def remove_zeros(given_list): list_without_zero = [] for element in given_list: if element != 0: list_without_zero.append(element) return list_without_zero # funkcja sortująca listę def sort_desc(given_list): # sorted_list = [] # for ...
normal
{ "blob_id": "0779e516e35c41acf0529961e11541dfd1320749", "index": 6501, "step-1": "def remove_zeros(given_list):\n list_without_zero = []\n for element in given_list:\n if element != 0:\n list_without_zero.append(element)\n return list_without_zero\n\n\ndef sort_desc(given_list):\n r...
[ 5, 7, 8, 10, 11 ]
import numpy as np import cPickle from features import create_features, PROJECT from parse import load_data from dict_vectorizer import DictVectorizer videos, users, reviews = load_data() orig_X = np.array([(x['date'], x['text'], x['user']) for x in reviews]) feats = create_features(orig_X, None) v = DictVectorizer(s...
normal
{ "blob_id": "e26fa69ea1f0bee82b4108ac5a541a6175645728", "index": 5955, "step-1": "<mask token>\n", "step-2": "<mask token>\ncPickle.dump(v, open(PROJECT + 'db/dictvectorizer.pickle', 'wb'))\n", "step-3": "<mask token>\nvideos, users, reviews = load_data()\norig_X = np.array([(x['date'], x['text'], x['user'])...
[ 0, 1, 2, 3, 4 ]
import os.path import bcolz import numpy as np import zmq context = zmq.Context() socket = context.socket(zmq.REP) socket.bind("tcp://*:5555") if not os.path.exists('db'): print("db not found, creating") ct = bcolz.ctable([np.empty(0, dtype="i8")], names=['data'], ...
normal
{ "blob_id": "71ac7240287b83be6ec1f2d98e3ee531a8a219e0", "index": 9879, "step-1": "<mask token>\n", "step-2": "<mask token>\nsocket.bind('tcp://*:5555')\nif not os.path.exists('db'):\n print('db not found, creating')\n ct = bcolz.ctable([np.empty(0, dtype='i8')], names=['data'], rootdir='db')\nelse:\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def json2yaml(json_input, yaml_input): json_data = json.load(open(json_input, 'r')) yaml_file = open(yaml_input, 'w') yaml.safe_dump(json_data, yaml_file, allow_unicode=True, default_flow_style=False) yaml_data = yaml.load_all(open(yaml_input, 'r'), Loader=yaml.Ful...
flexible
{ "blob_id": "5c15252611bee9cd9fbb5d91a19850c242bb51f1", "index": 4940, "step-1": "<mask token>\n\n\ndef json2yaml(json_input, yaml_input):\n json_data = json.load(open(json_input, 'r'))\n yaml_file = open(yaml_input, 'w')\n yaml.safe_dump(json_data, yaml_file, allow_unicode=True,\n default_flow_s...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- from django.conf.urls import patterns, url from customer_support.views import update_existing_subscriber, \ add_new_subscriber from .views import (EditSubscriberView, DeActivateSubscriberView, ReActivateSubscriberView, SupportSub...
normal
{ "blob_id": "fb4818e742ed3c7d131c426811f839dbe70f03de", "index": 2650, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', url(regex='new_subscriber/$', view=\n add_new_subscriber, name='support.new_subscriber'), url(regex=\n 'update_subscriber/(?P<pk>\\\\d+)/$', view=update_e...
[ 0, 1, 2, 3 ]
# -------------------------------------------------------------------------------------------------- # Property of UAH # IDS module for ladder logic monitoring # This codes is Written by Rishabh Das # Date:- 18th June 2018 # -----------------------------------------------------------------------------------------------...
normal
{ "blob_id": "6f8ce77dd45f555ca092482715b6ccaa33414fd8", "index": 4176, "step-1": "<mask token>\n\n\ndef Create_list():\n i = 0\n for file in os.listdir(os.getcwd()):\n if file.endswith('openplc'):\n Monitoredlist.append(file)\n i += 1\n if i == 0:\n print('No Files ar...
[ 5, 6, 8, 9, 10 ]
<|reserved_special_token_0|> class Pop(object): <|reserved_special_token_0|> def __init__(self, province, pop_job, population): """ Creates a new Pop. manager (Historia) province (SecondaryDivision) culture (Culture) religion (Religion) language (Lang...
flexible
{ "blob_id": "887a39f1eeb81e6472938c2451e57866d3ac4a45", "index": 661, "step-1": "<mask token>\n\n\nclass Pop(object):\n <mask token>\n\n def __init__(self, province, pop_job, population):\n \"\"\"\n Creates a new Pop.\n manager (Historia)\n province (SecondaryDivision)\n ...
[ 15, 26, 28, 32, 33 ]
<|reserved_special_token_0|> def compute(): poker_hand = load_data() ans = sum(1 for x in poker_hand if p1_wins(x)) return ans def p1_wins(hands): p1 = [(a[0], a[1]) for a in hands[:5]] p2 = [(a[0], a[1]) for a in hands[5:]] return get_score(p1) > get_score(p2) def get_score(hand): val...
flexible
{ "blob_id": "480e595c54da7426951d750187712fecdcb6d8c7", "index": 9081, "step-1": "<mask token>\n\n\ndef compute():\n poker_hand = load_data()\n ans = sum(1 for x in poker_hand if p1_wins(x))\n return ans\n\n\ndef p1_wins(hands):\n p1 = [(a[0], a[1]) for a in hands[:5]]\n p2 = [(a[0], a[1]) for a i...
[ 6, 7, 8, 9, 11 ]
<|reserved_special_token_0|> class ParcelAdmin(admin.ModelAdmin): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class ParcelAdmin(admin.ModelAdmin): list_display = ['billno', 'shippername', 'rate'] <|reserved_special_token_0|> <|...
flexible
{ "blob_id": "a550b9406e9dd301b863744bb28bc81fac0cd80c", "index": 9607, "step-1": "<mask token>\n\n\nclass ParcelAdmin(admin.ModelAdmin):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass ParcelAdmin(admin.ModelAdmin):\n list_display = ['billno', 'shippername', 'rate']\n\n\n<mask tok...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # coding: utf-8 #%%: import secrets import hashlib import base64 import ecdsa from sys import byteorder #%%: class k_box: def __init__(self, string = 0, file = 0): if string != 0: if not(len(string) == 64): raise Exception("Bad len") self.__pr...
normal
{ "blob_id": "1ff2f06349ab1906a1649bdb83828fbdb3cf584f", "index": 4516, "step-1": "<mask token>\n\n\nclass k_box:\n\n def __init__(self, string=0, file=0):\n if string != 0:\n if not len(string) == 64:\n raise Exception('Bad len')\n self.__priv_key = bytes.fromhex(st...
[ 9, 12, 14, 16, 18 ]
<|reserved_special_token_0|> @jwt.user_lookup_loader def user_loader_callback(_jwt_header, jwt_data): return user_service.first(id=jwt_data['sub']) @jwt.user_identity_loader def user_identity_lookup(email): return user_service.first(email=email).id @jwt.token_in_blocklist_loader def check_if_token_in_bloc...
flexible
{ "blob_id": "f1d813ccaf49c8941bf594e22d8683c0ab422a22", "index": 7632, "step-1": "<mask token>\n\n\n@jwt.user_lookup_loader\ndef user_loader_callback(_jwt_header, jwt_data):\n return user_service.first(id=jwt_data['sub'])\n\n\n@jwt.user_identity_loader\ndef user_identity_lookup(email):\n return user_servic...
[ 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append(os.pardir) <|reserved_special_token_0|> for i in range(len(x_test)): p = controller.accuracy(x_test[i]) a = np.argmax(t_test[i]) result[p][a] += 1 if p == a: accuracy_cnt += 1 if i == tr...
flexible
{ "blob_id": "c2d8e34ab0b449a971c920fc86f259f093f16cc5", "index": 7156, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.pardir)\n<mask token>\nfor i in range(len(x_test)):\n p = controller.accuracy(x_test[i])\n a = np.argmax(t_test[i])\n result[p][a] += 1\n if p == a:\n ...
[ 0, 1, 2, 3, 4 ]
from django.urls import path from .views import job_upload_view, job_view, job_applicants_view, posted_job_view, bussiness_list_view app_name = 'jobs' urlpatterns = [ path('', job_view, name='job-index'), path('applicants/', job_applicants_view, name='job-applicants'), path('posted/', posted_job_view, name='job-...
normal
{ "blob_id": "b88af16693eca10d0bd78fd706389f5468c9b99b", "index": 144, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'jobs'\nurlpatterns = [path('', job_view, name='job-index'), path('applicants/',\n job_applicants_view, name='job-applicants'), path('posted/',\n posted_job_view, name='jo...
[ 0, 1, 2, 3 ]
from tkinter import ttk from chapter04a.validated_mixin import ValidatedMixin class RequiredEntry(ValidatedMixin, ttk.Entry): def _focusout_validate(self, event): valid = True if not self.get(): valid = False self.error.set('A value is required') return valid
normal
{ "blob_id": "59047a113d76c64be48858258441fae5da505790", "index": 5792, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass RequiredEntry(ValidatedMixin, ttk.Entry):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass RequiredEntry(ValidatedMixin, ttk.Entry):\n\n def _focusout_validate(self...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def main(): describe() str = 'araaci' k = 2 res = find_substr_with_distinct_chars(str, k) print('Input', str, k) print('Longest substring with k distinct chars is : ', res) print('Length of longest such substring is : ', len(res)) <|reserved_special_token_0|>...
flexible
{ "blob_id": "1a730f4a5fa2be434af41a3e320cab8338d93644", "index": 5050, "step-1": "<mask token>\n\n\ndef main():\n describe()\n str = 'araaci'\n k = 2\n res = find_substr_with_distinct_chars(str, k)\n print('Input', str, k)\n print('Longest substring with k distinct chars is : ', res)\n print...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def ring_score(item): return 2 * math.pi * item[0] * item[1] def solve(pancakes, k): return max(itertools.combinations(pancakes, k), key=score) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def score(stack): syrup = math.pi * m...
flexible
{ "blob_id": "31304c3b0f41b848a36115f1ef098a2104c170ac", "index": 5779, "step-1": "<mask token>\n\n\ndef ring_score(item):\n return 2 * math.pi * item[0] * item[1]\n\n\ndef solve(pancakes, k):\n return max(itertools.combinations(pancakes, k), key=score)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nd...
[ 2, 3, 4, 5, 6 ]
""" This is a module containing convenience functions to create the JWST aperture and coronagraphic images with WebbPSF. """ import os import numpy as np import matplotlib.pyplot as plt import astropy.units as u import logging import poppy from pastis.config import CONFIG_PASTIS import pastis.util as util log = loggi...
normal
{ "blob_id": "e59763991974f4bfcd126879dd9aabd44bd89419", "index": 1406, "step-1": "<mask token>\n\n\ndef get_jwst_coords(outDir):\n log.info('Creating and saving aperture')\n jwst_pup = poppy.MultiHexagonAperture(rings=2, flattoflat=FLAT_TO_FLAT)\n jwst_pup.display(colorbar=False)\n plt.title('JWST te...
[ 6, 7, 8, 9, 10 ]
#!/usr/bin/env python #lesson4.py # See original source and C based tutorial at http://nehe.gamedev.net #This code was created by Richard Campbell '99 #(ported to Python/PyOpenGL by John Ferguson 2000) #John Ferguson at hakuin@voicenet.com #Code ported for use with pyglet by Jess Hill (Jestermon) 2009 #jestermon.wee...
normal
{ "blob_id": "5fc097518b6069131e1ca58fa885c6ad45ae143c", "index": 4741, "step-1": "<mask token>\n\n\nclass World(pyglet.window.Window):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def setup(self):\n self.width = 640\n self.height = 480\n self.rtri = 0.0\n ...
[ 9, 13, 15, 16, 17 ]
from savers.saver import SaverInterface import os from config import SaverConfig import mysql.connector import json import logging class SQLSaver(SaverInterface): # This class takes in json files and will interpret the jsons as follows. # {'tablename':[{'columnname01':'somevalue','columnname02':'somevalue'},{'columnana...
normal
{ "blob_id": "e695b9458c0e98521e560dbb291f6f05bda1549f", "index": 421, "step-1": "<mask token>\n\n\nclass SQLSaver(SaverInterface):\n\n def connect(self):\n self.logging.info('Logging to %s@%s:%s -p %s', self.config.SQL_USER,\n self.config.SQL_HOST, self.config.SQL_DATABASE, self.config.\n ...
[ 10, 11, 12, 13, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(n + 1): xs[i][-1] = abs(cards[-1] - cards[i]) ys[i][-1] = abs(cards[-1] - cards[i]) for j in range(n - 1, -1, -1): xs_temp = max(ys[j][j + 1:n + 1]) ys_temp = min(xs[j][j + 1:n + 1]) for i in ran...
flexible
{ "blob_id": "81b9fc78d92fdc4392cb71a77fdfd354ff950ae3", "index": 6153, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n + 1):\n xs[i][-1] = abs(cards[-1] - cards[i])\n ys[i][-1] = abs(cards[-1] - cards[i])\nfor j in range(n - 1, -1, -1):\n xs_temp = max(ys[j][j + 1:n + 1])\n ys...
[ 0, 1, 2, 3 ]
import logging from typing import Dict import numpy as np from meshkit import Mesh from rendkit.materials import DepthMaterial from vispy import gloo, app from vispy.gloo import gl logger = logging.getLogger(__name__) class Renderable: def __init__(self, material_name: str, at...
normal
{ "blob_id": "061c287d5f0a5feeeaedc80eea6b3fc4ff02286e", "index": 7191, "step-1": "<mask token>\n\n\nclass Renderable:\n\n def __init__(self, material_name: str, attributes: Dict[str, np.ndarray\n ], model_mat=np.eye(4), uv_scale=1.0):\n self.model_mat = model_mat\n self.material_name = ma...
[ 10, 11, 13, 16, 17 ]
<|reserved_special_token_0|> class CliConfigManager(BaseConfigManager): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @classmethod def _get_count(cls): config = cls.get_config_or_def...
flexible
{ "blob_id": "fd391d28d76b0c1b3cf6d0b5134390ab3f1267fb", "index": 5152, "step-1": "<mask token>\n\n\nclass CliConfigManager(BaseConfigManager):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @classmethod\n def _get_count(cls):\n config = cls.get_config_o...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def display_meta(request): context_dict = {'meta_dict': request.META} return render_to_response('display_meta.html', context_dict) <|reserved_special_token_1|> <|reserved_special_token_0|> def current_datetime(request): current_date = datetime.datetime.now() locals_pr...
flexible
{ "blob_id": "ef6f55bf27982f53441215da6822cfcdc80706a5", "index": 240, "step-1": "<mask token>\n\n\ndef display_meta(request):\n context_dict = {'meta_dict': request.META}\n return render_to_response('display_meta.html', context_dict)\n", "step-2": "<mask token>\n\n\ndef current_datetime(request):\n cu...
[ 1, 2, 3, 4, 5 ]
import sqlite3 def connect(): connect = sqlite3.connect("books.db") cursor = connect.cursor() cursor.execute("CREATE TABLE IF NOT EXISTS bookstore (id INTEGER PRIMARY KEY," "title TEXT," "author TEXT," "year INTEGER," "isbn INTEGER...
normal
{ "blob_id": "d7d23b04f6e73db6a0a8730192398941743f32ce", "index": 6800, "step-1": "<mask token>\n\n\ndef view():\n connect = sqlite3.connect('books.db')\n cursor = connect.cursor()\n cursor.execute('SELECT * FROM bookstore')\n books = cursor.fetchall()\n connect.close()\n return books\n\n\n<mask...
[ 4, 6, 7, 8, 10 ]
<|reserved_special_token_0|> def runTowerContainer(towerVersion, externalPort, osVersion, containerName, debug=False, **kwargs): """Runs Tower container from pre-existing image""" allowedMemory = None if debug == True: runOpts = dict(towerVersion=towerVersion, externalPort=externalPort, ...
flexible
{ "blob_id": "63e28e6a1ea5db1d1c41bbc755b9c33905e066bb", "index": 9832, "step-1": "<mask token>\n\n\ndef runTowerContainer(towerVersion, externalPort, osVersion, containerName,\n debug=False, **kwargs):\n \"\"\"Runs Tower container from pre-existing image\"\"\"\n allowedMemory = None\n if debug == Tru...
[ 1, 3, 4, 5, 6 ]
""" Exercício 1 - Facebook Você receberá uma lista de palavras e uma string . Escreva uma função que decida quais palavras podem ser formadas com os caracteres da string (cada caractere só pode ser utilizado uma vez). Retorne a soma do comprimento das palavras escolhidas. Exemplo 1: """ # words = ["cat", "bt", "hat", ...
normal
{ "blob_id": "bf7e3ddaf66f4c325d3f36c6b912b47f4ae22cba", "index": 4779, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef count_words(words, chars):\n ans = 0\n alphabet = {}\n for char in chars:\n if char not in alphabet:\n alphabet[char] = 1\n else:\n al...
[ 0, 1, 2, 3, 4 ]
from behave import given, when, then from pages.LoginPage import LoginPage from pages.ProductsPage import ProductsPage class ProductsListSteps: @given("Prepare classes products list") def prepare_class(context): context.login = LoginPage(context.driver) context.products = ProductsPage(context....
normal
{ "blob_id": "a74a880039bad030d665e001da74075bd61fcc23", "index": 1593, "step-1": "<mask token>\n\n\nclass ProductsListSteps:\n\n @given('Prepare classes products list')\n def prepare_class(context):\n context.login = LoginPage(context.driver)\n context.products = ProductsPage(context.driver)\...
[ 2, 3, 4, 5, 6 ]
# Fix a method's vtable calls + reference making #@author simo #@category iOS.kernel #@keybinding R #@toolbar logos/refs.png #@description Resolve references for better CFG # -*- coding: utf-8 -*- """ script which does the following: - adds references to virtual method calls - Identifies methods belong to a specific ...
normal
{ "blob_id": "30a57197e3156023ac9a7c4a5218bfe825e143d9", "index": 5978, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n fix_extra_refs(currentAddress)\n", "step-3": "<mask token>\nfrom utils.references import *\nif __name__ == '__main__':\n fix_extra_refs(currentAddress...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(len(check_list)): if check_list[i] in sentence: check = True idx = sentence.find(check_list[i]) sentence = sentence[idx + 1:] else: check = False break if check == Tru...
flexible
{ "blob_id": "4545d9756d1f396ead0b0c75d319fb6a718375cd", "index": 2108, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(check_list)):\n if check_list[i] in sentence:\n check = True\n idx = sentence.find(check_list[i])\n sentence = sentence[idx + 1:]\n else:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class PersonAdmin(admin.ModelAdmin): pass <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class PersonAdmin(admin.ModelAdmin): pass admin.site.register(Person) <|reserved...
flexible
{ "blob_id": "d90aeaaa682b371afb4771ecfbf1077fc12520b4", "index": 3873, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PersonAdmin(admin.ModelAdmin):\n pass\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass PersonAdmin(admin.ModelAdmin):\n pass\n\n\nadmin.site.register(Person)\n",...
[ 0, 1, 2, 3, 4 ]
import urllib.request import json import dml, prov.model import datetime, uuid import geojson # import csv """ Skelton file provided by lapets@bu.edu Heavily modified by bmroach@bu.edu City of Boston Open Spaces (Like parks, etc) Development notes: """ class retrieve_open_space(dml.Algorithm): contributor = '...
normal
{ "blob_id": "2c82dd33180a7442607e5cbedf8846bd72b37150", "index": 9914, "step-1": "<mask token>\n\n\nclass retrieve_open_space(dml.Algorithm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def provenance(doc=prov.model.ProvDocument(), startTime=None, endTime=Non...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def handle(text, mic, profile): messages1 = ['Naturally Sir ', 'Of course Sir ', "I'll get right at it"] final = random.choice(messages1) mic.say(final) command = 'ssh pi@' ip = profile['piip'] command += ip command += ' pkill omxplayer' os.system(command) ...
flexible
{ "blob_id": "668a8005f2f66190d588fb9289293d73a608f767", "index": 926, "step-1": "<mask token>\n\n\ndef handle(text, mic, profile):\n messages1 = ['Naturally Sir ', 'Of course Sir ', \"I'll get right at it\"]\n final = random.choice(messages1)\n mic.say(final)\n command = 'ssh pi@'\n ip = profile['...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> radio.on() while True: message = radio.receive_full() if message: strength = message[1] + 100 displaystrength = int(strength / 10 + 1) display.show(str(displaystrength)) sleep(200) else:...
flexible
{ "blob_id": "dffa5e2f34788c6f5a5ccc7d8375317a830288b5", "index": 7994, "step-1": "<mask token>\n", "step-2": "<mask token>\nradio.on()\nwhile True:\n message = radio.receive_full()\n if message:\n strength = message[1] + 100\n displaystrength = int(strength / 10 + 1)\n display.show(s...
[ 0, 1, 2, 3 ]
#!/usr/bin/python #The MIT License (MIT) # #Copyright (c) 2015 Stephen P. Smith # #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to...
normal
{ "blob_id": "5d92c68e0fe7f37d4719fb9ca4274b29ff1cbb43", "index": 4699, "step-1": "<mask token>\n\n\nclass max31865(object):\n <mask token>\n\n def __init__(self, csPin=8, misoPin=9, mosiPin=10, clkPin=11):\n self.csPin = csPin\n self.misoPin = misoPin\n self.mosiPin = mosiPin\n ...
[ 8, 9, 11, 12, 14 ]
# Copyright 2022 Huawei Technologies Co., Ltd # # 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...
normal
{ "blob_id": "883d2efeb6d7d43cf82eef2e0397110fd8e3ea03", "index": 4368, "step-1": "<mask token>\n\n\ndef parse_args():\n \"\"\"\n parse args\n \"\"\"\n parser = argparse.ArgumentParser(description='ternarybert evaluation')\n parser.add_argument('--device_target', type=str, default='Ascend',\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> setup(name='spt_compute', version='2.0.1', description= 'Computational framework for the Streamflow Prediciton Tool', long_description= "Computational framework to ingest ECMWF ensemble runoff forcasts or otherLand Su...
flexible
{ "blob_id": "53b6d30bf52c43daaebe8158002db1072e34f127", "index": 7956, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='spt_compute', version='2.0.1', description=\n 'Computational framework for the Streamflow Prediciton Tool',\n long_description=\n \"Computational framework to ingest ...
[ 0, 1, 2, 3 ]
from migen import * from migen.fhdl import verilog class Alignment_Corrector(Module): def __init__(self): self.din=din=Signal(32) self.aligned=aligned=Signal() self.dout=dout=Signal(32) self.correction_done=Signal() # # # first_half=Signal(16) first_half1=Signal(16) second_half=Signal(16) self.submo...
normal
{ "blob_id": "f3eed00a58491f36778b3a710d2f46be093d6eda", "index": 6320, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Alignment_Corrector(Module):\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Alignment_Corrector(Module):\n\n def __init__(self):\n self.d...
[ 0, 1, 2, 3, 4 ]
g=int(input()) num=0 while(g>0): num=num+g g=g-1 print(num)
normal
{ "blob_id": "8b18f098080c3f5773aa04dffaff0639fe7fa74f", "index": 8886, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile g > 0:\n num = num + g\n g = g - 1\nprint(num)\n", "step-3": "g = int(input())\nnum = 0\nwhile g > 0:\n num = num + g\n g = g - 1\nprint(num)\n", "step-4": "g=int(in...
[ 0, 1, 2, 3 ]
''' leetcode 338. 比特位计数 给定一个非负整数 num。对于 0 ≤ i ≤ num 范围中的每个数字 i ,计算其二进制数中的 1 的数目并将它们作为数组返回。 ''' class Solution(object): def countBits(self, n): """ :type n: int :rtype: List[int] """ out = [0] * (n+1) for i in range(1,n+1,1): if i%2==1: out[i]=o...
normal
{ "blob_id": "4cd1e385d18086b1045b1149d5f4573eaf9270c3", "index": 6223, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution(object):\n\n def countBits(self, n):\n \"\"\"\n :type n: int\n :rty...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # --------------------------------------------------- # SSHSploit Framework # --------------------------------------------------- # Copyright (C) <2020> <Entynetproject> # # This program is free soft...
normal
{ "blob_id": "caf83d35ce6e0bd4e92f3de3a32221705a529ec1", "index": 9467, "step-1": "<mask token>\n\n\ndef banner():\n os.system('clear')\n os.system('cat banner/banner.txt')\n print('')\n print('SSHSploit Framework v1.0')\n print('------------------------')\n print('')\n\n\n<mask token>\n", "st...
[ 1, 2, 4, 5, 6 ]
''' Created on 2021. 4. 8. @author: user ''' import matplotlib.pyplot as plt import numpy as np plt.rc("font", family="Malgun Gothic") def scoreBarChart(names, score): plt.bar(names, score) plt.show() def multiBarChart(names, score): plt.plot(names, score, "ro--") plt.plot([1, 2, 3], [70, 8...
normal
{ "blob_id": "542602a42eb873508ce2ec39d0856f10cc1e04ff", "index": 8426, "step-1": "<mask token>\n\n\ndef scoreBarChart(names, score):\n plt.bar(names, score)\n plt.show()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef scoreBarChart(names, score):\n plt.bar(names, score)\n plt.show()\n\n\ndef...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from django.http import request from restapp.ExcelSheet import * <|reserved_special_token_0|> <|reserved_special_token_1|> from django.http import request from restapp.ExcelSheet import * '''ApiHomeDict={} class LoadDict(): e = ExcelSheetAll() ...
flexible
{ "blob_id": "ff924b803a875d3f6201baa2c1251a6c5b8cde61", "index": 5903, "step-1": "<mask token>\n", "step-2": "from django.http import request\nfrom restapp.ExcelSheet import *\n<mask token>\n", "step-3": "from django.http import request\r\nfrom restapp.ExcelSheet import *\r\n\r\n\r\n'''ApiHomeDict={}\r\nclas...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def moveFingers(jointcmds, prefix, nbJoints): topic_name = '/' + prefix + '/effort_finger_trajectory_controller/command' pub = rospy.Publisher(topic_name, JointTrajectory, queue_size=1) jointCmd = JointTrajectory() point = JointTrajectoryPoint() jointCmd.header.stamp =...
flexible
{ "blob_id": "ee7c63f36b4720566389826680b90c6f68de85b2", "index": 5200, "step-1": "<mask token>\n\n\ndef moveFingers(jointcmds, prefix, nbJoints):\n topic_name = '/' + prefix + '/effort_finger_trajectory_controller/command'\n pub = rospy.Publisher(topic_name, JointTrajectory, queue_size=1)\n jointCmd = J...
[ 1, 2, 4, 5, 6 ]
<|reserved_special_token_0|> class Adj(NamedTuple): adj_t: SparseTensor e_id: Optional[Tensor] size: Tuple[int, int] <|reserved_special_token_0|> class RandomIndexSampler(torch.utils.data.Sampler): def __init__(self, num_nodes: int, num_parts: int, shuffle: bool=False): self.N = num_nod...
flexible
{ "blob_id": "3f4f396d1d18611e0248a08b42328422ca4b8146", "index": 4766, "step-1": "<mask token>\n\n\nclass Adj(NamedTuple):\n adj_t: SparseTensor\n e_id: Optional[Tensor]\n size: Tuple[int, int]\n <mask token>\n\n\nclass RandomIndexSampler(torch.utils.data.Sampler):\n\n def __init__(self, num_nodes...
[ 12, 15, 18, 20, 21 ]
from __future__ import absolute_import from __future__ import division from __future__ import print_function from cv2 import DualTVL1OpticalFlow_create as DualTVL1 from tensorflow.python.platform import flags import os import sys sys.path.insert(0, '..') from utils import image_funcs import numpy as np def make_di...
normal
{ "blob_id": "42a717591fb8fe480581d8996e9811d0292d0eb1", "index": 7567, "step-1": "<mask token>\n\n\ndef make_dir(directory):\n import os\n import errno\n try:\n os.makedirs(directory)\n except OSError as e:\n if e.errno != errno.EEXIST:\n raise\n\n\n<mask token>\n\n\ndef save...
[ 3, 5, 6, 7, 8 ]
print "test" print "moreing" print " a nnnnn"
normal
{ "blob_id": "551e9c696eaad6c78f2eae66e50cca34c153d9dd", "index": 4636, "step-1": "print \"test\"\n\nprint \"moreing\"\n\nprint \" a nnnnn\"", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
<|reserved_special_token_0|> def displayImage(winName, img): """ Helper function to display image arguments: winName -- Name of display window img -- Source Image """ cv.imshow(winName, img) cv.waitKey(0) def task_1_a(): print('Task 1 (a) ...') img = cv.imread('../images/shap...
flexible
{ "blob_id": "f7886f8d98ad0519f4635064f768f25dad101a3d", "index": 2612, "step-1": "<mask token>\n\n\ndef displayImage(winName, img):\n \"\"\" Helper function to display image\n arguments:\n winName -- Name of display window\n img -- Source Image\n \"\"\"\n cv.imshow(winName, img)\n cv.wai...
[ 7, 8, 10, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def bytes_from_file(path, size, quality=15): img = Image.open(path) img = img.resize(size) img_byte_arr = io.BytesIO() img.save(img_byte_arr, format='JPEG', quality=quality) return img_byte_arr.getvalue() <...
flexible
{ "blob_id": "3344eb5b3e5b5eaee7b08d0991be732dae62c7fc", "index": 7137, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bytes_from_file(path, size, quality=15):\n img = Image.open(path)\n img = img.resize(size)\n img_byte_arr = io.BytesIO()\n img.save(img_byte_arr, format='JPEG', qualit...
[ 0, 1, 2, 3 ]
# first we have to label the Banana / Apple / Tomato in the images # we will use lables me # pip install pyqt5 # pip install labelme # after labeling the images. lets test it. #Each image has a json file import pixellib from pixellib.custom_train import instance_custom_training train_maskRcnn = instance_custom_tra...
normal
{ "blob_id": "cb4ca5f91c7cd47197784085258536166055afe9", "index": 4212, "step-1": "<mask token>\n", "step-2": "<mask token>\ntrain_maskRcnn.modelConfig(network_backbone='resnet101', num_classes=3,\n batch_size=1)\ntrain_maskRcnn.load_pretrained_model('c:/models/mask_rcnn_coco.h5')\ntrain_maskRcnn.load_datase...
[ 0, 1, 2, 3, 4 ]
import requests from requests.adapters import HTTPAdapter from requests.exceptions import ConnectionError, Timeout, RequestException # import from `requests` because Jarvis / some platforms still have old urllib3 from requests.packages.urllib3.util.retry import Retry def retryable_session(retries=3, backoff_factor=0.5...
normal
{ "blob_id": "603708c830dadb6f1a3e5de00536d558f448b5fb", "index": 1352, "step-1": "<mask token>\n\n\nclass Getter(object):\n <mask token>\n\n def __call__(self, url, **kwargs):\n try:\n return self._inner_call(url, **kwargs)\n except (Timeout, ConnectionError, RequestException) as e...
[ 5, 6, 7, 8, 9 ]
from torch import Tensor from torch.autograd import Variable from torch.optim import Adam from maac.utils.misc import hard_update, onehot_from_logits from maac.utils.policies import DiscretePolicy class AttentionAgent(object): """ General class for Attention agents (policy, target policy) """ def __i...
normal
{ "blob_id": "845d04312abc0e64a7810b52bbee333d2bdf3dfb", "index": 7164, "step-1": "<mask token>\n\n\nclass AttentionAgent(object):\n <mask token>\n\n def __init__(self, num_in_pol, num_out_pol, hidden_dim=64, lr=0.01,\n onehot_dim=0):\n \"\"\"\n Inputs:\n num_in_pol (int): nu...
[ 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Solution: <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Solution: def fieldOfGreatestBlessing(self, forceField: List[List[int]]) ->int: allX, allY = set(...
flexible
{ "blob_id": "0212382b5c8cc1e98142a784fd26efd577ebceaf", "index": 1656, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def fieldOfGreatestBlessing(self, forceField: List[List[int]]) ->int:\n allX, allY =...
[ 0, 1, 2, 3, 4 ]
def missing_value_count_and_percent(df): """ Return the number and percent of missing values for each column. Args: df (Dataframe): A dataframe with many columns Return: df (Dataframe): A dataframe with one column showing number of missing values, one column showing percentage of ...
normal
{ "blob_id": "88c304f224ab60062582abbfa1146a651e1233e6", "index": 183, "step-1": "def missing_value_count_and_percent(df):\n \"\"\"\n Return the number and percent of missing values for each column. \n\n Args:\n df (Dataframe): A dataframe with many columns\n \n Return:\n df (Datafram...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> async def process_credential_queue(): print("Get exported wallet id's from agent", datetime.datetime.now()) agent_wallet_ids = get_agent_wallet_ids() print("# wallet id's:", len(agent_wallet_ids)) conn = None ...
flexible
{ "blob_id": "cdb49af584ae7befcaebfd9bb303073c8229667e", "index": 3433, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nasync def process_credential_queue():\n print(\"Get exported wallet id's from agent\", datetime.datetime.now())\n agent_wallet_ids = get_agent_wallet_ids()\n print(\"# wallet...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if not os.path.exists(LOG_DIR): os.mkdir(LOG_DIR) if not os.path.exists(PATH_LOG): f = open(PATH_LOG, 'w') f.write('') f.close() <|reserved_special_token_0|> logger.setLevel(logging.DEBUG) <|reserved_special_token_...
flexible
{ "blob_id": "96910e9b6861fc9af0db3a3130d898fd1ee3daad", "index": 3356, "step-1": "<mask token>\n", "step-2": "<mask token>\nif not os.path.exists(LOG_DIR):\n os.mkdir(LOG_DIR)\nif not os.path.exists(PATH_LOG):\n f = open(PATH_LOG, 'w')\n f.write('')\n f.close()\n<mask token>\nlogger.setLevel(loggin...
[ 0, 1, 2, 3, 4 ]
from symcollab.algebra import * from .ac import * from copy import deepcopy # This is a single arity function which only actually gets applied when called an odd number of times # Useful for the inverse function later on # A group G is an algebraic structure which satisfies the following properties # (1) G is closed...
normal
{ "blob_id": "93133b9a62d50e4e48e37721585116c1c7d70761", "index": 2490, "step-1": "<mask token>\n\n\nclass GroupVariable(GroupElement, Variable):\n\n def __init__(self, g: Group, symbol: str):\n GroupElement.__init__(self, g)\n Variable.__init__(self, symbol)\n\n def __hash__(self):\n r...
[ 18, 31, 34, 35, 37 ]
<|reserved_special_token_0|> class Sentence(object): def __init__(self, text): self.text = text self.data = dict() def SentS(self): sents = SentenceSplitter.split(self.text) return sents def getLTPAnalysis(self, sentence): words = segmentor.segment(sentence) ...
flexible
{ "blob_id": "dc41c64d09e5fdd0e234f516eeec0cbd2433876c", "index": 8507, "step-1": "<mask token>\n\n\nclass Sentence(object):\n\n def __init__(self, text):\n self.text = text\n self.data = dict()\n\n def SentS(self):\n sents = SentenceSplitter.split(self.text)\n return sents\n\n ...
[ 9, 11, 12, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def own_day_and_last_person(str_arg): print(str_arg) <|reserved_special_token_0|> <|reserved_special_token_1|> def see_great_place_about_large_man(str_arg): own_day_and_last_person(str_arg) print('own_case') d...
flexible
{ "blob_id": "515c14fcf2c3e9da31f6aba4b49296b18f04f262", "index": 4786, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef own_day_and_last_person(str_arg):\n print(str_arg)\n\n\n<mask token>\n", "step-3": "def see_great_place_about_large_man(str_arg):\n own_day_and_last_person(str_arg)\n p...
[ 0, 1, 2, 3, 4 ]
"Base document saver context classes." import copy import os.path import sys import flask from . import constants from . import utils class BaseSaver: "Base document saver context." DOCTYPE = None EXCLUDE_PATHS = [["_id"], ["_rev"], ["doctype"], ["modified"]] HIDDEN_VALUE_PATHS = [] def __ini...
normal
{ "blob_id": "83fe635e35711c2c41d043a59d00a50cc87e69fa", "index": 7696, "step-1": "<mask token>\n\n\nclass BaseSaver:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token...
[ 8, 15, 21, 22, 24 ]
#!/usr/bin/env python import pyaudio import wave import winshell """ This script accesses the Laptop's microphone using the library pyaudio and opens a stream to record the voice and writes it to an mp3 file """ def start(): try: CHUNK = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 2 RA...
normal
{ "blob_id": "bbbbf0e1bbd7ead034d8cd88ee6a09a61cde7803", "index": 3463, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef start():\n try:\n CHUNK = 1024\n FORMAT = pyaudio.paInt16\n CHANNELS = 2\n RATE = 44100\n dest_path = winshell.desktop() + '\\\\Spyware\\\\Ou...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python #------------------------------------------------------------------------------- # Name: Sequitr # Purpose: Sequitr is a small, lightweight Python library for common image # processing tasks in optical microscopy, in particular, single- # molecule imaging, super-resolution...
normal
{ "blob_id": "01f4d097cc5f4173fa5a13268b91753566a9f7e1", "index": 3112, "step-1": "#!/usr/bin/env python\n#-------------------------------------------------------------------------------\n# Name: Sequitr\n# Purpose: Sequitr is a small, lightweight Python library for common image\n# processing tasks...
[ 0 ]
import datetime from django.shortcuts import render from lims.models import * import os import zipfile def getpicture(word): if word.split(".")[1] not in ["doc","docx"]: return None word_zip = word.split(".")[0] + ".zip" path = "" for i in word.split("/")[0:-1]: path += i ...
normal
{ "blob_id": "e32c73abdcd384ee7c369182527cca6495f067b3", "index": 1977, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getData(request):\n index = request.GET.get('index')\n msg = '未查找到数据'\n if ExtExecute.objects.filter(query_code=index):\n ext = ExtExecute.objects.filter(query_cod...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def put_record_to_logstream(event: utils.LambdaEvent) ->str: """Put a record of source Lambda execution in LogWatch Logs.""" log_group_name = env['REPORT_LOG_GROUP_NAME'] utils.Log.info('Fetching requestPayload and r...
flexible
{ "blob_id": "01d545e77c211201332a637a493d27608721aad5", "index": 7004, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef put_record_to_logstream(event: utils.LambdaEvent) ->str:\n \"\"\"Put a record of source Lambda execution in LogWatch Logs.\"\"\"\n log_group_name = env['REPORT_LOG_GROUP_NAM...
[ 0, 1, 2, 3, 4 ]
from sys import stdin def IsPrime(x): for i in range(2, int(x ** 0.5) + 1): if not x % i: return False return True for x in stdin: x = x[:-1] y = x[::-1] a = IsPrime(int(x)) b = IsPrime(int(y)) if not a: print("%s is not prime." %x) elif (a and not ...
normal
{ "blob_id": "fcfec521e071aa586febc74efb2deb0e9d0a331e", "index": 3358, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef IsPrime(x):\n for i in range(2, int(x ** 0.5) + 1):\n if not x % i:\n return False\n return True\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef I...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.1.7 on 2021-04-16 05:56 from django.db import migrations import django.db.models.manager class Migration(migrations.Migration): dependencies = [ ('Checkbook', '0002_auto_20210415_2250'), ] operations = [ migrations.AlterModelManagers( name='transactio...
normal
{ "blob_id": "f15f49a29f91181d0aaf66b19ce9616dc7576be8", "index": 6740, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('Checkbook',...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class BotNotes: def __init__(self): self.notes = botdb.get_plugin_value('SpiceBot_Release_Notes', 'notes' ) or dict() self.dir_to_scan = botread.get_config_dirs('SpiceBot_Release_Notes') self.load_txt_files(self.dir_to_scan) self.save_notes...
flexible
{ "blob_id": "2a062f0c2836850320cdd39eee6a354032ba5c33", "index": 4565, "step-1": "<mask token>\n\n\nclass BotNotes:\n\n def __init__(self):\n self.notes = botdb.get_plugin_value('SpiceBot_Release_Notes', 'notes'\n ) or dict()\n self.dir_to_scan = botread.get_config_dirs('SpiceBot_Rele...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ One cycle policy based on Leslie Smith's paper(https://arxiv.org/pdf/1803.09820.pdf) Created on Wed Mar 31 13:53:39 2021 """ import logging import numpy as np import tensorflow as tf import matplotlib.pyplot as plt logging.getLogger('tensorflow').setLevel(logging.ERR...
normal
{ "blob_id": "056235f8f65a3d6a310ee8a8742c1369b5398f28", "index": 7749, "step-1": "<mask token>\n\n\nclass OneCycleScheduler(Callback):\n <mask token>\n\n def __init__(self, lr_max, steps, mom_min=0.85, mom_max=0.95,\n phase_1_pct=0.3, div_factor=25.0):\n super(OneCycleScheduler, self).__init_...
[ 7, 11, 15, 16, 19 ]
n = 0.3 c = 2 def func(x): return x**c def der_func(x): return c * x**(c - 1) def na_value(x): return x - n*der_func(x) def main(): x = 100 v_min = func(x) for i in range(10): cur_v = func(x) x = na_value(x) if cur_v < v_min: v_min = cur_v print...
normal
{ "blob_id": "fa7246a4e7595393ca9aaec777fa85d782bb816e", "index": 4815, "step-1": "<mask token>\n\n\ndef func(x):\n return x ** c\n\n\ndef der_func(x):\n return c * x ** (c - 1)\n\n\n<mask token>\n\n\ndef main():\n x = 100\n v_min = func(x)\n for i in range(10):\n cur_v = func(x)\n x ...
[ 3, 4, 5, 6, 7 ]
""" eulerian_path.py An Eulerian path, also called an Euler chain, Euler trail, Euler walk, or "Eulerian" version of any of these variants, is a walk on the graph edges of a graph which uses each graph edge in the original graph exactly once. A connected graph has an Eulerian path iff it has at most two graph vertices ...
normal
{ "blob_id": "73e6930c6866d3ccdbccec925bfc5e7e4702feb9", "index": 8348, "step-1": "<mask token>\n\n\nclass EulerianPath:\n <mask token>\n\n\n class EEdge(Edge):\n\n def __init__(self, v=0, w=0, is_used=False):\n super().__init__(v, w)\n self._is_used = is_used\n\n def get...
[ 7, 8, 10, 11, 12 ]
<|reserved_special_token_0|> def create_message(from_addr, to_addr, subject, message, encoding): body = MIMEText(message, 'plain', encoding) body['Subject'] = subject body['From'] = from_addr body['To'] = to_addr body['Date'] = formatdate() return body def send_via_gmail(from_addr, to_addr, ...
flexible
{ "blob_id": "237724db5130926123a3a31be7070947ec7b01f3", "index": 3492, "step-1": "<mask token>\n\n\ndef create_message(from_addr, to_addr, subject, message, encoding):\n body = MIMEText(message, 'plain', encoding)\n body['Subject'] = subject\n body['From'] = from_addr\n body['To'] = to_addr\n body...
[ 2, 3, 4, 5, 6 ]
from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Rec1(object): def setupUi(self, Rec1): Rec1.setObjectName("Rec1") Rec1.setFixedSize(450, 200) ico = QtGui.QIcon("mylogo.png") Rec1.setWindowIcon(ico) font = QtGui.QFont() font.setFamily("Times New Roman") f...
normal
{ "blob_id": "c500ecaa66672ac960dc548c3f3882e4bc196745", "index": 6870, "step-1": "<mask token>\n\n\nclass Ui_Rec1(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Ui_Rec1(object):\n <mask token>\n\n def retranslateUi(self, Rec1):\n _translate = QtCore.QCoreApplic...
[ 1, 2, 3, 4, 5 ]
''' 'Daniel Moulton '3/24/15 'Implementation of the mergesort sorting algorithm in python. 'Utilizes a series of random numbers as the initial input 'Uses a top down approach to recursively sort the original list and output the final result. ''' from random import randrange def mergeSort(original_list): #initiali...
normal
{ "blob_id": "294229849dcfac8d4afeab79dae3c652c853fc47", "index": 1924, "step-1": "<mask token>\n\n\ndef mergeSort(original_list):\n return subSort(original_list)\n\n\ndef subSort(sub_list):\n if len(sub_list) < 2:\n return sub_list\n index = len(sub_list) // 2\n left_list = sub_list[0:index]\n...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class MyEditor: def execute(self): print('Spell Cheack') print('Auto COmpile') print('COde check') print('compile') class laptop: def code(self, ide): ide.execute() <|reserved_special_token_0|> <|reserved_special_token_1|> class pyc...
flexible
{ "blob_id": "3ec162070f79ae38d6ae3ceb858c15b6e39f7027", "index": 9870, "step-1": "<mask token>\n\n\nclass MyEditor:\n\n def execute(self):\n print('Spell Cheack')\n print('Auto COmpile')\n print('COde check')\n print('compile')\n\n\nclass laptop:\n\n def code(self, ide):\n ...
[ 4, 6, 7, 8, 9 ]
# Obtener en otra lista unicamente números impares: my_list = [1, 4, 5, 6, 9, 13, 19, 21] # Vamos a hacer una list comprehension: lista_impares = [num for num in my_list if num % 2 != 0] print(my_list) print(lista_impares) print('') # Vamos a usar filter: lista_pares = list(filter(lambda x: x % 2 == 0 , my_list)) p...
normal
{ "blob_id": "e1913c80375e4871119182d0267e9f228818624f", "index": 4309, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(my_list)\nprint(lista_impares)\nprint('')\n<mask token>\nprint(my_list)\nprint(lista_pares)\n", "step-3": "my_list = [1, 4, 5, 6, 9, 13, 19, 21]\nlista_impares = [num for num in m...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ Created on Wed Dec 20 09:54:08 2017 @author: chuang """ import os import pickle #from collections import Counter #import user_replace import jieba import re from multiprocessing import Pool #%% # parameters for processing the dataset DATA_PATH = '../data/weibo_single...
normal
{ "blob_id": "5fd54de3b2f9c2e18a283d016fc16e0e622dc6a0", "index": 8415, "step-1": "<mask token>\n\n\ndef replace_tokens(text, replace_dict=None):\n pattern = re.compile('|'.join(DELETE))\n text = re.sub(pattern, '', text)\n return text\n\n\ndef read_txt(file_path, encoding):\n with open(os.path.join(D...
[ 6, 7, 10, 11, 12 ]
<|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": "316a34bbc2b3e3c818ef837f51bc1f86863ea59a", "index": 2473, "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 = [('pancar', '0...
[ 0, 1, 2, 3, 4 ]
class Figure: area = 0 def __new__(cls, *args): if cls is Figure: return None return object.__new__(cls) def add_area(self, other): if isinstance(other, Figure): return self.area + other.area else: raise ValueError("Should pass Figure as...
normal
{ "blob_id": "ceab21e41adf171e99e6c3c8541c418d82db6168", "index": 3272, "step-1": "class Figure:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Figure:\n <mask token>\n\n def __new__(cls, *args):\n if cls is Figure:\n return None\n return object.__new__...
[ 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_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "d8df9a9f95a1d4a9aa34987ec1244cc6c0c7c610", "index": 8048, "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 ]
from django.apps import AppConfig class ActivityConfig(AppConfig): name = 'apps.activity'
normal
{ "blob_id": "2a69aa0cd9d0e39ad82d6a354e956bdad0648797", "index": 2252, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ActivityConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ActivityConfig(AppConfig):\n name = 'apps.activity'\n", "step-4": "from django.apps im...
[ 0, 1, 2, 3 ]
from subprocess import check_output import json import sys import time import os import numpy as np from hutch_python.utils import safe_load from ophyd import EpicsSignalRO from ophyd import EpicsSignal from bluesky import RunEngine from bluesky.plans import scan from bluesky.plans import list_scan from bluesky.plan_...
normal
{ "blob_id": "4473971552aa48236b19dec7e7c1ea1e622d5795", "index": 7347, "step-1": "<mask token>\n\n\nclass User:\n <mask token>\n <mask token>\n <mask token>\n\n def get_dscan(self, motor, start, end, nsteps, nEvents, record=True):\n daq.configure(nEvents, record=record)\n currPos = moto...
[ 12, 21, 22, 24, 26 ]
import time import itertools import re from pyspark import SparkContext, SparkConf from pyspark.rdd import portable_hash from datetime import datetime APP_NAME = 'in-shuffle-secondary-sort-compute' INPUT_FILE = '/data/Taxi_Trips.csv.xsmall' OUTPUT_DIR = '/data/output-in-shuffle-sort-compute-{timestamp}.txt' COMMA_DE...
normal
{ "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|> <|reserved_special_token_1|> <|reserved_special_token_0|> def password_validation(password): return bool(re.search( '^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{6,}$', password)) <|reserved_special_token_1|> import re def password_validation(password): return bool(...
flexible
{ "blob_id": "d44c76ff7e94bea6e03324c45d139602c724c7be", "index": 2539, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef password_validation(password):\n return bool(re.search(\n '^(?=.*[a-z])(?=.*[A-Z])(?=.*\\\\d)[a-zA-Z\\\\d]{6,}$', password))\n", "step-3": "import re\n\n\ndef password...
[ 0, 1, 2, 3 ]
import math from os.path import join, relpath, dirname from typing import List, Tuple from common import read_input convert_output = List[str] class GridWalker: def __init__(self): self._current_pos = [0, 0] self._heading = math.pi / 2 @property def position(self): return self....
normal
{ "blob_id": "907f0564d574f197c25b05a79569a8b6f260a8cd", "index": 7817, "step-1": "<mask token>\n\n\nclass GridWalker:\n\n def __init__(self):\n self._current_pos = [0, 0]\n self._heading = math.pi / 2\n\n @property\n def position(self):\n return self._current_pos\n\n @property\n ...
[ 8, 9, 11, 13, 14 ]
""" Created on 01/10/18. Author: morgan Copyright defined in text_classification/LICENSE.txt """ import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F class RNNClassifier(nn.Module): def __init__(self, batch_size, num_classes, hidden_size, vocab_size, embed_size, w...
normal
{ "blob_id": "41417e3ce52edf6aee432886bbab6d16ec5bc88d", "index": 164, "step-1": "<mask token>\n\n\nclass RNNClassifier(nn.Module):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass RNNClassifier(nn.Module):\n\n def __init__(self, batch_size, num_classes, hidden_size, vocab_size,\n ...
[ 1, 2, 3, 4, 5 ]
from matasano import * ec = EC_M(233970423115425145524320034830162017933,534,1,4,order=233970423115425145498902418297807005944) assert(ec.scale(4,ec.order) == 0) aPriv = randint(1,ec.order-1) aPub = ec.scale(4,aPriv) print("Factoring...") twist_ord = 2*ec.prime+2 - ec.order factors = [] x = twist_ord for...
normal
{ "blob_id": "b5275fc068526063fd8baf13210052971b05503f", "index": 585, "step-1": "<mask token>\n", "step-2": "<mask token>\nassert ec.scale(4, ec.order) == 0\n<mask token>\nprint('Factoring...')\n<mask token>\nfor i in range(2, 2 ** 24):\n if x % i == 0:\n if x % (i * i) != 0:\n factors.app...
[ 0, 1, 2, 3, 4 ]
# -*- coding:utf-8 -*- from src.Client.Conf.config import * class SaveConfigFile(): """ 该类负责保存配置文件,属于实际操作类 """ def __init__(self, fileName='../conf/main.ini'): self.config = ConfigParser.ConfigParser() self.fileName = fileName def saveConfigFile(self, configMainName, configSubN...
normal
{ "blob_id": "b61bb47f3e059c607447cea92ce1712825735822", "index": 2373, "step-1": "<mask token>\n\n\nclass SaveConfigFile:\n <mask token>\n\n def __init__(self, fileName='../conf/main.ini'):\n self.config = ConfigParser.ConfigParser()\n self.fileName = fileName\n\n def saveConfigFile(self, ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def adder(x, y): return x + y <|reserved_special_token_0|> <|reserved_special_token_1|> def adder(x, y): return x + y adder('one', 'two') adder([3, 4], [9, 0, 33]) adder(4.3, 3.5)
flexible
{ "blob_id": "1ee5139cb1613977f1c85619404b3dcc6e996382", "index": 5364, "step-1": "<mask token>\n", "step-2": "def adder(x, y):\n return x + y\n\n\n<mask token>\n", "step-3": "def adder(x, y):\n return x + y\n\n\nadder('one', 'two')\nadder([3, 4], [9, 0, 33])\nadder(4.3, 3.5)\n", "step-4": null, "st...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-11-23 19:31 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('mocbackend', '0034_auto_20181122_1903'), ] operations = [ migrations.AddFi...
normal
{ "blob_id": "36bdd6f7c130914856ddf495c50f928405c345aa", "index": 6646, "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 = [('mocbackend'...
[ 0, 1, 2, 3, 4 ]
"""Restaurant""" def main(): """Restaurant""" moeny = int(input()) service = moeny*0.1 vat = moeny*0.07 print("Service Charge : %.2f Baht" %service) print("VAT : %.2f Baht" %vat) print("Total : %.2f Baht" %(moeny+vat+service)) main()
normal
{ "blob_id": "ae6cbb181e024b8c0b222d14120b910919f8cc81", "index": 3811, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n \"\"\"Restaurant\"\"\"\n moeny = int(input())\n service = moeny * 0.1\n vat = moeny * 0.07\n print('Service Charge : %.2f Baht' % service)\n print('VAT...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class RemovedResourceWarning(OpenStackDeprecationWarning): <|reserved_special_token_0|> class RemovedFieldWarning(OpenStackDeprecationWarning): """Indicates that a field has been removed in newer API versions and should not be used. """ class LegacyAPIWarning(OpenStack...
flexible
{ "blob_id": "6339a1a06319a748030b3411c7a8d00f36336e65", "index": 9778, "step-1": "<mask token>\n\n\nclass RemovedResourceWarning(OpenStackDeprecationWarning):\n <mask token>\n\n\nclass RemovedFieldWarning(OpenStackDeprecationWarning):\n \"\"\"Indicates that a field has been removed in newer API versions an...
[ 11, 12, 13, 14, 15 ]