code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
class Component: pass class Entity: def __init__(self, id): self.id = id self.components = {} def add_component(self, component): if type(component) in self.components: raise Exception("This entity already has a component of that type") # Since there is only ...
normal
{ "blob_id": "14f7f31fa64799cdc08b1363b945da50841d16b5", "index": 3020, "step-1": "<mask token>\n\n\nclass System:\n <mask token>\n\n def bind_manager(self, manager):\n self.manager = manager\n <mask token>\n\n def process(self, entity, deltaTime):\n pass\n <mask token>\n <mask tok...
[ 13, 14, 17, 18, 24 ]
from flask import Flask, flash, abort, redirect, url_for, request, render_template, make_response, json, Response import os, sys import config import boto.ec2.elb import boto from boto.ec2 import * app = Flask(__name__) @app.route('/') def index(): list = [] creds = config.get_ec2_conf() for region in con...
normal
{ "blob_id": "22c2425f1dc14b6b0005ebf2231af8abf43aa2e1", "index": 5273, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n list = []\n creds = config.get_ec2_conf()\n for region in config.region_list():\n conn = connect_to_region(region, aws_access_key_id=creds[\n 'AWS_ACCESS_...
[ 6, 7, 8, 9 ]
# Packages import PySimpleGUI as sg import mysql.connector import secrets # TODO Add a view all button # TODO Catch errors (specifically for TimeDate mismatches) # TODO Add a downtime graph # TODO Add a system feedback window instead of putting this in the out id textbox error_sel_flag = False # Flag to check whether...
normal
{ "blob_id": "8fb5ef7244a8ca057f11cbcdf42d383665dade5e", "index": 6884, "step-1": "# Packages\nimport PySimpleGUI as sg\nimport mysql.connector\nimport secrets\n\n# TODO Add a view all button\n# TODO Catch errors (specifically for TimeDate mismatches)\n# TODO Add a downtime graph\n# TODO Add a system feedback win...
[ 0 ]
n =int(input("nhap gia tri")) for i in range(1,n+1): print(i)
normal
{ "blob_id": "21b295e28a7e4443ea116df1b22ff5074dca955a", "index": 246, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(1, n + 1):\n print(i)\n", "step-3": "n = int(input('nhap gia tri'))\nfor i in range(1, n + 1):\n print(i)\n", "step-4": "n =int(input(\"nhap gia tri\"))\nfor i in...
[ 0, 1, 2, 3 ]
import os import time import uuid import subprocess # Global variables. ADJUST THEM TO YOUR NEEDS chia_executable = os.path.expanduser('~')+"/chia-blockchain/venv/bin/chia" # directory of chia binary file numberOfLogicalCores = 16 # number of logical cores that you want to use overall run_loop_interval = 10 # seconds ...
normal
{ "blob_id": "bc536440a8982d2d4a1bc5809c0d9bab5ac6553a", "index": 2313, "step-1": "<mask token>\n\n\ndef fetch_logs():\n item_in_location_list = os.listdir(logs_location)\n content_path_list = list(map(lambda log: logs_location + log,\n item_in_location_list))\n text_file_list = list(filter(lambda...
[ 4, 6, 8, 9, 10 ]
from helper.logger_helper import Log from helper.mail_helper import MailHelper import spider.spider as spider from configuration.configuration_handler import Configuration from configuration.products_handler import ProductsHandler if __name__ == "__main__": logger = Log() conf = Configuration('configuration/co...
normal
{ "blob_id": "2e140d1174e0b2d8a97df880b1bffdf84dc0d236", "index": 1029, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n logger = Log()\n conf = Configuration('configuration/configuration.yaml'\n ).load_configuration()\n ph = ProductsHandler(conf['products_path']...
[ 0, 1, 2, 3 ]
s = input() if len(s) < 26: for i in range(26): c = chr(ord("a")+i) if c not in s: print(s+c) exit() else: for i in reversed(range(1,26)): if s[i-1] < s[i]: s1 = s[0:i-1] for j in range(26): c = chr(ord("a")+j) ...
normal
{ "blob_id": "9931fc25118981bcce80cffd3fda9dc99d951bf5", "index": 180, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(s) < 26:\n for i in range(26):\n c = chr(ord('a') + i)\n if c not in s:\n print(s + c)\n exit()\nelse:\n for i in reversed(range(1, 26)):\n...
[ 0, 1, 2, 3 ]
""" Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: Input: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Output: 4 """ # 196ms. 98 percentile class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: if not matrix: ...
normal
{ "blob_id": "e5d31a2ea4a8615d24626be2414f5ae49b9cd6a1", "index": 184, "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 maximalSquare(self, matrix: List[List[str]]) ->int:\n if not ma...
[ 0, 1, 2, 3 ]
import cv2 import numpy as np cap = cv2.VideoCapture("./vStream.h264") count = 0 while True: ret, frame = cap.read() if ret: print("Decoded frame") # cv2.imshow("frame", frame) cv2.imwrite("fr_"+str(count)+".png", frame) count += 1 else: print("Couldn\'t decoded fra...
normal
{ "blob_id": "40ac3292befa2354878927ada0e10c24368a9d73", "index": 2643, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n ret, frame = cap.read()\n if ret:\n print('Decoded frame')\n cv2.imwrite('fr_' + str(count) + '.png', frame)\n count += 1\n else:\n prin...
[ 0, 1, 2, 3, 4 ]
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import minimize from scipy.stats import chisquare, chi2, binom, poisson def f_1(x, a): return (1 / (x + 5)) * np.sin(a * x) def f_2(x, a): return np.sin(a * x) + 1 def f_3(x, a): return np.sin(a * (x ** 2)) def f_4(x, a): ret...
normal
{ "blob_id": "27edc753ebb9d60715a2ffa25d77e69ef363d010", "index": 3568, "step-1": "<mask token>\n\n\ndef f_1(x, a):\n return 1 / (x + 5) * np.sin(a * x)\n\n\ndef f_2(x, a):\n return np.sin(a * x) + 1\n\n\ndef f_3(x, a):\n return np.sin(a * x ** 2)\n\n\n<mask token>\n\n\ndef f_5(x):\n return x * np.tan...
[ 6, 9, 12, 13, 14 ]
N,T=map(int,input().split()) nm=1000000 for i in range(N): c,t=map(int,input().split()) if nm>c and T>=t: nm=c if nm==1000000: print("TLE") else: print(nm)
normal
{ "blob_id": "8a0e781f29c426161240e33b9d2adc7537b3d352", "index": 2513, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(N):\n c, t = map(int, input().split())\n if nm > c and T >= t:\n nm = c\nif nm == 1000000:\n print('TLE')\nelse:\n print(nm)\n", "step-3": "N, T = map(...
[ 0, 1, 2, 3 ]
#implement variable! import numpy as np class Variable: def __init__(self, data): self.data = data class Function: ''' Base class specific functions are implemented in the inherited class ''' def __call__(self, input): x = input.data #data extract y = self.foward(x) ...
normal
{ "blob_id": "9efd83524ebb598f30c8fb6c0f9f0c65333578e6", "index": 6292, "step-1": "<mask token>\n\n\nclass Function:\n <mask token>\n <mask token>\n\n def foward(self, x):\n raise NotImplementedError()\n\n\nclass Square(Function):\n\n def foward(self, x):\n return x ** 2\n\n\nclass Exp(F...
[ 6, 10, 11, 12, 14 ]
from django.core.paginator import Paginator, EmptyPage from django.shortcuts import render from django.views import View from django.contrib.auth.mixins import LoginRequiredMixin from logging import getLogger from django_redis import get_redis_connection from decimal import Decimal import json from django import http f...
normal
{ "blob_id": "0402096f215ae600318d17bc70e5e3067b0a176b", "index": 3864, "step-1": "<mask token>\n\n\nclass OrderSuccessView(LoginRequiredMixin, View):\n \"\"\"订单成功页面\"\"\"\n\n def get(self, request):\n \"\"\"提供订单成功页面\"\"\"\n order_id = request.GET.get('order_id')\n payment_amount = requ...
[ 9, 16, 17, 19, 22 ]
import math #h=g^x h=input("h: ") g=input("g: ") p=input("p: ") m=math.ceil(math.sqrt(p)) m=int(m) aj=[0]*m for i in range(m): aj[i]=pow(g,i*m) ainvm=pow(g,p-2,p) gamma = h for i in range(m): if gamma in aj: j = aj.index(gamma) print (j*m)+i break gamma=(gamma*ainvm)%p
normal
{ "blob_id": "94439ffe3303f5efe15562f26d693e1e7a8115df", "index": 2009, "step-1": "import math #h=g^x\nh=input(\"h: \")\ng=input(\"g: \")\np=input(\"p: \")\nm=math.ceil(math.sqrt(p))\nm=int(m)\naj=[0]*m\nfor i in range(m):\n aj[i]=pow(g,i*m)\nainvm=pow(g,p-2,p)\ngamma = h\nfor i in range(m):\n if gamma in ...
[ 0 ]
# coding=utf-8 # *** WARNING: this file was generated by the Pulumi SDK Generator. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import copy import warnings import pulumi import pulumi.runtime from typing import Any, Mapping, Optional, Sequence, Union, overload from .. import _ut...
normal
{ "blob_id": "8535020e7157699310b3412fe6c5a28ee8e61f49", "index": 6911, "step-1": "<mask token>\n\n\n@pulumi.output_type\nclass ApplicationCredential(dict):\n <mask token>\n\n def __getitem__(self, key: str) ->Any:\n ApplicationCredential.__key_warning(key)\n return super().__getitem__(key)\n ...
[ 10, 11, 12, 13, 16 ]
student = [] while True: name = str(input('Name: ')).capitalize().strip() grade1 = float(input('Grade 1: ')) grade2 = float(input('Grade 2: ')) avgrade = (grade1 + grade2) / 2 student.append([name, [grade1, grade2], avgrade]) resp = ' ' while resp not in 'NnYy': resp = str(input('Ano...
normal
{ "blob_id": "74028a7b317c02c90603ad24c1ddb35a1d5d0e9d", "index": 8678, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n name = str(input('Name: ')).capitalize().strip()\n grade1 = float(input('Grade 1: '))\n grade2 = float(input('Grade 2: '))\n avgrade = (grade1 + grade2) / 2\n ...
[ 0, 1, 2, 3 ]
def merge_the_tools(string, k): # your code goes here num_sub_strings = len(string)/k #print num_sub_strings for idx in range(num_sub_strings): print "".join(set(list(string[idx * k : (idx + 1) * k])))
normal
{ "blob_id": "e95bda8be2294c295d89f1c035bc209128fa29c8", "index": 228, "step-1": "def merge_the_tools(string, k):\n # your code goes here\n num_sub_strings = len(string)/k\n #print num_sub_strings\n\n for idx in range(num_sub_strings):\n print \"\".join(set(list(string[idx * k : (idx + 1) * k])...
[ 0 ]
class Formater(): def clean_number (posible_number): sanitize_number = posible_number.replace(' ', '') number_of_dots = sanitize_number.count('.') if number_of_dots > 1: return None if number_of_dots == 1: dot_position = sanitize_number.index('.') ...
normal
{ "blob_id": "02c32cf04529ff8b5edddf4e4117f8c4fdf27da9", "index": 8612, "step-1": "<mask token>\n", "step-2": "class Formater:\n <mask token>\n", "step-3": "class Formater:\n\n def clean_number(posible_number):\n sanitize_number = posible_number.replace(' ', '')\n number_of_dots = sanitize...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-05-16 12:24 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('main', '0036_auto_20180516_1818'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "a7add26a919a41e52ae41c6b4c4079eadaa8aa1d", "index": 851, "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 = [('main', '0036...
[ 0, 1, 2, 3, 4 ]
import ambulance_game as abg import numpy as np import sympy as sym from sympy.abc import a, b, c, d, e, f, g, h, i, j def get_symbolic_pi(num_of_servers, threshold, system_capacity, buffer_capacity): Q_sym = abg.markov.get_symbolic_transition_matrix( num_of_servers=num_of_servers, threshold=thres...
normal
{ "blob_id": "9dd59fee46bd4bec87cc8c40099110b483ad0496", "index": 6990, "step-1": "<mask token>\n\n\ndef get_symbolic_state_probabilities_1222():\n num_of_servers = 1\n threshold = 2\n system_capacity = 2\n buffer_capacity = 2\n sym_pi_1222 = get_symbolic_pi(num_of_servers=num_of_servers, threshold...
[ 5, 12, 13, 16, 17 ]
import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt import numpy as np import struct import wave scale = 0.01 wav = wave.open('output.wav', 'r') print 'channels %d'%wav.getnchannels() print 'smpl width %d'%wav.getsampwidth() print 'frame rate %f'%wav.getframerate() nframes = wav.getnframes() pri...
normal
{ "blob_id": "c105f06e302740e9b7be100df905852bb5610a2c", "index": 49, "step-1": "import matplotlib\nmatplotlib.use('TkAgg')\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport struct\nimport wave\n\nscale = 0.01\nwav = wave.open('output.wav', 'r')\n\nprint 'channels %d'%wav.getnchannels()\nprint 'smpl wi...
[ 0 ]
import os import glob import pandas as pd import xml.etree.ElementTree as ET import argparse import numpy as np def run(path, output): #xml_df = xml_to_csv(path) #xml_df.to_csv(output, index=None) # for filename in os.listdir(path): # base_file, ext = os.path.splitext(filename) # print(bas...
normal
{ "blob_id": "26d14bc74d893f6f14ee7405280f4af41854c544", "index": 141, "step-1": "<mask token>\n\n\ndef run(path, output):\n for xml_file in glob.glob(path + '/*.xml'):\n tree = ET.parse(xml_file)\n root = tree.getroot()\n base_file, ext = os.path.splitext(root.find('filename').text)\n ...
[ 1, 2, 3, 4, 5 ]
__author__ = 'anderson' from pyramid.security import Everyone, Allow, ALL_PERMISSIONS class Root(object): #Access Control List __acl__ = [(Allow, Everyone, 'view'), (Allow, 'role_admin', ALL_PERMISSIONS), (Allow, 'role_usuario', 'comum')] def __init__(self, request): ...
normal
{ "blob_id": "5ee2a51ea981f0feab688d9c571620a95d89a422", "index": 6980, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Root(object):\n <mask token>\n\n def __init__(self, request):\n pass\n", "step-3": "__author__ = 'anderson'\n<mask token>\n\n\nclass Root(object):\n __acl__ = ...
[ 0, 2, 4, 5, 6 ]
print("n:",end="") n=int(input()) print("a:",end="") a=list(map(int,input().split())) ans=0 for i in range(n): for j in range(i+1,n): for k in range(j+1,n): ai,aj,ak=sorted([a[i],a[j],a[k]]) if(ai+aj>ak and ai+aj+ak>ans): ans=ai+aj+ak print(ans)
normal
{ "blob_id": "130f49028833bf57d7e4f9fbb0764801c3508c3b", "index": 3055, "step-1": "<mask token>\n", "step-2": "print('n:', end='')\n<mask token>\nprint('a:', end='')\n<mask token>\nfor i in range(n):\n for j in range(i + 1, n):\n for k in range(j + 1, n):\n ai, aj, ak = sorted([a[i], a[j], ...
[ 0, 1, 2, 3 ]
import os from NeuralEmulator.Configurators.NormalLeakSourceConfigurator import NormalLeakSourceConfigurator from NeuralEmulator.Configurators.OZNeuronConfigurator import OZNeuronConfigurator from NeuralEmulator.Configurators.PulseSynapseConfigurator import PulseSynapseConfigurator from NeuralEmulator.NormalLeakS...
normal
{ "blob_id": "177401f25471cf1cbd32dd0770acdc12bf271361", "index": 8030, "step-1": "<mask token>\n\n\nclass NeuronsGenerator:\n\n def __init__(self, neuronsNumber, synapse, lowerBound=100.0 * 10 ** -3,\n upperBound=800.0 * 10 ** -3, randomVals=False):\n noramalLeakSourceConfigurator = NormalLeakSo...
[ 3, 4, 5, 6, 7 ]
import pygame class BackGround: def __init__(self, x, y): self.y = y self.x = x def set_image(self, src): self.image = pygame.image.load(src) self.rect = self.image.get_rect() self.rect.y = self.y self.rect.x = self.x def draw(self, screen): scree...
normal
{ "blob_id": "071e3cf6b4337e0079bbb2c7694fff2468142070", "index": 6505, "step-1": "<mask token>\n\n\nclass BackGround:\n\n def __init__(self, x, y):\n self.y = y\n self.x = x\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass BackGround:\n\n def __init__(self, x, y):\...
[ 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # @Author: Marcela Campo # @Date: 2016-05-06 18:56:47 # @Last Modified by: Marcela Campo # @Last Modified time: 2016-05-06 19:03:21 import os from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand from server import app, db app.config.from_object('confi...
normal
{ "blob_id": "d7b91b0476a1f2e00408ce1f1501bf98d4c06e4e", "index": 9540, "step-1": "<mask token>\n", "step-2": "<mask token>\napp.config.from_object('config.DevelopmentConfig')\n<mask token>\nmanager.add_command('db', MigrateCommand)\nif __name__ == '__main__':\n manager.run()\n", "step-3": "<mask token>\na...
[ 0, 1, 2, 3, 4 ]
n = int(input("Please input the number of 1's and 0's you want to print:")) for i in range (1, n+1): if i%2 == 1: print ("1 ", end = "") else: print ("0 ", end = "")
normal
{ "blob_id": "bd96b31c5de2f0ad4bbc28c876b86ec238db3184", "index": 9108, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(1, n + 1):\n if i % 2 == 1:\n print('1 ', end='')\n else:\n print('0 ', end='')\n", "step-3": "n = int(input(\"Please input the number of 1's and 0's ...
[ 0, 1, 2, 3 ]
"""added Trail.Geometry without srid Revision ID: 56afb969b589 Revises: 2cf6c7c1f0d7 Create Date: 2014-12-05 18:13:55.512637 """ # revision identifiers, used by Alembic. revision = '56afb969b589' down_revision = '2cf6c7c1f0d7' from alembic import op import sqlalchemy as sa import flask_admin import geoalchemy2 de...
normal
{ "blob_id": "d724b4f57cf7683d6b6385bf991ed23a5dd8208f", "index": 3881, "step-1": "<mask token>\n\n\ndef upgrade():\n with op.batch_alter_table('trail', schema=None) as batch_op:\n batch_op.add_column(sa.Column('geom', geoalchemy2.types.Geometry(\n geometry_type='MULTILINESTRING'), nullable=T...
[ 1, 2, 3, 4, 5 ]
default_app_config = 'teacher.apps.A1Config'
normal
{ "blob_id": "c466c7e05608b1fbba5eea5bec16d301cee3688f", "index": 9817, "step-1": "<mask token>\n", "step-2": "default_app_config = 'teacher.apps.A1Config'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
## @file # Contains several utilitities shared by migration tools. # # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full...
normal
{ "blob_id": "2dbb1051b35898288db629fd0c5b3887c429e9b8", "index": 1313, "step-1": "<mask token>\n\n\ndef SetCommon(Common, XmlCommon):\n XmlTag = 'Usage'\n Common.Usage = XmlAttribute(XmlCommon, XmlTag).split()\n XmlTag = 'FeatureFlag'\n Common.FeatureFlag = XmlAttribute(XmlCommon, XmlTag)\n XmlTag...
[ 11, 18, 20, 21, 23 ]
import sys import os # Module "sys" # # See docs for the sys module: https://docs.python.org/3.7/library/sys.html # Print out the command line arguments in sys.argv, one per line: # Print out the plaform from sys: # for arg in sys.argv: # print(arg) # Print out the Python version from sys:print(sys.platform) ...
normal
{ "blob_id": "3fed96e9bedb157a14cf9c441de5aae8b4f6edc8", "index": 8664, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('platform: ' + sys.platform + '\\n' + 'maxsize: ' + str(sys.maxsize) +\n '\\n' + 'argv: ' + str(sys.argv))\nprint('Process ID: ' + str(os.getpid()) + '\\n' + 'cwd: ' + os.getcwd(...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.8 on 2018-04-12 12:37 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('cstasker', '0001_initial'), ] operations = [ migrations.AlterField( ...
normal
{ "blob_id": "2fbf312e1f8388008bb9ab9ba0ee4ccee1a8beae", "index": 3594, "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 = [('cstasker', ...
[ 0, 1, 2, 3, 4 ]
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> import turtle turtle.setup(650,350,200,200) turtle.penup() turtle.fd(-250) turtle.pendown() ...
normal
{ "blob_id": "e069ad88b5173e5859f1b01b9fb45951d1e82593", "index": 4280, "step-1": "Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license()\" for more information.\n>>> import turtle \nturtle.setup(65...
[ 0 ]
# -*- coding: utf-8 -*- # @Time : 2018/12/13 21:32 # @Author : sundongjian # @Email : xiaobomentu@163.com # @File : __init__.py.py # @Software: PyCharm
normal
{ "blob_id": "00ec56420831d8f4ab14259c7b07f1be0bcb7d78", "index": 9161, "step-1": "# -*- coding: utf-8 -*-\r\n# @Time : 2018/12/13 21:32\r\n# @Author : sundongjian\r\n# @Email : xiaobomentu@163.com\r\n# @File : __init__.py.py\r\n# @Software: PyCharm", "step-2": null, "step-3": null, "step-4": null,...
[ 1 ]
# Copyright (c) 2012 - Samuel Loretan <tynril at gmail.com> # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modi...
normal
{ "blob_id": "109a0ba0952bd5923ecbefa41556de7aa9f9eea8", "index": 4197, "step-1": "# Copyright (c) 2012 - Samuel Loretan <tynril at gmail.com>\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in...
[ 0 ]
import torch from torch import nn import pytorch_ssim class Custom_Loss_for_Autoencoder(nn.Module): def __init__(self, window_size=6): super(Custom_Loss_for_Autoencoder, self).__init__() self.ssim = pytorch_ssim.SSIM(window_size=window_size) self.mse = nn.MSELoss() def forward(self, ...
normal
{ "blob_id": "ce3e2aa2534bb404b45202bcb76e9d07080560cb", "index": 2739, "step-1": "<mask token>\n\n\nclass Custom_Loss_for_Autoencoder(nn.Module):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Custom_Loss_for_Autoencoder(nn.Module):\n <mask token>\n\n def forward(self, reconst...
[ 1, 2, 3, 4 ]
from flask import Flask from flask import render_template from flask import make_response import json from lib import powerswitch app = Flask(__name__) @app.route('/') def hello_world(): return render_template('index.html') @app.route('/on/') def on(): state = powerswitch.on() return json.dumps(state) ...
normal
{ "blob_id": "18d3f58048b7e5d792eb2494ecc62bb158ac7407", "index": 254, "step-1": "<mask token>\n\n\n@app.route('/')\ndef hello_world():\n return render_template('index.html')\n\n\n<mask token>\n\n\n@app.route('/off/')\ndef off():\n state = powerswitch.off()\n return json.dumps(state)\n\n\n@app.route('/to...
[ 4, 6, 7, 8, 9 ]
import subprocess import glob import os import time import sys import xml.etree.ElementTree as ET import getpass import psutil if len(sys.argv)==1: photoscanname = r"C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe" scriptname = r"C:\Users\slocumr\github\SimUAS\batchphotoscan\agiproc.py" #xmlnames ...
normal
{ "blob_id": "00f95733505b3e853a76bbdd65439bcb230fa262", "index": 3345, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv) == 1:\n photoscanname = 'C:\\\\Program Files\\\\Agisoft\\\\PhotoScan Pro\\\\photoscan.exe'\n scriptname = (\n 'C:\\\\Users\\\\slocumr\\\\github\\\\SimUAS\\\\...
[ 0, 1, 2, 3, 4 ]
""" -*- coding:utf-8 -*- @ Time : 14:05 @ Name : handle_ini_file.py @ Author : xiaoyin_ing @ Email : 2455899418@qq.com @ Software : PyCharm ... """ from configparser import ConfigParser from Common.handle_path import conf_dir import os class HandleConfig(ConfigParser): def __init__(self, ini_...
normal
{ "blob_id": "01e60123ad87d9ff49812fe3a6f5d55bc85921c5", "index": 4071, "step-1": "<mask token>\n\n\nclass HandleConfig(ConfigParser):\n\n def __init__(self, ini_file_neme):\n super().__init__()\n self.ini_file_neme = ini_file_neme\n\n def red_conf__(self):\n file_path = os.path.join(co...
[ 3, 4, 5, 6, 7 ]
class Rect(): def __init__(self, w, h): self.w = w self.h = h def half(self): return self.w / 2; bricks = [Rect(40, 25), Rect(30, 25), Rect(28, 25), Rect(13, 25)] def setup(): size(500, 500) noLoop() def draw(): posx = 0 posy = 0 i = 0 for...
normal
{ "blob_id": "807f0094a9736abdfa3f5b629615a80f1e0d13ef", "index": 3037, "step-1": "class Rect:\n\n def __init__(self, w, h):\n self.w = w\n self.h = h\n\n def half(self):\n return self.w / 2\n\n\n<mask token>\n\n\ndef setup():\n size(500, 500)\n noLoop()\n\n\n<mask token>\n", "s...
[ 4, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, unicode_literals import urllib def normalize_mac_address(address): return address.lower().replace("-", ":") def urlencode(s): return urllib.quote(s.encode("utf-8"), "") def urlencode_plus(s): return urllib.quote_plus(s.encode("...
normal
{ "blob_id": "33b8baf2ca819315eaa5f16c7986390acb4d6efd", "index": 878, "step-1": "<mask token>\n\n\ndef normalize_mac_address(address):\n return address.lower().replace('-', ':')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef normalize_mac_address(address):\n return address.lower().replace('-', ':...
[ 1, 2, 3, 4, 5 ]
TTTSIZE = 4 def who_win_line(line): elements = set(line) if '.' in elements: return '.' elements.discard('T') if len(elements) >= 2: return 'D' else: return elements.pop() def who_win_tic_tac_toe(original_rows): #print('%s' % repr(original_rows)) board...
normal
{ "blob_id": "2e041e33b5c34c2bddc72b36ff641817f1e21db2", "index": 3735, "step-1": "<mask token>\n\n\ndef who_win_line(line):\n elements = set(line)\n if '.' in elements:\n return '.'\n elements.discard('T')\n if len(elements) >= 2:\n return 'D'\n else:\n return elements.pop()\n...
[ 2, 3, 4, 5, 6 ]
from django.urls import path from .views import ( TreeCreateView, TreeListView, TreeUpdateView, ) app_name = 'trees' urlpatterns = [ path('list/', TreeListView.as_view(), name='list'), path('create/', TreeCreateView.as_view(), name='create'), path('<int:pk>/update/', TreeCreat...
normal
{ "blob_id": "0c1de2c1eb5a4de7aeb14ad6b27aa61e07bc4c51", "index": 602, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'trees'\nurlpatterns = [path('list/', TreeListView.as_view(), name='list'), path(\n 'create/', TreeCreateView.as_view(), name='create'), path(\n '<int:pk>/update/', TreeCr...
[ 0, 1, 2, 3 ]
import json import requests import boto3 import uuid import time profile_name = 'mine' region = 'us-west-2' session = boto3.Session(profile_name=profile_name) api = session.client('apigateway', region_name=region) cf = session.client('cloudformation', region_name=region) def get_key(name_of_key): print('Discover...
normal
{ "blob_id": "10fda09f47c292cb3dc901f42d38ead7757460f5", "index": 3699, "step-1": "<mask token>\n\n\ndef get_key(name_of_key):\n print('Discovering API Key')\n response = api.get_api_keys(includeValues=True)\n items = response['items']\n for item in items:\n if name_of_key in item['name']:\n ...
[ 3, 4, 5, 6, 7 ]
# OpenWeatherMap API Key api_key = "078c8443640961d5ce547c8269db5fd7"
normal
{ "blob_id": "4eb3d94a5fd22fc29000ec32475de9cbae1c183a", "index": 5255, "step-1": "<mask token>\n", "step-2": "api_key = '078c8443640961d5ce547c8269db5fd7'\n", "step-3": "# OpenWeatherMap API Key\napi_key = \"078c8443640961d5ce547c8269db5fd7\"\n", "step-4": null, "step-5": null, "step-ids": [ 0, ...
[ 0, 1, 2 ]
import random OPTIONS = ['rock', 'paper', 'scissors'] def get_human_choice(): print('(1) Rock\n(2) Paper\n(3) Scissors') return OPTIONS[int(input('Enter the number of your choice: ')) - 1] def get_computer_choice(): return random.choice(OPTIONS) def print_choices(human_choice, computer_choice): pr...
normal
{ "blob_id": "2e6bce05c8ba21aa322e306d2cdb8871531d7341", "index": 5499, "step-1": "<mask token>\n\n\ndef get_human_choice():\n print('(1) Rock\\n(2) Paper\\n(3) Scissors')\n return OPTIONS[int(input('Enter the number of your choice: ')) - 1]\n\n\ndef get_computer_choice():\n return random.choice(OPTIONS)...
[ 6, 7, 8, 9 ]
# 运算符的优先级 # 和数学中一样,在Python运算也有优先级,比如先乘除 后加减 # 运算符的优先级可以根据优先级的表格来查询, # 在表格中位置越靠下的运算符优先级越高,优先级越高的越优先计算 # 如果优先级一样则自左向右计算 # 关于优先级的表格,你知道有这么一个东西就够了,千万不要去记 # 在开发中如果遇到优先级不清楚的,则可以通过小括号来改变运算顺序 a = 1 + 2 * 3 # 一样 and高 or高 # 如果or的优先级高,或者两个运算符的优先级一样高 # 则需要先进行或运算,则运算结果是3 # 如果and的优先级高,则应该先计算与运算 # 则运算结果是1 a = 1 or 2 and 3 ...
normal
{ "blob_id": "25550cbaf6e0e5bdbbe3852bb8cdc05ac300d315", "index": 8872, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(result)\n", "step-3": "a = 1 + 2 * 3\na = 1 or 2 and 3\nresult = 1 < 2 < 3\nresult = 10 < 20 > 15\nprint(result)\n", "step-4": "# 运算符的优先级\n# 和数学中一样,在Python运算也有优先级,比如先乘除 后加减\n# 运...
[ 0, 1, 2, 3 ]
import os import pickle from matplotlib import pyplot as plt cwd = os.path.join(os.getcwd(), 'DEDA_2020SS_Crypto_Options_RND_HD', 'CrypOpt_RiskNeutralDensity') data_path = os.path.join(cwd, 'data') + '/' day = '2020-03-11' res = pickle.load(open(data_path + 'results_{}.pkl'.format(day), 'rb')) ...
normal
{ "blob_id": "a01f812584e4cee14c9fe15e9fb6ede4ae3e937a", "index": 4953, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor key, ax in zip(sorted(res), axes.flatten()):\n print(key, ax)\n ax.plot(res[key]['df'].M, res[key]['df'].iv, '.')\n ax.plot(res[key]['M'], res[key]['smile'])\n ax.text(0.9...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python from __future__ import division from __future__ import print_function import numpy as np from mpi4py import MPI from parutils import pprint comm = MPI.COMM_WORLD pprint("-"*78) pprint(" Running on %d cores" % comm.size) pprint("-"*78) comm.Barrier() # Prepare a vector of N=5 elements to be ...
normal
{ "blob_id": "839b3ebffebce95de25f75edc67a647bd1318268", "index": 5077, "step-1": "<mask token>\n", "step-2": "<mask token>\npprint('-' * 78)\npprint(' Running on %d cores' % comm.size)\npprint('-' * 78)\ncomm.Barrier()\n<mask token>\nif comm.rank == 0:\n A = np.arange(N, dtype=np.float64)\nelse:\n A = np...
[ 0, 1, 2, 3, 4 ]
# ch14_26.py fn = 'out14_26.txt' x = 100 with open(fn, 'w') as file_Obj: file_Obj.write(x) # 直接輸出數值x產生錯誤
normal
{ "blob_id": "e4f07355300003943d2fc09f80746a1201de7e37", "index": 1678, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(fn, 'w') as file_Obj:\n file_Obj.write(x)\n", "step-3": "fn = 'out14_26.txt'\nx = 100\nwith open(fn, 'w') as file_Obj:\n file_Obj.write(x)\n", "step-4": "# ch14_26.py\...
[ 0, 1, 2, 3 ]
"""Largest product in a series Problem 8 The four adjacent digits in the 1000-digit number that have the greatest product are 9 x 9 x 8 x 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 125406987471585238...
normal
{ "blob_id": "601d32bf30aa454bbc7d31d6ce4b7296cef0fdfe", "index": 9374, "step-1": "\"\"\"Largest product in a series\nProblem 8\nThe four adjacent digits in the 1000-digit number that have the greatest product\nare 9 x 9 x 8 x 9 = 5832.\n\n73167176531330624919225119674426574742355349194934\n9698352031277450632623...
[ 0 ]
#Embedded file name: c:/depot/games/branches/release/EVE-TRANQUILITY/eve/client/script/paperDoll/SkinRaytracing.py import trinity import blue import telemetry import ctypes import math import time import geo2 import struct import itertools import weakref import uthread import paperDoll as PD import log import random my...
normal
{ "blob_id": "3c01ca27a5eef877b606b93b04ffe6f73168cd6b", "index": 9090, "step-1": "#Embedded file name: c:/depot/games/branches/release/EVE-TRANQUILITY/eve/client/script/paperDoll/SkinRaytracing.py\nimport trinity\nimport blue\nimport telemetry\nimport ctypes\nimport math\nimport time\nimport geo2\nimport struct\...
[ 0 ]
import cv2 img = cv2.imread('Chapter1/resources/jacuzi.jpg') imgGrey = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) imgCanny = cv2.Canny(img,240,250) cv2.imshow("output",imgCanny) cv2.waitKey(0)
normal
{ "blob_id": "292cfecb701ecc179381d4453063aff532a0e877", "index": 8961, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.imshow('output', imgCanny)\ncv2.waitKey(0)\n", "step-3": "<mask token>\nimg = cv2.imread('Chapter1/resources/jacuzi.jpg')\nimgGrey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\nimgCanny ...
[ 0, 1, 2, 3, 4 ]
km=float(input()) cg=float(input()) print(round(km/cg,3),"km/l")
normal
{ "blob_id": "db33f7386d1eacbfbfd29aa367df310c557ae864", "index": 8520, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(round(km / cg, 3), 'km/l')\n", "step-3": "km = float(input())\ncg = float(input())\nprint(round(km / cg, 3), 'km/l')\n", "step-4": "km=float(input())\ncg=float(input())\nprint(r...
[ 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 ]
""" Author: Alan Danque Date: 20210323 Purpose:Final Data Wrangling, strips html and punctuation. """ from sklearn.tree import export_graphviz import pydot import pickle from pathlib import Path import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from sklearn.ensemble import ...
normal
{ "blob_id": "b9678b447bc6e7c4e928ffa6b8cd58639e41a801", "index": 2688, "step-1": "<mask token>\n", "step-2": "<mask token>\nresults_dir.mkdir(parents=True, exist_ok=True)\n<mask token>\nprint(data.shape)\n<mask token>\nprint(\"\"\"\nDataFrame Shape :\"\"\", shape)\nprint(\"\"\"\nNumber of rows :\"\"\", shape[0...
[ 0, 1, 2, 3, 4 ]
""" Package for haasplugin. """
normal
{ "blob_id": "20518302b6a67f8f1ac01f1adf4fe06ab2eaf280", "index": 3098, "step-1": "<mask token>\n", "step-2": "\"\"\"\nPackage for haasplugin.\n\"\"\"\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
''' Take list of iam users in a csv file like S_NO, IAM_User_Name,Programatic_Access,Console_Access,PolicyARN 1,XYZ, Yes,No,arn:aws:iam::aws:policy/AdministratorAccess 2.pqr,Yes,Yes,arn:aws:iam::aws:policy/AdministratorAccess 3.abc,No,Yes,arn:aws:iam::aws:policy/AmazonAPIGatewayInvokeFullAccess ''' import boto3,s...
normal
{ "blob_id": "00afab442f56d364c785324f816b52b4a6be609d", "index": 3078, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n session = boto3.session.Session(profile_name='dev_root')\n iam_re = session.resource(service_name='iam')\n for each in range(701, 1100):\n try:\n ...
[ 0, 1, 2, 3 ]
import rpy2.robjects as robjects from rpy2.robjects.packages import importr # print(robjects.__file__) import sys sys.path.append('./') import importlib import json import os from web_app.function.WordCould import word_img # importlib.reload(sys) # #sys.setdefaultencoding('gbk') class Ubiquitination(): def __ini...
normal
{ "blob_id": "a6ae4324580a8471969e0229c02ea1670728f25b", "index": 3767, "step-1": "<mask token>\n\n\nclass Ubiquitination:\n <mask token>\n\n def load_R(self):\n pass\n\n def data_path(self, name):\n exp_path = './web_app/data/disease/exp_data/{}.txt'.format(name)\n clinical_path = '...
[ 7, 8, 10, 12, 13 ]
import numpy as np import pandas as pd import logging import matplotlib.pyplot as plt from sklearn.impute import SimpleImputer from sklearn.preprocessing import LabelEncoder, OneHotEncoder, StandardScaler, RobustScaler from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline, make_pipeline f...
normal
{ "blob_id": "dc51ca86a49dbec6f714753782494f21d4b1591d", "index": 9091, "step-1": "<mask token>\n\n\ndef preprocess_data(train, test):\n global train_features, test_features, train_target, categorical, numerical\n train_features = train.drop(['Sales', 'Customers'], axis=1)\n train_target = train[['Sales'...
[ 2, 3, 4, 5, 6 ]
''' filter_items = lambda a : a[0] == 'b' fruits = ["apple", "banana", "pear", "orange"] result = filter(filter_items, fruits) print(list(result)) ''' ''' Given a list of integers, return the even integers in the list. input = [11, 4, 5, 8, 9, 2, 12] output = [4, 8, 2, 12] input = [3, 5, 7] output = [] ''' # even_...
normal
{ "blob_id": "7d9032b2426dbf3c285b99efa78be38d8f76ec24", "index": 1933, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(list(result))\n<mask token>\nprint(list(result))\n", "step-3": "<mask token>\neven_integers = lambda a: a % 2 == 0\ninput = [11, 4, 5, 8, 9, 2, 12]\nresult = filter(even_integers,...
[ 0, 1, 2, 3 ]
import discord from app.vars.client import client from app.helpers import delete, getUser, getGuild @client.command() async def inviteInfo(ctx, link): try: await delete.byContext(ctx) except: pass linkData = await client.fetch_invite(url=link) if (linkData.inviter): inviterData...
normal
{ "blob_id": "b8f9633ab3110d00b2f0b82c78ad047fca0d3eee", "index": 6999, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@client.command()\nasync def inviteInfo(ctx, link):\n try:\n await delete.byContext(ctx)\n except:\n pass\n linkData = await client.fetch_invite(url=link)\n ...
[ 0, 1, 2, 3 ]
import collections s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] d = collections.defaultdict(list) d2 = {'test':121} for k, v in s: d[k].append(v) d['test'].append('value') print list(d.items()) print d print d['blue'] print type(d) print type(d2)
normal
{ "blob_id": "15a894e6f94fc62b97d1614a4213f21331ef12a0", "index": 7843, "step-1": "import collections\ns = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]\n\nd = collections.defaultdict(list)\nd2 = {'test':121}\nfor k, v in s:\n d[k].append(v)\n\nd['test'].append('value')\n\nprint list(d.i...
[ 0 ]
# Ques1: # To create a program that asks the user to enter their name and their age # and prints out a message addressed to them that tells them the year that # they will turn 100 years old. Additionally, the program asks the user for # another number and prints out that many copies of the previous message on ...
normal
{ "blob_id": "948b793359555f98872e0bdbf6db970ed1ff3b83", "index": 7046, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(msg * copies)\n", "step-3": "<mask token>\nname = input('Enter your name : ')\nage = int(input('Enter your age : '))\nyear = int(100 - age + datetime.now().year)\ncopies = int(inp...
[ 0, 1, 2, 3, 4 ]
from django import forms from crawlr.models import Route, Category, UserProfile from django.contrib.auth.models import User class CategoryForm(forms.ModelForm): name = forms.CharField(max_length=128, help_text = "Please enter the category name.") views = forms.IntegerField(widget=for...
normal
{ "blob_id": "abf25cf3d4435754b916fa06e5e887b1e3589a1c", "index": 5073, "step-1": "<mask token>\n\n\nclass RouteForm(forms.ModelForm):\n error_messages = {'duplicate_title':\n 'Please enter a unique name for the crawl'}\n title = forms.CharField(max_length=128, help_text=\n 'Please enter the n...
[ 6, 7, 8, 9, 10 ]
from django.urls import path from django.contrib.auth import views as auth_views from . views import register, channel urlpatterns = [ path('register/', register, name="register"), path('channel/', channel, name="channel"), path('login/', auth_views.LoginView.as_view(template_name='user/login.html'), name...
normal
{ "blob_id": "d76c1507594bb0c1ed7a83e6c5961097c7fbf54a", "index": 9859, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('register/', register, name='register'), path(\n 'channel/', channel, name='channel'), path('login/', auth_views.\n LoginView.as_view(template_name='user/login.h...
[ 0, 1, 2, 3 ]
from socketserver import StreamRequestHandler, TCPServer from functools import partial class EchoHandler(StreamRequestHandler): def __init__(self, *args, ack, **kwargs): self.ack = ack super.__init__(*args, **kwargs) def handle(self): for line in self.rfile: self.wfile.wri...
normal
{ "blob_id": "7819e41d567daabe64bd6eba62461d9e553566b3", "index": 5393, "step-1": "<mask token>\n\n\nclass EchoHandler(StreamRequestHandler):\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass EchoHandler(StreamRequestHandler):\n\n def __init__(self, *args, ack, **kw...
[ 1, 3, 5, 6, 7 ]
from layout import UIDump import Tkinter from Tkinter import * from ScriptGenerator import ScriptGen class Divide_and_Conquer(): def __init__(self, XY): self.XY = XY self.user_val = 'None' self.flag = 'green' print self.XY def bounds_Compare(self, bounds, filename): """ Compares the bounds with Master...
normal
{ "blob_id": "7a65a5522db97a7a113a412883b640feede5bcee", "index": 909, "step-1": "from layout import UIDump\nimport Tkinter \nfrom Tkinter import *\nfrom ScriptGenerator import ScriptGen\n\nclass Divide_and_Conquer():\n\n\tdef __init__(self, XY):\n\t\tself.XY = XY\n\t\tself.user_val = 'None'\n\t\tself.flag = 'gre...
[ 0 ]
from django.shortcuts import render from django.shortcuts import redirect # Create your views here. from .forms import AddBookForm ,UpdateBookForm,BookCreateModelForm,SearchForm,RegistrationForm,SignInForm from book.models import Books from django.contrib.auth import authenticate,login,logout def book_add(reques...
normal
{ "blob_id": "aba2a0a262c14f286c278f21ba42871410c174f0", "index": 953, "step-1": "<mask token>\n\n\ndef book_add(request):\n if request.user.is_authenticated:\n context = {}\n if request.method == 'GET':\n form = BookCreateModelForm()\n context['form'] = form\n re...
[ 4, 6, 7, 8, 10 ]
from discord.ext import commands, tasks from discord.utils import get import discord import re import json import time import random import asyncio import os import datetime from live_ticker_scrape import wrangle_data from tokens import dev, dev1, es, nas, dow, us10y, dollar, vix, btc, eth, silver , link es_bot = d...
normal
{ "blob_id": "e57109f1c5c2e1468ef1cf9f10fba743633ca150", "index": 8094, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@es_bot.event\nasync def on_ready():\n print('es started')\n\n\n@nas_bot.event\nasync def on_ready():\n print('nas started')\n\n\n@dow_bot.event\nasync def on_ready():\n prin...
[ 0, 1, 2, 3, 4 ]
import numpy as np import matplotlib.pyplot as plt def sigmoid(X): """ Applies the logistic function to x, element-wise. """ return 1 / (1 + np.exp(-X)) def x_strich(X): return np.column_stack((np.ones(len(X)), X)) def feature_scaling(X): x_mean = np.mean(X, axis=0) x_std = np.std(X, axis=0) ...
normal
{ "blob_id": "36e7398f576aa1d298a20b4d4a27a7b93e3bd992", "index": 5482, "step-1": "<mask token>\n\n\ndef sigmoid(X):\n \"\"\" Applies the logistic function to x, element-wise. \"\"\"\n return 1 / (1 + np.exp(-X))\n\n\ndef x_strich(X):\n return np.column_stack((np.ones(len(X)), X))\n\n\n<mask token>\n\n\n...
[ 7, 9, 10, 11, 13 ]
def progress_format(user): json = dict() json["progres_id"] = user[0] json["percentage"] = user[1] json["user_id"] = user[2] json["technology"] = user[3] return json def progresses_format(users): json = dict() json["users_progresses"] = list() for user in users: ...
normal
{ "blob_id": "6ebf6bdfc6a4a1fe49f4eed1a2c1802f8adeef08", "index": 1195, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef progresses_format(users):\n json = dict()\n json['users_progresses'] = list()\n for user in users:\n json['users_progresses'].append(progress_format(user))\n re...
[ 0, 1, 2, 3, 4 ]
import sys n = int(input()) min_number = sys.maxsize max_number = -sys.maxsize for i in range(0, n): num = int(input()) if num > max_number: max_number = num if num < min_number: min_number = num print(f"Max number: {max_number}") print(f"Min number: {min_number}")
normal
{ "blob_id": "ac6f2287390bdad8fe20cdc73c0063f685970cfb", "index": 5289, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(0, n):\n num = int(input())\n if num > max_number:\n max_number = num\n if num < min_number:\n min_number = num\nprint(f'Max number: {max_number}')\n...
[ 0, 1, 2, 3, 4 ]
import datetime import subprocess from time import sleep from flask import render_template, redirect, request, url_for, flash, abort from dirkules import app, db, scheduler, app_version import dirkules.manager.serviceManager as servMan import dirkules.manager.driveManager as driveMan import dirkules.manager.cleaning as...
normal
{ "blob_id": "ab27780b19db6854855af51eea063f07d9eb7302", "index": 3553, "step-1": "<mask token>\n\n\n@app.errorhandler(500)\ndef internal_server_error(e):\n return render_template('500.html', error=str(e))\n\n\n<mask token>\n\n\n@app.route('/pools', methods=['GET'])\ndef pools():\n return render_template('p...
[ 5, 8, 9, 11, 13 ]
#!/usr/bin/env python import sys import subprocess import mystem def run(args, fin=sys.stdin, fout=sys.stdout, ferr=sys.stderr, input_data=None): '''\ Generic wrapper for MyStem ''' mystem_path = mystem.util.find_mystem() # make utf-8 a default encoding if '-e' not in args: args.exten...
normal
{ "blob_id": "d4a4ea67a06107ad7ea18bb21fb1ec9e74ccd7c1", "index": 7187, "step-1": "<mask token>\n\n\ndef main(args):\n return run(args)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef run(args, fin=sys.stdin, fout=sys.stdout, ferr=sys.stderr, input_data=None\n ):\n \"\"\" Generic wrapper for ...
[ 1, 2, 3, 4, 5 ]
from collections import deque def my_queue(n=5): return deque([], n) pass if __name__ == '__main__': mq = my_queue() for i in range(10): mq.append(i) print((i, list(mq))) """Queue size does not go beyond n int, this outputs: (0, [0]) (1, [0, 1]) (2, [0, 1, 2]) (3,...
normal
{ "blob_id": "499baaa8c739c1bd846edc944e510542d76bbed5", "index": 9312, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef my_queue(n=5):\n return deque([], n)\n pass\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef my_queue(n=5):\n return deque([], n)\n pass\n\n\nif __name__ == '_...
[ 0, 1, 2, 3 ]
import pandas as pd import matplotlib.pyplot as plt import math import seaborn as sns import numpy as np suv_data=pd.read_csv("F:/Development/Machine Learning/suv-data/suv_data.csv") print(suv_data.head(10)) print("the no of passengers in the list is"+str(len(suv_data.index))) sns.countplot(x="Purchased",data=suv_data...
normal
{ "blob_id": "c955057d7f8d5289898ecb96a290f5a7d241b787", "index": 6440, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(suv_data.head(10))\nprint('the no of passengers in the list is' + str(len(suv_data.index)))\nsns.countplot(x='Purchased', data=suv_data)\nsns.countplot(x='Purchased', hue='Gender', ...
[ 0, 1, 2, 3, 4 ]
class Graph: def __init__(self, num_vertices): self.adj_list = {} for i in range(num_vertices): self.adj_list[i] = [] def add_vertice(self, source): self.adj_list[source] = [] def add_edge(self, source, dest): self.adj_list[source].append(dest) def print_g...
normal
{ "blob_id": "ae5ec7919b9de4fbf578547c31837add32826f60", "index": 7448, "step-1": "class Graph:\n\n def __init__(self, num_vertices):\n self.adj_list = {}\n for i in range(num_vertices):\n self.adj_list[i] = []\n\n def add_vertice(self, source):\n self.adj_list[source] = []\n...
[ 5, 6, 7, 8 ]
A,B=map(str,input().split()) if(A>B): print(A) elif(B>A): print(B) else: print(AorB)
normal
{ "blob_id": "8cbe78863de535a5b83eacebe67402569b4015fa", "index": 9189, "step-1": "<mask token>\n", "step-2": "<mask token>\nif A > B:\n print(A)\nelif B > A:\n print(B)\nelse:\n print(AorB)\n", "step-3": "A, B = map(str, input().split())\nif A > B:\n print(A)\nelif B > A:\n print(B)\nelse:\n ...
[ 0, 1, 2, 3 ]
import requests from requests.auth import HTTPBasicAuth def __run_query(self, query): URL = 'https://api.github.com/graphql' request = requests.post(URL, json=query,auth=HTTPBasicAuth('gleisonbt', 'Aleister93')) if request.status_code == 200: return request.json() else: ...
normal
{ "blob_id": "fa511411e59880fd80fba0ccc49c95d42cb4b78d", "index": 6962, "step-1": "<mask token>\n\n\ndef __run_query(self, query):\n URL = 'https://api.github.com/graphql'\n request = requests.post(URL, json=query, auth=HTTPBasicAuth('gleisonbt',\n 'Aleister93'))\n if request.status_code == 200:\n...
[ 1, 2, 3, 4, 5 ]
from .score_funcs import * from cryptonita.fuzzy_set import FuzzySet from cryptonita.helpers import are_bytes_or_fail def scoring(msg, space, score_func, min_score=0.5, **score_func_params): ''' Run the score function over the given message and over a parametric value x. Return all the values x as a Fuzz...
normal
{ "blob_id": "99048ddb3f42382c8b8b435d832a45011a031cf1", "index": 8537, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef scoring(msg, space, score_func, min_score=0.5, **score_func_params):\n \"\"\" Run the score function over the given message and over a parametric\n value x. Return all t...
[ 0, 1, 2, 3 ]
import requests import os import numpy as np from bs4 import BeautifulSoup from nltk import word_tokenize from collections import Counter import random from utils import save_pickle root = 'data' ratios = [('train', 0.85), ('valid', 0.05), ('test', 0.1)] max_len = 64 vocab_size = 16000 data = [] path = os.path.joi...
normal
{ "blob_id": "977841e0bb73cec879fbb1868f1e64102c6d8c1a", "index": 2119, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor topic in topics:\n i += 1\n arts = os.listdir(os.path.join(path, topic))\n j = 0\n for art in arts:\n j += 1\n with open(os.path.join(path, topic, art), enco...
[ 0, 1, 2, 3, 4 ]
import nltk import A from collections import defaultdict from nltk.align import Alignment, AlignedSent class BerkeleyAligner(): def __init__(self, align_sents, num_iter): self.t, self.q = self.train(align_sents, num_iter) # TODO: Computes the alignments for align_sent, using this model's parameters. Return...
normal
{ "blob_id": "bf40b516e202af14469cd4012597ba412e663f56", "index": 5898, "step-1": "import nltk\nimport A\nfrom collections import defaultdict\nfrom nltk.align import Alignment, AlignedSent\n\nclass BerkeleyAligner():\n\n def __init__(self, align_sents, num_iter):\n\tself.t, self.q = self.train(align_sents, num...
[ 0 ]
#Opens the file that the user specifies fileopen = open(input("Please enter the name of the file that you wish to open."), 'r') #Reads the lines within the file and determines the length of the file lines = fileopen.readlines() count = len(lines) #Count is how long the file is, so number is the index values basically...
normal
{ "blob_id": "258b28153124ce42578c9eede429354069d8a7d6", "index": 2869, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile number < count:\n print(number, '.', lines[number])\n number = number + 1\nfileopen.close()\n", "step-3": "fileopen = open(input(\n 'Please enter the name of the file tha...
[ 0, 1, 2, 3 ]
if __name__ == '__main__': import sys import os.path srcpath = sys.argv[1] if len(sys.argv) >= 1 else './' verfn = sys.argv[2] if len(sys.argv) >= 2 else None try : with open(os.path.join(srcpath,'.svn/entries'),'r') as fp: x = fp.read().s...
normal
{ "blob_id": "1ebf92cf40053e561b04a666eb1dd36f54999e2c", "index": 7324, "step-1": "\r\n\r\n\r\nif __name__ == '__main__':\r\n \r\n import sys\r\n import os.path\r\n \r\n srcpath = sys.argv[1] if len(sys.argv) >= 1 else './'\r\n verfn = sys.argv[2] if len(sys.argv) >= 2 else None\r\n \r\n t...
[ 0 ]
""" 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 ]
#!/usr/bin/env python ''' Usage: dep_tree.py [-h] [-v] [-p P] [-m component_map] repos_root top_dir [top_depfile] Parse design dependency tree and generate build scripts and other useful files positional arguments: repos_root repository root top_dir top level design directory top_depfile ...
normal
{ "blob_id": "ccfc78ae430f835244e0618afdeebe960c868415", "index": 6126, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n lCommandLineArgs = CommandLineParser().parse()\n lPathmaker = Pathmaker(lCommandLineArgs.root, lCommandLineArgs.top,\n lCommandLineArgs.componentmap, lComma...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python # encoding:utf-8 from selenium.webdriver.common.by import By import random import basePage # 门店入库button stock_in = (By.XPATH, "//android.widget.TextView[contains(@text,'门店入库')]") # 调拨入库button transfer_in = (By.XPATH, "//android.widget.TextView[contains(@text,'调拨入库')]") # 确认签收button take_receive = (By...
normal
{ "blob_id": "d1b025ddbf7d0ad48ff92a098d074820a3eb35ed", "index": 6723, "step-1": "<mask token>\n", "step-2": "<mask token>\nstock_in = By.XPATH, \"//android.widget.TextView[contains(@text,'门店入库')]\"\ntransfer_in = By.XPATH, \"//android.widget.TextView[contains(@text,'调拨入库')]\"\ntake_receive = By.ID, '%s:id/tak...
[ 0, 1, 2, 3 ]
import logging from exceptions.invalid_api_usage import InvalidAPIUsage from wgadget.endpoints.ep import EP class EPInfoLight(EP): NAME = 'info_light' URL = '/info' URL_ROUTE_PAR_PAYLOAD = '/' URL_ROUTE_PAR_URL = '/actuatorId/<actuatorId>' METHOD = 'GET' ATTR_ACTUATOR_ID = 'actuatorId' ...
normal
{ "blob_id": "e5abab3f718bbbd25dcfc49290383203d53248c3", "index": 9464, "step-1": "<mask token>\n\n\nclass EPInfoLight(EP):\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", "ste...
[ 1, 3, 4, 6, 8 ]
# from mini_imagenet_dataloader import MiniImageNetDataLoader import os os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" import matplotlib.pyplot as plt import torch import torch.nn as nn from tqdm import tqdm import torch.nn.functional as F from torchmeta.utils.gradient_based import gradient_update_parameters from libs.model...
normal
{ "blob_id": "e2a50fbd277ab868fbe71f9ff113a68a30b9f893", "index": 2523, "step-1": "<mask token>\n\n\ndef ModelConvMiniImagenet(out_features, hidden_size=84):\n return MetaConvModel(3, out_features, hidden_size=hidden_size,\n feature_size=5 * 5 * hidden_size)\n\n\n<mask token>\n", "step-2": "<mask toke...
[ 1, 2, 4, 5, 6 ]
import cv2 import numpy as np img1 = cv2.imread('img0008.jpg') img2 = cv2.imread('img0009.jpg') #img3 = cv2.imread('img0009.jpg') img3 = np.zeros(img1.shape) iter = 51 def sumas(ux, uy, wx, wy, dx, dy, img_i, img_j): suma = 0 x = ux - wx y = uy - wy while x < ux + wx: while y < uy + wy: ...
normal
{ "blob_id": "749e6a1f807843c9e2591f51561174cc51668b11", "index": 1588, "step-1": "<mask token>\n\n\ndef sumas(ux, uy, wx, wy, dx, dy, img_i, img_j):\n suma = 0\n x = ux - wx\n y = uy - wy\n while x < ux + wx:\n while y < uy + wy:\n xdx = x + dx if x + dx < img1.shape[0] else x\n ...
[ 2, 3, 4, 5, 6 ]
import urllib.request def get_html(url): """ Returns the html of url or None if status code is not 200 """ req = urllib.request.Request( url, headers={ 'User-Agent': 'Python Learning Program', 'From': 'hklee310@gmail.com' } ) resp = urllib.reques...
normal
{ "blob_id": "4572e243f75ad92c04f5cdc0b454df7389183a6a", "index": 3238, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_html(url):\n \"\"\"\n Returns the html of url or None if status code is not 200\n \"\"\"\n req = urllib.request.Request(url, headers={'User-Agent':\n 'Pytho...
[ 0, 1, 2, 3 ]
import numpy as np from .build_processing_chain import build_processing_chain from collections import namedtuple from pprint import pprint def run_one_dsp(tb_data, dsp_config, db_dict=None, fom_function=None, verbosity=0): """ Run one iteration of DSP on tb_data Optionally returns a value for optimizati...
normal
{ "blob_id": "efe2d6f5da36679b77de32d631cca50c2c1dd29e", "index": 5170, "step-1": "<mask token>\n\n\nclass ParGrid:\n <mask token>\n\n def __init__(self):\n self.dims = []\n\n def add_dimension(self, name, i_arg, value_strs, companions=None):\n self.dims.append(ParGridDimension(name, i_arg,...
[ 11, 14, 16, 18, 19 ]
#!/usr/bin/python3 """0. How many subs""" def number_of_subscribers(subreddit): """return the number of subscribers from an Reddit API""" import requests resInf = requests.get("https://www.reddit.com/r/{}/about.json" .format(subreddit), headers={"Us...
normal
{ "blob_id": "db1e3a109af2db2c8794a7c9c7dfb0c2ccee5800", "index": 932, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef number_of_subscribers(subreddit):\n \"\"\"return the number of subscribers from an Reddit API\"\"\"\n import requests\n resInf = requests.get('https://www.reddit.com/r/{}/...
[ 0, 1, 2 ]
# ------------------------------------------- # Created by: jasper # Date: 11/24/19 # -------------------------------------------- from os import path, mkdir class IOHandler: def __init__(self, directory, fName, data_instance): """Save the setup of a class instance or...
normal
{ "blob_id": "267276eab470b5216a2102f3e7616f7aecadcfe9", "index": 9428, "step-1": "<mask token>\n\n\nclass IOHandler:\n <mask token>\n\n def dump_data(self):\n \"\"\"save the data contained in data_instance, checking whether the\n directories already exist and asking whether to create them if ...
[ 3, 4, 5, 6, 7 ]
from ctypes import * import os import sys import time import datetime import subprocess import RPi.GPIO as GPIO from PIL import Image from PIL import ImageDraw from PIL import ImageFont #import Adafruit_GPIO as GPIO import Adafruit_GPIO.SPI as SPI import ST7735 as TFT import pigpio # use BCM pin define pin_meas = 24 ...
normal
{ "blob_id": "d250cc0aafdd48cb0eb56108d9c7148153cde002", "index": 6840, "step-1": "<mask token>\n", "step-2": "<mask token>\ntime.sleep(1)\n<mask token>\nif len(sys.argv) < 6:\n error_str = str(sys.argv[0]\n ) + ' led1_current led2_current led_stable_time int_time1 int_time2'\n print(error_str)\nel...
[ 0, 1, 2, 3, 4 ]
#-*- coding: utf-8 -*- ############################################################################# # # # Copyright (c) 2008 Rok Garbas <rok@garbas.si> # # ...
normal
{ "blob_id": "d0f9dd0a06023dd844b0bf70dff360f6bb46c152", "index": 4412, "step-1": "<mask token>\n\n\nclass MonthYearWidget(DateWidget):\n \"\"\" Month and year widget \"\"\"\n zope.interface.implementsOnly(IMonthYearWidget)\n klass = u'monthyear-widget'\n value = '', '', 1\n\n\n<mask token>\n", "ste...
[ 3, 4, 5, 6, 7 ]
import wx from six import print_ import os FONTSIZE = 10 class TextDocPrintout(wx.Printout): """ A printout class that is able to print simple text documents. Does not handle page numbers or titles, and it assumes that no lines are longer than what will fit within the page width. Those features a...
normal
{ "blob_id": "2790bd80949bafe4e98ab9aca9cf80a6a0f31490", "index": 6200, "step-1": "<mask token>\n\n\nclass TextDocPrintout(wx.Printout):\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\nclass PrintFrameworkSample(w...
[ 10, 14, 16, 19, 22 ]
from accessor import * from order import Order from copy import deepcopy import pandas as pd import numpy as np import util class Broker: def __init__(self, equity): self.execute = Execute(equity) # Execute def make_order(self, unit, limit_price, stop_loss, stop_profit): ord...
normal
{ "blob_id": "ca0aedcfb997299240870649823fb872e0d9f99a", "index": 6023, "step-1": "<mask token>\n\n\nclass Broker:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def liquidation(self, pos, price, date, commission):\n \"\"\"\n clean the last position\...
[ 9, 11, 12, 16, 17 ]