code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
import cv2, os, fitz, shutil import numpy as np from PIL import Image from pytesseract import pytesseract from PIL import UnidentifiedImageError pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe' config = r'--oem 3 --psm' # Возвращает путь к картинке, созданной на основе 1 ...
normal
{ "blob_id": "84980b8923fa25664833f810a906d27531145141", "index": 1066, "step-1": "<mask token>\n\n\ndef pdf_to_png(filename):\n doc = fitz.open('pdf_files\\\\{}'.format(filename))\n zoom = 4\n page = doc.loadPage(0)\n mat = fitz.Matrix(zoom, zoom)\n pix = page.getPixmap(matrix=mat)\n new_filena...
[ 4, 5, 6, 7, 8 ]
#!/usr/bin/env python s = '''Вбс лче ,мтс ооепта т.сбзек о ып гоэятмв,те гоктеивеысокячел–аонкы оах ннлнисьрнксе ьрм отаб тёьдр ннласааосд це аЧиу нвыанзи еслкмиетл,леево ннлтпо еик:ыаырялньб пнм би на це азоватоша Вепьлаяокеолвоытрх еытодрпьтае,кллгфм ытитослРянозит нсонунс.р лунттаё ооиВяе зн етвйеетелттв еСлл...
normal
{ "blob_id": "a8bed0b5a6a95d67b5602b395f1d0ea12cd53fb0", "index": 9166, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fence_decipher(m: str, key: int) ->str:\n chunklens = [(0) for _ in range(key)]\n nfence = 0\n dx = 1\n for i in m:\n chunklens[nfence] += 1\n nfence += ...
[ 0, 1, 2, 3, 4 ]
from mock import Mock from shelf.hook.background import action from shelf.hook.event import Event from tests.test_base import TestBase import json import os import logging from pyproctor import MonkeyPatcher class ExecuteCommandTest(TestBase): def setUp(self): super(ExecuteCommandTest, self).setUp() ...
normal
{ "blob_id": "c312bf096c7f4aaf9269a8885ff254fd4852cfe0", "index": 9996, "step-1": "<mask token>\n\n\nclass ExecuteCommandTest(TestBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ExecuteCommandTest(TestBase):\n\n def setUp...
[ 1, 5, 6, 7, 8 ]
#!/usr/bin/python # -*- coding: utf-8 -*- import os import os.path import json from collections import defaultdict, Counter MOST_COMMON = 120000 savepath = r'D:\My Documents\My Project\experiment1\finished\test_vocabs.json' dirpath = 'D:\\My Documents\\My Project\\experiment1\\finished\\test' #dirpath = 'D:\\Corpus\...
normal
{ "blob_id": "d30e2fa4d5b0a0965dad7d69b672b8f4ad137ff4", "index": 1359, "step-1": "<mask token>\n\n\ndef get_file_vocabs(file):\n file_vocabs = Counter()\n for sent in file.readlines():\n voc = Counter()\n for word in sent.split():\n voc[word] += 1\n file_vocabs.update(voc)\n...
[ 1, 3, 4, 5, 6 ]
'''OpenGL extension EXT.YUV_target This module customises the behaviour of the OpenGL.raw.GLES2.EXT.YUV_target to provide a more Python-friendly API Overview (from the spec) This extension adds support for three new YUV related items: first rendering to YUV images, second sampling from YUV images while keeping ...
normal
{ "blob_id": "08420d31713859946b2f19cebf68c333331cb80e", "index": 1494, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef glInitYuvTargetEXT():\n \"\"\"Return boolean indicating whether this extension is available\"\"\"\n from OpenGL import extensions\n return extensions.hasGLExtension(_EXTE...
[ 0, 1, 2, 3 ]
''' Autor: Jazielinho ''' import keyboard from PIL import ImageGrab import os import tqdm import random from training import config_tr class DataSet(object): ''' clase que crea dataset de entrenamiento ''' saltar = 'saltar' nada = 'nada' reglas = [saltar, nada] formato = 'PNG' train = 'trai...
normal
{ "blob_id": "c931d1ac5c2d003a8eaac3c6d777ce408df57117", "index": 8534, "step-1": "<mask token>\n\n\nclass DataSet(object):\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 def genera_datos(self) ->None:\n ...
[ 3, 4, 6, 8, 9 ]
import tornado.web import tornado.escape from torcms.core.base_handler import BaseHandler from owslib.csw import CatalogueServiceWeb from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox class DirectorySearchHandler(BaseHandler): def initialize(self): super(DirectorySearchHandler, self).initializ...
normal
{ "blob_id": "72ce7c48c9d1a7bcdbaead12648d03970663a11e", "index": 3227, "step-1": "<mask token>\n\n\nclass DirectorySearchHandler(BaseHandler):\n\n def initialize(self):\n super(DirectorySearchHandler, self).initialize()\n <mask token>\n <mask token>\n <mask token>\n\n def ajax_get(self, uui...
[ 9, 10, 11, 13, 14 ]
from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import RequestContext from django.db.models import Q from cvmo import settings from cvmo.context.models import ContextDefinition, Machines, ClusterDefinition, MarketplaceContextEntry from cvmo.context.plugins im...
normal
{ "blob_id": "4db8b4403dd9064b7d5f935d4b9d111508c965fb", "index": 1268, "step-1": "<mask token>\n\n\ndef dashboard(request):\n context = {'context_list': ContextDefinition.objects.filter(Q(owner=\n request.user) & Q(inherited=False) & Q(abstract=False)).order_by(\n '-public', 'name'), 'full_abstr...
[ 1, 3, 4, 5, 6 ]
import unittest from .context import * class BasicTestSuite(unittest.TestCase): """Basic test cases.""" def test_hello_world(self): self.assertEqual(hello_world(), 'hello world') if __name__ == '__main__': unittest.main()
normal
{ "blob_id": "6420d1b9da7ff205e1e138f72b194f63d1011012", "index": 4554, "step-1": "<mask token>\n\n\nclass BasicTestSuite(unittest.TestCase):\n <mask token>\n\n def test_hello_world(self):\n self.assertEqual(hello_world(), 'hello world')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Basi...
[ 2, 3, 4, 5 ]
import os class Config(object): """Base Config Object""" DEBUG = False SECRET_KEY = os.environ.get('SECRET_KEY') or 'Som3$ec5etK*y' UPLOAD_FOLDER = './uploads' dbconfig = {'host': os.environ.get('MYSQL_HOST') or 'localhost', 'user': os .environ.get('MYSQL_USER') or 'root', 'password': os.environ...
normal
{ "blob_id": "833923c1928862e13c24904f5614927a683b168f", "index": 611, "step-1": "<mask token>\n\n\nclass DevelopmentConfig(Config):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass ProductionConfig(Config):\n \"\"\"Production Config that extends the Base Config Object\"\"\"\n DEBUG = False\...
[ 4, 6, 9, 11 ]
''' Created on Mar 7, 2019 @author: hzhang0418 ''' import pymp from v6.mono import Mono class BruteForce(Mono): def __init__(self, features, labels, params): super(BruteForce, self).__init__(features, labels, params) def _count_inconsistencies(self): if self.num_cores==1: ...
normal
{ "blob_id": "32c18bd578bbf91c76604f063421a65a4f7a8b63", "index": 2204, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BruteForce(Mono):\n <mask token>\n\n def _count_inconsistencies(self):\n if self.num_cores == 1:\n for ni in self.nonmatch_indices:\n self...
[ 0, 3, 4, 5, 6 ]
k = 0 for x in range(100, 1000, 2): x = str(x) if x[0] == x[1] or x[0] == x[2] or x[1] == x[2]: k += 1 print(k)
normal
{ "blob_id": "af6dd7bde25453f25c0701e4ac246ff6bce29fa7", "index": 1141, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor x in range(100, 1000, 2):\n x = str(x)\n if x[0] == x[1] or x[0] == x[2] or x[1] == x[2]:\n k += 1\nprint(k)\n", "step-3": "k = 0\nfor x in range(100, 1000, 2):\n x ...
[ 0, 1, 2 ]
from bs4 import BeautifulSoup from aiounfurl.parsers import oembed def test_oembed_not_match(oembed_providers): oembed_url_extractor = oembed.OEmbedURLExtractor(oembed_providers) url = 'http://test.com' assert oembed_url_extractor.get_oembed_url(url) is None def test_oembed_founded(oembed_providers): ...
normal
{ "blob_id": "7b2ad0b4eca7b31b314e32ad57d51be82f0eaf61", "index": 6979, "step-1": "<mask token>\n\n\ndef test_oembed_founded(oembed_providers):\n oembed_url_extractor = oembed.OEmbedURLExtractor(oembed_providers)\n url = 'https://www.instagram.com/p/BNHh2YJDdcY/'\n oembed_url = oembed_url_extractor.get_o...
[ 2, 3, 4, 5 ]
# dates.py """Date/time parsing and manipulation functions """ # Some people, when confronted with a problem, think # "I know, I'll use regular expressions." # Now they have two problems. # -- Jamie Zawinski import datetime as dt import time import re _months = [ 'january', '...
normal
{ "blob_id": "458bc2b5f843e4c5bb3f9180ab2cbec7409b8d3e", "index": 4946, "step-1": "# dates.py\n\n\"\"\"Date/time parsing and manipulation functions\n\"\"\"\n\n# Some people, when confronted with a problem, think\n# \"I know, I'll use regular expressions.\"\n# Now they have two problems.\n# ...
[ 0 ]
import pandas as pd; import time; import matplotlib.pyplot as plt; import matplotlib.cm as cm import matplotlib.patches as mpatch; import numpy as np; import sys; sys.path.append("/uufs/chpc.utah.edu/common/home/u0403692/prog/prism/test") import bettersankey as bsk; datapath = "/uufs/chpc.utah.edu/common/home/u04036...
normal
{ "blob_id": "07b6ded9b4841bdba62d481664a399f0b125fcbf", "index": 7876, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('/uufs/chpc.utah.edu/common/home/u0403692/prog/prism/test')\n<mask token>\nprint('reading...')\n<mask token>\nprint('joining...')\n<mask token>\nprint('processing...')\n<m...
[ 0, 1, 2, 3, 4 ]
# ------------------------------- # --------- Set Methods --------- # ------------------------------- # difference() return the values in the first set that not in the second set set1 ={1, 2, 3, 4, 5, 6, 7, 8 , 9} set2 = {1, 2, 3, 4, 5, 6, "A", "B"} print(set1) print(set2) print(set1.difference(set2)) print(set1-set2...
normal
{ "blob_id": "faf2f5da92cf45cfedda91955688b3ca1c7c0db9", "index": 8280, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(set1)\nprint(set2)\nprint(set1.difference(set2))\nprint(set1 - set2)\nprint(set2.difference(set1))\nprint(set2 - set1)\nprint(set1)\nprint(set2)\nprint('*' * 40)\n<mask token>\nprin...
[ 0, 1, 2, 3 ]
import firebase_admin from firebase_admin import credentials from firebase_admin import db import paho.mqtt.client as mqtt # Fetch the service account key JSON file contents cred = credentials.Certificate('iot_mikro.json') # Initialize the app with a service account, granting admin privileges firebase_admin.initialize...
normal
{ "blob_id": "acff8618754658104ac36214901d346447a0134f", "index": 811, "step-1": "<mask token>\n", "step-2": "<mask token>\nfirebase_admin.initialize_app(cred, {'databaseURL':\n 'https://mikro-b4844.firebaseio.com/'})\n<mask token>\nprint(ref.get())\n<mask token>\nwhile True:\n print(ref.get())\n if re...
[ 0, 1, 2, 3, 4 ]
from flask import request from flask_restful import abort from sqlalchemy.exc import SQLAlchemyError from gm.main.models.model import db, Metric, QuantModelMetricSchema, \ MlModelMetricSchema, Frequency, QuantModelMetric, MlModelMetric, \ ThresholdType from gm.main.resources import success, get_metric_b...
normal
{ "blob_id": "1431a0049c05a99e0b68052f56bf8e2e3c48e1aa", "index": 622, "step-1": "<mask token>\n\n\nclass QuantModelMetricsResource(MetricsResource):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass MlModelMetricsResource(MetricsResource):\n \"\"\"\n This resource handles the HTTP requests c...
[ 16, 19, 23, 25, 26 ]
# coding=UTF-8 ''' Created on Jul 21, 2013 @author: jin ''' from django import template register = template.Library() @register.filter def get_list_number(value,num): result=value[num] return result # register.filter('get_list_num', get_list_num) ''' test ''' if __name__=='__main__': print get_list_numb...
normal
{ "blob_id": "679d4b224733dbe264caeeda4e228edd090ea9de", "index": 7797, "step-1": "# coding=UTF-8\n'''\nCreated on Jul 21, 2013\n\n@author: jin\n'''\nfrom django import template\nregister = template.Library()\n@register.filter\ndef get_list_number(value,num):\n result=value[num]\n return result\n# register....
[ 0 ]
from django.contrib import admin from .models import Advert, Category, ImageAd @admin.register(Advert) class AdminAdvert(admin.ModelAdmin): filter_horizontal = "categories", @admin.register(Category) class AdminCategory(admin.ModelAdmin): pass @admin.register(ImageAd) class AdminImageAd(admin.ModelAdmin)...
normal
{ "blob_id": "fdcee5b3f6b3ec170c9ef3017e0cc6c4b28cf22d", "index": 454, "step-1": "<mask token>\n\n\n@admin.register(ImageAd)\nclass AdminImageAd(admin.ModelAdmin):\n pass\n", "step-2": "<mask token>\n\n\n@admin.register(Advert)\nclass AdminAdvert(admin.ModelAdmin):\n <mask token>\n\n\n@admin.register(Cate...
[ 1, 3, 4, 5, 6 ]
from django.http import HttpResponse from django.shortcuts import render def home(request): return render(request, 'home.html') def people(request): return render(request, 'people.html') def docs(request): return render(request, 'docs.html') def gallery(request, page=None): if page: retu...
normal
{ "blob_id": "f7a493ab8e9845d0e9da33a0ee45d7c3ef66deb5", "index": 7507, "step-1": "<mask token>\n\n\ndef home(request):\n return render(request, 'home.html')\n\n\n<mask token>\n\n\ndef docs(request):\n return render(request, 'docs.html')\n\n\n<mask token>\n\n\ndef publications(request):\n return render(r...
[ 3, 4, 5, 7 ]
#!/usr/bin/python import serial import time import sys senderId="\x01" receiverId="\x00" #openSerial just opens the serial connection def openSerial(port): #Some configuration for the serial port ser = serial.Serial() ser.baudrate = 300 ser.port = port ser.bytesize = 8 ser.stopbits = 2 ser.open() return ser ...
normal
{ "blob_id": "bf1d54015a9ae529f4fda4fa9b9f7c874ec3b240", "index": 4514, "step-1": "#!/usr/bin/python\n\nimport serial\nimport time\nimport sys\n\nsenderId=\"\\x01\"\nreceiverId=\"\\x00\"\n\n#openSerial just opens the serial connection\ndef openSerial(port):\n\t#Some configuration for the serial port\n\tser = seri...
[ 0 ]
try: a = int(input("Enter a:")) b = int(input("Enter b:")) c = a/b except: print("Can't divide with zero")
normal
{ "blob_id": "143f6ee38413a0713c18281e9737c09d9947a61a", "index": 2805, "step-1": "<mask token>\n", "step-2": "try:\n a = int(input('Enter a:'))\n b = int(input('Enter b:'))\n c = a / b\nexcept:\n print(\"Can't divide with zero\")\n", "step-3": "try:\n a = int(input(\"Enter a:\"))\n b = int(...
[ 0, 1, 2 ]
class Classifier(object): """ Trained classifier """ def __init__(self, classifier, scaler, orient, color_space, pix_per_cell, cell_per_block, spatial_size, hist_bins): """ Initializes an instance. Parameters ---------- classifier : Trained SciPy classif...
normal
{ "blob_id": "9188d58a6d9e832b8908b823d57249fcdd80ff51", "index": 171, "step-1": "<mask token>\n", "step-2": "class Classifier(object):\n <mask token>\n <mask token>\n", "step-3": "class Classifier(object):\n <mask token>\n\n def __init__(self, classifier, scaler, orient, color_space,\n pix...
[ 0, 1, 2, 3 ]
import hashlib import json #import logger import Login.loger as logger #configurations import Configurations.config as config def generate_data(*args): #add data into seperate variables try: station_data = args[0] except KeyError as e: logger.log(log_type=config.log_error,params=e) ...
normal
{ "blob_id": "2a5c6f442e6e6cec6c4663b764c8a9a15aec8c40", "index": 6971, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_id(parameter, station_id):\n meta_data = parameter + station_id\n hash_id = hashlib.sha256(config.encryption_key)\n hash_id.update(json.dumps(meta_data).encode()...
[ 0, 1, 2, 3, 4 ]
import pandas as pd import matplotlib.pyplot as plt loansData = pd.read_csv('loansData.csv') # Print the first 5 rows of each of the column to see what needs to be cleaned print loansData['Interest.Rate'][0:5] print loansData['Loan.Length'][0:5] print loansData['FICO.Range'][0:5] # Clean up the columns loansData['...
normal
{ "blob_id": "fc17b865815a7a5ec51f477a9fdda54667686eed", "index": 1672, "step-1": "import pandas as pd\nimport matplotlib.pyplot as plt\n\n\nloansData = pd.read_csv('loansData.csv')\n\n# Print the first 5 rows of each of the column to see what needs to be cleaned\nprint loansData['Interest.Rate'][0:5]\nprint loan...
[ 0 ]
from django.test import TestCase, Client from django.urls import reverse from django.contrib.auth import get_user_model from tweets.models import Tweet from ..models import UserProfile User = get_user_model() class TestAccountsViews(TestCase): def setUp(self): self.username = 'masterbdx' self.ema...
normal
{ "blob_id": "888a5847beca2470f4063da474da1f05079abca9", "index": 5579, "step-1": "<mask token>\n\n\nclass TestAccountsViews(TestCase):\n <mask token>\n <mask token>\n\n def test_logout_view(self):\n response = self.client.get(reverse('accounts:logout'))\n self.assertEqual(response.status_c...
[ 9, 10, 11, 12, 16 ]
TABLE_NAME = 'active_module'
normal
{ "blob_id": "ff3962d875da8e3f9e6c3178b1a8191ebb8a7b60", "index": 3639, "step-1": "<mask token>\n", "step-2": "TABLE_NAME = 'active_module'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
""" TODO: update description after everything (requirements) is (are) stable/concrete Description: Script to extract KeepingTrac's creative names and send team notification to start manual mapping as necessary. This step must happen BEFORE the processing of deduping of RenTrak creative names (step 2 in RenTrak p...
normal
{ "blob_id": "71c6d5e385e3db8444d7ef8b0231e72db8538eb7", "index": 8106, "step-1": "<mask token>\n\n\ndef notify_no_new_mapping_found():\n email_str = \"\"\"\n <p>Python script does not find any new creative names from keepingtrac data.\n Stage 2 of processing RenTrak data will begin when we load ...
[ 4, 6, 7, 8, 10 ]
from .proxies import Proxies from .roles import Roles from .products import Products from .resourcefiles import ResourceFiles class Apigee(object): """Provides easy access to all endpoint classes Args: domain (str): Your Auth0 domain, e.g: 'username.auth0.com' token (str): Management API v2 ...
normal
{ "blob_id": "656927013d9a0254e2bc4cdf05b7cfd5947feb05", "index": 7868, "step-1": "<mask token>\n\n\nclass Apigee(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Apigee(object):\n <mask token>\n\n def __init__(self, org_name, username, password):\n self.proxies =...
[ 1, 2, 3, 4 ]
from django.db import models from django.db.models.base import Model # Create your models here. class Categoria(models.Model): categoria = models.CharField(max_length=40) def __str__(self): return self.categoria class Producto(models.Model): codigo = models.CharField(max_length=40) nombre = mo...
normal
{ "blob_id": "0e19d7251db3382c34ad2d38a7984b65325ecfbf", "index": 7584, "step-1": "<mask token>\n\n\nclass Descuento(models.Model):\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.codigo_descuento\n\n\nclass Venta(models.Model):\n descripcion = models.CharField(max_length=100...
[ 22, 29, 33, 34, 40 ]
class Solution: def findAndReplacePattern(self, words: List[str], pattern: str) -> List[str]: def convert(word): table = {} count, converted = 0, '' for w in word: if w in table: converted += table[w] else: ...
normal
{ "blob_id": "e9ea48dec40e75f2fc73f8dcb3b5b975065cf8af", "index": 5854, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution:\n\n def findAndReplacePattern(self, words: List[str], pattern: str) ->List[str\n ]:\n\n def convert...
[ 0, 1, 2, 3 ]
# # Copyright 2021 Splunk Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
normal
{ "blob_id": "24b1afb18e1cfdc8d5a62f5ee0147b2d73bc10d8", "index": 7492, "step-1": "<mask token>\n\n\nclass ConcurrentExecutor:\n <mask token>\n <mask token>\n <mask token>\n\n def run_io_func_sync(self, func, args=(), kwargs=None):\n \"\"\"\n :param func: callable\n :param args: f...
[ 3, 6, 8, 10, 11 ]
from django.db import models from private_storage.fields import PrivateFileField class PrivateFile(models.Model): title = models.CharField("Title", max_length=200) file = PrivateFileField("File") class PrivateFile2(models.Model): title = models.CharField("Title", max_length=200) file = models.FileFi...
normal
{ "blob_id": "e12c397ca1ae91ce314cda5fe2cd8e0ec4cfa861", "index": 2199, "step-1": "<mask token>\n\n\nclass PrivateFile2(models.Model):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass PrivateFile(models.Model):\n <mask token>\n <mask token>\n\n\nclass PrivateFile2(models.Model):\...
[ 1, 3, 4, 5, 6 ]
######################################################################### # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You...
normal
{ "blob_id": "e6010ec05ec24dcd2a44e54ce1b1f11000e775ce", "index": 8399, "step-1": "<mask token>\n\n\nclass INDENT_STACK:\n <mask token>\n\n def __init__(self):\n self.my_stack = [{'physical': 0, 'logical': 0, 'type': 'none'}]\n\n def init_indent(self):\n del self.my_stack\n self.my_s...
[ 7, 10, 11, 17, 19 ]
from page_objects import PageObject, PageElement class MainPage(PageObject): level_menu_opened = False level_menu_created = False css_input = PageElement(css='input.input-strobe') level_text_span = PageElement(css='span.level-text') instruction_h2 = PageElement(css='h2.order') enter_button = P...
normal
{ "blob_id": "c6cf085330f47ffb139c5acc91d91e9758f5396a", "index": 274, "step-1": "<mask token>\n\n\nclass MainPage(PageObject):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, webdriver, root_uri=None):\n ...
[ 6, 7, 10, 11, 12 ]
#!/usr/bin/python import sys class Generator: def __init__(self, seed, factor, multiple): self.value = seed self.factor = factor self.multiple = multiple def iterate(self): self.value = ( self.value * self.factor ) % 2147483647 # Repeat if this isn't an exact multiple ...
normal
{ "blob_id": "4bb006e2e457f5b11157dacb43fe94c8b400f146", "index": 5105, "step-1": "#!/usr/bin/python\n\nimport sys\n\nclass Generator:\n def __init__(self, seed, factor, multiple):\n self.value = seed\n self.factor = factor\n self.multiple = multiple\n\n def iterate(self):\n self...
[ 0 ]
__author__ = 'AChen' from rec_linked_list import * def filter_pos_rec(lst): """ @type lst: LinkedListRec >>> lst = LinkedListRec([3, -10, 4, 0]) >>> pos = filter_pos_rec(lst) >>> str(pos) '3 -> 4' """ if lst.is_empty(): return lst else: pos_rec = LinkedListRec([]) ...
normal
{ "blob_id": "efcbe296ea72a94be967124a8ba8c84a524e2eb1", "index": 66, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef filter_pos_rec(lst):\n \"\"\"\n @type lst: LinkedListRec\n >>> lst = LinkedListRec([3, -10, 4, 0])\n >>> pos = filter_pos_rec(lst)\n >>> str(pos)\n '3 -> 4'\n\n ...
[ 0, 1, 2, 3 ]
import os import sys from flask import Flask, request, abort, flash, jsonify, Response from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS from flask_migrate import Migrate import random import unittest from models import db, Question, Category # set the number of pages fpr pagination QUESTIONS_PER_PA...
normal
{ "blob_id": "b84a2093a51e57c448ee7b4f5a89d69dfb14b1b6", "index": 4876, "step-1": "<mask token>\n\n\n@app.after_request\ndef after_request(response):\n response.headers.add('Access-Control-Allow-Headers',\n 'Content-Type, Authorization, true')\n response.headers.add('Access-Control-Allow-Methods',\n ...
[ 8, 10, 12, 14, 17 ]
from django.shortcuts import render from django.template import loader # Create your views here. from django.http import HttpResponse from .models import Student def index(request): student_objects = Student.objects.all() context = {"students": student_objects} return render(request, 'student_list.html', context...
normal
{ "blob_id": "00e8e0b5aeccd2a67f6cfdad63012a0d8b066e6f", "index": 9551, "step-1": "<mask token>\n\n\ndef addstudent(request):\n context = {}\n return render(request, 'add_student.html', context)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef index(request):\n student_objects = Student.objects.a...
[ 1, 2, 3, 4, 5 ]
import bisect import sys input = sys.stdin.readline N = int(input()) A = [int(input()) for _ in range(N)] dp = [float('inf')] * (N + 1) for a in A[::-1]: idx = bisect.bisect_right(dp, a) dp[idx] = a ans = 0 for n in dp: if n != float('inf'): ans += 1 print(ans)
normal
{ "blob_id": "dfe79d2f4bf4abc1d04035cf4556237a53c01122", "index": 6913, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor a in A[::-1]:\n idx = bisect.bisect_right(dp, a)\n dp[idx] = a\n<mask token>\nfor n in dp:\n if n != float('inf'):\n ans += 1\nprint(ans)\n", "step-3": "<mask token>...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import os, sys, json sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python_task_helper', 'files')) from task_helper import TaskHelper hosts_file = open("/etc/hosts", "r").read() resolv_file = open("/etc/resolv.conf", "r").read() output = hosts_file + resolv_file class Gen...
normal
{ "blob_id": "24813e03de05058925a42847042157fa65450d21", "index": 3773, "step-1": "<mask token>\n\n\nclass Generate(TaskHelper):\n\n def task(self, args):\n return {'result': output}\n\n\n<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',\n ...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- from django.db import models # Create your models here. class Test(models.Model): name = models.CharField(max_length=20) def __unicode__(self): return self.name class Contact(models.Model): GENDER_TYPES = ( ('M', u'男'), ('F', u'女'), ('X', u'不告诉...
normal
{ "blob_id": "514a3fc312d36e6f9b601ede7f7a3940c138d39a", "index": 2000, "step-1": "<mask token>\n\n\nclass Contact(models.Model):\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 def __unicode__...
[ 5, 8, 9, 10, 11 ]
# Copyright (c) 2009 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'variables': { 'chromium_code': 1, }, 'includes': [ 'ots-common.gypi', ], 'targets': [ { 'target_name': 'ots', 'type'...
normal
{ "blob_id": "7413d4e98f79bf7b389a6305257833293714fc81", "index": 1786, "step-1": "<mask token>\n", "step-2": "{'variables': {'chromium_code': 1}, 'includes': ['ots-common.gypi'],\n 'targets': [{'target_name': 'ots', 'type': '<(library)', 'sources': [\n '<@(ots_sources)'], 'include_dirs': ['<@(ots_include...
[ 0, 1, 2 ]
import os import sys import random import pygame import time from pygame import locals SCREEN_WIDTH = 1280 SCREEN_HEIGHT = 1024 class Moto(pygame.sprite.Sprite): def __init__(self, player_num, start_direction): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("motor" + str(pla...
normal
{ "blob_id": "1d1f1c9b70ca487b48593c85c3e0b5afc10f0b07", "index": 6642, "step-1": "<mask token>\n\n\nclass Player(object):\n\n def __init__(self, player_num, px, py, sx, sy, start_direction):\n self.player_num = player_num\n self.rect = pygame.Rect(px, py, sx, sy)\n self.direction = start_...
[ 13, 15, 19, 22, 24 ]
import torch import random from itertools import product from Struct import Action class Agent(object): """the agent""" def __init__(self, q, epsilon=0.8, discount=0.9, learningRate=0.5, traceDecay=0.3): # action set possibleChangesPerMagnet = (1e-2, 1e-3, 0, -1e-2, -1e-3) # possible...
normal
{ "blob_id": "63edbbbad9561ddae005d2b5e22a089819dc34c5", "index": 1821, "step-1": "<mask token>\n\n\nclass Agent(object):\n <mask token>\n\n def __init__(self, q, epsilon=0.8, discount=0.9, learningRate=0.5,\n traceDecay=0.3):\n possibleChangesPerMagnet = 0.01, 0.001, 0, -0.01, -0.001\n ...
[ 8, 9, 10, 12, 13 ]
import subprocess class BaseExecution: def __init__(self, flag, parser): self.flag = flag self.parser = parser def execute(self): process = subprocess.Popen(f'df {self.flag}', shell=True, stdout= subprocess.PIPE, stderr=subprocess.PIPE) output, err = process.commu...
normal
{ "blob_id": "d8af43d24a2f2b99bc8b5098f251e017852d6d86", "index": 1085, "step-1": "<mask token>\n\n\nclass BaseExecution:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass BaseExecution:\n\n def __init__(self, flag, parser):\n self.flag = flag\n self.parser = parser\n ...
[ 1, 2, 3, 4 ]
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2020, Lukas Bestle <project-ansible@lukasbestle.com> # Copyright: (c) 2017, Michael Heap <m@michaelheap.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_f...
normal
{ "blob_id": "8b965fd91396735e0153390b4eff540d3aac3aff", "index": 4916, "step-1": "<mask token>\n\n\nclass Mas(object):\n\n def __init__(self, module):\n self.module = module\n self.mas_path = self.module.get_bin_path('mas')\n self._checked_signin = False\n self._installed = None\n ...
[ 14, 15, 16, 17, 18 ]
w=int(input()) lst=[i+1 for i in range(100)] for i in range(2,100): lst.append(i*100) lst.append(i*10000) lst.append(10000) print(297) print(*lst)
normal
{ "blob_id": "1d004ec0f4f5c50f49834f169812737d16f22b96", "index": 3967, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(2, 100):\n lst.append(i * 100)\n lst.append(i * 10000)\nlst.append(10000)\nprint(297)\nprint(*lst)\n", "step-3": "w = int(input())\nlst = [(i + 1) for i in range(10...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import argparse import keyring import papercut import ConfigParser import getpass import time import os config = ConfigParser.ConfigParser() config.read([os.path.expanduser('~/.papercut')]) try: username = config.get('papercut','username') except ConfigParser.NoSectionError: username = No...
normal
{ "blob_id": "33cc8814d9397bcb0041728407efef80a136f151", "index": 505, "step-1": "#!/usr/bin/env python\nimport argparse\nimport keyring\nimport papercut\nimport ConfigParser\nimport getpass\nimport time\nimport os\n\nconfig = ConfigParser.ConfigParser()\nconfig.read([os.path.expanduser('~/.papercut')])\ntry:\n ...
[ 0 ]
#!/usr/bin/env python from __future__ import print_function from types_ import SimpleObject, SimpleObjectImmutable, NamedTuple, SimpleTuple, c_struct import timeit import random TYPES = [ SimpleObjectImmutable, SimpleObject, NamedTuple, SimpleTuple, c_struct, ] a = 1035 b = b'\x54 - fo!' c =...
normal
{ "blob_id": "ba73562cd8ffa52a1fede35c3325e7e76a6dad54", "index": 7966, "step-1": "<mask token>\n\n\ndef measure_creation():\n random.shuffle(TYPES)\n for type_ in TYPES:\n pre = 'from __main__ import {}, a, b, c'.format(type_.__name__)\n body = '{}(a, b, c)'.format(type_.__name__)\n pr...
[ 2, 3, 4, 5, 6 ]
import os import numpy import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def plotObject(obj): fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x,y,z = numpy.nonzero(obj>0) ax.scatter(x,y,z,c='r',s=10) xb,yb,zb = numpy.nonzero(obj<0) ax.scatter(xb,yb,zb,c='b',s=1) plt.show() c...
normal
{ "blob_id": "8475792cc2d55f030f0bd9e7d0240e3b59ed996b", "index": 7774, "step-1": "<mask token>\n\n\nclass GridData:\n\n def __init__(self, datafile, labelfile):\n f = open(datafile, 'rb')\n f2 = open(labelfile, 'r')\n self.samples = []\n self.labels = []\n self.label_names =...
[ 2, 4, 5, 7, 8 ]
import os from distutils.core import setup from Cython.Distutils import Extension from Cython.Build import cythonize CUR_DIR = os.path.dirname(os.path.abspath(__file__)) SRC_DIR = os.path.join(CUR_DIR, 'src') TPM_DIR = os.path.join(SRC_DIR, 'tpm') include_dirs = [SRC_DIR] src_files = ["pytpm/_tpm.pyx"] # TPM library ...
normal
{ "blob_id": "3875d85bef37900f9066c108dc720b364cbafffa", "index": 8476, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='pytpm', packages=['pytpm'], package_dir={'pytpm': 'pytpm'},\n package_data={'pytpm': ['*.pxd', '*.pyx', '*.pxi']}, ext_modules=\n cythonize(ext_modules))\n", "step-3":...
[ 0, 1, 2, 3, 4 ]
#! /usr/bin/python from bs4 import BeautifulSoup import requests import sys def exit(err): print err sys.exit(0) def get_text(node, lower = True): if lower: return (''.join(node.findAll(text = True))).strip().lower() return (''.join(node.findAll(text = True))).strip() def get_method_signatu...
normal
{ "blob_id": "e3119979028d3dd4e1061563db4ec20607e744d1", "index": 3749, "step-1": "#! /usr/bin/python\n\nfrom bs4 import BeautifulSoup\n\nimport requests\nimport sys\n\ndef exit(err):\n print err\n sys.exit(0)\n\ndef get_text(node, lower = True):\n if lower:\n return (''.join(node.findAll(text = T...
[ 0 ]
"""Access IP Camera in Python OpenCV""" import cv2 #stream = cv2.VideoCapture('protocol://IP:port/1') # Use the next line if your camera has a username and password stream = cv2.VideoCapture('rtsp://SeniorDesign:1Hwe2Dxy@10.9.27.28:554/video') while True: r, f = stream.read() cv2.imshow('IP C...
normal
{ "blob_id": "f9db3c96bc3fd4911640d0428672c87072564b0d", "index": 710, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n r, f = stream.read()\n cv2.imshow('IP Camera stream', f)\n if cv2.waitKey(1) & 255 == ord('q'):\n break\ncv2.destroyAllWindows()\n", "step-3": "<mask token>...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import pymysql dbServerName = "127.0.0.1" dbUser = "root" dbPassword = "1448" dbName = "TestDataBase2" charSet = "utf8mb4" cusrorType = pymysql.cursors.DictCursor connectionObject = pymysql.connect(host=dbServerName, user=dbUser, password=dbPassword, ...
normal
{ "blob_id": "1c85ccaacfb47808e9e74f2a18bfe3b309891cf4", "index": 877, "step-1": "#!/usr/bin/python\nimport pymysql\n\n\ndbServerName = \"127.0.0.1\"\n\ndbUser = \"root\"\n\ndbPassword = \"1448\"\n\ndbName = \"TestDataBase2\"\n\ncharSet = \"utf8mb4\"\n\ncusrorType = pymysql....
[ 0 ]
# noinspection PyStatementEffect { 'name': 'ldap_user', 'summary': '', 'description': '域账号用户管理,登录及查询用户信息', 'author': '', 'website': '', 'source': {'git': 'https://github.com/LeiQiao/Parasite-Plugins.git', 'branch': 'master'}, 'category': '', 'version': '0.1', 'api': { '/use...
normal
{ "blob_id": "b95619f3f52ff3747e38ecc153123962d0122a4d", "index": 387, "step-1": "<mask token>\n", "step-2": "{'name': 'ldap_user', 'summary': '', 'description': '域账号用户管理,登录及查询用户信息',\n 'author': '', 'website': '', 'source': {'git':\n 'https://github.com/LeiQiao/Parasite-Plugins.git', 'branch': 'master'},\...
[ 0, 1, 2 ]
from fastapi import APIRouter from .endpoints import submissions def get_api_router(): api_router = APIRouter() api_router.include_router(submissions.router, prefix="/submissions", tags=["submissions"]) # api_router.include_router(users.router, ...
normal
{ "blob_id": "844c9af4f0d4ca33e7c69b72f9886f58ceebefdb", "index": 2719, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_api_router():\n api_router = APIRouter()\n api_router.include_router(submissions.router, prefix='/submissions',\n tags=['submissions'])\n return api_router\n",...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import webapp2 # web application framework import jinja2 # template engine import os # access file system import csv from google.appengine.api import users # Google account authentication from google.appengine.ext import db # datastore # initialise template jinja_environment = jinja2.Envir...
normal
{ "blob_id": "aeef27d667f95e3818f73533439385ea949b96a4", "index": 2445, "step-1": "<mask token>\n\n\nclass Submit(webapp2.RequestHandler):\n <mask token>\n\n def post(self):\n if self.request.get('submit'):\n updated_handphone = self.request.get('handphone')\n updated_tickets_cs...
[ 2, 8, 11, 12, 13 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import tinymce.models class Migration(migrations.Migration): dependencies = [ ('book', '0002_auto_20180402_2344'), ] operations = [ migrations.CreateModel( name='HeriInfo...
normal
{ "blob_id": "2c4fe8015968b8a78c7b2ea33ac5e21e01c82e6e", "index": 2818, "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 = [('book', '000...
[ 0, 1, 2, 3, 4 ]
#!/usr/local/bin/python import cgi import pymysql import pymysql.cursors import binascii import os from mylib import siteLines import threading def checkStringLine(ip, host, pagel, objects, title): onlyIp = ip.split(":")[0] connection = siteLines() with connection.cursor() as cursor: #...
normal
{ "blob_id": "6c5c07dadbe7ec70a210ee42e756be0d710c0993", "index": 5272, "step-1": "<mask token>\n\n\ndef checkStringLine(ip, host, pagel, objects, title):\n onlyIp = ip.split(':')[0]\n connection = siteLines()\n with connection.cursor() as cursor:\n sql = f\"SELECT `IP` FROM `sites` WHERE `IP`='{o...
[ 1, 2, 4, 5, 6 ]
import sys import math def get_max_sum(arr): max_sum = -math.inf for i in range(1, 5): for j in range(1, 5): temp = arr[i][j] + arr[i - 1][j - 1] + arr[i - 1][j] + arr[i - 1][ j + 1] + arr[i + 1][j + 1] + arr[i + 1][j] + arr[i + 1][j - 1] max_sum = max(max_sum, ...
normal
{ "blob_id": "c99f1333c5ca3221e9932d9a9ba1d95a77924f0d", "index": 351, "step-1": "<mask token>\n\n\ndef get_max_sum(arr):\n max_sum = -math.inf\n for i in range(1, 5):\n for j in range(1, 5):\n temp = arr[i][j] + arr[i - 1][j - 1] + arr[i - 1][j] + arr[i - 1][\n j + 1] + arr...
[ 1, 2, 3, 4 ]
import socket import sys TCP_IP = '192.168.149.129' TCP_PORT = 5005 BUFFER_SIZE = 2000 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) while 1: print 'user data:' content = sys.stdin.readline(); s.send(content) data = s.recv(BUFFER_SIZE) print "received data:", data s.clo...
normal
{ "blob_id": "5669476cc735f569263417b907e8f4a9802cd325", "index": 3189, "step-1": "import socket\nimport sys\nTCP_IP = '192.168.149.129'\nTCP_PORT = 5005\nBUFFER_SIZE = 2000\n\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM) \ns.connect((TCP_IP, TCP_PORT))\nwhile 1:\n print 'user data:'\n content = sys.st...
[ 0 ]
# Generated by Django 3.1.7 on 2021-03-28 01:03 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('details', '0002_auto_20210310_1421'), ] operations = [ migrations.AlterModelOptions( name='detail', options={'get_latest_by'...
normal
{ "blob_id": "cdaceb2d8804e08f0b35b9b65f2d06695efad002", "index": 6470, "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 = [('details', '...
[ 0, 1, 2, 3, 4 ]
import json import datetime import requests import pymysql import pymongo def insert_category(conn): """将商品的种类插入数据库 """ # 商品种类的 id 和对应的名称 categories_dict = { 66: "手机", 327: "腕表配饰", 65: "电脑办公", 67: "相机单反", 217: "平板数码", 179: "运动户外", 255: "家电家居", ...
normal
{ "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 ]
# -*- coding:utf-8 -*- import easygui as eg import time as tm import numpy as np import thread import os from urllib2 import urlopen, Request import json from datetime import datetime, timedelta URL_IFENG='http://api.finance.ifeng.com/akmin?scode=%s&type=%s' NUM_PER_THREAD=100#单线程监控的股票数 SCAN_INTERVAL=10 FILE_PATH=u'.\...
normal
{ "blob_id": "57027cd638a01a1e556bcde99bcbe2a3b2fa0ef8", "index": 2388, "step-1": "# -*- coding:utf-8 -*-\nimport easygui as eg\nimport time as tm\nimport numpy as np\nimport thread\nimport os\nfrom urllib2 import urlopen, Request\nimport json\nfrom datetime import datetime, timedelta\n\nURL_IFENG='http://api.fin...
[ 0 ]
#This program is a nice example of a core algorithm #Remove Individual Digits # To remove individual digits you use two operations # 1 MOD: # mod return the remainder after division. 5%2 = 1. # If we mod by 10 we get the units digit. 723%10 = 3 # 2 Integer Division: # Integer division is when we divide and remove de...
normal
{ "blob_id": "2a95a68d8570a314b2b6e5731d7a695e5d7e7b30", "index": 6261, "step-1": "<mask token>\n\n\ndef isHarshad(n):\n if n % findSum(n) == 0:\n return True\n return False\n\n\ndef findHarshad(low, high):\n low = 500\n high = 525\n streak = 0\n maxStreak = 0\n for i in range(low, hig...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # menuScrnTxt.py # Created on Mon Mar 8 16:17:50 2021 # @author: jcj52436999 # menuScrnTxt.py-2021-03-08-1641-just noting a general restart in efforts here import sys def printTest2(): if 0 == 0 : print(" ") print("# jcj-jcj-jcj- TOP START OF...
normal
{ "blob_id": "e4f7e0c40edde4aac6ba0a7529a2e028a09689ae", "index": 7260, "step-1": "<mask token>\n\n\ndef printTest2():\n if 0 == 0:\n print(' ')\n print(\n '# jcj-jcj-jcj- TOP START OF PROGRAM - jcj-jcj-jcj-jcj-jcj-jcj-jcj-jcj-jcj'\n )\n thisProgramIs = 'menuScrnTxt.p...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python from application import app import pprint import sys URL_PREFIX = '/pub/livemap' class LoggingMiddleware(object): def __init__(self, app): self._app = app def __call__(self, environ, resp): errorlog = environ['wsgi.errors'] pprint.pprint(('REQUEST', environ), st...
normal
{ "blob_id": "a2aa615ac660f13727a97cdd2feaca8f6e457da4", "index": 4830, "step-1": "<mask token>\n\n\nclass LoggingMiddleware(object):\n <mask token>\n <mask token>\n\n\nclass ScriptNameEdit(object):\n\n def __init__(self, app):\n self.app = app\n\n def __call__(self, environ, start_response):\n...
[ 4, 5, 6, 9, 10 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.6 on 2017-05-29 04:28 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('nomenclature', '0002_saloon_default'), ] operations = [ migrations.AlterFiel...
normal
{ "blob_id": "7817a42e5aee1786cfb3e8018bd7ca0a5e74749d", "index": 8447, "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 = [('nomenclatur...
[ 0, 1, 2, 3, 4 ]
from app import create_app, db import unittest import json class Test(unittest.TestCase): def setUp(self): """Before each test, set up a blank database""" self.app = create_app("configmodule.TestingConfig") self.app.testing = True self.client = self.app.test_client() with...
normal
{ "blob_id": "56b4262e88793be366d8ffe0fe4427fdb2a99bd7", "index": 7447, "step-1": "<mask token>\n\n\nclass Test(unittest.TestCase):\n\n def setUp(self):\n \"\"\"Before each test, set up a blank database\"\"\"\n self.app = create_app('configmodule.TestingConfig')\n self.app.testing = True\n...
[ 4, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- # упражнение выполнено на Python 3 manual_calc = 53 + 1.0/3 def trapezoidal(f, a, b, n): h = float(b - a)/n result = 0.5*(f(a) + f(b)) for i in range(1, n): result += f(a + i*h) result *= h return result def rectangular(f, a, b, n): h = float(b - a)/n result = f(a+0.5*h) for ...
normal
{ "blob_id": "4fbf5b4520aa4dca4c7cc80d56ba00f634d184bf", "index": 3405, "step-1": "<mask token>\n\n\ndef rectangular(f, a, b, n):\n h = float(b - a) / n\n result = f(a + 0.5 * h)\n for i in range(1, n):\n result += f(a + 0.5 * h + i * h)\n result *= h\n return result\n\n\n<mask token>\n", ...
[ 1, 2, 3, 4, 5 ]
import proactive import unittest import numbers import os import pytest class RestApiTestSuite(unittest.TestCase): """Advanced test cases.""" gateway = None username = "" password = "" @pytest.fixture(autouse=True) def setup_gateway(self, metadata): self.gateway = proactive.ProActive...
normal
{ "blob_id": "da2c615b8fab8de6bd63864508da254a46e65bb8", "index": 4543, "step-1": "<mask token>\n\n\nclass RestApiTestSuite(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @pytest.fixture(autouse=True)\n def setup_gateway(self, metadata):\n self.gateway...
[ 4, 7, 8, 9, 10 ]
''' Given an expression with numbers, brackets and operators. But in this task only brackets are important. Brackets can be one of three types -- "{}" "()" "[]". Brackets are determine the scope or restricted some expression. So each if was opened, then must be closed with the same type. The scopes of brackets must not...
normal
{ "blob_id": "f69b4d022ebed5a0b660f55704bbe762d5d765d5", "index": 1332, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef checkio(data):\n return True or False\n", "step-3": "'''\nGiven an expression with numbers, brackets and operators. But in this task only brackets are important. Brackets can...
[ 0, 1, 2 ]
''' O(n) time complexity O(n) space complexity ''' class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ seenum = dict() for idx, val in enumerate(nums): if target - val in seenum: ...
normal
{ "blob_id": "b3f62c331ff4ae9f909fc90cc7303997b32daceb", "index": 1876, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 # --------------------( LICENSE )-------------------- # Copyright (c) 2014-2023 Beartype authors. # See "LICENSE" for further details. ''' Project-wide **standard Python module globals** (i.e., global constants describing modules and packages bundled with CPython's sta...
normal
{ "blob_id": "a42f36fca2f65d0c5c9b65055af1814d8b4b3d42", "index": 89, "step-1": "<mask token>\n", "step-2": "<mask token>\nBUILTINS_MODULE_NAME = 'builtins'\n<mask token>\n", "step-3": "#!/usr/bin/env python3\n# --------------------( LICENSE )--------------------\n# Copyright (c) 20...
[ 0, 1, 2 ]
import numpy as np from ARA import * from State import * def theta_given_s(theta, q): """ Probability of an random event theta given current state s. Args: theta: Random event s = [q, r, w]: State Returns: Unnormalized probability of the random event. """ if q == 0: ...
normal
{ "blob_id": "87f3885b4357d66a745932f3c79804e6c15a57fa", "index": 3162, "step-1": "<mask token>\n\n\ndef new_w(w, d):\n \"\"\"\n Multi-period commitments in the next epoch.\n Args:\n d: Defender's actions\n m: Number of non multi-period commitments. (i.e. The first m defender's actions are ...
[ 3, 4, 5, 6, 7 ]
# Generated by Django 2.2.16 on 2020-10-27 14:55 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('trades', '0001_initial'), ] operations = [ migrations.AddField( model_name='orderinfo', name='nonce_str', ...
normal
{ "blob_id": "4e04e748a97c59a26a394b049c15d96476b98517", "index": 9382, "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 = [('trades', '0...
[ 0, 1, 2, 3, 4 ]
#coding=utf-8 # """ my custom common module """ import json import base64 # sdk账号信息 APP_ID = '10676432' API_KEY = 'Hy1D1urUTdXzTOzqr9LeN3gc' SECRET_KEY = 'foS4GMg2w3QZtO9XNoSQF17Kkk007xWk' def print_json(obj): """json格式打印信息 Args: obj 待打印的对象信息 """ print(json.dumps(obj, ensure_ascii=False)) ...
normal
{ "blob_id": "0b0eebd31d822ff5c1b951c3ee213f58a3a13aa0", "index": 134, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef print_json(obj):\n \"\"\"json格式打印信息\n\n Args:\n obj 待打印的对象信息\n \"\"\"\n print(json.dumps(obj, ensure_ascii=False))\n\n\ndef print_error(err_code, err_msg):\n ...
[ 0, 3, 4, 5, 6 ]
# ------------------------------------------ # # Project: VEXcode VR Maze Solver # Author: Hyunwoo Choi # Created: January 12 2021 # Description: Solves a VEXcode VR maze using the right hand rule # # ------------------------------------------ # Library imports from vexcode import * #main def main...
normal
{ "blob_id": "e560f2f202e477822729d1361b8d7ef7831a00e6", "index": 8339, "step-1": "<mask token>\n\n\ndef checkSides():\n rightC, frontC, leftC = True, True, True\n drivetrain.turn_for(RIGHT, 90, DEGREES)\n if front_eye.near_object() and distance.get_distance(MM) < 3000:\n rightC = False\n drive...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- """ Created on Sat Aug 11 13:13:53 2018 @author: zhang """ ''' Warp Commands use during diffusion-weighted images preprocessing ================================================================ dwidenoise & mrdegibbs from MRTrix3.0; eddy-openmp from FSL ------------------------------------------...
normal
{ "blob_id": "419aee3045a0d532afa0fc314df9cdef7aab5219", "index": 4181, "step-1": "<mask token>\n\n\nclass MRdegibbsInputSpec(CommandLineInputSpec):\n in_file = File(desc='input DWI image', exists=True, mandatory=True,\n position=0, argstr='%s')\n force = traits.Bool(desc='force overwrite of output f...
[ 20, 22, 24, 26, 29 ]
""" Configuration management. Environment must be set before use. Call .get() to obtain configuration variable. If the variable does not exist in the set environment, then """ CONFIG_KEY = "config_class" ENV = {} class EMPTY: """ Signifies that a default value was not set. Should trigger an error if ...
normal
{ "blob_id": "263d2fe43cf8747f20fd51897ba003c9c4cb4280", "index": 9907, "step-1": "<mask token>\n\n\nclass EMPTY:\n <mask token>\n pass\n\n\nclass Config:\n \"\"\"\n Configuration management entity.\n\n Args:\n name (str): Name of config environment.\n fallback (bool): Indicate if con...
[ 6, 7, 8, 9, 11 ]
import os from enum import Enum STAFF_CODE = os.getenv('STAFF_CODE', '20190607') ADMIN_CODE = os.getenv('ADMIN_CODE', 'nerd-bear') TEAM_NAMES = ( '밍크고래팀', '혹등고래팀', '대왕고래팀', '향유고래팀', ) TEAM_COUNT = 3 MAX_TEAM_MEMBER_COUNT = 10 class TIME_CHECK(Enum): BEFORE_START = 0 DURING_TIME = 1 AFTER...
normal
{ "blob_id": "967984444d9e26452226b13f33c5afbc96b5fe2b", "index": 3176, "step-1": "<mask token>\n\n\nclass TIME_CHECK(Enum):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TIME_CHECK(Enum):\n BEFORE_START = 0\n DURING_TIME = 1\n AFTER_END = 2\n", "step-3"...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # coding: utf-8 import sys,pysrt import urllib2,urllib,json import re from urlparse import urlparse import os from mtranslate import translate from argparse import ArgumentParser reload(sys) sys.setdefaultencoding('utf8') #------------------------------------------------------------------------...
normal
{ "blob_id": "e51c57f4487a3225936d073142f1f770815c0d47", "index": 7589, "step-1": "#!/usr/bin/env python\n# coding: utf-8\nimport sys,pysrt\nimport urllib2,urllib,json\nimport re\nfrom urlparse import urlparse\nimport os\nfrom mtranslate import translate\nfrom argparse import ArgumentParser\nreload(sys) \nsys.se...
[ 0 ]
__version__ = "1.2.0" import hashlib from collections import Counter from re import findall from secrets import choice from string import ascii_letters, ascii_lowercase, ascii_uppercase from string import digits as all_digits from string import punctuation import requests def check_password(password): """Check ...
normal
{ "blob_id": "eafe89de10c4187057b0cc1e0e9772f03a576b0d", "index": 9771, "step-1": "<mask token>\n\n\nclass PasswordGenerator:\n <mask token>\n\n def __init__(self, length, *, uppercase=True, lowercase=True, digits=\n True, special=True):\n self.length = length\n self.uppercase = upperca...
[ 4, 6, 10, 12, 13 ]
import os import numpy as np import pandas as pd import random import platform import subprocess import shlex import teradata from joblib import dump import shutil from tqdm import tqdm def get_session(db, usr, pwd): """Функция устанавливает соединение с ТД и возвращает сессию""" if platform....
normal
{ "blob_id": "a05c94ae0ee41cfef5687f741e07a54ae793e40d", "index": 2183, "step-1": "<mask token>\n\n\ndef get_session(db, usr, pwd):\n \"\"\"Функция устанавливает соединение с ТД и возвращает сессию\"\"\"\n if platform.system() == 'Windows':\n driver = 'Teradata'\n else:\n driver = 'Teradata...
[ 4, 5, 6, 7, 8 ]
'''It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. ''' import common import itertools def digits(x): return set(int(d) for d in str(x)) commo...
normal
{ "blob_id": "2ec8b9a92f8dd42faf99f0cd569ebf356e12c1d6", "index": 8042, "step-1": "<mask token>\n\n\ndef digits(x):\n return set(int(d) for d in str(x))\n\n\n<mask token>\n\n\ndef euler052():\n multiples = range(2, 7)\n for i in itertools.count(10 ** 5):\n if same_digits_as_multiples(i, multiples)...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python # coding: utf-8 from __future__ import print_function import uuid import cgi import squareconnect from squareconnect.rest import ApiException from squareconnect.apis.transactions_api import TransactionsApi from squareconnect.apis.locations_api import LocationsApi from squareconnect.apis.customers...
normal
{ "blob_id": "bb7910af5334641fd2db7146112afaff7a2e42b9", "index": 565, "step-1": "<mask token>\n", "step-2": "<mask token>\nif boxChecked == 'true':\n heading = 'Recurring Donation'\n customerRequest = {'given_name': firstName, 'family_name': lastName,\n 'email_address': email}\n try:\n c...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 import csv import math def load_data_from_file(filename): """ Load that data, my dude(tte) :param filename: The file from which you want to load data :return: Time and position data of the file """ time = [] position = [] with open(filename, 'r') a...
normal
{ "blob_id": "4545ce36c4d3df50e263d3323c04c53acb2b50e0", "index": 7888, "step-1": "<mask token>\n\n\ndef load_data_from_file(filename):\n \"\"\"\n Load that data, my dude(tte)\n :param filename: The file from which you want to load data\n :return: Time and position data of the file\n \"\"\"\n ti...
[ 5, 6, 8, 9, 10 ]
# -*- coding: utf-8 -*- """ Created on Wed Oct 3 16:04:19 2018 @author: khanhle """ # Create first network with Keras from keras.models import Sequential from keras.layers import Dense from keras.layers import Activation from keras.utils import np_utils from keras.layers.convolutional import Convolut...
normal
{ "blob_id": "721f23d2b6109194b8bca54b1cd04263e30cdf24", "index": 3964, "step-1": "<mask token>\n\n\ndef cnn_model():\n model = Sequential()\n model.add(ZeroPadding2D((1, 1), input_shape=(1, 20, window_sizes)))\n model.add(Convolution2D(32, nb_kernels, nb_kernels))\n model.add(Activation('relu'))\n ...
[ 1, 2, 3, 4, 5 ]
import cv2 import numpy as np img = cv2.imread('data/j.png', cv2.IMREAD_GRAYSCALE) kernel = cv2.getStructuringElement(cv2.MORPH_CROSS, (7, 7)) erode = cv2.erode(img, kernel) contorno = img - erode cv2.imshow('Original', img) cv2.imshow('Contorno', contorno) cv2.waitKey() cv2.destroyAllWindows()
normal
{ "blob_id": "809c9ce2b017612bedd1eb889c2b017275ee8b6f", "index": 1729, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.imshow('Original', img)\ncv2.imshow('Contorno', contorno)\ncv2.waitKey()\ncv2.destroyAllWindows()\n", "step-3": "<mask token>\nimg = cv2.imread('data/j.png', cv2.IMREAD_GRAYSCALE)\n...
[ 0, 1, 2, 3 ]
#list,for replacing element we use {a[0='']}:for adding element we use {append()} a=['somesh','aakash','sarika','datta','rudra','4mridula'] a[2] = 'nandini' a.append('sarika') print(a[2]) print(a)
normal
{ "blob_id": "5c643dfce9cf7a9f774957ff4819d3be8ac4f1da", "index": 7376, "step-1": "<mask token>\n", "step-2": "<mask token>\na.append('sarika')\nprint(a[2])\nprint(a)\n", "step-3": "a = ['somesh', 'aakash', 'sarika', 'datta', 'rudra', '4mridula']\na[2] = 'nandini'\na.append('sarika')\nprint(a[2])\nprint(a)\n"...
[ 0, 1, 2, 3 ]
# 4 Pillars of OOP: # 1. Encapsulation: Encapsulation in Python is the process of wrapping up variables and methods into a single entity.In programming, a class is an example that wraps all the variables and methods defined inside it. # 2. Abstraction: Abstraction in Python is the process of hiding the real implementat...
normal
{ "blob_id": "0e4c82d6eb77d2b6357925c9aab516bcc3310a4c", "index": 140, "step-1": "<mask token>\n\n\nclass House2:\n <mask token>\n <mask token>\n\n\nclass Vehicle(ABC):\n\n def __init__(self, speed, year):\n self.speed = speed\n self.year = year\n\n def start(self):\n print('Start...
[ 9, 12, 13, 14, 17 ]
name = '' while name != 'your name' and name != 'Your name': print('Please type your name.') name = input() print('Thanks!') #while 1 == 2 or : # print('Type your name') # name = input() # if name == 'your name': # break #print('Thanks!')
normal
{ "blob_id": "f3644b42d1a6c87c6169f8d123dadf6cd209270c", "index": 2617, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile name != 'your name' and name != 'Your name':\n print('Please type your name.')\n name = input()\nprint('Thanks!')\n", "step-3": "name = ''\nwhile name != 'your name' and nam...
[ 0, 1, 2, 3 ]
''' Classes ''' class Person: alive = True ''' Possible Attributes for a Person: 1. Name 2. Age 3. Gender ''' def __init__(self, name, age, gender): self.name = name self.age = age self.gender = gender self.salary = 0 def greet(self): ...
normal
{ "blob_id": "11feb13f38f2484c867a8b3fa525ffecf419dfe5", "index": 9957, "step-1": "<mask token>\n\n\nclass Person:\n alive = True\n <mask token>\n\n def __init__(self, name, age, gender):\n self.name = name\n self.age = age\n self.gender = gender\n self.salary = 0\n\n def g...
[ 5, 6, 7, 8, 9 ]
import math def solution(X, Y, D): # write your code in Python 3.6 xy = Y-X; if xy == 0: return 0 jumps = math.ceil(xy/D) return jumps
normal
{ "blob_id": "bdf819d8a5bc3906febced785c6d95db7dc3a603", "index": 2376, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solution(X, Y, D):\n xy = Y - X\n if xy == 0:\n return 0\n jumps = math.ceil(xy / D)\n return jumps\n", "step-3": "import math\n\n\ndef solution(X, Y, D):\n ...
[ 0, 1, 2, 3 ]
contador_pares = 0 contador_impares = 0 for i in range(100): numero = int(input('Digite um valor:')) if numero % 2 == 0: contador_pares += 1 else: contador_impares += 1 print('A quantidade de números pares é igual a:', contador_pares) print('A quantidade de números ímpares é igual a:', conta...
normal
{ "blob_id": "03aa33861def30a46de85c5b309878a1180a760f", "index": 5211, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(100):\n numero = int(input('Digite um valor:'))\n if numero % 2 == 0:\n contador_pares += 1\n else:\n contador_impares += 1\nprint('A quantidade de n...
[ 0, 1, 2 ]
import art import random print(art.guess) print(art.the) print(art.number) print("I'm thinking of a number between 1 and 100") number = random.randint(1,100) turns = 0 difficulty = input("Chose a difficulty. 'easy' or 'hard'?\n") if difficulty == 'easy': turns +=10 else: turns +=5 gameover = False while n...
normal
{ "blob_id": "f2bf4f5b057af1d2362ec8d1472aa76e774be1c7", "index": 2736, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(art.guess)\nprint(art.the)\nprint(art.number)\nprint(\"I'm thinking of a number between 1 and 100\")\n<mask token>\nif difficulty == 'easy':\n turns += 10\nelse:\n turns += 5\...
[ 0, 1, 2, 3, 4 ]
#Homework 2 PyPoll #The total number of votes cast #A complete list of candidates who received votes #The percentage of votes each candidate won #The total number of votes each candidate won #The winner of the election based on popular vote. #First we'll import the os module # This will allow us to create file pat...
normal
{ "blob_id": "800d87a879987c47f1a66b729932279fc8d4fa38", "index": 7314, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('election_data.csv') as csvfile:\n csvreader = csv.reader(csvfile, delimiter=',')\n print(csvreader)\n", "step-3": "<mask token>\ncsvpath = os.path.join('election_data.c...
[ 0, 1, 2, 3, 4 ]
# coding=utf-8 import pyautogui from xpinyin import Pinyin rubbish_dic=1 if rubbish_dic==0: chinese_rubbish=( u"草泥马", u"你妈死了", u"你是不是", u"低能", u"人话都听不懂", u"没家教的狗东西", ) elif rubbish_dic==1: rubbish_file=open("rubbish_dic.txt") chinese_rubbish=rubbish_file.read().splitlines() ...
normal
{ "blob_id": "23e673909b2f1eb9a265ce84ad63464e20e99c6a", "index": 3449, "step-1": "<mask token>\n\n\ndef trans_screen():\n pyautogui.doubleClick(492, 974)\n pyautogui.typewrite(['enter'], 0.01)\n\n\ndef trans_chinese():\n for c_rubbish in chinese_rubbish:\n pin = p.get_pinyin(c_rubbish, '')\n ...
[ 4, 5, 6, 7, 8 ]