code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
"""Copied from http://svn.sourceforge.jp/svnroot/slothlib/CSharp/Version1/SlothLib/NLP/Filter/StopWord/word/Japanese.txt"""
STOP_WORDS = set(
"""
あそこ
あたり
あちら
あっち
あと
あな
あなた
あれ
いくつ
いつ
いま
いや
いろいろ
うち
おおまか
おまえ
おれ
がい
かく
かたち
かやの
から
がら
きた
くせ
ここ
こっち
こと
ごと
こちら
ごっちゃ
これ
これら
ごろ
さまざま
さらい
さん
しかた
しよう
すか
ずつ
すね
すべて
ぜんぶ
そう
そこ
そちら
そっち... | normal | {
"blob_id": "254afebcc909c805d1e4972a0910eb4451d1e64e",
"index": 8704,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nSTOP_WORDS = set(\n \"\"\"\nあそこ\nあたり\nあちら\nあっち\nあと\nあな\nあなた\nあれ\nいくつ\nいつ\nいま\nいや\nいろいろ\nうち\nおおまか\nおまえ\nおれ\nがい\nかく\nかたち\nかやの\nから\nがら\nきた\nくせ\nここ\nこっち\nこと\nごと\nこちら\nごっちゃ\nこれ\nこれら\nごろ\nさま... | [
0,
1,
2
] |
from datetime import *
import datetime
import time
time_one = datetime.time(1, 2, 3)
print("Time One :: ", time_one)
time_two = datetime.time(hour=23, minute=59, second=59, microsecond=99)
print("Time Two :: ", time_two)
date_one = datetime.date(month=3, year=2019, day=31)
print("Date One :: ", date_one)
today = dat... | normal | {
"blob_id": "1ed7dba63db38e53a1dc5fac3c36f0dd98075c1f",
"index": 4305,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Time One :: ', time_one)\n<mask token>\nprint('Time Two :: ', time_two)\n<mask token>\nprint('Date One :: ', date_one)\n<mask token>\nprint('Today :: ', today, today.timetuple())\n... | [
0,
1,
2,
3,
4
] |
"""
Carl Bunge
Washington State University
June 2018
Adapted from @author: Luka Denies from TU Delft.
Changelog:
11/2017 - Integration of CoolProp
06/2018 - Update to OpenFOAM-5.x (Mass-based thermodynamics (for example: cpMcv to CpMCv))
03/2019 - Update to include parahydrogen properties from Refprop
"""
import Co... | normal | {
"blob_id": "7ac15f422ca2cd0d30e936b7dd17c96e1f3abff0",
"index": 8429,
"step-1": "\"\"\"\nCarl Bunge\nWashington State University\nJune 2018\n\nAdapted from @author: Luka Denies from TU Delft.\n\nChangelog:\n11/2017 - Integration of CoolProp\n06/2018 - Update to OpenFOAM-5.x (Mass-based thermodynamics (for examp... | [
0
] |
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 6 12:20:45 2017
@author: 7
"""
from os import listdir
from PIL import Image as PImage
from scipy import misc
import numpy as np
from Image_loader import LoadImages
"""
def LoadImages(path):
# return array of images
imagesList = listdir(path)
... | normal | {
"blob_id": "9cad36de6231f310ef9022f16f6ed0da83a003b3",
"index": 9757,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef ModifyImages(path, path1):\n imagesList = listdir(path)\n for image in imagesList:\n old_img = PImage.open(path + image)\n old_size = old_img.size\n new... | [
0,
1,
2,
3
] |
"""
Python shell for Diofant.
This is just a normal Python shell (IPython shell if you have the
IPython package installed), that adds default imports and run
some initialization code.
"""
import argparse
import ast
import atexit
import code
import os
import readline
import rlcompleter
from diofant.interactive.sessio... | normal | {
"blob_id": "80e395715d3ae216beb17e7caed1d8d03c5c56de",
"index": 9943,
"step-1": "<mask token>\n\n\ndef main():\n args, ipython_args = parser.parse_known_args()\n lines = ['from diofant import *', 'init_printing()',\n \"a, b, c, d, t, x, y, z = symbols('a:d t x:z')\",\n \"k, m, n = symbols('k... | [
1,
2,
3,
4,
5
] |
import numpy as np
from flask import Flask,request,render_template
import pickle
from werkzeug.serving import run_simple
app=Flask(__name__,template_folder='template')
model=pickle.load(open("model.pkl",'rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict',me... | normal | {
"blob_id": "02b760b16cdcd42f8d8d7222b439da87fb8076a3",
"index": 4959,
"step-1": "<mask token>\n\n\n@app.route('/predict', methods=['POST'])\ndef predict():\n arr = [int(x) for x in request.form.values()]\n arr2 = [np.array(arr)]\n output = model.predict(arr2)\n return render_template('index.html', p... | [
1,
3,
4,
5,
6
] |
import numpy as np
import os
import sys
file_path = sys.argv[1]
triplets = np.loadtxt(os.path.join(file_path, "kaggle_visible_evaluation_triplets.txt"),
delimiter="\t", dtype="str")
enum_users = np.ndenumerate(np.unique(triplets[:, 0]))
print(enum_users)
triplets[triplets[:, 0] == user... | normal | {
"blob_id": "f3d9e783491916e684cda659afa73ce5a6a5894a",
"index": 4063,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(enum_users)\n<mask token>\nprint(triplets)\n",
"step-3": "<mask token>\nfile_path = sys.argv[1]\ntriplets = np.loadtxt(os.path.join(file_path,\n 'kaggle_visible_evaluation_trip... | [
0,
1,
2,
3,
4
] |
def maxProduct(self, A):
size= len(A)
if size==1:
return A[0]
Max=[A[0]]
Min=[A[0]]
for i in range(1,size):
Max.append(max(max(Max[i-1]*A[i],Min[i-1]*A[i]),A[i]))
Min.append(min(min(Max[i-1]*A[i],Min[i-1]*A[i]),A[i]))
tmax=Max[0]
... | normal | {
"blob_id": "1fafbc1e415b5089afcd2976d4f0dc2aa1c5a144",
"index": 1077,
"step-1": " def maxProduct(self, A):\n size= len(A)\n if size==1:\n return A[0]\n Max=[A[0]]\n Min=[A[0]]\n for i in range(1,size):\n Max.append(max(max(Max[i-1]*A[i],Min[i-1]*A[i]),... | [
0
] |
# Алексей Головлев, группа БСБО-07-19
def lucky(ticket):
def sum_(number):
number = str(number)
while len(number) != 6:
number = '0' + number
x = list(map(int, number))
return sum(x[:3]) == sum(x[3:])
return 'Счастливый' if sum_(ticket) == sum_(lastTicket) else 'Нес... | normal | {
"blob_id": "85ac851e28dba3816f18fefb727001b8e396cc2b",
"index": 5278,
"step-1": "<mask token>\n",
"step-2": "def lucky(ticket):\n\n def sum_(number):\n number = str(number)\n while len(number) != 6:\n number = '0' + number\n x = list(map(int, number))\n return sum(x[:... | [
0,
1,
2,
3,
4
] |
import sys
def main():
# String to format output
format_string = "%s %s %s %s %s %s %s %s %s\n"
while True:
# Read 14 lines at a time from stdin for wikipedia dataset
edit = [sys.stdin.readline() for i in range(14)]
# Break if we've reached the end of stdin
if edit[13] == "":
break
# Parse data from re... | normal | {
"blob_id": "f6b2169a4644f4f39bbdebd9bb9c7cc637b54f8b",
"index": 9920,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n format_string = '%s %s %s %s %s %s %s %s %s\\n'\n while True:\n edit = [sys.stdin.readline() for i in range(14)]\n if edit[13] == '':\n br... | [
0,
1,
2,
3,
4
] |
from django.db import models
class TamLicense(models.Model):
license = models.TextField("Inserisci qui il tuo codice licenza.")
| normal | {
"blob_id": "1daecce86769e36a17fe2935f89b9266a0197cf0",
"index": 3942,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TamLicense(models.Model):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TamLicense(models.Model):\n license = models.TextField('Inserisci qui il tuo codice licen... | [
0,
1,
2,
3,
4
] |
button6 = Button(tk,text=" ",font=('Times 26 bold'), heigh = 4, width = 8, command=lambda:checker(button6))
button6.grid(row=2, column=2,sticky = S+N+E+W)
button7 = Button(tk,text=" ",font=('Times 26 bold'), heigh = 4, width = 8, command=lambda:checker(button7))
button7.grid(row=3, column=0,sticky = S+N+E+W)
button8 = ... | normal | {
"blob_id": "e543c7f7f1b249e53b8ebf82641ec398abf557af",
"index": 477,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nbutton6.grid(row=2, column=2, sticky=S + N + E + W)\n<mask token>\nbutton7.grid(row=3, column=0, sticky=S + N + E + W)\n<mask token>\nbutton8.grid(row=3, column=1, sticky=S + N + E + W)\n<... | [
0,
1,
2,
3
] |
G = 1000000000
M = 1000000
K = 1000
| normal | {
"blob_id": "f765f54a89a98a5f61c70a37379860f170444c0a",
"index": 4069,
"step-1": "<mask token>\n",
"step-2": "G = 1000000000\nM = 1000000\nK = 1000\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
no=int(input("enter no:"))
rev=0
while no!=0:
r=no%10
no=no//10
rev=rev*10+r
print("reverse no is:",rev)
| normal | {
"blob_id": "b2371f9c774c605a52ff1a4fae2dd44a856076aa",
"index": 5522,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile no != 0:\n r = no % 10\n no = no // 10\n rev = rev * 10 + r\nprint('reverse no is:', rev)\n",
"step-3": "no = int(input('enter no:'))\nrev = 0\nwhile no != 0:\n r = no... | [
0,
1,
2,
3
] |
def minutes to hours(minutes) :
hours = minutes/60
return hours
print(minutes to hours(70))
| normal | {
"blob_id": "a1b33d0a8a074bc7a2a3e2085b1ff01267e00d3b",
"index": 8815,
"step-1": "def minutes to hours(minutes) :\r\n hours = minutes/60\r\n return hours\r\n\r\nprint(minutes to hours(70))\r\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
import random
import datetime
import os
import time
import json
#
l_target_path = "E:/code/PYTHON_TRAINING/Training/Apr2020/BillingSystem/bills/"
while True:
l_store_id = random.randint(1, 4)
now = datetime.datetime.now()
l_bill_id = now.strftime("%Y%m%d%H%M%S")
# Generate Random Date
start_da... | normal | {
"blob_id": "fad2ad89e4d0f04fad61e27048397a5702870ca9",
"index": 6177,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n l_store_id = random.randint(1, 4)\n now = datetime.datetime.now()\n l_bill_id = now.strftime('%Y%m%d%H%M%S')\n start_date = datetime.date(2000, 1, 1)\n end_da... | [
0,
1,
2,
3,
4
] |
from django.apps import AppConfig
class GerenciaLedsConfig(AppConfig):
name = 'gerencia_leds'
| normal | {
"blob_id": "0754103c2d8cef0fd23b03a8f64ade8f049bce48",
"index": 4890,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass GerenciaLedsConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass GerenciaLedsConfig(AppConfig):\n name = 'gerencia_leds'\n",
"step-4": "from django... | [
0,
1,
2,
3
] |
from django.db import models
from datetime import datetime
class Message(models.Model):
text = models.CharField(max_length=200)
votes = models.IntegerField()
date_added = models.DateTimeField(default=datetime.now)
score = models.BigIntegerField()
next_vote = models.IntegerField(default=3600) # 8640... | normal | {
"blob_id": "7159b447ed6fcb2005f63c7b7359970defbc9d43",
"index": 1496,
"step-1": "<mask token>\n\n\nclass Message(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Message(models.Model):\n <mask t... | [
1,
2,
3,
4,
5
] |
# -*- coding: utf-8 -*-
# Author:sen
# Date:2020/4/2 14:15
class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def find(root, val):
if not root:
return None
if val < root.val:
return find(root.left, val)
elif val > root.va... | normal | {
"blob_id": "9e525eccbf10a710d6f37c903370cc10f7d2c62b",
"index": 8475,
"step-1": "class TreeNode:\n <mask token>\n\n\n<mask token>\n",
"step-2": "class TreeNode:\n\n def __init__(self, val):\n self.val = val\n self.left = None\n self.right = None\n\n\ndef find(root, val):\n if not... | [
1,
6,
7,
9,
10
] |
'''
A linear regression learning algorithm example using TensorFlow library.
Author: Aymeric Damien
Project: https://github.com/aymericdamien/TensorFlow-Examples/
'''
from __future__ import print_function
import tensorflow as tf
import argparse
import numpy
rng = numpy.random
#"python tf_cnn_benchmarks.py --device... | normal | {
"blob_id": "2e8d39d6d72672de8e4eac8295b90d68b1dff938",
"index": 9007,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nparser.add_argument('--batch_size', help='batch_size', required=False,\n default=32)\nparser.add_argument('--data_size', help='data_size', required=False,\n default=1700)\nparser.ad... | [
0,
1,
2,
3,
4
] |
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""The GIFT module provides basic functions for interfacing with some of the GIFT tools.
In order to use the standalone MCR version of GIFT, you need to ensure that
the following commands are executed at ... | normal | {
"blob_id": "fef1cf75de8358807f29cd06d2338e087d6f2d23",
"index": 9162,
"step-1": "<mask token>\n\n\nclass GIFTCommand(BaseInterface):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, **inputs):\n super(GIFTCommand, self).... | [
8,
10,
15,
16,
18
] |
import os
import sys
import glob
import shutil
import json
import codecs
from collections import OrderedDict
def getRegionClass(image_path, data_id, imgName):
region_class = ['nosmoke_background', 'nosmoke_face', 'nosmoke_suspect', 'nosmoke_cover', 'smoke_hand', 'smoke_nohand', 'smoke_hard']
label_class = ['nosmok... | normal | {
"blob_id": "75833617996549167fa157ff78cc1a11f870784f",
"index": 8639,
"step-1": "<mask token>\n\n\ndef getRegionClass(image_path, data_id, imgName):\n region_class = ['nosmoke_background', 'nosmoke_face', 'nosmoke_suspect',\n 'nosmoke_cover', 'smoke_hand', 'smoke_nohand', 'smoke_hard']\n label_clas... | [
1,
2,
3,
4,
5
] |
""" Soil and water decomposition rates """
import math
from water_balance import WaterBalance
from utilities import float_eq, float_lt, float_le, float_gt, float_ge, clip
__author__ = "Martin De Kauwe"
__version__ = "1.0 (25.02.2011)"
__email__ = "mdekauwe@gmail.com"
class DecompFactors(object):
""" Calcula... | normal | {
"blob_id": "74f3b4001a0520a25a314ff537719b679ba0fca4",
"index": 2578,
"step-1": "<mask token>\n\n\nclass DecompFactors(object):\n <mask token>\n\n def __init__(self, control, params, state, fluxes, met_data):\n \"\"\"\n Parameters\n ----------\n control : integers, structure\n ... | [
2,
5,
6,
7,
8
] |
from django.db import models
from django.contrib import admin
from django.utils import timezone
class Libros(models.Model):
ISBN = models.CharField(max_length=13,primary_key=True)
Titulo = models.CharField(max_length=15)
# Portada = models.ImageField(upload_to='imagen/')
Autor = models.CharField(max_le... | normal | {
"blob_id": "86fdea2ae8e253aa4639bb3114de70c693536760",
"index": 1046,
"step-1": "<mask token>\n\n\nclass Prestamo(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass PrestamoInLine(admin.TabularInline):\n model = Prestamo\n extra = 1\n\n\ncla... | [
7,
8,
12,
13,
16
] |
numbers = [3, 7, 5]
maxNumber = 0
for number in numbers:
if maxNumber < number:
maxNumber = number
print maxNumber | normal | {
"blob_id": "2d9d66ea8a95285744b797570bfbeaa17fdc922a",
"index": 4036,
"step-1": "numbers = [3, 7, 5]\nmaxNumber = 0\nfor number in numbers:\n if maxNumber < number:\n maxNumber = number\n\nprint maxNumber",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
... | [
0
] |
print(input()in[str(i**i+i)for i in range(11)])
num = int(input())
suma = 0
x = 0
while(suma < num):
x += 1
suma = x**x + x
print(True if suma == num else False
| normal | {
"blob_id": "20fe9b68e65f6f017897bfa8e99d0c21ba1617fb",
"index": 1522,
"step-1": "print(input()in[str(i**i+i)for i in range(11)])\n\n\n\nnum = int(input())\nsuma = 0\nx = 0\nwhile(suma < num):\n x += 1\n suma = x**x + x\nprint(True if suma == num else False\n\n\n",
"step-2": null,
"step-3": null,
"st... | [
0
] |
#
# 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, software
# ... | normal | {
"blob_id": "43e721ac45570e4f9ab9c1970abee3da6db40afa",
"index": 156,
"step-1": "<mask token>\n\n\n@six.add_metaclass(abc.ABCMeta)\nclass ParallelMigrationStrategy(base.BaseStrategy):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ... | [
11,
13,
16,
18,
19
] |
#!/usr/bin/env python
import serial
from action import Action
import math
comm = serial.Serial("/dev/ttyACM3", 115200, timeout=1)
#comm = None
robot = Action(comm)
from flask import Flask
from flask import send_from_directory
import os
static_dir = os.path.join(os.getcwd(), "ControlApp")
print "serving from " + sta... | normal | {
"blob_id": "54a6405e3447d488aa4fca88159ccaac2506df2c",
"index": 5995,
"step-1": "#!/usr/bin/env python\n\nimport serial\nfrom action import Action\nimport math\n\ncomm = serial.Serial(\"/dev/ttyACM3\", 115200, timeout=1)\n#comm = None\nrobot = Action(comm)\n\nfrom flask import Flask\nfrom flask import send_from... | [
0
] |
from selenium.webdriver.common.by import By
class BasePageLocators:
LOGIN_LINK = (By.CSS_SELECTOR, "#login_link")
BASKET_LINK = (By.CSS_SELECTOR, '[class="btn btn-default"]:nth-child(1)')
USER_ICON = (By.CSS_SELECTOR, ".icon-user")
class LoginPageLocators:
LOG_IN_FORM = (By.CSS_SELECTOR, "#login_for... | normal | {
"blob_id": "5d3b9005b8924da36a5885201339aa41082034cd",
"index": 8692,
"step-1": "<mask token>\n\n\nclass BasketPageLocators:\n BASKET_STATUS = By.CSS_SELECTOR, '#content_inner'\n NAME_OF_ADDED_SHIPMENT = (By.CSS_SELECTOR,\n '#messages .alert:nth-child(1) > .alertinner strong')\n PRICE_OF_ADDED_S... | [
4,
5,
6,
8,
10
] |
def unique(lisst):
setlisst = set(lisst)
return len(setlisst)
print(unique({4, 5, 1, 1, 3}))
| normal | {
"blob_id": "42d26ef51bb4dafc8a0201a828652e166a3905e4",
"index": 7339,
"step-1": "<mask token>\n",
"step-2": "def unique(lisst):\n setlisst = set(lisst)\n return len(setlisst)\n\n\n<mask token>\n",
"step-3": "def unique(lisst):\n setlisst = set(lisst)\n return len(setlisst)\n\n\nprint(unique({4, ... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-29 03:38
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('django_otp', '0001_initial'),
]
operations = [
migrations.AddField(
... | normal | {
"blob_id": "d45ca839a24093266c48e5f97164b160190b154d",
"index": 2133,
"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 = [('django_otp'... | [
0,
1,
2,
3,
4
] |
import matplotlib.pyplot as plt
import cv2
# 0
img = cv2.imread('test.jpg', cv2.IMREAD_GRAYSCALE)
# IMREAD_COLOR = 1
# IMREAD_UNCHANGED = -1
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# cv2.imwrite('watchgray,png', img)
plt.imshow(img, cmap='gray', interpolation='bicu... | normal | {
"blob_id": "34ccaaf5eb47afd556588cd94cddbddaee1f0b53",
"index": 2851,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncv2.imshow('image', img)\ncv2.waitKey(0)\ncv2.destroyAllWindows()\nplt.imshow(img, cmap='gray', interpolation='bicubic')\nplt.show()\n",
"step-3": "<mask token>\nimg = cv2.imread('test.... | [
0,
1,
2,
3,
4
] |
#!/usr/local/autopkg/python
"""
JamfExtensionAttributeUploader processor for uploading extension attributes
to Jamf Pro using AutoPkg
by G Pugh
"""
import os
import sys
from time import sleep
from xml.sax.saxutils import escape
from autopkglib import ProcessorError # pylint: disable=import-error
# to use a base... | normal | {
"blob_id": "31f91e67d0adde0a984a6d162ea5607f06e9208e",
"index": 9876,
"step-1": "<mask token>\n\n\nclass JamfExtensionAttributeUploader(JamfUploaderBase):\n description = (\n 'A processor for AutoPkg that will upload an Extension Attribute item to a Jamf Cloud or on-prem server.'\n )\n input... | [
4,
5,
6,
7,
8
] |
# Generated by Django 2.2.6 on 2019-10-10 07:02
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='cronjob',
fields=[
('id', m... | normal | {
"blob_id": "af523777e32c44112bd37a4b9dcbc0941f7e8236",
"index": 4242,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
import sys
from io import BytesIO
import telegram
from flask import Flask, request, send_file
from fsm import TocMachine
API_TOKEN = '375541027:AAFvLkySNkMSGgOl7PtsPIsJgnxophQpllQ'
WEBHOOK_URL = 'https://a140f4ad.ngrok.io/show-fsm'
app = Flask(__name__)
bot = telegram.Bot(token=API_TOKEN)
machine = TocMachine(
... | normal | {
"blob_id": "984efa858e782777472d84aab85471616a05b0e0",
"index": 2886,
"step-1": "<mask token>\n\n\ndef _set_webhook():\n status = bot.set_webhook(WEBHOOK_URL)\n if not status:\n print('Webhook setup failed')\n sys.exit(1)\n else:\n print('Your webhook URL has been set to \"{}\"'.fo... | [
3,
4,
5,
6,
7
] |
from django.test import TestCase, Client
from accounts.models import Account
from .data import account
from rest_framework import status
class TestAccountRequests(TestCase):
def setUp(self):
self.client = Client()
self.superuser = Account.objects.create_superuser(**account)
def test_register... | normal | {
"blob_id": "3d43bf0d0ca1df06b3647a33f88cee067eeff9f4",
"index": 2605,
"step-1": "<mask token>\n\n\nclass TestAccountRequests(TestCase):\n\n def setUp(self):\n self.client = Client()\n self.superuser = Account.objects.create_superuser(**account)\n <mask token>\n <mask token>\n",
"step-2"... | [
2,
3,
4,
5,
6
] |
from django.db import models
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from model_utils.models import TimeStampedModel
user = settings.AUTH_USER_MODEL
commment_lenght = settings.COMMENT_LENGTH
# Entity Comment
class Comment(TimeStampedModel):
"""
Text comment po... | normal | {
"blob_id": "68ea462f56ba029a7c977d9c8b94e6f913336fb7",
"index": 4680,
"step-1": "<mask token>\n\n\nclass Cigarette(models.Model):\n <mask token>\n user = models.ForeignKey(user, blank=False, null=False, related_name=\n 'user_cigarettes')\n cigarette_date = models.DateField(_('cigarette date'), a... | [
6,
12,
16,
17,
19
] |
# 15650번 수열 2번째
n, m = list(map(int, input().split()))
arr = [i for i in range(1,n+1)]
check = []
def seq(ctn, array, l):
if sorted(check) in array:
return
# if ctn == m:
# # l+=1
# # print('ctn :',ctn,' check :',sorted(check))
# array.append(sorted(check))
# for k in ... | normal | {
"blob_id": "dc5d56d65417dd8061a018a2f07132b03e2d616e",
"index": 5127,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef seq(ctn, array, l):\n if sorted(check) in array:\n return\n for i in range(n):\n l += 1\n check.append(arr[i])\n seq(ctn + 1, array, l)\n ... | [
0,
1,
2,
3,
4
] |
import logging
from blogofile.cache import bf
github = bf.config.controllers.github
from github2.client import Github
github_api = Github()
config = {
"name": "Github",
"description": "Makes a nice github project listing for the sidebar",
"priority": 95.0,
}
def get_list(user):
"""
Each item... | normal | {
"blob_id": "ee2cf6c472fa955ba3718bf3a3f60b66811b4907",
"index": 4705,
"step-1": "<mask token>\n\n\ndef get_list(user):\n \"\"\"\n Each item in the list has:\n name, url, description, forks, watchers, homepage, open_issues\n\n \"\"\"\n return [g for g in github_api.repos.list(user) if not g.fo... | [
1,
2,
3,
4,
5
] |
import sys
try:
myfile = open("mydata.txt",encoding ="utf-8")
except FileNotFoundError as ex:
print("file is not found")
print(ex.args)
else:
print("file :",myfile.read())
myfile.close()
finally :
print("finished working")
| normal | {
"blob_id": "8bf75bf3b16296c36c34e8c4c50149259d792af7",
"index": 4319,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n myfile = open('mydata.txt', encoding='utf-8')\nexcept FileNotFoundError as ex:\n print('file is not found')\n print(ex.args)\nelse:\n print('file :', myfile.read())\n ... | [
0,
1,
2,
3
] |
import unittest
from LempelZivWelchDecoder import LempelZivWelchDecoder
class TestLempelZivWelchDecoder(unittest.TestCase):
def test_decode(self):
test_value = ['t', 256, 257, 'e', 's', 260, 't', '1']
run_length_decoder = LempelZivWelchDecoder()
self.assertRaises(ValueError,
... | normal | {
"blob_id": "8126af930ec75e2818455d959f00285bdc08c044",
"index": 1899,
"step-1": "<mask token>\n\n\nclass TestLempelZivWelchDecoder(unittest.TestCase):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass TestLempelZivWelchDecoder(unittest.TestCase):\n\n def test_decode(self):\n ... | [
1,
2,
3,
4,
5
] |
import ast
import datetime
import json
from base64 import b64encode
import requests
IMGUR_BASE = "https://api.imgur.com"
class Task:
"""
A class used to represent a job
...
Attributes
----------
queue : list
the list of all urls
pending : list
the name of all pending urls... | normal | {
"blob_id": "63ee99012089dcb0e5b41860c95e13fff52c6731",
"index": 1546,
"step-1": "<mask token>\n\n\nclass Task:\n <mask token>\n\n def __init__(self):\n \"\"\"\n Create the object\n :rtype: object\n \"\"\"\n self.queue = list()\n self.pending = []\n self.com... | [
8,
9,
12,
13,
14
] |
# Copyright 2019 PerfKitBenchmarker Authors. All rights reserved.
#
# 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 appli... | normal | {
"blob_id": "9cebce7f97a1848885883692cd0f494cce6bae7f",
"index": 5263,
"step-1": "<mask token>\n\n\nclass RedshiftClusterSubnetGroup(resource.BaseResource):\n <mask token>\n\n def __init__(self, cmd_prefix):\n super(RedshiftClusterSubnetGroup, self).__init__(user_managed=False)\n self.cmd_pre... | [
4,
5,
6,
7,
8
] |
# coding=utf-8
# Copyright 2016 Mystopia.
from __future__ import (absolute_import, division, generators, nested_scopes,
print_function, unicode_literals, with_statement)
from django.db.models.signals import m2m_changed, post_save
from django.dispatch import receiver
from dicpick.models import... | normal | {
"blob_id": "065a566b3e520c14f20d0d7d668ec58404d6e11b",
"index": 494,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@receiver(post_save, sender=TaskType)\ndef create_task_instances(sender, instance, **kwargs):\n \"\"\"Ensure that there is a task instance for each date in the range specified by th... | [
0,
1,
2,
3,
4
] |
# write dictionary objects to be stored in a binary file
import pickle
#dictionary objects to be stored in a binary file
emp1 = {"Empno" : 1201, "Name" : "Anushree", "Age" : 25, "Salary" : 47000}
emp2 = {"Empno" : 1211, "Name" : "Zoya", "Age" : 30, "Salary" : 48000}
emp3 = {"Empno" : 1251, "Name" : "Simarjeet", "Age"... | normal | {
"blob_id": "23937ae531cc95069a1319f8c77a459ba7645363",
"index": 4331,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npickle.dump(emp1, empObj)\npickle.dump(emp2, empObj)\npickle.dump(emp3, empObj)\npickle.dump(emp4, empObj)\nprint('Successfully written four dictionaries')\nempObj.close()\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# @Time : 2020/3/4 10:34
# @Author : YYLin
# @Email : 854280599@qq.com
# @File : Skip_GAN.py
from Dataload import load_anime_old, save_images, load_CelebA
from Srresnet_Model import Generator_srresnet, Discriminator_srresnet
import tensorflow as tf
import numpy as np
import sys... | normal | {
"blob_id": "d3b00a8d410248aedb1c43354e89ccc298b56a3c",
"index": 7693,
"step-1": "<mask token>\n\n\nclass Skip_GAN(object):\n\n def __init__(self, sess, epoch, batch_size, dataset_name, result_dir,\n z_dim, y_dim, checkpoint_dir, num_resblock, Cycle_lr, Class_weight,\n Resnet_weight):\n s... | [
2,
3,
4,
5,
6
] |
#!/usr/bin/env python
import os
import tempfile
import shutil
import math
import sys
import subprocess
from irank.config import IrankOptionParser, IrankApp
from irank import db as irank_db
STATUS = 0
def main():
p = IrankOptionParser('%prog -d DEST playlist_name [playlist_name ...]')
p.add_option('-d', '--dest', he... | normal | {
"blob_id": "df64d769ffba8cddac34282a526122e3c941249d",
"index": 245,
"step-1": "#!/usr/bin/env python\nimport os\nimport tempfile\nimport shutil\nimport math\nimport sys\nimport subprocess\n\nfrom irank.config import IrankOptionParser, IrankApp\nfrom irank import db as irank_db\nSTATUS = 0\n\ndef main():\n\tp =... | [
0
] |
import src.engine.functions.root_analyzer.main as main
from src.engine.functions.function import Function
class GetRootData(Function):
def __init__(self, data_display):
self.data_display = data_display
def call(self, args):
image_folder_path = args[0]
output_path = args[1]
sel... | normal | {
"blob_id": "e8ea307352805bf0b5129e2ad7f7b68c44e78fc9",
"index": 9118,
"step-1": "<mask token>\n\n\nclass GetRootData(Function):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass GetRootData(Function):\n\n def __init__(self, data_display):\n self.data_display = data_display\n... | [
1,
2,
3,
4,
5
] |
# -*- coding: GB18030 -*-
import inspect
import os,sys
import subprocess
from lib.common.utils import *
from lib.common.loger import loger
from lib.common import checker
from lib.common.logreader import LogReader
import shutil
from lib.common.XmlHandler import *
from lib.common.Dict import *
class baseModule(object):
... | normal | {
"blob_id": "a74d27d9e31872100b4f22512abe9de7d9277de7",
"index": 2970,
"step-1": "# -*- coding: GB18030 -*-\nimport inspect\nimport os,sys\nimport subprocess\nfrom lib.common.utils import *\nfrom lib.common.loger import loger\nfrom lib.common import checker\nfrom lib.common.logreader import LogReader\nimport shu... | [
0
] |
import pytesseract
from PIL import Image
import tensorflow as tf
from keras.models import load_model
from tensorflow import Graph
import os
import json
import cv2
import numpy as np
global class_graph
def classify(img, c_model):
#global class_graph
""" classifies images in a given folder using the 'model... | normal | {
"blob_id": "c7d51f6448400af5630bdc0c29493320af88288e",
"index": 7424,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef classify(img, c_model):\n \"\"\" classifies images in a given folder using the 'model'\"\"\"\n im_size = 128\n img = cv2.resize(img, (im_size, im_size))\n img = img.as... | [
0,
1,
2,
3,
4
] |
import sublime
import sublime_plugin
class PromptSurrounderCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.show_input_panel("Surround by:", "", self.on_done, None, None)
def on_done(self, tag):
try:
if self.window.active_view():
self.window.active_... | normal | {
"blob_id": "bcc4276ea240247519cabbf5fc5646a9147ee3be",
"index": 545,
"step-1": "<mask token>\n\n\nclass SurroundByCommand(sublime_plugin.TextCommand):\n\n def run(self, edit, tag):\n for region in self.view.sel():\n text = self.view.substr(region)\n self.view.replace(edit, region... | [
2,
3,
5,
6,
7
] |
# %matplotlib inline
import tensorflow as tf
#import tensorflow.keras as K
import numpy as np
import math
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
# from keras import backend as K
from keras.models import Sequential, load_model
# from K.models import Sequential, load_model
from keras.... | normal | {
"blob_id": "db9068e54607e9df48328435ef07f15b4c25a6db",
"index": 7412,
"step-1": "<mask token>\n\n\ndef log_dir_name(learning_rate, dense_layers, nodes, activation):\n \"\"\"\n\tCreates a directory named after the set of hyperparameters that was recently selected. A helper function\n\tto log the results of tr... | [
3,
4,
5,
6,
7
] |
array_length = int(input())
source = [int(x) for x in input().split()]
def find_neighbors():
previous_zero_index = -1
count = 0
result = []
for index, value in enumerate(source):
count += 1
if value == 0:
if index == 0:
previous_zero_index = 0
... | normal | {
"blob_id": "6d362b87b595fc59df31d1f0bb561dc83633a2ac",
"index": 9216,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef find_neighbors():\n previous_zero_index = -1\n count = 0\n result = []\n for index, value in enumerate(source):\n count += 1\n if value == 0:\n ... | [
0,
1,
2,
3,
4
] |
from django.shortcuts import render
import datetime
from django.http import*
from django.core.files.storage import FileSystemStorage
import uuid
import os
import cv2
import numpy as np
from pathlib import Path
def index(request):
print(request.session);
today=datetime.datetime.now()
return render(request,'index.h... | normal | {
"blob_id": "3378ce72ae67d09258554048138b7f9023000922",
"index": 6619,
"step-1": "<mask token>\n\n\ndef index(request):\n print(request.session)\n today = datetime.datetime.now()\n return render(request, 'index.html', {'today': today.strftime('%d-%m=%Y')})\n\n\ndef isFileOpen(request):\n stack = requ... | [
12,
14,
15,
17,
19
] |
from setuptools import setup, find_packages
setup(name='qn',
version='0.2.2',
description='Handy functions I use everyday.',
url='https://github.com/frlender/qn',
author='Qiaonan Duan',
author_email='geonann@gmail.com',
license='MIT',
packages=find_packages(),
# install_... | normal | {
"blob_id": "3b307ae7f8b8b25c93eb2dc54b2603b1291b6232",
"index": 1789,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='qn', version='0.2.2', description=\n 'Handy functions I use everyday.', url='https://github.com/frlender/qn',\n author='Qiaonan Duan', author_email='geonann@gmail.com', ... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-15 18:46
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('aposta', '0003_aposta_nome'),
]
operations = [
... | normal | {
"blob_id": "a917dd6171a78142fefa8c8bfad0110729fc1bb0",
"index": 3190,
"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 = [('aposta', '0... | [
0,
1,
2,
3,
4
] |
'''
Factory for creating and running ssimulations against optimization tools
Author:
Matthew Barber <mfmbarber@gmail.com>
'''
from .strategy_annealer import StrategyAnnealer
from .strategy_deap import StrategyDeap
class CalulateStrategyWith:
@staticmethod
def Annealing(car, include_initial_ty... | normal | {
"blob_id": "1cab38721e6b96a9877bd67cbddaa4d6b4e53d1b",
"index": 8175,
"step-1": "<mask token>\n\n\nclass CalulateStrategyWith:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass CalulateStrategyWith:\n <mask token>\n\n @staticmethod\n def geneticAlgorithm(car, include_initial_... | [
1,
2,
3,
4,
5
] |
# -*- coding: utf-8 -*-
u"""Hellweg execution template.
:copyright: Copyright (c) 2017 RadiaSoft LLC. All Rights Reserved.
:license: http://www.apache.org/licenses/LICENSE-2.0.html
"""
from __future__ import absolute_import, division, print_function
from pykern import pkcollections
from pykern import pkio
from pyker... | normal | {
"blob_id": "9e6fd6620b4ec6a574d7948fb0d14b0a2ad0d24e",
"index": 5240,
"step-1": "<mask token>\n\n\ndef background_percent_complete(report, run_dir, is_running):\n if is_running:\n return {'percentComplete': 0, 'frameCount': 0}\n dump_file = _dump_file(run_dir)\n if os.path.exists(dump_file):\n ... | [
22,
26,
32,
36,
37
] |
# Copyright 2016 Tesora, Inc.
# All Rights Reserved.
#
# 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 ... | normal | {
"blob_id": "5e29c6d1034f6612b0081037f8dc679b49f1dbef",
"index": 2855,
"step-1": "<mask token>\n",
"step-2": "charset = {'big5': ['big5_chinese_ci', 'big5_bin'], 'dec8': [\n 'dec8_swedish_ci', 'dec8_bin'], 'cp850': ['cp850_general_ci',\n 'cp850_bin'], 'hp8': ['hp8_english_ci', 'hp8_bin'], 'koi8r': [\n ... | [
0,
1,
2
] |
# Parsing the raw.csv generated by running lis2dh_cluster.py
g = 9.806
def twos_complement(lsb, msb):
signBit = (msb & 0b10000000) >> 7
msb &= 0x7F # Strip off sign bit
if signBit:
x = (msb << 8) + lsb
x ^= 0x7FFF
x = -1 - x
else:
x = (msb << 8) + lsb
x = x>>6 # Remove left justification of... | normal | {
"blob_id": "a1b579494d20e8b8a26f7636ebd444252d2aa250",
"index": 4824,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef twos_complement(lsb, msb):\n signBit = (msb & 128) >> 7\n msb &= 127\n if signBit:\n x = (msb << 8) + lsb\n x ^= 32767\n x = -1 - x\n else:\n ... | [
0,
1,
2,
3,
4
] |
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4, 5], [1, 2, 3, 4, 5],
'go-', label='line 1', linewidth=2)
plt.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25],
'rs--', label='line 2', linewidth=4)
plt.axis([0, 6, 0, 26])
plt.legend(loc="upper right")
plt.show()
| normal | {
"blob_id": "7eeba06e78bd1e7139b1706574c4d040465d4566",
"index": 4178,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nplt.plot([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 'go-', label='line 1', linewidth=2)\nplt.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25], 'rs--', label='line 2',\n linewidth=4)\nplt.axis([0, 6, 0, ... | [
0,
1,
2,
3
] |
class Solution:
def sumSubarrayMins(self, A: List[int]) ->int:
stack = []
prev = [None] * len(A)
for i in range(len(A)):
while stack and A[stack[-1]] >= A[i]:
stack.pop()
prev[i] = stack[-1] if stack else -1
stack.append(i)
stack =... | normal | {
"blob_id": "97029ac9f05037bf9304dacf86c35f5534d887c4",
"index": 8303,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def sumSubarrayMins(self, A: List[int]) ->int:\n stack = []\n prev = [None] * len(A)\n for i in range(len(... | [
0,
1,
2
] |
import torch
def DiceLoss(pred,target,smooth=2):
# print("pred shape: ",pred.shape)
# print("target shape: ",target.shape)
index = (2*torch.sum(pred*target)+smooth)/(torch.sum(pred)+torch.sum(target)+smooth)
#if torch.sum(target).item() == 0:
#print("instersection: ",torch.sum(pred*target).item())
... | normal | {
"blob_id": "0aa0fcbb0ec1272bea93574a9287de9f526539c8",
"index": 3119,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef DiceLoss(pred, target, smooth=2):\n index = (2 * torch.sum(pred * target) + smooth) / (torch.sum(pred) +\n torch.sum(target) + smooth)\n return 1 - index\n",
"step-... | [
0,
1,
2,
3
] |
from functools import partial
import torch
from torch import nn
from src.backbone.layers.conv_block import ConvBNAct, MBConvConfig, MBConvSE, mobilenet_v2_init
from src.backbone.mobilenet_v2 import MobileNetV2
from src.backbone.utils import load_from_zoo
class MobileNetV3(MobileNetV2):
def __init__(self, residu... | normal | {
"blob_id": "4a5185fac7d6c09daa76b5d0d5aee863028a6bce",
"index": 5328,
"step-1": "<mask token>\n\n\nclass MobileNetV3(MobileNetV2):\n <mask token>\n\n def forward(self, x):\n return self.dropout(self.classifier(torch.flatten(self.avg_pool(\n self.features(x)), 1)))\n\n\n<mask token>\n",
... | [
2,
3,
4,
5,
6
] |
import os
import io
import yaml
from collections import OrderedDict
from rich.console import Console
from malwarebazaar.platform import get_config_path, get_config_dir
class Config(OrderedDict):
instance = None
def __init__(self):
ec = Console(stderr=True, style="bold red")
Config.ensure_pa... | normal | {
"blob_id": "5a9e0b220d2c94aea7e3d67338771cf48c3aec8f",
"index": 6439,
"step-1": "<mask token>\n\n\nclass Config(OrderedDict):\n <mask token>\n\n def __init__(self):\n ec = Console(stderr=True, style='bold red')\n Config.ensure_path(ec)\n config_file = get_config_path()\n if not... | [
4,
5,
6,
7,
8
] |
# @Time : 2019/12/12 15:54
# @Author : Libuda
# @FileName: 远程服务器文件监控.py
# @Software: PyCharm
import itchat
@itchat.msg_register(itchat.content.TEXT)
def text_reply(msg):
return msg.text
itchat.auto_login()
itchat.run()
| normal | {
"blob_id": "2b87b8571664989e78790bd9df23eee9cbd44035",
"index": 1363,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@itchat.msg_register(itchat.content.TEXT)\ndef text_reply(msg):\n return msg.text\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\n@itchat.msg_register(itchat.content.TEXT)\nde... | [
0,
1,
2,
3,
4
] |
import sys
import os
import random
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO
def file_len(file):
initial = file.tell()
file.seek(0, os.SEEK_END)
size = file.tell()
file.seek(initial)
return size
def run():
rand_seed = None
stderr_file... | normal | {
"blob_id": "b7db0d2f4bbbc2c7763b9d2e6bede74979b65161",
"index": 4283,
"step-1": "<mask token>\n\n\ndef run():\n rand_seed = None\n stderr_filename = None\n stdout_filename = None\n if len(sys.argv) >= 4:\n rand_seed = int(sys.argv[3])\n if len(sys.argv) >= 3:\n stderr_filename = sys... | [
1,
2,
3,
4
] |
#!/usr/bin/python3
"""
Requests username and tasks from JSON Placeholder
based on userid (which is sys.argv[1])
"""
import json
import requests
import sys
if __name__ == "__main__":
url = "https://jsonplaceholder.typicode.com"
if len(sys.argv) > 1:
user_id = sys.argv[1]
name = requests.get("{}... | normal | {
"blob_id": "e1a2b33a1ec7aca21a157895d8c7c5b5f29ff49c",
"index": 5047,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n url = 'https://jsonplaceholder.typicode.com'\n if len(sys.argv) > 1:\n user_id = sys.argv[1]\n name = requests.get('{}/users/{}'.format(ur... | [
0,
1,
2,
3
] |
from foods.fruits import *
orange.eat()
apple.eat()
| normal | {
"blob_id": "ad84a5bfcf82dff1f4a7e8f08f3c4243ad24de52",
"index": 7318,
"step-1": "<mask token>\n",
"step-2": "<mask token>\norange.eat()\napple.eat()\n",
"step-3": "from foods.fruits import *\norange.eat()\napple.eat()\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
from typing import List
import scrapy
from cssselect import Selector
class RwidSpider(scrapy.Spider):
name = 'rwid'
allowed_domains = ['0.0.0.0']
# REQUEST LOGIN DARI URLS
start_urls = ['http://0.0.0.0:9999/']
# LOGIN DISINI
def parse(self, response):
# apa bedanya yield & return
... | normal | {
"blob_id": "2185d332f7cd4cbf17d6b72a19297d156c2182a1",
"index": 2233,
"step-1": "<mask token>\n\n\nclass RwidSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n\n def parse(self, response):\n data = {'username': 'user', 'password': 'user12345'}\n return scrapy.FormReq... | [
3,
4,
5,
6,
7
] |
import sys
prop = float(sys.argv[1])
def kind(n):
s = str(n)
l = len(s)
i = 0
j = i + 1
decr, bouncy, incr = False, False, False
while j < l:
a = int(s[i])
b = int(s[j])
if s[i] > s[j]:
decr = True
elif s[i] < s[j]:
incr = True
i += 1
j += 1
if decr and incr:
retu... | normal | {
"blob_id": "0de27101675eb8328d9a2831ed468a969b03e7d3",
"index": 5741,
"step-1": "<mask token>\n\n\ndef kind(n):\n s = str(n)\n l = len(s)\n i = 0\n j = i + 1\n decr, bouncy, incr = False, False, False\n while j < l:\n a = int(s[i])\n b = int(s[j])\n if s[i] > s[j]:\n ... | [
2,
3,
4,
5,
6
] |
# coding: utf-8
import logging
from flask import request
from flask.ext.admin import expose
from cores.actions import action
from cores.adminweb import BaseHandler
from dao.bannerdao import banner
from extends import csrf
from libs.flask_login import login_required
from utils.function_data_flow import flow_tools
from... | normal | {
"blob_id": "d80cb5ea57faa0f9e3a8dd5d40c9852c2f7f83e4",
"index": 4586,
"step-1": "<mask token>\n\n\nclass BannerHandler(BaseHandler):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @expose('/banner/action.html', methods=('POST',))\n @login_re... | [
6,
8,
9,
13,
16
] |
'''
Created on Dec 18, 2011
@author: ppa
'''
import unittest
from ultrafinance.pyTaLib.indicator import Sma
class testPyTaLib(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testSma(self):
sma = Sma(period = 3)
expectedAvgs = [1, 1.5, 2, 3, 4]
... | normal | {
"blob_id": "fcd2bd91dff3193c661d71ade8039765f8498fd4",
"index": 8317,
"step-1": "<mask token>\n\n\nclass testPyTaLib(unittest.TestCase):\n\n def setUp(self):\n pass\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass testPyTaLib(unittest.TestCase):\n\n def setUp(self):\n ... | [
2,
3,
4,
5,
6
] |
# -*- coding:utf-8 -*-
'''
@author:oldwai
'''
# email: frankandrew@163.com
def multipliers():
return lab1(x)
def lab1(x):
list1 = []
for i in range(4):
sum = x*i
list1.append(sum)
return list1
#print ([m(2) for m in multipliers()])
def func1(x):
list2 = []
... | normal | {
"blob_id": "807e19f09f4a46b6c39457b8916714e2c54c3e8d",
"index": 5802,
"step-1": "<mask token>\n\n\ndef lab1(x):\n list1 = []\n for i in range(4):\n sum = x * i\n list1.append(sum)\n return list1\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef lab1(x):\n list1 = []\n for i i... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/python
# -*- coding:utf-8 -*-
################################################################
# 服务器程序
################################################################
import json
import time
import traceback
from flask import Flask, abort, render_template, redirect, send_from_directory, request, make_respon... | normal | {
"blob_id": "2c89f12d633da8da4d500dca910662d351b0958f",
"index": 4509,
"step-1": "#!/usr/bin/python\n# -*- coding:utf-8 -*-\n################################################################\n# 服务器程序\n################################################################\nimport json\nimport time\nimport traceback\nfro... | [
0
] |
# This file is used to run a program to perform Active measuremnts
import commands
import SocketServer
import sys
#Class to handle Socket request
class Handler(SocketServer.BaseRequestHandler):
def handle(self):
# Get the IP of the client
IP = self.request.recv(1024)
#print 'IP=' + IP
... | normal | {
"blob_id": "c853f922d1e4369df9816d150e5c0abc729b325c",
"index": 4902,
"step-1": "# This file is used to run a program to perform Active measuremnts\n\n\nimport commands\nimport SocketServer\nimport sys\n\n#Class to handle Socket request\nclass Handler(SocketServer.BaseRequestHandler):\n\n def handle(self):\n... | [
0
] |
from functools import wraps
import maya.cmds as mc
import maya.mel as mel
import pymel.core as pm
from PySide2 import QtCore, QtGui, QtWidgets
import adb_core.Class__multi_skin as ms
import adbrower
from CollDict import pysideColorDic as pyQtDic
from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
import a... | normal | {
"blob_id": "819607d89035413fc2800e9f16222619a74a5d64",
"index": 6429,
"step-1": "<mask token>\n\n\nclass MultiSkin_UI(MayaQWidgetDockableMixin, QtWidgets.QDialog):\n <mask token>\n <mask token>\n <mask token>\n\n def widgetsAndLayouts(self):\n\n def addLine():\n line = QtWidgets.QF... | [
17,
18,
23,
24,
28
] |
n = int(input())
a = [int(e) for e in input().split()]
ans = [0] * n
for i in range(n):
s = a[i]
ans[s - 1] = i + 1
print(*ans)
| normal | {
"blob_id": "f74e2e6b59330bd63fee9192e74a72178abc1cab",
"index": 8195,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(n):\n s = a[i]\n ans[s - 1] = i + 1\nprint(*ans)\n",
"step-3": "n = int(input())\na = [int(e) for e in input().split()]\nans = [0] * n\nfor i in range(n):\n s = ... | [
0,
1,
2
] |
yuki = list(map(int, input().split()))
S = input()
enemy = [S.count('G'), S.count('C'), S.count('P')]
ans = 0
for i in range(3):
ans += min(yuki[i], enemy[(i + 1) % 3]) * 3
yuki[i], enemy[(i + 1) % 3] = max(0, yuki[i] - enemy[(i + 1) % 3]), max(
0, enemy[(i + 1) % 3] - yuki[i])
for i in range(3):
an... | normal | {
"blob_id": "ce98c13555c474de0a9cb12e99a97b2316312b00",
"index": 979,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(3):\n ans += min(yuki[i], enemy[(i + 1) % 3]) * 3\n yuki[i], enemy[(i + 1) % 3] = max(0, yuki[i] - enemy[(i + 1) % 3]), max(\n 0, enemy[(i + 1) % 3] - yuki[i])\... | [
0,
1,
2
] |
# The following code causes an infinite loop. Can you figure out what’s missing and how to fix it?
# def print_range(start, end):
# # Loop through the numbers from start to end
# n = start
# while n <= end:
# print(n)
# print_range(1, 5) # Should print 1 2 3 4 5 (each number on its own line)
# Solution
# Vari... | normal | {
"blob_id": "05454cc6c9961aa5e0de6979bb546342f5bd7b79",
"index": 3321,
"step-1": "# The following code causes an infinite loop. Can you figure out what’s missing and how to fix it?\n\n# def print_range(start, end):\n# \t# Loop through the numbers from start to end\n# \tn = start\n# \twhile n <= end:\n# \t\tprint... | [
0
] |
#!/usr/bin/env python
# coding: utf-8
# In[1]:
#multi layer perceptron with back propogation
import numpy as np
import theano
import matplotlib.pyplot as plt
# In[2]:
inputs=[[0,0],
[1,0],
[0,1],
[1,1]]
outputs=[1,0,0,1]
# In[3]:
x=theano.tensor.matrix(name='x')
# In[4]:
#Hidden laye... | normal | {
"blob_id": "adec7efceb038c0ecb23c256c23c2ea212752d64",
"index": 4010,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(25000):\n pval, costval = train(inputs, outputs)\n print(costval)\n val1.append(pval)\n cost1.append(costval)\nprint('the final outputs are:')\nfor i in range(l... | [
0,
1,
2,
3,
4
] |
from flask_restful import Resource, reqparse
import nltk
from nltk.tokenize import sent_tokenize
tokenizer = nltk.RegexpTokenizer(r"\w+")
# CLASS DESCRIPTION:
# Devides and clears the sentence of punctuation marks and builds a dependency tree on each sentence
# Allocates its own names and verbs
# added: Te... | normal | {
"blob_id": "6d042a2035eab579193452e4dc44c425125d9515",
"index": 9402,
"step-1": "<mask token>\n\n\nclass Chunk_CleanSentences(Resource):\n <mask token>\n parser.add_argument('text', type=str, required=True, help=\n 'გთხოვთ შეიყვანოთ სწორი წინადადება')\n\n def get(self):\n data = Chunk_Cle... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
"""Transcoder with TOSHIBA RECAIUS API."""
import threading
import queue
import time
import numpy as np
from logzero import logger
import requests
import model.key
AUTH_URL = 'https://api.recaius.jp/auth/v2/tokens'
VOICE_URL = 'https://api.recaius.jp/asr/v2/voices'
class Transcoder:
"""... | normal | {
"blob_id": "421b0c1871350ff541b4e56d1e18d77016884552",
"index": 5199,
"step-1": "<mask token>\n\n\nclass Transcoder:\n <mask token>\n\n def __init__(self):\n \"\"\"Constructor.\"\"\"\n logger.info('__init__:Enter')\n self._token = None\n self.transcript = None\n self._qu... | [
9,
10,
12,
14,
16
] |
def print_duplicates(arr):
uniques = set()
for elem in arr:
if elem in uniques:
print(elem, end=' ')
else:
uniques.add(elem)
| normal | {
"blob_id": "420c3944de0a5436a9824604fd6caf27706eb99c",
"index": 4102,
"step-1": "<mask token>\n",
"step-2": "def print_duplicates(arr):\n uniques = set()\n for elem in arr:\n if elem in uniques:\n print(elem, end=' ')\n else:\n uniques.add(elem)\n",
"step-3": null,
... | [
0,
1
] |
# module: order functionality
# HW2: complete this func
def process_option(food, option):
# print(food.keys())
food_name = list(food.keys())[option-1]
food_price = food[food_name]
print(food_price)
print("You have chosen: ", option, food_name, "!", " For unit price: ", food_price)
... | normal | {
"blob_id": "07bd3c7cacbf8d0e39d06b21456258ad92cb2294",
"index": 676,
"step-1": "<mask token>\n",
"step-2": "def process_option(food, option):\n food_name = list(food.keys())[option - 1]\n food_price = food[food_name]\n print(food_price)\n print('You have chosen: ', option, food_name, '!', ' For u... | [
0,
1,
2,
3,
4
] |
"""
table.py [-m] base1 base2 ... baseN
Combines output from base1.txt, base2.txt, etc., which are created by
the TestDriver (such as timcv.py) output, and displays tabulated
comparison statistics to stdout. Each input file is represented by
one column in the table.
Optional argument -m shows a final column with the m... | normal | {
"blob_id": "4e94e9e2b45d3786aa86be800be882cc3d5a80b5",
"index": 8328,
"step-1": "<mask token>\n\n\ndef suck(f):\n hamdevall = spamdevall = 0.0, 0.0\n cost = 0.0\n bestcost = 0.0\n fp = 0\n fn = 0\n un = 0\n fpp = 0.0\n fnp = 0.0\n unp = 0.0\n htest = 0\n stest = 0\n get = f.r... | [
1,
2,
3,
4,
5
] |
# Advent of Code: Day 4
"""A new system policy has been put in place that requires all accounts to
use a passphrase instead of simply a password. A passphrase consists of a
series of words (lowercase letters) separated by spaces.
To ensure security, a valid passphrase must contain no duplicate words.
"""
def valid... | normal | {
"blob_id": "7dce240a891e807b1f5251a09a69368f4e513973",
"index": 4472,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef valid_anagram(filename):\n f = open(filename, 'r')\n lines = f.readlines()\n f.close()\n result = len(lines)\n for line in lines:\n split = line.rstrip().spl... | [
0,
1,
2,
3,
4
] |
# THIS FILE WAS CREATED IN THIS DIRECTORY EARLIER, NOW MOIVED TO ROOT OF THE REPO
print "Hello buddy"
print "Let's get started"
spy_name = raw_input ("What is your spy name? ")
if len(spy_name) >3:
print "Welcome " + spy_name + ". Glad to have you with us."
spy_salutation= raw_input("What's your titl... | normal | {
"blob_id": "79f03af05fb40f5f5247b582eabae2dc125e6b52",
"index": 4522,
"step-1": "# THIS FILE WAS CREATED IN THIS DIRECTORY EARLIER, NOW MOIVED TO ROOT OF THE REPO\r\n\r\n\r\nprint \"Hello buddy\"\r\nprint \"Let's get started\"\r\nspy_name = raw_input (\"What is your spy name? \")\r\nif len(spy_name) >3:\r\n ... | [
0
] |
# -*- coding:utf-8 -*-
import time
class Base:
def getTime(self):
'''
获取时间戳
:return:
'''
return str(time.time()).split('.')[0] | normal | {
"blob_id": "28a920072bad1b411d71f7f70cd991cb7dfbeb8c",
"index": 8754,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Base:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Base:\n\n def getTime(self):\n \"\"\"\n 获取时间戳\n :return: \n \"\"\"\n retur... | [
0,
1,
2,
3,
4
] |
"""
Created on 02.09.2013
@author: Paul Schweizer
@email: paulschweizer@gmx.net
@brief: Holds all the namingconventions for pandora's box
"""
import os
import json
class NamingConvention():
"""Imports naming conventions from the respective .json file and puts them
into class variables.
"""
def __init... | normal | {
"blob_id": "d2a153fffccd4b681eebce823e641e195197cde7",
"index": 54,
"step-1": "<mask token>\n\n\nclass NamingConvention:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass NamingConvention:\n <mask token>\n\n def __init__(self):\n namingconventions = os.path.join(os.path.d... | [
1,
2,
3,
4,
5
] |
import argparse
import cv2
import numpy as np
refPt = []
cropping = False
def click_and_crop(event, x, y, flags, param):
global refPt, cropping
if event == cv2.EVENT_LBUTTONDOWN:
refPt = [(x, y)]
cropping = True
elif event == cv2.EVENT_LBUTTONUP:
refPt.append((x, y))
cropping = False
cv2.rect... | normal | {
"blob_id": "986df5a41bc87ecb390dfbd1db9e1f5cd6c5b8fb",
"index": 9702,
"step-1": "\nimport argparse\nimport cv2\nimport numpy as np\n \n\nrefPt = []\ncropping = False\n \ndef click_and_crop(event, x, y, flags, param):\n\tglobal refPt, cropping\n \n\tif event == cv2.EVENT_LBUTTONDOWN:\n\t\trefPt = [(x, y)]\n\t\tc... | [
0
] |
#coding=utf-8
#########################################
# dbscan:
# 用法说明:读取文件
# 生成路径文件及簇文件,输出分类准确率
#########################################
from matplotlib.pyplot import *
import matplotlib.pyplot as plt
from collections import defaultdict
import random
from math import *
import numpy
import datetime
... | normal | {
"blob_id": "99c839eddcbe985c81e709878d03c59e3be3c909",
"index": 293,
"step-1": "#coding=utf-8\n######################################### \n# dbscan: \n# 用法说明:读取文件\n# 生成路径文件及簇文件,输出分类准确率 \n######################################### \n\n\nfrom matplotlib.pyplot import *\nimport matplotlib.pyplot as plt\nfr... | [
0
] |
import argparse
def wrong_subtraction(n, k):
output = n
for i in range(k):
string_n = str(output)
if string_n[len(string_n) - 1] == '0':
output = int(string_n[:-1])
else:
output -= 1
return output
# d = "Do the wrong subtraction as per https://codeforces.com... | normal | {
"blob_id": "166a8cd0e09fbec739f43019659eeaf98b1d4fa4",
"index": 4446,
"step-1": "<mask token>\n\n\ndef wrong_subtraction(n, k):\n output = n\n for i in range(k):\n string_n = str(output)\n if string_n[len(string_n) - 1] == '0':\n output = int(string_n[:-1])\n else:\n ... | [
1,
2,
3,
4,
5
] |
# @Author: Chen yunsheng(Leo YS CHen)
# @Location: Taiwan
# @E-mail:leoyenschen@gmail.com
# @Date: 2017-02-14 00:11:27
# @Last Modified by: Chen yunsheng
import click
from qstrader import settings
from qstrader.compat import queue
from qstrader.price_parser import PriceParser
from qstrader.price_handler.yahoo_dai... | normal | {
"blob_id": "0cec92bbfad87020baf5ef1bd005e64bc9a6ed01",
"index": 5232,
"step-1": "<mask token>\n\n\ndef run(config, testing, tickers, filename):\n events_queue = queue.Queue()\n csv_dir = config.CSV_DATA_DIR\n initial_equity = PriceParser.parse(500000.0)\n price_handler = YahooDailyCsvBarPriceHandler... | [
2,
3,
4,
5,
6
] |
from click.testing import CliRunner
from apitest.actions.cli import cli
def test_sendto_cli_runs_ok():
runner = CliRunner()
result = runner.invoke(cli, ["sendto"])
assert result.exit_code == 0
| normal | {
"blob_id": "7537deb4560e880365b23a99584d0b1f8fa3daf4",
"index": 5675,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_sendto_cli_runs_ok():\n runner = CliRunner()\n result = runner.invoke(cli, ['sendto'])\n assert result.exit_code == 0\n",
"step-3": "from click.testing import CliR... | [
0,
1,
2,
3
] |
class UF(object):
def __init__(self, n):
self.parents = [i for i in range(n)]
self.weights = [1 for i in range(n)]
self.n = n
def find(self, i):
while i != self.parents[i]:
self.parents[i] = self.parents[self.parents[i]]
i = self.parents[i]
return... | normal | {
"blob_id": "c8d5b8515a468190d14311118e12a7d414908be6",
"index": 8109,
"step-1": "class UF(object):\n <mask token>\n\n def find(self, i):\n while i != self.parents[i]:\n self.parents[i] = self.parents[self.parents[i]]\n i = self.parents[i]\n return i\n\n def union(sel... | [
4,
5,
6,
7,
8
] |
import random
from turtle import Turtle
colors = ["red", "blue", 'green', 'peru', 'purple', 'pink', 'chocolate', 'grey', 'cyan', 'brown']
class Food(Turtle):
def __init__(self):
super().__init__()
self.shape("circle")
self.penup()
self.color("red")
self.speed("fastest")
... | normal | {
"blob_id": "8adda42dfebd3f394a1026720465824a836c1dd1",
"index": 7997,
"step-1": "<mask token>\n\n\nclass Food(Turtle):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Food(Turtle):\n\n def __init__(self):\n super().__init__()\n self.shape('circle')\n self.pen... | [
1,
3,
4,
5,
6
] |
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.feature import ShapelyFeature
from shapely.geometry import shape
def plot(s):
proj = ccrs.PlateCarree()
ax = plt.axes(projection=proj)
ax.set_extent((s.bounds[0], s.bounds[2], s.bounds[1], s.bounds[3]), crs=ccrs.PlateCarree())
sha... | normal | {
"blob_id": "75754f4032d6e22e53cdbed0f6c640247473faec",
"index": 7606,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef plot_merc(s):\n proj = ccrs.Mercator()\n ax = plt.axes(projection=proj)\n ax.set_extent((s.bounds[0], s.bounds[2], s.bounds[1], s.bounds[3]), crs\n =ccrs.PlateCarr... | [
0,
1,
2,
3,
4
] |
individual = html.Div([
html.Div([ # input container
html.Div([
dcc.RadioItems(id='view-radio',
options=[
{'label': i, 'value': i} for i in ['Players',
'Tea... | normal | {
"blob_id": "6c65d63ef07b6cdb2029e6a6e99f6ee35b448c4b",
"index": 3147,
"step-1": "individual = html.Div([\n\n html.Div([ # input container\n \n html.Div([\n dcc.RadioItems(id='view-radio',\n options=[\n {'label': i, 'value'... | [
0
] |
"""
losettings.py
Contains a class for profiles and methods to save and load them from xml files.
Author: Stonepaw
Version 2.0
Rewrote pretty much everything. Much more modular and requires no maintence when a new attribute is added.
No longer fully supports profiles from 1.6 and earlier.
Copy... | normal | {
"blob_id": "b29c11b11fd357c7c4f774c3c6a857297ff0d021",
"index": 3144,
"step-1": "\"\"\"\r\nlosettings.py\r\n\r\nContains a class for profiles and methods to save and load them from xml files.\r\n\r\nAuthor: Stonepaw\r\n\r\nVersion 2.0\r\n\r\n Rewrote pretty much everything. Much more modular and requires no... | [
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.