code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
#
# FISL Live
# =========
# Copyright (c) 2010, Triveos Tecnologia Ltda.
# License: AGPLv3
from os.path import *
from datetime import datetime
from google.appengine.api import users
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.... | normal | {
"blob_id": "64ed3c512894902f85d619020b78338e228dddb6",
"index": 4380,
"step-1": "<mask token>\n\n\nclass Page(webapp.RequestHandler):\n\n def get(self):\n if users.get_current_user():\n url = users.create_logout_url(self.request.uri)\n linktext = 'Logout'\n user = user... | [
5,
6,
7,
9,
10
] |
"""
Config module for storage read only disks
"""
from rhevmtests.storage.config import * # flake8: noqa
TEST_NAME = "read_only"
VM_NAME = "{0}_vm_%s".format(TEST_NAME)
VM_COUNT = 2
DISK_NAMES = dict() # dictionary with storage type as key
DISK_TIMEOUT = 600
# allocation policies
SPARSE = True
DIRECT_LUNS = UNUSE... | normal | {
"blob_id": "ecdc8f5f76b92c3c9dcf2a12b3d9452166fcb706",
"index": 1098,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nTEST_NAME = 'read_only'\nVM_NAME = '{0}_vm_%s'.format(TEST_NAME)\nVM_COUNT = 2\nDISK_NAMES = dict()\nDISK_TIMEOUT = 600\nSPARSE = True\nDIRECT_LUNS = UNUSED_LUNS\nDIRECT_LUN_ADDRESSES = U... | [
0,
1,
2,
3
] |
from setuptools import setup, find_packages
setup(
packages=find_packages(),
setup_requires=["flask"],
name="mith1",
) | normal | {
"blob_id": "a5a7cd112faad1096ce4c6f04b2179fbdf732702",
"index": 1479,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(packages=find_packages(), setup_requires=['flask'], name='mith1')\n",
"step-3": "from setuptools import setup, find_packages\nsetup(packages=find_packages(), setup_requires=['flas... | [
0,
1,
2,
3
] |
import serial
import time
import struct
# Assign Arduino's serial port address
# Windows example
# usbport = 'COM3'
# Linux example
# usbport = '/dev/ttyUSB0'
# MacOSX example
# usbport = '/dev/tty.usbserial-FTALLOK2'
# basically just see what ports are open - >>> ls /dev/tty*
# Set up s... | normal | {
"blob_id": "6c98be473bf4cd458ea8a801f8b1197c9d8a07b3",
"index": 3514,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntime.sleep(2)\n\n\ndef write(i):\n ser.write(struct.pack('>BBB', 255, 0, i))\n\n\nwrite(0)\ntime.sleep(1)\n",
"step-3": "<mask token>\nusbport = '/dev/ttyS3'\nser = serial.Serial(usb... | [
0,
2,
3,
4,
5
] |
import time
import numpy as np
import matplotlib.pyplot as plt #tutorial: http://pybonacci.org/2012/05/19/manual-de-introduccion-a-matplotlib-pyplot-ii-creando-y-manejando-ventanas-y-configurando-la-sesion/
import threading
from random import shuffle
T = 1
eps = 0.000000001
agilityMin = 1/T
'''------------GOVERMENT'... | normal | {
"blob_id": "ab0c3cf3e43f34874dd94629b746ca1237c3349a",
"index": 7494,
"step-1": "<mask token>\n\n\nclass Map:\n <mask token>\n\n def __init__(self, size, num_feeds):\n self.size = size\n self.map_cells = np.zeros((self.size, self.size))\n <mask token>\n <mask token>\n\n def createCe... | [
21,
26,
27,
32,
34
] |
import argparse
from ray.tune.config_parser import make_parser
from ray.tune.result import DEFAULT_RESULTS_DIR
EXAMPLE_USAGE = """
Training example:
python ./train.py --run DQN --env CartPole-v0 --no-log-flatland-stats
Training with Config:
python ./train.py -f experiments/flatland_random_sparse_small/global... | normal | {
"blob_id": "79a8ff0000f3be79a62d693ed6bae7480673d970",
"index": 6075,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef create_parser(parser_creator=None):\n parser = make_parser(parser_creator=parser_creator, formatter_class=\n argparse.RawDescriptionHelpFormatter, description=\n ... | [
0,
1,
2,
3,
4
] |
a=[i for i in range(10)]
del a[0]
print a
del a[-1]
print a
del a[1]
print a
del a[0:2]
print a
del a[1:3:1]
print a
#test del all
del a[:]
print a
a.append(1)
print a
# Make sure that del's work correctly in sub-scopes:
x = 1
def f1():
x = range(5)
def f2():
del x[1]
return f2
f1()()
| normal | {
"blob_id": "d0e5cfc7b619c2eaec19248619d7d59e41503c89",
"index": 4302,
"step-1": "a=[i for i in range(10)]\ndel a[0]\nprint a\ndel a[-1]\nprint a\ndel a[1]\nprint a\n\ndel a[0:2] \nprint a \ndel a[1:3:1]\nprint a\n#test del all\ndel a[:]\nprint a\na.append(1)\nprint a\n\n# Make sure that del's work correctly in ... | [
0
] |
import sys
def show_data(data):
for line in data:
print(''.join(line))
print("")
def check_seat(data, i, j):
if data[i][j] == '#':
occupied = 1
found = True
elif data[i][j] == 'L':
occupied = 0
found = True
else:
occupied = 0
found = False
... | normal | {
"blob_id": "246ec0d6833c9292487cb4d381d2ae82b220677e",
"index": 3969,
"step-1": "<mask token>\n\n\ndef is_top_left_occupied(data, i, j):\n found = False\n occupied = 0\n while i >= 0 and j >= 0 and not found:\n occupied, found = check_seat(data, i, j)\n i -= 1\n j -= 1\n return ... | [
5,
10,
11,
14,
16
] |
"""
Author: Le Bui Ngoc Khang
Date: 12/07/1997
Program: Write a script that inputs a line of plaintext and a distance value and outputs an encrypted text using
a Caesar cipher. The script should work for any printable characters.
Solution:
Enter a message: hello world
Enter distance value: 3
khoor#zruog
"""
# Reque... | normal | {
"blob_id": "bf98e81c160d13b79ebe9d6f0487b57ad64d1322",
"index": 7827,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor ch in plainText:\n ordvalue = ord(ch)\n cipherValue = ordvalue + distance\n if cipherValue > 127:\n cipherValue = distance - (127 - ordvalue + 1)\n code += chr(ciph... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Eric Pascual'
from tornado.web import RequestHandler
import os
class UIHandler(RequestHandler):
def get_template_args(self):
return {
'app_title':"Capteurs de lumière et de couleur"
}
def get(self, *args, **kwargs):
... | normal | {
"blob_id": "b13d4b0ccb693fb97befb4ee47974d8ee076b52b",
"index": 5177,
"step-1": "<mask token>\n\n\nclass UIHBarrier(UIHandler):\n <mask token>\n\n\nclass UIWBDetector(UIHandler):\n\n def get(self, *args, **kwargs):\n template_args = self.get_template_args()\n template_args['demo_title'] = 'D... | [
7,
11,
14,
15,
16
] |
# -*- coding: utf-8 -*-
import chainer.links as L
import chainer.functions as F
from chainer import optimizer, optimizers, training, iterators
from chainer.training import extensions
from chainer.datasets import tuple_dataset
class SoftMaxTrainer():
def __init__(self, net):
self.model = L.Classifier(net)... | normal | {
"blob_id": "474700968e563d34d6a0296ec62950e2e71fe1b0",
"index": 1671,
"step-1": "<mask token>\n\n\nclass SoftMaxTrainer:\n\n def __init__(self, net):\n self.model = L.Classifier(net)\n\n def set_train_data(self, train_x, train_t, valid_x, valid_t, n_batch):\n train = tuple_dataset.TupleDatas... | [
4,
5,
6,
7,
8
] |
from typing import Sized
import pygame
import time
from pygame.locals import *
import random
SIZE = 20
BACKGROUND = (45, 34, 44)
W = 800
H = 400
SCREEN = (W, H)
class Snake:
def __init__(self, parent_screen, length):
self.parent_screen = parent_screen
self.length = length
self.snake = pyg... | normal | {
"blob_id": "935853a4afdb50a4652e14913d0cdb251a84ea14",
"index": 6427,
"step-1": "<mask token>\n\n\nclass Food:\n <mask token>\n\n def draw(self):\n seq = [self.food1, self.food2]\n self.parent_screen.blit(random.choice(seq), (self.food_x, self.food_y))\n pygame.display.flip()\n\n d... | [
17,
26,
29,
30,
31
] |
####
#Some more on variables
####
#Variables are easily redefined.
#Let's start simple.
x=2 #x is going to start at 2
print (x)
x=54 #we are redefining x to equal 54
print (x)
x= "Cheese" #x is now the string 'cheese'
print (x)
#Try running this program to see x
#printed at each point
#Clearly variables can be... | normal | {
"blob_id": "dae8529aa58f1451d5acdd6607543c202c3c0c66",
"index": 3810,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(x)\n<mask token>\nprint(x)\n<mask token>\nprint(x)\n",
"step-3": "x = 2\nprint(x)\nx = 54\nprint(x)\nx = 'Cheese'\nprint(x)\n",
"step-4": "####\n#Some more on variables\n####\n\... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2021.03.18
setup for package.
@author: zoharslong
"""
from setuptools import setup, find_packages
from os.path import join as os_join, abspath as os_abspath, dirname as os_dirname
here = os_abspath(os_dirname(__file__))
with open(os_join(here, 'README.md')) ... | normal | {
"blob_id": "e0f7837731520ad76ca91d78c20327d1d9bb6d4f",
"index": 9970,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(os_join(here, 'README.md')) as f:\n README = f.read()\nsetup(name='pyzohar', version='0.1.11', author='zoharslong', author_email=\n 'zoharslong@hotmail.com', description=\... | [
0,
1,
2,
3,
4
] |
#! /usr/bin/python3
import pprint
import tkinter as tk
from tkinter import messagebox
from PIL import Image
from tkinter import *
from prettytable import PrettyTable
import ttk
import os
import subprocess
import mysql.connector
from datetime import datetime
import time
db=mysql.connector.connect(host='localhost',user... | normal | {
"blob_id": "9f3fcc6e097e37479e3ccf1385f20d70d7c3b6c7",
"index": 8228,
"step-1": "<mask token>\n\n\ndef First_page(root):\n global T1, T2, T3\n frame = Frame(root, height=500, width=800, bg='ivory')\n frame.pack()\n label = Label(root, text='WELCOME TO AGRI MARKET', font=(\n 'Times new roman',... | [
46,
47,
52,
53,
66
] |
from datetime import datetime
import logging
import os
import re
from bs4 import BeautifulSoup
import requests
from .utils.log import get_logger
logger = get_logger(os.path.basename(__file__))
EVENTBRITE_TOKEN = os.environ['EVENTBRITE_TOKEN']
def get_category_name(page):
if page["category_id"] is None:
... | normal | {
"blob_id": "edfc8794fab2c95e01ae254f9f13d446faafe6fd",
"index": 9213,
"step-1": "<mask token>\n\n\ndef scrape(event_id, event_cost):\n page = get(event_id, resource='events').json()\n venue = get(page['venue_id'], resource='venues').json()\n start = datetime.strptime(page['start']['local'], '%Y-%m-%dT%... | [
5,
7,
8,
9,
10
] |
# -*- coding: utf-8 -*-
"""
Created on Wed May 15 17:05:30 2019
@author: qinzhen
"""
import numpy as np
# =============================================================================
# Q5
# =============================================================================
#### Part 1 计算MLE
File = "ner_proc.counts"
q2 = ... | normal | {
"blob_id": "9683c7df01eda0d97615fb3e8f9496ecc95d1d32",
"index": 8494,
"step-1": "<mask token>\n\n\ndef Viterbi(sentence, q, e):\n K = list(Count_y.keys())\n Pi = {}\n bp = {}\n n = len(sentence)\n for i in range(n + 1):\n Pi[i - 1] = {}\n bp[i - 1] = {}\n Pi[-1]['*', '*'] = 1\n ... | [
1,
2,
3,
4,
5
] |
import cv2
import numpy as np
from matplotlib import pyplot as plt
#cargar la imagen a analizar
imagen= cv2.imread("tomate22.jpg")
#cv2.imshow("Original", imagen)
#cv2.waitKey(0)
# Convertimos en escala de grise
gris = cv2.cvtColor(imagen, cv2.COLOR_BGR2GRAY)
#cv2.imshow("En gris", gris)
#cv2.waitKey(0)
# Aplicar s... | normal | {
"blob_id": "9f42a9d0ca622d6c4e2cf20bc2e494262c16055b",
"index": 7744,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nplt.subplot(121), plt.imshow(canny, cmap='gray')\nplt.title('Canny'), plt.xticks([]), plt.yticks([])\n<mask token>\ncv2.drawContours(imagen, contornos, -1, (255, 0, 0), 2)\ncv2.imshow('co... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/7/10 14:26
# @Author : MengHe
# @File : c1.py
# @Software: PyCharm
import re
a = 'Python|Java|C#|C++|Kotlin|JavaScript'
r = re.findall('Java', a)
print(r)
# print(a.index('Python') > -1)
# print('Kotlin' in a) | normal | {
"blob_id": "e05f545ca969e0c2330779ed54a33a594d6ebb25",
"index": 2501,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(r)\n",
"step-3": "<mask token>\na = 'Python|Java|C#|C++|Kotlin|JavaScript'\nr = re.findall('Java', a)\nprint(r)\n",
"step-4": "import re\na = 'Python|Java|C#|C++|Kotlin|JavaScri... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
# Describes where to search for the config file if no location is specified
DEFAULT_CONFIG_LOCATION = "config.json"
DEFAULT_CONFIG = {
"project": None,
"fixed_model_name": None,
"config": DEFAULT_CONFIG_LOCATION,
"data": None,
"emulate": None... | normal | {
"blob_id": "5c4c893caa19e58491e641420261bb70e7202cf0",
"index": 3566,
"step-1": "<mask token>\n\n\nclass AnnotatorConfig(object):\n <mask token>\n\n def __init__(self, filename=None):\n pass\n <mask token>\n\n def get(self, key, default=None):\n return self.__dict__.get(key, default)\n... | [
11,
13,
15,
16,
19
] |
from processing.DLDataEngineering import DLDataEngineering
from sklearn.preprocessing import OneHotEncoder
import pandas as pd
import numpy as np
import h5py
import os
from scipy.ndimage import gaussian_filter
#Deep learning packages
import tensorflow as tf
#from tensorflow import keras
from tensorflow.keras... | normal | {
"blob_id": "a0a6bd5de39a7599f7872639cdf3a59b8cda5498",
"index": 5230,
"step-1": "<mask token>\n\n\nclass DLModeler(object):\n\n def __init__(self, model_path, hf_path, num_examples, class_percentages,\n predictors, model_args, model_type):\n self.model_path = model_path\n self.hf_path = ... | [
8,
9,
10,
12,
13
] |
# 가위, 바위, 보 게임
# 컴퓨터 가위, 바위, 보 리스트에서 랜덤하게 뽑기 위해 random 함수 호출
import random
# 컴퓨터 가위, 바위, 보 리스트
list_b = ["가위", "바위", "보"]
# 이긴횟수, 진 횟수 카운팅 하기 위한 변수
person_win_count = 0
person_lose_count = 0
while person_win_count < 4 or person_lose_count < 4:
# 가위, 바위, 보 입력 받기
player = input("가위, 바위, 보 중 어떤 것을 낼래요? ")
... | normal | {
"blob_id": "93d4c6b6aef827d6746afc684c32a9cf1d0229e4",
"index": 717,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile person_win_count < 4 or person_lose_count < 4:\n player = input('가위, 바위, 보 중 어떤 것을 낼래요? ')\n if player != '가위' and player != '바위' and player != '보':\n player = input('다시... | [
0,
1,
2,
3,
4
] |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 차트에 한글 가능하도록
from matplotlib import font_manager, rc, rcParams
font_name = font_manager.FontProperties(
fname="c:/windows/Fonts/malgun.ttf").get_name()
rc('font',family=font_name)... | normal | {
"blob_id": "fb82724aab7e0819c9921d41dcb612b304b25753",
"index": 9723,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nrc('font', family=font_name)\n<mask token>\nprint(df1)\ndf1.plot()\nplt.show()\n",
"step-3": "<mask token>\nfont_name = font_manager.FontProperties(fname='c:/windows/Fonts/malgun.ttf'\n... | [
0,
1,
2,
3,
4
] |
# Generated by Django 3.1.7 on 2021-05-05 23:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('travels', '0011_auto_20210505_2230'),
]
operations = [
migrations.RenameField(
model_name='trip',
old_name='hotel_de... | normal | {
"blob_id": "1e853d58c2066f3fbd381d0d603cd2fcece0cf15",
"index": 7933,
"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 = [('travels', '... | [
0,
1,
2,
3,
4
] |
class SurveyRepository:
def __init__(self):
self._surveys = {}
def get_survey(self, survey_id):
if survey_id in self._surveys:
return self._surveys[survey_id]
def save(self, survey):
self._surveys[survey.id] = survey
| normal | {
"blob_id": "961643e93582bd92e148d00efebbfe38f99100fc",
"index": 2866,
"step-1": "class SurveyRepository:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class SurveyRepository:\n\n def __init__(self):\n self._surveys = {}\n <mask token>\n <mask token>\n",
"step-3": "clas... | [
1,
2,
3,
4
] |
from ob import *
if __name__ == "__main__":
# Game starts
print('New game!')
# Deal
deck = Deck()
deck.shuffle()
players = deck.deal()
# Bid
auction = Auction(players)
auction.bid()
# Play
tricks = Tricks(auction)
tricks.play()
| normal | {
"blob_id": "06161b1f45e435d0273dd193229ad2ecfd46c625",
"index": 9002,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n print('New game!')\n deck = Deck()\n deck.shuffle()\n players = deck.deal()\n auction = Auction(players)\n auction.bid()\n tricks = Trick... | [
0,
1,
2,
3
] |
from collections import defaultdict
from django.shortcuts import render
from django.views.decorators.cache import cache_control
from peterbecom.plog.models import BlogItem, Category
from peterbecom.plog.utils import utc_now
from peterbecom.plog.views import json_view
ONE_MONTH = 60 * 60 * 24 * 30
@cache_control(pu... | normal | {
"blob_id": "e90fb3b6009dd4fb780649c04398b361fa1ae195",
"index": 8489,
"step-1": "<mask token>\n\n\n@cache_control(public=True, max_age=ONE_MONTH)\ndef index(request):\n return render(request, 'ajaxornot/index.html')\n\n\n<mask token>\n\n\n@cache_control(public=True, max_age=ONE_MONTH)\ndef view1(request):\n ... | [
7,
9,
14,
15,
17
] |
def printBoard(board,pref):
border = "+----+----+----+----+----+----+----+----+"
for row in board:
print(pref,border)
cells ="|"
for cell in row:
if cell == 0:
cell = " "
elif cell in range(1,10):
cell = "0{}".format(cell)
... | normal | {
"blob_id": "07e875a24d0e63ef596db57c4ec402f768225eec",
"index": 5103,
"step-1": "<mask token>\n",
"step-2": "def printBoard(board, pref):\n border = '+----+----+----+----+----+----+----+----+'\n for row in board:\n print(pref, border)\n cells = '|'\n for cell in row:\n if... | [
0,
1,
2
] |
# Generated by Django 3.0.4 on 2020-03-29 19:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('index', '0003_auto_20200330_0444'),
]
operations = [
migrations.AlterField(
model_name='information',
name='comment'... | normal | {
"blob_id": "72c1226d40b3cdce29ef28493344c3cf68892149",
"index": 6001,
"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 = [('index', '00... | [
0,
1,
2,
3,
4
] |
import requests
import os
from slugify import slugify as PipSlugify
import shutil
# will install any valid .deb package
def install_debian_package_binary(package_path):
os.system("sudo dpkg -i {package_path}".format(
package_path=package_path
))
os.system("sudo apt-get install -f")
def download_inst... | normal | {
"blob_id": "f546eb40ee8a7308ded62532731561029e5ec335",
"index": 7870,
"step-1": "<mask token>\n\n\ndef download_install_deb(package_path, package_url):\n download_file(package_path, package_url)\n install_debian_package_binary(package_path)\n remove_file(package_path)\n\n\n<mask token>\n\n\ndef write_f... | [
4,
6,
7,
8,
10
] |
from pylab import *
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import random
import time
from scipy.misc import imread
from scipy.misc import imresize
import matplotlib.image as mpimg
import os
from scipy.ndimage import filters
import urllib
import sys
from PIL import Image
fro... | normal | {
"blob_id": "ccb3ec8e367881710c437e7ae53082a1bb0137e5",
"index": 9335,
"step-1": "from pylab import *\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.cbook as cbook\nimport random\nimport time\nfrom scipy.misc import imread\nfrom scipy.misc import imresize\nimport matplotlib.image as mpim... | [
0
] |
import sqlite3
connection = sqlite3.connect("../db.sqlite3")
cursor = connection.cursor()
sql_file = open("sample.sql")
sql_as_string = sql_file.read()
cursor.executescript(sql_as_string)
for row in cursor.execute("SELECT * FROM results_states"):
print(row)
| normal | {
"blob_id": "10a981e35ce00ee8e32a613823d3bc919fafaae8",
"index": 8225,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncursor.executescript(sql_as_string)\nfor row in cursor.execute('SELECT * FROM results_states'):\n print(row)\n",
"step-3": "<mask token>\nconnection = sqlite3.connect('../db.sqlite3'... | [
0,
1,
2,
3,
4
] |
"""
对自定义的类进行排序
"""
import operator
class User:
def __init__(self, name, id):
self.name = name
self.id = id
def __repr__(self):
return 'User({},{})'.format(self.name, self.id)
def run():
users = [User('wang', 1), User('zhao', 4), User('chen', 3), User('wang', 2)]
# 这种方式相对速度快... | normal | {
"blob_id": "e8ef3a5e41e68b4d219aa1403be392c51cc010e6",
"index": 7302,
"step-1": "<mask token>\n\n\nclass User:\n\n def __init__(self, name, id):\n self.name = name\n self.id = id\n\n def __repr__(self):\n return 'User({},{})'.format(self.name, self.id)\n\n\n<mask token>\n",
"step-2"... | [
3,
4,
5,
6,
7
] |
# Generated by Django 3.2.4 on 2021-09-13 17:41
import dataUpload.models
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Task',
fields=[
... | normal | {
"blob_id": "9cab749b915dbb808ac105caa5287b50729f5fd9",
"index": 111,
"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 = Tr... | [
0,
1,
2,
3,
4
] |
"""
Python package setup file.
"""
from setuptools import setup
setup(
name="TF_Speech",
version="0.2.0",
extras_require={'tensorflow': ['tensorflow'],
'tensorflow with gpu': ['tensorflow-gpu']},
)
| normal | {
"blob_id": "97ebdeada3d797a971b5c3851b75f9754595f67c",
"index": 358,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='TF_Speech', version='0.2.0', extras_require={'tensorflow': [\n 'tensorflow'], 'tensorflow with gpu': ['tensorflow-gpu']})\n",
"step-3": "<mask token>\nfrom setuptools impo... | [
0,
1,
2,
3
] |
'''
@name: ros_env_img.py
@brief: This (abstract) class is a simulation environment wrapper for
the X-Image Representation.
@author: Ronja Gueldenring
@version: 3.5
@date: 2019/04/05
'''
# python relevant
import numpy as np
# custom classes
from rl_agent.env_wra... | normal | {
"blob_id": "1a979933eb02e9d12dc034021448cbade59abc48",
"index": 2585,
"step-1": "<mask token>\n\n\nclass RosEnvImg(RosEnvAbs):\n <mask token>\n <mask token>\n\n def get_observation_(self):\n \"\"\"\n Function returns state that will be fed to the rl-agent\n It includes\n the... | [
2,
3,
4,
5,
6
] |
from setuptools import setup
setup(name='discord-ext-menus', author='TierGamerpy', url=
'https://github.com/TierGamerpy/discord-ext-menus', version=0.1,
packages=['discord.ext.menus'], description=
'An extension module to make reaction based menus with discord.py',
install_requires=['discord.py>=1.2.5']... | normal | {
"blob_id": "daa287eeb967d47c9a8420beccf531d9c157e925",
"index": 3217,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='discord-ext-menus', author='TierGamerpy', url=\n 'https://github.com/TierGamerpy/discord-ext-menus', version=0.1,\n packages=['discord.ext.menus'], description=\n 'An... | [
0,
1,
2
] |
import pydgm
import numpy as np
import sys
class XS():
# Hold the cross section values with routines for outputting to txt file
def __init__(self, sig_t, sig_f, chi, sig_s, mu=None):
self.sig_t = sig_t
self.sig_f = sig_f
self.chi = chi
self.sig_s = sig_s
self.mu = mu i... | normal | {
"blob_id": "1358adc3b2b3ffe72c0ed87fb0024f1079ca7d04",
"index": 1710,
"step-1": "<mask token>\n\n\nclass DGMSOLVER:\n\n def __init__(self, G, fname, fm, cm, mm, nPin, norm=None, mapping=None,\n vacuum=False, k=None, phi=None, psi=None):\n \"\"\"\n Inputs:\n G - Number of e... | [
6,
8,
9,
11,
13
] |
"""
We have created mash sketches of the GPDB database, the MGV database, and the SDSU phage, and
this will figure out the top hits and summarize their familes.
"""
import os
import sys
import argparse
def best_hits(distf, maxscore, verbose=False):
"""
Find the best hits
"""
bh = {}
allph = set()... | normal | {
"blob_id": "22523304c9e2ce1339a7527cdbd67a81c780d806",
"index": 1090,
"step-1": "<mask token>\n\n\ndef best_hits(distf, maxscore, verbose=False):\n \"\"\"\n Find the best hits\n \"\"\"\n bh = {}\n allph = set()\n with open(distf, 'r') as din:\n for li in din:\n p = li.strip()... | [
2,
3,
4,
5,
6
] |
class HashTable:
def __init__(self):
self.size = 11
self.slots = [None] * self.size
self.data = [None] * self.size
def put(self, key, data):
# there are three situations,
#1. the hashvalue returned by hashfunction of the slot is empty, just put the key in that slot, and the data in the datalist
hashvalu... | normal | {
"blob_id": "75741d11bebcd74b790efe7e5633d4507e65a25f",
"index": 6034,
"step-1": "class HashTable:\n <mask token>\n\n def put(self, key, data):\n hashvalue = self.hashfunction(key, len(self.slots))\n if self.slots[hashvalue] == None:\n self.slots[hashvalue] = key\n self.... | [
5,
6,
7,
8,
9
] |
#####coding=utf-8
import re
import urllib.request
import sys
import redis
from urllib.error import URLError, HTTPError
import urllib.parse
# /redis/cluster/23:1417694197540
def con():
pool = redis.ConnectionPool(host='ap2.jd.local', port=5360, password='/redis/cluster/1:1803528818953446384')
r = redis.Stric... | normal | {
"blob_id": "4863581a1a557186ceee8d544d1a996082edcf2c",
"index": 4644,
"step-1": "<mask token>\n\n\ndef con():\n pool = redis.ConnectionPool(host='ap2.jd.local', port=5360, password=\n '/redis/cluster/1:1803528818953446384')\n r = redis.StrictRedis(connection_pool=pool)\n r.set('foo', 'bar')\n ... | [
5,
6,
7,
8,
9
] |
"""Time client"""
import urllib.request
import json
from datetime import datetime
# make sure that module51-server.py service is running
TIME_URL = "http://localhost:5000/"
def ex51():
with urllib.request.urlopen(TIME_URL) as response:
body = response.read()
parsed = json.loads(body)
date = datet... | normal | {
"blob_id": "e8f05a66c642ef3b570130a2996ca27efb8b0cb5",
"index": 5287,
"step-1": "<mask token>\n\n\ndef ex51():\n with urllib.request.urlopen(TIME_URL) as response:\n body = response.read()\n parsed = json.loads(body)\n date = datetime.fromisoformat(parsed['currentTime'])\n stamp = date.strfti... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python3
# Script qui permet de couper au début ou à la fin d'un fichier audio (.wav)
# un silence ou un passage musical à partir d'un fichier de transcription correspondant.
# Supporte uniquement l'extension audio .wav.
# Supporte les formats de transcriptions suivants :
# - .stm
# - .mlfmanu... | normal | {
"blob_id": "77531233219b76be51aed86536e4d92b8dc5ccad",
"index": 5494,
"step-1": "<mask token>\n\n\ndef searchBeginAndEndStm(transFileName):\n fileName = path.splitext(path.basename(transFileName))[0]\n if path.isfile(path.dirname(transFileName) + '/encoding.txt'):\n e = open(path.dirname(transFileN... | [
4,
5,
6,
7,
8
] |
import sys
from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext import ndb
from helpers import *
def valid_pw(name, password, h):
salt = h.split(',')[0]
return h == make_pw_hash(name, password, salt)
class CVEProfile(ndb.Model):
profile_nam... | normal | {
"blob_id": "ac60fd79d7fb15624cf79adc7e456960e7523e2e",
"index": 9131,
"step-1": "<mask token>\n\n\nclass Graph(ndb.Model):\n name = ndb.StringProperty(required=True)\n graphID = ndb.IntegerProperty(required=True)\n owner_id = ndb.IntegerProperty(required=True)\n machines = ndb.StructuredProperty(Mac... | [
38,
45,
49,
52,
53
] |
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'D:\Naveen\Selenium\chromedriver_win32\chromedriver.exe')
driver.maximize_window()
driver.get('http://zero.webappsecurity.com/')
parent_window_handle = driver.current_window_handle
driver.find_element_by_xpath("(//a[contains(text(),'privacy')])... | normal | {
"blob_id": "223413918ba2a49cd13a34026d39b17fb5944572",
"index": 5849,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndriver.maximize_window()\ndriver.get('http://zero.webappsecurity.com/')\n<mask token>\ndriver.find_element_by_xpath(\"(//a[contains(text(),'privacy')])[1]\").click()\n<mask token>\nfor wi... | [
0,
1,
2,
3,
4
] |
# pylint: disable=C0103, C0413, E1101, W0611
"""Covid Catcher Backend"""
import os
from os.path import join, dirname
import json
import requests
import flask
from flask import request
import flask_sqlalchemy
import flask_socketio
from dotenv import load_dotenv
from covid import get_covid_stats_by_state
from covid impor... | normal | {
"blob_id": "8d48b5b831edb62b2d9624bc23cae45d390fd224",
"index": 8035,
"step-1": "<mask token>\n\n\ndef emit_all_users(channel):\n \"\"\"emits all users\"\"\"\n all_users = [user.name for user in db.session.query(models.User1).all()]\n socketio.emit(channel, {'allUsers': all_users})\n return channel\... | [
12,
13,
14,
18,
19
] |
from collections import defaultdict
def solution(clothes):
answer = 1
hash_map = defaultdict(lambda : 0)
for value, key in clothes:
hash_map[key] += 1
for v in hash_map.values():
answer *= v + 1
return answer - 1
| normal | {
"blob_id": "601089c2555e6fc75803087ee1d8af7f8180f651",
"index": 4199,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef solution(clothes):\n answer = 1\n hash_map = defaultdict(lambda : 0)\n for value, key in clothes:\n hash_map[key] += 1\n for v in hash_map.values():\n an... | [
0,
1,
2
] |
# Makes use of the scholar.py Google Scholar parser available here:
# https://github.com/ckreibich/scholar.py
# to run a list of citations collected from other sources (PubMed, PsychINFO, etc.) through
# Google Scholar to return a consistent format and saved as a .csv file.
# This can be imported into a spreadsheet for... | normal | {
"blob_id": "58eef45f8827df02c0aa0ac45eafa77f70f81679",
"index": 9276,
"step-1": "# Makes use of the scholar.py Google Scholar parser available here:\n# https://github.com/ckreibich/scholar.py\n# to run a list of citations collected from other sources (PubMed, PsychINFO, etc.) through\n# Google Scholar to return... | [
0
] |
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
from libtbx.program_template import ProgramTemplate
from mmtbx import pdbtools
from libtbx import Auto
import os
import mmtbx.pdbtools
from cctbx import uctbx
class Program(ProgramTemplate):
description = '''
phenix.pdbtools to... | normal | {
"blob_id": "e1228f5e17bae6632f8decd114f72723dbbce944",
"index": 6186,
"step-1": "<mask token>\n\n\nclass Program(ProgramTemplate):\n <mask token>\n <mask token>\n <mask token>\n\n def validate(self):\n print('Validating inputs', file=self.logger)\n self.data_manager.has_models(raise_so... | [
3,
5,
6,
7,
8
] |
import pytz
from django.utils import timezone
class TimezoneMiddleware(object):
""" Middleware to get user's timezone and activate timezone
if user timezone is not available default value 'UTC' is activated """
def process_request(self, request):
user = request.user
if hasattr(user, ... | normal | {
"blob_id": "839d4182663983a03975465d3909631bd6db1d83",
"index": 9919,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TimezoneMiddleware(object):\n <mask token>\n\n def process_request(self, request):\n user = request.user\n if hasattr(user, 'profile'):\n user_tz ... | [
0,
2,
3,
4
] |
import logging
import azure.functions as func
def main(event: func.EventHubEvent):
logging.info('Python EventHub trigger processed an event: %s', event.
get_body().decode('utf-8'))
| normal | {
"blob_id": "58f8924a9cd2af4106e54b163e96bcd8517282b5",
"index": 2803,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(event: func.EventHubEvent):\n logging.info('Python EventHub trigger processed an event: %s', event.\n get_body().decode('utf-8'))\n",
"step-3": "import logging\ni... | [
0,
1,
2
] |
n = int(input())
if n % 10 == 1 and (n < 11 or n > 20):
print(n, "korova")
elif n % 10 > 1 and n % 10 < 5 and (n < 11 or n > 20):
print(n, "korovy")
else:
print(n, "korov")
| normal | {
"blob_id": "78037d936ee5f9b31bf00263885fbec225a4f8f2",
"index": 2191,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif n % 10 == 1 and (n < 11 or n > 20):\n print(n, 'korova')\nelif n % 10 > 1 and n % 10 < 5 and (n < 11 or n > 20):\n print(n, 'korovy')\nelse:\n print(n, 'korov')\n",
"step-3"... | [
0,
1,
2,
3
] |
n=int(input("please enter the number : "))
for i in range(11):
print(n," X ",i," = ",n*i) | normal | {
"blob_id": "ea4a55ed17c5cc2c6f127112af636ca885159c86",
"index": 5768,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(11):\n print(n, ' X ', i, ' = ', n * i)\n",
"step-3": "n = int(input('please enter the number : '))\nfor i in range(11):\n print(n, ' X ', i, ' = ', n * i)\n",
"... | [
0,
1,
2,
3
] |
#finding optimal betting strategy for the blackjack game using Monte Carlo ES method
import random
class Player():
def __init__(self) -> None:
q = None
policy = None
returns = None
cards = 0
dealer = 0
def hit(self):
self.cards += random.randint(1,11)
def d... | normal | {
"blob_id": "db159cfb198311b0369f65eb9e10947c4d28c695",
"index": 2919,
"step-1": "<mask token>\n\n\nclass Player:\n <mask token>\n\n def hit(self):\n self.cards += random.randint(1, 11)\n\n def deal(self):\n self.cards = random.randint(1, 11) + random.randint(1, 11)\n self.dealer = ... | [
4,
5,
8,
9,
10
] |
#!/usr/bin/env python
from bumblebee.motion import *
from simulation.path import *
from simulation.settings import *
import tf.transformations
from geometry_msgs.msg import TransformStamped,Transform,Quaternion,Vector3
from bumblebee.baseTypes import basicGraph,slidingGraph
from simulation.dataset import stereo_simul... | normal | {
"blob_id": "4b3de2d817aa6f8b92d513bcdba612362becefdc",
"index": 9070,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsty.use('seaborn')\n<mask token>\nrospy.init_node('graph_poses_extract')\nfor f in replayFiles:\n print('new SLiding Graph')\n inlierData = []\n rmsData = []\n inlierRatio = [... | [
0,
1,
2,
3,
4
] |
"""
Django settings for hauki project.
"""
import logging
import os
import subprocess
import environ
import sentry_sdk
from django.conf.global_settings import LANGUAGES as GLOBAL_LANGUAGES
from django.core.exceptions import ImproperlyConfigured
from sentry_sdk.integrations.django import DjangoIntegration
CONFIG_FILE... | normal | {
"blob_id": "5ed34ada35dfb2f783af4485bf9d31aa42712b9a",
"index": 4480,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_git_revision_hash() ->str:\n \"\"\"\n Retrieve the git hash for the underlying git repository or die trying\n\n We need a way to retrieve git revision hash for sentry... | [
0,
2,
3,
4,
5
] |
import argparse
from time import sleep
from threading import Thread
from threading import Lock
from multiprocessing.connection import Listener
from multiprocessing.connection import Client
ADDRESS = '127.0.0.1'
PORT = 5000
# Threaded function snippet
def threaded(fn):
def wrapper(*args, **kwargs):
thread ... | normal | {
"blob_id": "c5a2c00d53111d62df413907d4ff4ca5a02d4035",
"index": 7005,
"step-1": "<mask token>\n\n\nclass Process:\n <mask token>\n <mask token>\n <mask token>\n\n def send_neighbours(self, data, exceptions=[]):\n for i in [x for x in self.neighbours if x not in exceptions]:\n self.... | [
2,
8,
9,
11,
12
] |
import pyhs2
import sys
import datetime
i = datetime.datetime.now()
# args
if len(sys.argv) < 2:
print "Run with python version 2.6"
print "Requires arg: <orgId>"
sys.exit()
orgId = sys.argv[1]
print "\n\nCreating document external ID manifest for Org ID: " + orgId
## strings
fileLine = "%s\... | normal | {
"blob_id": "29c630b56eb56d91d1e917078138a2bbf562e0bf",
"index": 579,
"step-1": "import pyhs2\nimport sys\nimport datetime\ni = datetime.datetime.now()\n\n# args\nif len(sys.argv) < 2:\n print \"Run with python version 2.6\"\n print \"Requires arg: <orgId>\"\n sys.exit()\n\norgId = sys.argv[... | [
0
] |
'''CLASS message_unpacker
Message bodies sent through RabbitMQ may take various forms. They were packed
accordingly by the message_packager.
This class reverses the process. Currently, only implemented for message bodies
represented as strings, but could also handle various image formats in a real use
... | normal | {
"blob_id": "2afc1027c6866e8ab9584a5f7feef4470661f763",
"index": 4246,
"step-1": "<mask token>\n\n\nclass MessageUnpacker:\n <mask token>\n <mask token>\n\n def unpack_json_to_dict(self, incoming_json):\n record_as_dict = json.loads(incoming_json)\n return record_as_dict\n <mask token>\... | [
2,
4,
5,
6,
7
] |
"""
-------------------------------------------------------
Stack utilities
-------------------------------------------------------
Author: Evan Attfield
ID: 180817010
Email: attf7010@mylaurier.ca
__updated__ = "Jan 22, 2019"
-------------------------------------------------------
"""
from Stack_array... | normal | {
"blob_id": "dab9b58b08b562d902ee0ae1104198cb1ebbffe5",
"index": 1928,
"step-1": "<mask token>\n\n\ndef array_to_stack(stack, source):\n \"\"\"\n -------------------------------------------------------\n Pushes contents of source onto stack. At finish, source is empty.\n Last value in source is at bo... | [
4,
9,
12,
13,
14
] |
import numpy as np
from django.contrib.auth import logout, login, authenticate
from django.contrib.auth.decorators import login_required
from django.core.mail import EmailMessage
from django.shortcuts import render, redirect
from django.template.loader import get_template
from dashboard.notebook.creditcard import cred... | normal | {
"blob_id": "26bb5dc2679a4375d0950667ed02369df10857a8",
"index": 8410,
"step-1": "<mask token>\n\n\ndef contact(request):\n form_class = ContactForm\n if request.method == 'POST':\n form = form_class(data=request.POST)\n if form.is_valid():\n contact_name = request.POST.get('contac... | [
7,
9,
11,
14,
16
] |
import sys
import pygame
import os
import random
import subprocess
FPS, NEWENEMYSPAWN, fst_spawn, not_paused, coins, enemies_count, killed, score = 50, 30, 2000, True, 0, 0, 0, 0
MiniG_rate, EnemyG_rate, MetalM_rate = 1, 5, 15
WEAPONS_LIST = ['Green laser gun', 'Purple laser gun', 'Plasma gun']
def load_i... | normal | {
"blob_id": "244191087fcab2a6f03bf024708484b9838731ed",
"index": 9301,
"step-1": "<mask token>\n\n\nclass Player(pygame.sprite.Sprite):\n\n def __init__(self, group):\n super().__init__(group)\n self.weapon = Weapon(self, 'Green laser gun')\n self.image = load_image('player.jpg', -1)\n ... | [
7,
13,
16,
22,
30
] |
from symcollab.algebra import *
from .ac import *
from copy import deepcopy
# This is a single arity function which only actually gets applied when called an odd number of times
# Useful for the inverse function later on
# A group G is an algebraic structure which satisfies the following properties
# (1) G is closed... | normal | {
"blob_id": "93133b9a62d50e4e48e37721585116c1c7d70761",
"index": 2490,
"step-1": "<mask token>\n\n\nclass GroupVariable(GroupElement, Variable):\n\n def __init__(self, g: Group, symbol: str):\n GroupElement.__init__(self, g)\n Variable.__init__(self, symbol)\n\n def __hash__(self):\n r... | [
18,
31,
34,
35,
37
] |
from features.steps.web.test_home_page import *
from features.steps.mobile.test_home_page import *
from features.steps.web.test_login_page import *
| normal | {
"blob_id": "b09d0806dfc6f4badfd9f2ac9c3f6d17d3df8e8c",
"index": 3254,
"step-1": "<mask token>\n",
"step-2": "from features.steps.web.test_home_page import *\nfrom features.steps.mobile.test_home_page import *\nfrom features.steps.web.test_login_page import *\n",
"step-3": null,
"step-4": null,
"step-5":... | [
0,
1
] |
"""AWS CDK application.
See https://docs.aws.amazon.com/cdk/ for details.
"""
from ias_pmi_cdk_common import PMIApp
from stacks import MainStack
APP_NAME = 'etl-pm-pipeline-be'
# create CDK application
app = PMIApp(APP_NAME)
# add stacks
MainStack(app, app, 'main')
# synthesize application assembly
app.synth(... | normal | {
"blob_id": "dfbbbaf6b5f02c60ca48f7864068d59349c547d1",
"index": 5484,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nMainStack(app, app, 'main')\napp.synth()\n",
"step-3": "<mask token>\nAPP_NAME = 'etl-pm-pipeline-be'\napp = PMIApp(APP_NAME)\nMainStack(app, app, 'main')\napp.synth()\n",
"step-4": "... | [
0,
1,
2,
3,
4
] |
field = [['*', '1', '2', '3'], ['1', '-', '-', '-'], ['2', '-', '-', '-'], ['3', '-', '-', '-']]
def show(a):
for i in range(len(a)):
for j in range(len(a[i])):
print(a[i][j], end=' ')
print()
def askUserZero():
while True:
inputX = input('Введите номер строки нолика'... | normal | {
"blob_id": "3f22bf954a8c4608ec4bd4a28bea3679a664a99a",
"index": 2364,
"step-1": "<mask token>\n\n\ndef show(a):\n for i in range(len(a)):\n for j in range(len(a[i])):\n print(a[i][j], end=' ')\n print()\n\n\ndef askUserZero():\n while True:\n inputX = input('Введите номер с... | [
3,
4,
5,
6,
7
] |
from django.conf.urls import url
from . import consumers
websocket_urlpatterns = [
url(r'^account/home', consumers.NotificationConsumer),
url(r'^fund/(?P<fund>[\w-]+)', consumers.NotificationConsumer),
url(r'^websockets', consumers.StreamConsumer),
] | normal | {
"blob_id": "7ab9c530035185ee2250f3f6ce8cde87bdfd9803",
"index": 5295,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwebsocket_urlpatterns = [url('^account/home', consumers.\n NotificationConsumer), url('^fund/(?P<fund>[\\\\w-]+)', consumers.\n NotificationConsumer), url('^websockets', consumers.S... | [
0,
1,
2,
3
] |
def descending_order(num):
return int(''.join(sorted(str(num), reverse=True)))
import unittest
class TestIsBalanced(unittest.TestCase):
def test_is_balanced(self):
self.assertEquals(descending_order(0), 0)
self.assertEquals(descending_order(15), 51)
self.assertEquals(descending_orde... | normal | {
"blob_id": "fc5d0dd16b87ab073bf4b054bd2641bdec88e019",
"index": 6594,
"step-1": "<mask token>\n\n\nclass TestIsBalanced(unittest.TestCase):\n\n def test_is_balanced(self):\n self.assertEquals(descending_order(0), 0)\n self.assertEquals(descending_order(15), 51)\n self.assertEquals(descen... | [
2,
3,
4,
5
] |
# Generated by Django 3.0.4 on 2020-03-29 09:27
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('portfolio_app', '0008_feedback_product'),
]
operations = [
migrations.RemoveField(
model_name='feedback',
name... | normal | {
"blob_id": "11ad3e1ab4ffd491e27998a7235b7e18857632ed",
"index": 3141,
"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 = [('portfolio_a... | [
0,
1,
2,
3,
4
] |
from alive_progress import alive_bar
from time import sleep
with alive_bar(100) as bar: # default setting
for i in range(100):
sleep(0.03)
bar() # call after consuming one item
# using bubble bar and notes spinner
with alive_bar(200, bar='bubbles', spinner=... | normal | {
"blob_id": "06f961c07695d1c312cb943afbfa64508a709c7e",
"index": 1076,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith alive_bar(100) as bar:\n for i in range(100):\n sleep(0.03)\n bar()\n with alive_bar(200, bar='bubbles', spinner='notes2') as bar:\n for i in range... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('twitter', '0002_tweet'),
]
operations = [
migrations.CreateModel(
name='TwitterKeys',
fields=[
... | normal | {
"blob_id": "c8406db010a506b782030c5d3f84c319851e89d6",
"index": 3662,
"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 = [('twitter', '... | [
0,
1,
2,
3,
4
] |
'''
Write the necessary code calculate the volume and surface area
of a cylinder with a radius of 3.14 and a height of 5. Print out the result.
'''
pi = 3.14159
r = 3.14
h = 5
volume = pi*r**2*h
surface_area = 2*pi*r**2+r*h
print(volume,surface_area) | normal | {
"blob_id": "d04e69c234f2887f5301e4348b4c4ec2ad3af7a2",
"index": 2623,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(volume, surface_area)\n",
"step-3": "<mask token>\npi = 3.14159\nr = 3.14\nh = 5\nvolume = pi * r ** 2 * h\nsurface_area = 2 * pi * r ** 2 + r * h\nprint(volume, surface_area)\n",... | [
0,
1,
2,
3
] |
def rank_and_file(l):
dict = {}
final_list = []
for each in l:
for num in each:
dict[num] = dict[num] + 1 if num in dict else 1
for key in dict:
if dict[key] % 2 != 0:
final_list.append(key)
final_list = sorted(final_list)
return " ".join(map(str, final_list))
f = open('B-large.in.txt', 'r')
f2 = open(... | normal | {
"blob_id": "359f4fa75379cc2dd80d372144ced08b8d15e0a4",
"index": 6758,
"step-1": "<mask token>\n",
"step-2": "def rank_and_file(l):\n dict = {}\n final_list = []\n for each in l:\n for num in each:\n dict[num] = dict[num] + 1 if num in dict else 1\n for key in dict:\n if di... | [
0,
1,
2,
3,
4
] |
#grabbed the following from moses marsh -- https://github.com/sidetrackedmind/gimme-bus/blob/master/gimmebus/utilities.py
from datetime import datetime as dt
from math import radians, cos, sin, acos, asin, sqrt
import networkx as nx
## These functions will go in model.py for matching historical GPS
## positions to th... | normal | {
"blob_id": "89ce3d3ec9691ab8f54cc0d9d008e06c65b5f2cc",
"index": 7847,
"step-1": "<mask token>\n\n\ndef haversine(pt1, pt2):\n \"\"\"\n INPUT: tuples (lon1, lat1), (lon2, lat2)\n\n OUTPUT: The great circle distance between two points\n on the earth (specified in decimal degrees)\n \"\"\"\n lon1... | [
2,
3,
4,
5,
6
] |
# Generated by Django 2.1.7 on 2019-05-31 18:45
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('events', '0004_auto_2019... | normal | {
"blob_id": "2ec8d3853ea4a99d4e764c6c24d7b5a3afb64f63",
"index": 2830,
"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 = [migrations.sw... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
import sys
from os import path
try:
import DMP
except ImportError:
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from DMP.modeling.vectorMaker import VectorMaker
from DMP.modeling.variables import KEY_TOTAL, KEY_TRAIN, KEY_VALID, KEY_TEST
from DMP.dataset.dataHan... | normal | {
"blob_id": "ca25739583d3b7ff449fbd2f56a96631981c815d",
"index": 5986,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n import DMP\nexcept ImportError:\n sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))\n<mask token>\nif __name__ == '__main__':\n file_dict = {KEY_TOTAL: S... | [
0,
1,
2,
3
] |
import pytorch_lightning as pl
from matplotlib import pyplot as plt
class Model(pl.LightningModule):
def __init__(self, net):
super(Model, self).__init__()
self.net = net
self.save_hyperparameters()
self.criterion = None
self.optimizer = None
self.batch_loss_collec... | normal | {
"blob_id": "324081eb4e133f6d16e716f3119e4cbc5e045ede",
"index": 8526,
"step-1": "<mask token>\n\n\nclass Model(pl.LightningModule):\n <mask token>\n\n def init_training_parameters(self, criterion, optimizer):\n self.criterion = criterion\n self.optimizer = optimizer\n\n def set_criterion(... | [
8,
10,
12,
15
] |
from __future__ import print_function
from itertools import permutations
s, space, k = raw_input().partition(' ')
for t in sorted(list(permutations(s, int(k)))):
print(*t, sep='')
| normal | {
"blob_id": "37580939a0e58bdffb8cfad8252f339a7da4446e",
"index": 1130,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor t in sorted(list(permutations(s, int(k)))):\n print(*t, sep='')\n",
"step-3": "<mask token>\ns, space, k = raw_input().partition(' ')\nfor t in sorted(list(permutations(s, int(k)... | [
0,
1,
2,
3
] |
from itertools import count, islice
from math import sqrt
def is_prime(x):
if x<2:
return False
for i in range(2, int(sqrt(x)) + 1):
if x%i == 0:
return False
return True
def primes(x):
return islice((p for p in count() if is_prime(p)), x)
print(list(primes(1000))[-10:])
... | normal | {
"blob_id": "0f1bad350faaff6aab339944b4d24c4801fa8c64",
"index": 4965,
"step-1": "<mask token>\n\n\ndef is_prime(x):\n if x < 2:\n return False\n for i in range(2, int(sqrt(x)) + 1):\n if x % i == 0:\n return False\n return True\n\n\ndef primes(x):\n return islice((p for p in... | [
2,
3,
4,
5,
6
] |
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '../tools'))
import files
import genetics
def main(argv):
S = files.read_lines(argv[0])
S_rc = [genetics.dna_complement(s) for s in S]
S_u = set(S + S_rc)
B_k = []
for s in S_u:
B_k.append((s[:-1], s[1:]))... | normal | {
"blob_id": "b616b907eb67fff97d57ee2b0d3ab8e01d154956",
"index": 2038,
"step-1": "import os\nimport sys\nsys.path.append(os.path.join(os.path.dirname(__file__), '../tools'))\n\nimport files\nimport genetics\n\n\ndef main(argv):\n S = files.read_lines(argv[0])\n S_rc = [genetics.dna_complement(s) for s i... | [
0
] |
import random #import random module
guesses_taken = 0 #assign 0 to guesses_taken variable
print('Hello! What is your name?')# print Hello! What is your name? to console
myName = input()#take an input from user(name)
number = random.randint(1, 20)# make random number between 1 and 19 and save in number variable
print... | normal | {
"blob_id": "3302dc058032d9fe412bde6fd89699203526a72d",
"index": 4695,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Hello! What is your name?')\n<mask token>\nprint('Well, ' + myName + ', I am thinking of a number between 1 and 20.')\nwhile guesses_taken < 6:\n print('Take a guess.')\n gue... | [
0,
1,
2,
3,
4
] |
# views which respond to ajax requests
from django.contrib import messages
from django.conf import settings
from django.contrib.auth.models import User
from social.models import Like, Post, Comment, Notification
from social.notifications import Notify
from social.forms import CommentForm
from django.http impor... | normal | {
"blob_id": "0b4f070d30642449536118accffa371a89dd3075",
"index": 8857,
"step-1": "<mask token>\n\n\ndef follow(request):\n action = request.POST.get('action')\n followed_user_id = request.POST.get('followedUserId')\n followed_user = User.objects.get(id=followed_user_id)\n if followed_user == request.... | [
6,
9,
11,
12,
16
] |
# -*- coding=UTF-8 -*-
'''
Created on 20180127
@author: Harry
'''
import datetime
# today = datetime.date.today()
# weekday = today.weekday()
#
# if weekday == 0:
# print "周一"
# else:
# print "other days"
nowtime=datetime.datetime.now()
detaday = datetime.timedelta(days=-1)
da_days= nowtime + detad... | normal | {
"blob_id": "662fc9d64b9046180cf70ce4b26ac2b9665dba0e",
"index": 887,
"step-1": "# -*- coding=UTF-8 -*-\n\n'''\nCreated on 20180127\n\n@author: Harry\n'''\n\nimport datetime\n \n# today = datetime.date.today() \n# weekday = today.weekday() \n# \n# if weekday == 0:\n# print \"周一\"\n# else:\n# print \"othe... | [
0
] |
#!/usr/bin/python
# -*- coding : utf-8 -*-
"""
@author: Diogenes Augusto Fernandes Herminio <diofeher@gmail.com>
"""
# Director
class Director(object):
def __init__(self):
self.builder = None
def construct_building(self):
self.builder.new_building()
self.builder.build_floor... | normal | {
"blob_id": "8ee26d181f06a2caf2b2b5a71a6113c245a89c03",
"index": 3322,
"step-1": "#!/usr/bin/python\n# -*- coding : utf-8 -*-\n\"\"\"\n @author: Diogenes Augusto Fernandes Herminio <diofeher@gmail.com>\n\"\"\"\n\n# Director\nclass Director(object):\n def __init__(self):\n self.builder = None\n ... | [
0
] |
# pylint: disable=not-callable, no-member, invalid-name, missing-docstring, arguments-differ
import argparse
import itertools
import os
import torch
import torch.nn as nn
import tqdm
import time_logging
from hanabi import Game
def mean(xs):
xs = list(xs)
return sum(xs) / len(xs)
@torch.jit.script
def swis... | normal | {
"blob_id": "070330f8d343ff65852c5fbb9a3e96fe1bfc55b5",
"index": 8816,
"step-1": "<mask token>\n\n\n@torch.jit.script\ndef swish_jit_fwd(x):\n return x * torch.sigmoid(x) * 1.6768\n\n\n<mask token>\n\n\nclass SwishJitAutoFn(torch.autograd.Function):\n\n @staticmethod\n def forward(ctx, x):\n ctx.... | [
6,
7,
9,
14,
16
] |
import sys
import cv2
import numpy as np
import matplotlib.pyplot as plt
from .caffe_path import caffe
from .timer import Timer
__all__ = ['Detector']
# VOC Class list
CLASSES = dict(
voc = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car',
'cat', 'chair', 'cow', 'diningtable', 'dog', 'h... | normal | {
"blob_id": "de12c6d78c0144978ffc651829364de16930b173",
"index": 2078,
"step-1": "<mask token>\n\n\nclass Detector(object):\n <mask token>\n\n def __init__(self, prototxt, caffemodel, gpu_id, dataset='coco', scale=\n 600, max_size=1000, transpose=(2, 0, 1), mean=[102.9801, 115.9465, \n 122.77... | [
6,
7,
8,
9,
10
] |
from django.urls import path
from player.views import (
MusicListView, MusicPlayView, MusicPauseView, MusicUnPauseView,
NextSongView, PreviousSongView
)
urlpatterns = [
path('list/', MusicListView, name="music_list"),
path('play/<str:name>/', MusicPlayView, name="play_music"),
path('pause/', Music... | normal | {
"blob_id": "f23b002ec0eefa376890e255b1ac0137e3a1c989",
"index": 5338,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('list/', MusicListView, name='music_list'), path(\n 'play/<str:name>/', MusicPlayView, name='play_music'), path('pause/',\n MusicPauseView, name='pause_music'), ... | [
0,
1,
2,
3
] |
import os
import sys
sys.path.insert(0, "/path/to/mm-api/python")
sys.path.insert(0, "/path/to/mm-api/distrib/python_osx")
print(sys.path)
import mmapi
from mmRemote import *
import mm;
# assumption: we are running
examples_dir = "/dir/of/models/"
part_filename1 = os.path.join( examples_dir, "model1.stl" )
part_file... | normal | {
"blob_id": "bf6d1ddf66bc0d54320c0491e344925a5f507df7",
"index": 861,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.insert(0, '/path/to/mm-api/python')\nsys.path.insert(0, '/path/to/mm-api/distrib/python_osx')\nprint(sys.path)\n<mask token>\nremote.connect()\n<mask token>\nremote.shutdown()\n",... | [
0,
1,
2,
3,
4
] |
import numpy as np
from collections import Counter
import matplotlib.pyplot as plt
# 1. sepal length in cm
# 2. sepal width in cm
# 3. petal length in cm
# 4. petal width in cm
TrainingData = np.loadtxt("Data2",delimiter = ',',skiprows = 1,dtype = str)
class Knn(object):
"""docstring for data"""
def ... | normal | {
"blob_id": "5e0affbd295d7237784cd8e72926afeda6456500",
"index": 7080,
"step-1": "<mask token>\n\n\nclass Knn(object):\n <mask token>\n\n def __init__(self, TrainingData):\n self.TrainingData = TrainingData\n self.nFeatures = self.TrainingData.shape[1] - 1\n self.data = TrainingData[:,... | [
4,
5,
7,
8,
9
] |
i = 100
while i >= 100:
print(i)
i -= 1
print(i)
| normal | {
"blob_id": "9527743802a0bb680ab3dcf325c0f7749a51afc6",
"index": 5949,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile i >= 100:\n print(i)\ni -= 1\nprint(i)\n",
"step-3": "i = 100\nwhile i >= 100:\n print(i)\ni -= 1\nprint(i)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
'''
Created on Dec 22, 2014
@author: Alan Tai
'''
from handlers.handler_webapp2_extra_auth import BaseHandler
from models.models_porn_info import WebLinkRoot, WebLinkPornTemp, WebLinkPorn,\
Tag
from dictionaries.dict_key_value_pairs import KeyValuePairsGeneral
from bs4 import BeautifulSoup
... | normal | {
"blob_id": "f6cebf6ec848a06f81c4e1f584ebb83f4d9ff47c",
"index": 3549,
"step-1": "# -*- coding: utf-8 -*-\n'''\nCreated on Dec 22, 2014\n\n@author: Alan Tai\n'''\nfrom handlers.handler_webapp2_extra_auth import BaseHandler\nfrom models.models_porn_info import WebLinkRoot, WebLinkPornTemp, WebLinkPorn,\\\n Tag... | [
0
] |
from barista.sensor import CarafeLevel, CarafeTemp
class Carafe(object):
def __init__(self):
self.level = CarafeLevel()
self.temp = CarafeTemp()
# TODO add callback for when the temperature or level are too low. | normal | {
"blob_id": "a0cce8d48f929dd63ba809a1e9bf02b172e8bc1b",
"index": 2192,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Carafe(object):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Carafe(object):\n\n def __init__(self):\n self.level = CarafeLevel()\n self.temp = Ca... | [
0,
1,
2,
3,
4
] |
#! /usr/bin/env python3
import sys
def stage_merge_checksums(
old_survey=None,
survey=None,
brickname=None,
**kwargs):
'''
For debugging / special-case processing, read previous checksums, and update them with
current checksums values, then write out the result.
'''
... | normal | {
"blob_id": "a98d03b169b59704b3b592cee0b59f5389fd77b3",
"index": 8899,
"step-1": "<mask token>\n\n\ndef main():\n import argparse\n parser = argparse.ArgumentParser()\n parser.add_argument('--old-output', required=True, help=\n '\"Old\" output directory to read old checksum file from.')\n pars... | [
1,
2,
3,
4,
5
] |
"""Splits the google speech commands into train, validation and test sets.
"""
import os
import shutil
import argparse
def move_files(src_folder, to_folder, list_file):
with open(list_file) as f:
for line in f.readlines():
line = line.rstrip()
dirname = os.path.dirname(line)
... | normal | {
"blob_id": "6b2fc94d9a53b8f669cab5e1fb625dd01e20ba98",
"index": 664,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef move_files(src_folder, to_folder, list_file):\n with open(list_file) as f:\n for line in f.readlines():\n line = line.rstrip()\n dirname = os.path.d... | [
0,
1,
2,
3,
4
] |
import requests
from bs4 import BeautifulSoup
import re
# if no using some headers, wikiloc answers HTML error 503, probably they protect their servers against scrapping
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',}
def main():
print("################... | normal | {
"blob_id": "5a4a014d07cf312f148e089ea43484f663ce32bc",
"index": 8586,
"step-1": "<mask token>\n\n\ndef main():\n print('##############################')\n response = requests.get(\n 'http://www.muenchen.de/rathaus/Serviceangebote/familie/kinderbetreuung/corona.html#geschlossene-kitas-oder-kitagrupp... | [
1,
2,
3,
4,
5
] |
from django.shortcuts import render, redirect, get_object_or_404
from .models import Article, Comment
# from IPython import embed
# Create your views here.
def article_list(request):
articles = Article.objects.all()
return render(request, 'board/list.html', {
'articles': articles,
})
def articl... | normal | {
"blob_id": "6946601050802aaaa559d25612d0d4f5116559eb",
"index": 1845,
"step-1": "<mask token>\n\n\ndef article_list(request):\n articles = Article.objects.all()\n return render(request, 'board/list.html', {'articles': articles})\n\n\ndef article_detail(request, article_id):\n article = get_object_or_40... | [
5,
6,
7,
8,
9
] |
# square environment. there are the wall at the edge
from environment import super_environment
class SquareNormal(super_environment.Environment):
def __init__(self, size_x, size_y):
super().__init__(size_x, size_y)
@staticmethod
def environment_type():
return 'square'
def get_convert... | normal | {
"blob_id": "919f1746bfdec61f5e81e6ce0e17bb3bf040230a",
"index": 2958,
"step-1": "<mask token>\n\n\nclass SquareNormal(super_environment.Environment):\n <mask token>\n\n @staticmethod\n def environment_type():\n return 'square'\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass SquareNorm... | [
2,
3,
4,
5,
6
] |
from .dispatch import dispatch_expts
| normal | {
"blob_id": "394ebfe25bbf8eaf427509f28a82a98b9b481b63",
"index": 4957,
"step-1": "<mask token>\n",
"step-2": "from .dispatch import dispatch_expts\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
#Simple Pig Latin
def pig_it(text):
return " ".join( letter if letter == "!" or letter == "?" else (letter[1:] + letter[0] + "ay") for letter in text.split(" "))
| normal | {
"blob_id": "25641b3a9919db1f172fca22acf413062505de1b",
"index": 6894,
"step-1": "<mask token>\n",
"step-2": "def pig_it(text):\n return ' '.join(letter if letter == '!' or letter == '?' else letter[1:\n ] + letter[0] + 'ay' for letter in text.split(' '))\n",
"step-3": "#Simple Pig Latin\ndef pig_i... | [
0,
1,
2
] |
'''
Applies the mish function element-wise:
.. math::
mish(x) = x * tanh(softplus(x)) = x * tanh(ln(1 + e^{x}))
'''
# import pytorch
import torch
from torch import nn
# import activation functions
import echoAI.Activation.Torch.functional as Func
class Mish(nn.Module):
'''
Applies the mish function ele... | normal | {
"blob_id": "2deb73c7d2588ea1a5b16eb1ed617583d41f0130",
"index": 2846,
"step-1": "<mask token>\n\n\nclass Mish(nn.Module):\n <mask token>\n <mask token>\n\n def forward(self, input):\n \"\"\"\n Forward pass of the function.\n \"\"\"\n return Func.mish(input, inplace=self.inpl... | [
2,
3,
4,
5,
6
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.