code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
# coding: utf-8
"""
Picarto.TV API Documentation
The Picarto.TV API documentation Note, for fixed access tokens, the header that needs to be sent is of the format: `Authorization: Bearer yourTokenHere` This can be generated at https://oauth.picarto.tv/ For chat API, see https://docs.picarto.tv/chat/chat.pr... | normal | {
"blob_id": "939011fca968d5f9250beb29a0bb700200e637df",
"index": 6274,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nconfiguration = Configuration()\n",
"step-3": "<mask token>\nfrom __future__ import absolute_import\nfrom .models.basic_channel_info import BasicChannelInfo\nfrom .models.basic_follower... | [
0,
1,
2,
3
] |
# Generated by Django 3.2.5 on 2021-08-05 07:19
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),
('organization', '0010_aut... | normal | {
"blob_id": "f2c53efa4b7c2df592582e3093ff269b703be1e0",
"index": 3054,
"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
] |
import sys
word = input()
if word[0].islower():
print('{}{}'.format(word[0].upper(), word[1:]))
sys.exit()
else:
print(word)
sys.exit()
| normal | {
"blob_id": "227e78312b5bad85df562b6ba360de352c305e7b",
"index": 3913,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif word[0].islower():\n print('{}{}'.format(word[0].upper(), word[1:]))\n sys.exit()\nelse:\n print(word)\n sys.exit()\n",
"step-3": "<mask token>\nword = input()\nif word[0... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
import os
import sys
from setuptools import setup
from textwrap import dedent
NAME = "docker-zabbix-script-sender"
GITHUB_ORG_URL = "https://github.com/troptop/"
ROOT_DIR = os.path.dirname(__file__)
SOURCE_DIR = os.path.join(ROOT_DIR)
exec(open('docker_zabbix_script_sender/version.py').read())
... | normal | {
"blob_id": "0769003c248c099da5bcd75541d35234b01af5de",
"index": 2723,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nexec(open('docker_zabbix_script_sender/version.py').read())\nsetup(name=NAME, version=version, author='Cyril Moreau', author_email=\n 'cyril.moreauu@gmail.com', url=GITHUB_ORG_URL + '/... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Title: Counting summations
import math
limit = 201
comboList = dict()
alphabet = range(1, limit)
searchAlphabet = set(alphabet)
def concat(a, b):
return "%i %i" % (a, b)
def split(n, min=1, tab=6):
if concat(n,min) in comboList.keys():
if tab == 6:
print " %sn = %i, ... | normal | {
"blob_id": "618a8430d50aeca1c4b9c3fba975be342cc1893f",
"index": 6348,
"step-1": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#Title: Counting summations\n\nimport math\n\nlimit = 201\ncomboList = dict()\nalphabet = range(1, limit)\nsearchAlphabet = set(alphabet)\ndef concat(a, b):\n\treturn \"%i %i\" % (a, b)\n... | [
0
] |
from Graph import create_random_graph
def find_accessible_vertices_backwards(graph, end_vertex):
if end_vertex not in graph.parse_vertices():
raise ValueError("The end vertex is not in the graph.")
visited = []
queue = []
next_vertex = {}
distance_to_end = {}
queue.append... | normal | {
"blob_id": "f882589729d74a910d20856d4dc02546fe316e0d",
"index": 2994,
"step-1": "<mask token>\n\n\ndef main():\n random_graph = create_random_graph(5, 10)\n print('THE GRAPH:')\n for vertex in random_graph.parse_vertices():\n for edge in random_graph.parse_outbound_edges(vertex):\n pr... | [
1,
2,
4,
5,
6
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 21 11:40:26 2020
@author: jlee
"""
import time
start_time = time.time()
import numpy as np
import glob, os
from astropy.io import fits
import init_cfg as ic
# ----- Making scripts for PSFEx ----- #
os.system("psfex -dd > config.psfex")
if ic.... | normal | {
"blob_id": "c23125018a77508dad6fd2cb86ec6d556fbd1019",
"index": 90,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nos.system('psfex -dd > config.psfex')\nif ic.use_backsub:\n prefix = 'b'\nelse:\n prefix = ''\n<mask token>\nf.write('\\n')\nf.write('#############################' + '\\n')\nf.write(... | [
0,
1,
2,
3,
4
] |
# Python bytecode 2.7 (decompiled from Python 2.7)
# Embedded file name: scripts/client/web_client_api/__init__.py
from soft_exception import SoftException
class WebCommandException(SoftException):
def __init__(self, description):
super(WebCommandException, self).__init__(description)
| normal | {
"blob_id": "0f4864b745768994ea55a931e4d8b0681c058465",
"index": 2828,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass WebCommandException(SoftException):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass WebCommandException(SoftException):\n\n def __init__(self, description):\n ... | [
0,
1,
2,
3,
4
] |
from ...java import opcodes as JavaOpcodes
from .primitives import ICONST_val
##########################################################################
# Common Java operations
##########################################################################
class New:
def __init__(self, classname):
self.clas... | normal | {
"blob_id": "67e0536dc9f38ab82fe30e715599fed93c5425a5",
"index": 5142,
"step-1": "<mask token>\n\n\nclass Array:\n\n def __init__(self, size, classname='org/python/Object', fill=None):\n self.size = size\n self.classname = classname\n self.fill = fill\n\n def process(self, context):\n ... | [
12,
15,
16,
18,
23
] |
from pynput.keyboard import Listener
import logging
import daemon
import socket
import thread
logging.basicConfig(format="%(asctime)s:%(message)s")
file_logger = logging.FileHandler("/home/user0308/logger.log", "a")
logger = logging.getLogger()
logger.addHandler(file_logger)
logger.setLevel(logging.DEBUG)
def press(... | normal | {
"blob_id": "3dc2d9a5e37ce1f546c0478de5a0bb777238ad00",
"index": 4306,
"step-1": "<mask token>\n\n\ndef press(key):\n logging.info(key)\n\n\ndef work():\n with Listener(on_press=press) as listener:\n listener.join()\n\n\n<mask token>\n",
"step-2": "<mask token>\nlogging.basicConfig(format='%(ascti... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
# https://github.com/Raschka-research-group/coral-cnn/tree/master/model-code/resnet34
from absl import flags, app
from Rank_consistent_model_fix import *
from Rank_consistent_model import *
from random import shuffle, random
import tensorflow as tf
import numpy as np
# import cv2
import os
impo... | normal | {
"blob_id": "9ffe350ff9a568111620ef7dafef83d341f6f01e",
"index": 9409,
"step-1": "<mask token>\n\n\ndef _func(filename, label):\n image_string = tf.io.read_file(filename)\n decode_image = tf.image.decode_jpeg(image_string, channels=3)\n decode_image = tf.image.resize(decode_image, [FLAGS.img_size - 8, F... | [
7,
8,
9,
10,
12
] |
import sys
sys.setrecursionlimit(10 ** 6)
n, s = map(int, input().split())
value = list(map(int, input().split()))
count = 0
def recursive(index, sum):
global count
if index == n:
if sum == s:
count += 1
return
recursive(index + 1, sum + value[index])
recursive(index + 1, s... | normal | {
"blob_id": "f1aa12ec4ee2482db8abf1121a3443502544e1a2",
"index": 2815,
"step-1": "<mask token>\n\n\ndef recursive(index, sum):\n global count\n if index == n:\n if sum == s:\n count += 1\n return\n recursive(index + 1, sum + value[index])\n recursive(index + 1, sum)\n\n\n<mas... | [
1,
2,
3,
4
] |
# leetcode 718 最长重复子数组
# 给两个整数数组 A 和 B ,返回两个数组中公共的、长度最长的子数组的长度。
#
# 示例 1:
# 输入:
# A: [1,2,3,2,1]
# B: [3,2,1,4,7]
# 输出: 3
# 解释:
# 长度最长的公共子数组是 [3, 2, 1]。
#
# 说明:
# 1 <= len(A), len(B) <= 1000
# 0 <= A[i], B[i] < 100
class Solution:
def findLength(self, A: [int], B: [int])->int:
"""
动态规划, 维护... | normal | {
"blob_id": "b8219c21dc2cdd497d3de48c59c146a1fd1509ec",
"index": 6673,
"step-1": "class Solution:\n <mask token>\n\n\n<mask token>\n",
"step-2": "class Solution:\n\n def findLength(self, A: [int], B: [int]) ->int:\n \"\"\"\n 动态规划, 维护一个公共子串长度表DP\n DP[i][j]表示A中以第i个元素,B中以第j个元素结尾的公共子串长度\... | [
1,
2,
3,
4,
5
] |
'''Given a range of 2 numbers (i.e) L and R count the number of prime numbers in the range (inclusive of L and R ).
Input Size : L <= R <= 100000(complexity O(n) read about Sieve of Eratosthenes)
Sample Testcase :
INPUT
2 5
OUTPUT
3'''
x,y=map(int,input().split())
count=0
for i in range(x,y+1):
if i>1:
for... | normal | {
"blob_id": "06848ec0e327fed1da00446cec6392c6f42130af",
"index": 2158,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(x, y + 1):\n if i > 1:\n for j in range(2, i):\n if i % j == 0:\n break\n else:\n count += 1\nprint(count)\n",
"step... | [
0,
1,
2,
3
] |
import math
def max_heapity(arr, start, end):
root = start
while True:
child = 2 * root + 1
# 若子節點指標超出範圍則結束
if child > end:
break
# 先比較左右兩個子節點大小,選擇最大的那個子節點
if child + 1 <= end and arr[child] < arr[child + 1]:
child += 1
# 如果 root 的值小於 c... | normal | {
"blob_id": "2ffe4b0eb7af9b3a4d5724442b5409d27bfa92a1",
"index": 6130,
"step-1": "<mask token>\n\n\ndef max_heapity(arr, start, end):\n root = start\n while True:\n child = 2 * root + 1\n if child > end:\n break\n if child + 1 <= end and arr[child] < arr[child + 1]:\n ... | [
2,
3,
4,
5,
6
] |
import re
n = input("電話番号を入力してください>>")
pattern = r'[\(]{0,1}[0-9]{2,4}[\)\-\(]{0,1}[0-9]{2,4}[\)\-]{0,1}[0-9]{3,4}'
if re.findall(pattern, n):
print(n, "は電話番号の形式です")
else:
print(n, "は電話番号の形式ではありません")
| normal | {
"blob_id": "7ea81f83f556fcc55c9c9d44bcd63c583829fc08",
"index": 8977,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif re.findall(pattern, n):\n print(n, 'は電話番号の形式です')\nelse:\n print(n, 'は電話番号の形式ではありません')\n",
"step-3": "<mask token>\nn = input('電話番号を入力してください>>')\npattern = (\n '[\\\\(]{0,1}[... | [
0,
1,
2,
3,
4
] |
from deuces.card import Card
from deuces.deck import Deck
from fast_utils.hand_strength.original_HS import *
from fast_utils.hand_strength.nn_HS import encode_hs
from fast_utils.expected_hand_strength.nn_EHS import *
from keras.models import load_model
def read_lookup_table(hole_cards, lookup_table):
"""
Read... | normal | {
"blob_id": "8503998fc881f47dc695d3ea4c7f56fa65a96e8a",
"index": 2874,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef read_lookup_table(hole_cards, lookup_table):\n \"\"\"\n Reads the preflop lookup table preflop_EHSs.txt.\n Args: \n hole_cards: list of int (deuces cards)\n ... | [
0,
1,
2
] |
# Umut Cakan Computer Science S006742
# Fibonacci list. First and second terms are static.
fib_list = [0, 1]
# Current index.
CURRENT_INDEX = 2
# Function for the checking input is a Fibonacci number or not.
def check_fibonacci_number():
global CURRENT_INDEX
# Get the fibonacci numbers that are less or equal ... | normal | {
"blob_id": "50fa8852f74f4d2428fb238a86dd1feedb210877",
"index": 3261,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef check_fibonacci_number():\n global CURRENT_INDEX\n while fib_list[CURRENT_INDEX - 1] < NUMBER_TO_BE_CHECKED:\n fib_list.append(fib_list[CURRENT_INDEX - 1] + fib_list[... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# ! -*- coding: utf-8 -*-
'''
@Time : 2020/6/4 16:33
@Author : MaohuaYang
@Contact : maohuay@hotmail.com
@File : pinganFudan-GUI.py
@Software: PyCharm
'''
import time
import requests
import tkinter as tk
from login import Ehall
def set_win_center(root, curWidth='', curHight=''):
"""
... | normal | {
"blob_id": "d133a07f69d2dadb5559d881b01050abb2a9602b",
"index": 3891,
"step-1": "<mask token>\n\n\ndef main():\n root = tk.Tk()\n root.title('DailyFudan')\n set_win_center(root, 700, 350)\n root.resizable(0, 0)\n lblid = tk.Label(root, text='学号:')\n lblid.grid(row=0, column=0)\n entID = tk.... | [
1,
3,
4,
5,
6
] |
import csv
with open('healthviolations.csv', 'w') as fp:
with open('Restaurant_Inspections.csv', 'rb') as csvfile:
reader = csv.reader(csvfile)
header = next(reader, None)
writer = csv.writer(fp, delimiter=',')
writer.writerow([header[0], "violation"])
for row in reader:
if (row[20] != '')... | normal | {
"blob_id": "1825b365032a224ed56a1814d7f6457e2add8fdd",
"index": 8008,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('healthviolations.csv', 'w') as fp:\n with open('Restaurant_Inspections.csv', 'rb') as csvfile:\n reader = csv.reader(csvfile)\n header = next(reader, None)\n ... | [
0,
1,
2,
3
] |
# LCP 74. 最强祝福力场-离散化+二维差分
# https://leetcode.cn/problems/xepqZ5/
# forceField[i] = [x,y,side] 表示第 i 片力场将覆盖以坐标 (x,y) 为中心,边长为 side 的正方形区域。
# !若任意一点的 力场强度 等于覆盖该点的力场数量,请求出在这片地带中 力场强度 最强处的 力场强度。
# !统计所有左下和右上坐标,由于会出现 0.5可以将坐标乘 2。
# O(n^2)
from typing import List
from 二维差分模板 import DiffMatrix
class Solution:... | normal | {
"blob_id": "0212382b5c8cc1e98142a784fd26efd577ebceaf",
"index": 1656,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def fieldOfGreatestBlessing(self, forceField: List[List[int]]) ->int:\n allX, allY =... | [
0,
1,
2,
3,
4
] |
def helloWorld():
print "We are in DEMO land!"
for i in range(10):
helloWorld()
print listBuilder()
def listBuilder():
b = []
for x in range(5):
b.append(10 * x)
return b
print "[done, for real]"
| normal | {
"blob_id": "57516a17c1f3ee208076852369999d74dbb2b3ba",
"index": 98,
"step-1": "def helloWorld():\n print \"We are in DEMO land!\"\n\nfor i in range(10):\n helloWorld()\nprint listBuilder()\n\ndef listBuilder():\n b = []\n for x in range(5):\n b.append(10 * x)\n return b\n\nprint \"[done, for real]\"\n",... | [
0
] |
from keras.models import *
from keras.layers import *
from keras.optimizers import *
from keras.callbacks import ModelCheckpoint, LearningRateScheduler
from keras import backend as keras
unet_feature_n = 512
unet_feature_nstep_size = 1e-4
unet_input_image_size = 128
def unet(pretrained_weights=None, input_size=(unet_... | normal | {
"blob_id": "b8d45a0028cb4e393ddca9dd6d246289328d1791",
"index": 4044,
"step-1": "<mask token>\n\n\ndef small_unet(pretrained_weights=False, patch_size=128):\n input_ = Input((patch_size, patch_size, 1))\n skips = []\n output = input_\n for shape, filters in zip([5, 3, 3, 3, 3, 3, 3], [16, 32, 64, 64... | [
1,
2,
3,
4,
5
] |
from django import forms
from django.utils.translation import gettext_lazy as _
import django_filters
from elasticsearch_dsl.query import Q
class BaseSearchFilterSet(django_filters.FilterSet):
query_fields = ["content"]
q = django_filters.CharFilter(
method="auto_query",
widget=forms.TextInp... | normal | {
"blob_id": "f225fbf363f1b170704418ed339f2e57ca790975",
"index": 5317,
"step-1": "<mask token>\n\n\nclass BaseSearchFilterSet(django_filters.FilterSet):\n <mask token>\n <mask token>\n\n def __init__(self, *args, **kwargs):\n self.facet_config = kwargs.pop('facet_config', {})\n self.view =... | [
4,
5,
6,
7,
8
] |
import requests
#try make the request
try:
r = requests.get('http://skitter.com')
print(r) # see the results
# catch a failue
except (requests.ConnectionError, requests.Timeout) as x:
pass | normal | {
"blob_id": "a26cab29f0777764f014eeff13745be60e55b62d",
"index": 724,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n r = requests.get('http://skitter.com')\n print(r)\nexcept (requests.ConnectionError, requests.Timeout) as x:\n pass\n",
"step-3": "import requests\ntry:\n r = requests... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
import rospy
import cv2
from geometry_msgs.msg import PoseStamped
class PositionReader:
def __init__(self):
self.image_sub = rospy.Subscriber(
"/visp_auto_tracker/object_position", PoseStamped, self.callback)
self.pub = rospy.Publisher('object_position', PoseSta... | normal | {
"blob_id": "26ac0c94d0ab70d90854ca2c913ef0f633b54a3c",
"index": 4527,
"step-1": "<mask token>\n\n\nclass PositionReader:\n\n def __init__(self):\n self.image_sub = rospy.Subscriber('/visp_auto_tracker/object_position',\n PoseStamped, self.callback)\n self.pub = rospy.Publisher('objec... | [
2,
3,
4,
5,
6
] |
#!/usr/bin/env python3
import gatt
class AnyDevice(gatt.Device):
def connect_succeeded(self):
super().connect_succeeded()
print("[%s] Connected" % (self.mac_address))
def connect_failed(self, error):
super().connect_failed(error)
print("[%s] Connection failed: %s" % (self.mac_a... | normal | {
"blob_id": "480e636cfe28f2509d8ecf1e6e89924e994f100d",
"index": 4888,
"step-1": "<mask token>\n\n\nclass AnyDevice(gatt.Device):\n <mask token>\n\n def connect_failed(self, error):\n super().connect_failed(error)\n print('[%s] Connection failed: %s' % (self.mac_address, str(error)))\n <ma... | [
5,
7,
9,
11,
12
] |
import threading
import time
# import numpy as np
import pickle
from utils.ret_utils import error_info
from nodule_class.isnodule import LungIsncls
from preprocessing.location import lobe_locate_gmm
from detection.lung_detection import LungDetection
from func_timeout import FunctionTimedOut
from func_timeout import fu... | normal | {
"blob_id": "8035f195cd01dc50691cd93ea91a6377b1d83f24",
"index": 1166,
"step-1": "<mask token>\n\n\nclass GpuThread(threading.Thread):\n <mask token>\n\n def run(self):\n i = 0\n while True:\n result_dict = self.que_det.get(block=True)\n try:\n print(time.... | [
2,
3,
4,
5,
6
] |
# SSURGO_ExportMuRaster.py
#
# Convert MUPOLYGON featureclass to raster for the specified SSURGO geodatabase.
# By default any small NoData areas (< 5000 sq meters) will be filled using
# the Majority value.
#
# Input mupolygon featureclass must have a projected coordinate system or it will skip.
# Input databas... | normal | {
"blob_id": "d9a871fb6c889bcff455732007718af734859c72",
"index": 1325,
"step-1": "# SSURGO_ExportMuRaster.py\r\n#\r\n# Convert MUPOLYGON featureclass to raster for the specified SSURGO geodatabase.\r\n# By default any small NoData areas (< 5000 sq meters) will be filled using\r\n# the Majority value.\r\n#\r\n# I... | [
0
] |
import math as m
def calcula_elongacao(A, ϕ, ω, t):
x = A * m.cos(ϕ + ϕ * t )
return x | normal | {
"blob_id": "225687729b64f455bcc841e83105c7444efdfad3",
"index": 5545,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef calcula_elongacao(A, φ, ω, t):\n x = A * m.cos(φ + φ * t)\n return x\n",
"step-3": "import math as m\n\n\ndef calcula_elongacao(A, φ, ω, t):\n x = A * m.cos(φ + φ * t)\... | [
0,
1,
2,
3
] |
# 1.闭包
# 2.装饰圈初识
# 3.标准版装饰器 | normal | {
"blob_id": "a1ebb00d7cda65cb528b2253e817d925214cdce3",
"index": 5847,
"step-1": "# 1.闭包\n# 2.装饰圈初识\n# 3.标准版装饰器",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
1
]
} | [
1
] |
#! /usr/bin/python
# Project Euler problem 21
"""Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a != b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 ... | normal | {
"blob_id": "2ee5991e2b6de6ee48c8207f2b78574fc8a02fc0",
"index": 2432,
"step-1": "#! /usr/bin/python\n\n# Project Euler problem 21\n\n\"\"\"Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).\nIf d(a) = b and d(b) = a, where a != b, then a and b are an amicabl... | [
0
] |
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponse
# Create your views here.
def check(request):
if not request.user.is_authenticated:
return redirect('/auth/login/')
else:
return redirect('/worker/')
... | normal | {
"blob_id": "fc2afc99dc754b58c36bc76c723727337851cc3e",
"index": 5326,
"step-1": "<mask token>\n\n\ndef check(request):\n if not request.user.is_authenticated:\n return redirect('/auth/login/')\n else:\n return redirect('/worker/')\n\n\ndef loginpg(request):\n return render(request, 'regis... | [
2,
3,
4,
5,
6
] |
import pygame
import wave
import threading
import numpy as np
import pylab
import struct
import io
from PIL import Image
import sounddevice as sd
# 处理音频频谱
# voice.wav 格式:8000 rate 16bit 单声道
class SpectrumMap:
def __init__(self):
FILENAME = 'Sound/SoundResource/voice.wav'
self.wavefile = wave.open(... | normal | {
"blob_id": "fbde00d727d7ea99d1a7704f46cb9850c8b210d7",
"index": 2610,
"step-1": "<mask token>\n\n\nclass SpectrumMap:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass SpectrumMap2:\n\n def __init__(self):\n devices = sd.query_devices()\n devic... | [
12,
14,
16,
18,
19
] |
def foo(x, y=5):
def bar(x):
return x + 1
return bar(y * 2)
print(foo(3))
| normal | {
"blob_id": "80d1979c5767d0ff90f464651c9d0ca6d65effb2",
"index": 6472,
"step-1": "<mask token>\n",
"step-2": "def foo(x, y=5):\n\n def bar(x):\n return x + 1\n return bar(y * 2)\n\n\n<mask token>\n",
"step-3": "def foo(x, y=5):\n\n def bar(x):\n return x + 1\n return bar(y * 2)\n\n\... | [
0,
1,
2
] |
import re
import itertools
import setpath
import functions
import lib.jopts as jopts
from operator import itemgetter
import random
__docformat__ = 'reStructuredText en'
re_params=re.compile('(\w*):(.*)')
def consumer(func):
"""A decorator, advances func to its first yield point when called.
"""
from fun... | normal | {
"blob_id": "60411e922bfec8f98028f959a370f954eef5437e",
"index": 1329,
"step-1": "import re\nimport itertools\nimport setpath\nimport functions\nimport lib.jopts as jopts\nfrom operator import itemgetter\nimport random\n\n__docformat__ = 'reStructuredText en'\n\nre_params=re.compile('(\\w*):(.*)')\n\ndef consume... | [
0
] |
import sys
def ReadFile(array, fileName):
with open(fileName, 'r') as f:
if f.readline().rstrip() != 'MS':
print("prosze podac macierz sasiedztwa")
for i in f:
el = list(map(int, i.rstrip().split()))
if len(el) > 1:
array.append(el)
def Prim(mat... | normal | {
"blob_id": "56b8b9884b8500ff70f59058484c4a351b709311",
"index": 3517,
"step-1": "<mask token>\n\n\ndef main():\n if len(sys.argv) < 2:\n print('prosze podac plik')\n sys.exit()\n fileName = sys.argv[1]\n matrix = []\n ReadFile(matrix, fileName)\n Prim(matrix, 0)\n\n\n<mask token>\n"... | [
1,
3,
4,
5,
6
] |
N = int(input())
StopPoint = N
cycle = 0
ten = 0
one = 0
new_N = 0
while True:
ten = N // 10
one = N % 10
total = ten + one
new_N = one * 10 + total % 10
cycle += 1
N = new_N
if new_N == StopPoint:
break
print(cycle)
| normal | {
"blob_id": "047b3b25cb064115a46cde1f1480ce55a1256bc1",
"index": 5827,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n ten = N // 10\n one = N % 10\n total = ten + one\n new_N = one * 10 + total % 10\n cycle += 1\n N = new_N\n if new_N == StopPoint:\n break\nprint... | [
0,
1,
2
] |
"""This module provides the definition of the exceptions that can be raised from the database module."""
class DatabaseError(Exception):
"""Raised when the requested database operation can not be completed."""
pass
class InvalidDictError(Exception):
"""Raised when the object can not be created from the pr... | normal | {
"blob_id": "94130b4962ecff2ea087ab34cf50a084254bf980",
"index": 8948,
"step-1": "<mask token>\n\n\nclass InvalidDictError(Exception):\n <mask token>\n pass\n",
"step-2": "<mask token>\n\n\nclass InvalidDictError(Exception):\n \"\"\"Raised when the object can not be created from the provided dict.\"\"... | [
1,
2,
3,
4,
5
] |
import itertools
import urllib
import word2vec
# MSD: http://corpus.leeds.ac.uk/mocky/ru-table.tab
# Universal: http://universaldependencies.org/ru/pos/index.html
def convert_pos_MSD_to_Universal(pos):
if pos.startswith('A'):
return 'ADJ'
elif pos.startswith('C'):
return 'CCONJ'
elif pos.... | normal | {
"blob_id": "b2a2e06c5db8b12acbc852bafc4ea869b006c1c8",
"index": 9722,
"step-1": "<mask token>\n\n\ndef convert_pos_MSD_to_Universal(pos):\n if pos.startswith('A'):\n return 'ADJ'\n elif pos.startswith('C'):\n return 'CCONJ'\n elif pos.startswith('I'):\n return 'INTJ'\n elif pos.... | [
3,
4,
5,
6,
7
] |
import sys, os; sys.path.insert(0,'..'); sys.path.insert(0,'../NEURON');
from tests.cells.NEURONCellTest import NEURONCellTest
from tests.cells.NeuroMLCellTest import NeuroMLCellTest
class NEURON(NEURONCellTest):
def __init__(self):
super(NEURON, self).__init__()
self.path = "../NEURON/... | normal | {
"blob_id": "6dbafbcf126c37edb2187eb28c01e2c1125c1c64",
"index": 7134,
"step-1": "<mask token>\n\n\nclass NEURON(NEURONCellTest):\n\n def __init__(self):\n super(NEURON, self).__init__()\n self.path = '../NEURON/granule.hoc'\n self.label = 'granule'\n self.resultsFile = 'results/ce... | [
5,
6,
7,
8,
9
] |
# -*- coding: utf-8 -*-
import os
import sys
import socket
import signal
import functools
import atexit
import tempfile
from subprocess import Popen, PIPE, STDOUT
from threading import Thread
from queue import Queue, Empty
from time import sleep
import json
from .exceptions import CommandError, TimeoutWaitingFor
ON_PO... | normal | {
"blob_id": "7f220a970d65a91228501f7db59089e6c0604fb5",
"index": 9915,
"step-1": "<mask token>\n\n\ndef wait_condition(cond, timeout=1, sleeptime=0.01):\n \"\"\"Wait for condition to return anything other than None\n \"\"\"\n if timeout is None:\n timeout = 1\n if timeout < sleeptime:\n ... | [
7,
11,
13,
14,
16
] |
class DuplicatedBlockException(Exception):
code = 'duplicated_block_exception'
| normal | {
"blob_id": "983e3b2902fe3bc701167da2f308fdaed612ae84",
"index": 1784,
"step-1": "<mask token>\n",
"step-2": "class DuplicatedBlockException(Exception):\n <mask token>\n",
"step-3": "class DuplicatedBlockException(Exception):\n code = 'duplicated_block_exception'\n",
"step-4": null,
"step-5": null,... | [
0,
1,
2
] |
from django import forms
from django.contrib.auth.forms import UserCreationForm
from .models import AuthUser
class SignUpForm(forms.Form):
username = forms.CharField(widget=forms.TextInput(attrs={'class':
'form-control'}))
email = forms.EmailField(widget=forms.EmailInput(attrs={'class':
'form-... | normal | {
"blob_id": "7644dcd956e1ad179f42e44870864386744c6cdf",
"index": 2553,
"step-1": "<mask token>\n\n\nclass LoginForm(forms.Form):\n username = forms.CharField(widget=forms.TextInput(attrs={'class':\n 'form-control'}))\n password = forms.CharField(widget=forms.PasswordInput(attrs={'class':\n 'f... | [
2,
3,
4,
5
] |
def sieve(limit):
numbers = list(range(3, limit, 2))
for prime in numbers:
for multiplier in reversed(range(2, limit)):
try:
numbers.remove(prime * multiplier)
except ValueError:
pass
return [2] + numbers
| normal | {
"blob_id": "ec7ca03f627eaa635aac56e302b9c40bf0a3da38",
"index": 1796,
"step-1": "<mask token>\n",
"step-2": "def sieve(limit):\n numbers = list(range(3, limit, 2))\n for prime in numbers:\n for multiplier in reversed(range(2, limit)):\n try:\n numbers.remove(prime * mult... | [
0,
1
] |
from django.db import models
class Professor(models.Model):
nome = models.CharField(max_length=100)
apelido = models.CharField(max_length=30)
descricao = models.TextField(max_length=1000)
def __str__(self):
return self.nome
class ImagemProfessor(models.Model):
professor = models.Foreign... | normal | {
"blob_id": "acb879cb72e5b3ac897a271dc680e4ca763d2122",
"index": 7541,
"step-1": "<mask token>\n\n\nclass ImagemProfessor(models.Model):\n professor = models.ForeignKey(Professor, on_delete=models.CASCADE)\n foto = models.ImageField(upload_to='fotos/%d/%m/%Y/', blank=True)\n",
"step-2": "<mask token>\n\n... | [
2,
3,
5,
6
] |
import datetime
from httpx import AsyncClient
from testing.conftest import (LESSONS_PATH, REVIEWS_PATH, pytestmark,
register_and_get_token)
class TestReview:
async def test_review_add_get(self, ac, fill_db):
# Creating users first
token = await register_and_get_tok... | normal | {
"blob_id": "3ec858c04a7622ae621bf322730b6b3ba9f4d07e",
"index": 5826,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TestReview:\n\n async def test_review_add_get(self, ac, fill_db):\n token = await register_and_get_token(ac)\n token2 = await register_and_get_token(ac, main_us... | [
0,
1,
2,
3
] |
import json
import sys
from os import listdir
from os.path import isfile, join
import params
def encodeText(tweet_text):
tweet_text = tweet_text.replace('\n',' ')
return str(tweet_text)
def parse_file(file_in, file_out):
ptrFile_in = open(file_in, "r")
ptrFile_out = open(file_out, "w", encoding=... | normal | {
"blob_id": "e3afaabc1f7f64b9189fc88dd478ed75e81f35e1",
"index": 4564,
"step-1": "<mask token>\n\n\ndef parse_file(file_in, file_out):\n ptrFile_in = open(file_in, 'r')\n ptrFile_out = open(file_out, 'w', encoding='utf-8')\n cleanLines = []\n for line in ptrFile_in:\n cleanLine = {}\n l... | [
1,
2,
3,
4,
5
] |
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
def test_guest_should_see_button_add_to_basket(browser):
browser.get(lin... | normal | {
"blob_id": "464be943f4fe34dda826ebada9e128f1d7d671ac",
"index": 8485,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_guest_should_see_button_add_to_basket(browser):\n browser.get(link)\n btn_add = 'btn.btn-lg.btn-primary.btn-add-to-basket'\n found_button = WebDriverWait(browser, 5)... | [
0,
1,
2,
3,
4
] |
# accessing array elements rows/columns
import numpy as np
a = np.array([[1, 2, 3, 4, 5, 6, 7], [9, 8, 7, 6, 5, 4, 3]])
print(a.shape) # array shape
print(a)
print('\n')
# specific array element [r,c]
# item 6
print(a[0][5])
# item 8
print(a[1][1]) # or
print(a[1][-6])
# get a specific row/specific column
print(a... | normal | {
"blob_id": "8cc97ebe0ff7617eaf31919d40fa6c312d7b6f94",
"index": 8814,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(a.shape)\nprint(a)\nprint('\\n')\nprint(a[0][5])\nprint(a[1][1])\nprint(a[1][-6])\nprint(a[1])\nprint(a[0])\nprint(a[0, :])\nprint(a[:, 1])\nprint('\\n')\nprint('even numbers from f... | [
0,
1,
2,
3,
4
] |
import pandas as pd
import numpy as np
import random
import csv
import pprint
import datamake
import dafunc_H
def simulation(cnt, a, b):
df, df_collist = datamake.make_df(
'/Users/masato/Desktop/UTTdata/prog/PyProgramming/DA_algorithm/Mavo/csvdata/sinhuri2018.csv'
)
n, m, k = datamake.stu_num()
... | normal | {
"blob_id": "cad00f80afa142b69ced880de000b6b5b230640c",
"index": 6228,
"step-1": "<mask token>\n\n\ndef simulation(cnt, a, b):\n df, df_collist = datamake.make_df(\n '/Users/masato/Desktop/UTTdata/prog/PyProgramming/DA_algorithm/Mavo/csvdata/sinhuri2018.csv'\n )\n n, m, k = datamake.stu_num()... | [
1,
2,
3,
4,
5
] |
from mongoengine import Document, StringField, BooleanField, ListField, Q
import exceptions
class Category(Document):
id = StringField(primary_key=True)
name = StringField()
is_base_expenses = BooleanField(default=False)
aliases = ListField(StringField())
@classmethod
def get_category_by_text... | normal | {
"blob_id": "63d9a0fa0d0747762e65f6f1e85e53090035454c",
"index": 583,
"step-1": "<mask token>\n\n\nclass Category(Document):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Category(Document):\n <mask token>\n <mask token>\n... | [
1,
2,
3,
4
] |
# coding: utf-8
# 2019/11/27 @ tongshiwei
import pytest
def test_api(env):
assert set(env.parameters.keys()) == {"knowledge_structure", "action_space", "learning_item_base"}
@pytest.mark.parametrize("n_step", [True, False])
def test_env(env, tmp_path, n_step):
from EduSim.Envs.KSS import kss_train_eval, KS... | normal | {
"blob_id": "b1ae3abb6decf4d70bc2372e70cf4f5b868e805d",
"index": 8756,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_api(env):\n assert set(env.parameters.keys()) == {'knowledge_structure',\n 'action_space', 'learning_item_base'}\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
from flask import Blueprint, render_template, redirect, url_for, flash
import subprocess
def check_output(*args):
return subprocess.Popen(*args, stdout=subprocess.PIPE).communicate()[0]
mod = Blueprint('system', __name__)
@mod.route('/')
def index():
uptime = check_output(["uptime"])
... | normal | {
"blob_id": "e056a1600b620519e729c597dcec57793284019a",
"index": 1470,
"step-1": "<mask token>\n\n\n@mod.route('/shutdown')\ndef shutdown():\n flash(\n 'Shutting down.<br>When the LEDs on the board stop flashing, it should be safe to unplug your Raspberry Pi.'\n )\n subprocess.call(['sudo... | [
1,
4,
5,
6,
7
] |
import random
#quicksort a list of objects based on keys, which can be any of 3 values
# done in O(n) time in one pass, and O(1) additional space complexity
def quicksort(x, pivot_index):
key1_idx, key2_idx, key3_idx = 0, 0, len(x)
key1_val, key2_val= 'key1', 'key2'
while key2_idx < key3_idx:
if x... | normal | {
"blob_id": "f193094c551df2a32860948b1a8710b53ca0dfb6",
"index": 2413,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef quicksort(x, pivot_index):\n key1_idx, key2_idx, key3_idx = 0, 0, len(x)\n key1_val, key2_val = 'key1', 'key2'\n while key2_idx < key3_idx:\n if x[key2_idx]['key']... | [
0,
1,
2,
3,
4
] |
# project/tests/test_tmdb.py
import unittest
import json
from project.server import db
from project.server.models import Tmdb
from project.tests.base import BaseTestCase
class TestTmdb(BaseTestCase):
"""
Testing if we have the good responses from the api
"""
def test_discover(self):
""" Tes... | normal | {
"blob_id": "9e9403ea1c128e07803d080b337003055759c5ae",
"index": 4507,
"step-1": "<mask token>\n\n\nclass TestTmdb(BaseTestCase):\n <mask token>\n\n def test_discover(self):\n \"\"\" Testing the TMDB API discover endpoint \"\"\"\n response = Tmdb.discover()\n self.assertTrue(int(respon... | [
4,
5,
6,
7,
10
] |
class CardHolder:
acctlen = 8
retireage = 59.5
def __init__(self, acct, name, age, addr):
self.acct = acct
self.name = name
self.age = age
self.addr = addr
def __getattribute__(self, item): # __getattribute__ intercepts calls for all
... | normal | {
"blob_id": "602a7676129721dbfd318407dd972f80d681146c",
"index": 3062,
"step-1": "class CardHolder:\n <mask token>\n <mask token>\n <mask token>\n\n def __getattribute__(self, item):\n superget = object.__getattribute__\n if item == 'acct':\n return superget(self, 'acct')[:-3... | [
3,
4,
5,
6,
7
] |
import socket
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 8886)
sock.connect(server_address)
data = "TCP"
length = len(data)
ret = bytearray([])
for byte in data.encode("utf-8"):
ret.append(byte)
sock.sendall(ret)
if __na... | normal | {
"blob_id": "c6fd848bb3d845a50b928c18a51f296a500e7746",
"index": 2922,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n server_address = 'localhost', 8886\n sock.connect(server_address)\n data = 'TCP'\n length = len... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
import time
import errno
from gi.repository import GLib
from ..async import (FutureSourcePair, FutureCanceled, SucceededFuture,
BrokenPipeError, ConnectionError)
__all__ = ('GCore',)
#------------------------------------------------------------------------------#
# GLib Co... | normal | {
"blob_id": "4d43e470144a6284d85902b495dc19dc150eb681",
"index": 4000,
"step-1": "# -*- coding: utf-8 -*-\nimport time\nimport errno\nfrom gi.repository import GLib\n\nfrom ..async import (FutureSourcePair, FutureCanceled, SucceededFuture,\n BrokenPipeError, ConnectionError)\n\n__all__ = ('GC... | [
0
] |
"""Class for better periodic call handling"""
import tornado
import tornado.gen
import logging
class YieldPeriodicCallback(object):
"""Class for better periodic call"""
def __init__(self, callback, callback_time, io_loop=None, faststart=False):
"""Init method it can be used like tornado periodic callb... | normal | {
"blob_id": "7726f8cc9adf15823cccdaa4ba316800bb134460",
"index": 1920,
"step-1": "<mask token>\n\n\nclass YieldPeriodicCallback(object):\n <mask token>\n\n def __init__(self, callback, callback_time, io_loop=None, faststart=False):\n \"\"\"Init method it can be used like tornado periodic callback, b... | [
5,
6,
7,
8,
9
] |
#! /usr/bin/env python
import roslib
roslib.load_manifest('learning_tf')
import rospy
import actionlib
from geometry_msgs.msg import Twist
from turtlesim.msg import Pose
from goal.msg import moveAction, moveGoal
if __name__ == '__main__':
rospy.init_node('move_client')
client = actionlib.SimpleActionClient('... | normal | {
"blob_id": "791935f63f7a0ab2755ad33369d2afa8c10dffbb",
"index": 4708,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nroslib.load_manifest('learning_tf')\n<mask token>\nif __name__ == '__main__':\n rospy.init_node('move_client')\n client = actionlib.SimpleActionClient('moveTo', turtlesim_)\n cli... | [
0,
1,
2,
3
] |
#this apps is open
#Let's start with introduction
print "Hi, I am x0x. Could we introduce ourselves? (yes/no)"
answer = raw_input()
if answer.lower() == 'yes':
print "Okay, what is your name?"
name = raw_input()
print "Hi", name
print "Nice to meet you."
print "What are you going to do?"
print... | normal | {
"blob_id": "a28c62a18d793fb285353902d01801c720bcb454",
"index": 1653,
"step-1": "#this apps is open\n\n#Let's start with introduction\n\nprint \"Hi, I am x0x. Could we introduce ourselves? (yes/no)\"\nanswer = raw_input()\nif answer.lower() == 'yes':\n print \"Okay, what is your name?\"\n name = raw_input... | [
0
] |
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('', views.artifact, name="artifacts"),
path('<int:artifact_id>', views.detail, name="detail"),
path('register/', views.register, name="register")
] | normal | {
"blob_id": "9b73037e8af7d4f91261cebf895b68650182fcd5",
"index": 2780,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', views.artifact, name='artifacts'), path(\n '<int:artifact_id>', views.detail, name='detail'), path('register/',\n views.register, name='register')]\n",
"st... | [
0,
1,
2,
3
] |
#
# @lc app=leetcode.cn id=909 lang=python3
#
# [909] 蛇梯棋
#
# @lc code=start
from typing import List
class Solution:
def snakesAndLadders(self, board: List[List[int]]) -> int:
N = len(board)
def get_pos(num):
r = (num-1) // N
c = (num-1) % N
c = c if ((r+1) & 1)... | normal | {
"blob_id": "da5a366d1cc4f192a220dc38c7a74aeb3fba7cdb",
"index": 9839,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def snakesAndLadders(self, board: List[List[int]]) ->int:\n N = le... | [
0,
1,
2,
3,
4
] |
from pynput import keyboard
# list of chars entered by the user
list = []
number_of_chars = 0
# if entered chars go above MAX LENGTH they will be written inside a file
MAX_LENGTH = 300
def on_press(key):
global number_of_chars
global list
list.append(key)
number_of_chars+=1
if number_of_cha... | normal | {
"blob_id": "e60fcf19560b4826577797c8ae8b626ff984dcfd",
"index": 6923,
"step-1": "<mask token>\n\n\ndef on_release(key):\n if key == keyboard.Key.esc:\n write_in_file()\n return False\n\n\ndef write_in_file():\n file = open('strokes.txt', 'a')\n for k in list:\n file.writelines('{}\... | [
2,
3,
4,
5,
7
] |
class GameOfLife:
@staticmethod
def simulate(board):
for row in range(len(board)):
for col in range(len(board[0])):
ones = GameOfLife.countOnes(board, row, col)
if board[row][col] and (ones == 2 or ones == 3):
board[row][col] |= 2
... | normal | {
"blob_id": "862c5794a4da794678de419f053ae15b11bca6e7",
"index": 7453,
"step-1": "class GameOfLife:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class GameOfLife:\n\n @staticmethod\n def simulate(board):\n for row in range(len(board)):\n for col in range(len(boar... | [
1,
2,
3,
4
] |
"""
Main class of the interface.
It setups the experimental parameters such as the :class:`.Experiment`'s and
:class:`.Sample`, geometry (:attr:`geometry <Stratagem.geometry>`), type of
:math:`\\phi(\\rho z)` model (:attr:`prz_mode <Stratagem.prz_mode>`) and
fluorescence mode (:attr:`fluorescence <Stratagem.fluoresce... | normal | {
"blob_id": "6914656a2f78fa1fe74a67bf09b017585b3eac88",
"index": 2770,
"step-1": "<mask token>\n\n\nclass Stratagem:\n <mask token>\n\n def __init__(self, dll_path=None, display_error=True):\n \"\"\"\n :arg dll_path: complete path to the location of ``stratadllogger.dll``\n (option... | [
21,
23,
38,
39,
40
] |
text=open('mytext.txt','w')
x=text.write("I like coding\nit is a new part\nof my life!!!")
text=open('mytext.txt')
read=text.readlines()
i=0
counter=0
total=0
print("number of lines :"+str(len(read)))
while i<=len(read)-1:
counter=counter+read[i].count('\n') + read[i].count(' ')
total+=len(read[i])-read[i].cou... | normal | {
"blob_id": "5ad8db85f4f705173cf5d0649af6039ebe1544b2",
"index": 7488,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('number of lines :' + str(len(read)))\nwhile i <= len(read) - 1:\n counter = counter + read[i].count('\\n') + read[i].count(' ')\n total += len(read[i]) - read[i].count('\\n')... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
'''
Script for analysis of wavefunctions on GaSb/InAs/GaSb simmetric quantum wells.
This piece code is part of the project "phd_gasb_inas", which comprises the work
related to the Phd. Dissertation named: "Quantum transport of charge and spin in
topological insulators 2D".
Author: Marcos Medeiro... | normal | {
"blob_id": "a012055d11202c68d9eddf5cf2a17043f9bbaf0a",
"index": 6851,
"step-1": "<mask token>\n\n\ndef map_density(ax, syst, psi_sqrd, colormap='Reds'):\n kwant.plotter.map(syst, psi_sqrd, ax=ax, fig_size=(7, 3), cmap=colormap,\n vmax=0.99 * max(psi_sqrd))\n tools.edit_axis(ax, 'dens')\n return ... | [
4,
5,
7,
8,
9
] |
from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator
from .models import Blog, BlogType
from django.conf import settings
from read_statistics.utils import read_statistics_once_read
from user.forms import LoginForm
# Create your views here.
#分页函数
def get_blogs_common_data(r... | normal | {
"blob_id": "9731f45b19d40a031216f8a430c09764fd34e984",
"index": 2594,
"step-1": "<mask token>\n\n\ndef get_blogs_common_data(request, blogs_all_list):\n page_num = request.GET.get('page', 1)\n paginator = Paginator(blogs_all_list, settings.BLOGS_PER_PAGE)\n page_of_blogs = paginator.get_page(page_num)\... | [
3,
4,
5,
6,
7
] |
#!/usr/bin/env python3
import argparse
import json
import os
import random
import timeit
from glob import glob
import numpy as np
def parse_args():
"""[summary]
Returns:
[type]: [description]
"""
parser = argparse.ArgumentParser()
parser.add_argument('--train_dir',
... | normal | {
"blob_id": "71eadf5073b5ed13c7d4a58b2aeb52f550a32238",
"index": 3104,
"step-1": "<mask token>\n\n\ndef parse_args():\n \"\"\"[summary]\n\n Returns:\n [type]: [description]\n \"\"\"\n parser = argparse.ArgumentParser()\n parser.add_argument('--train_dir', help=\n 'directory containin... | [
1,
2,
3,
4,
5
] |
import os, pickle, logging, numpy as np
from .. import utils as U
class CMU_Generator():
def __init__(self, args, dataset_args):
self.in_path = dataset_args['cmu_data_path']
self.out_path = '{}/{}'.format(dataset_args['path'], args.dataset)
self.actions = ['walking', 'running', '... | normal | {
"blob_id": "2c58a9e83f80d437160b87ec64c7631e7a35bf90",
"index": 6315,
"step-1": "<mask token>\n\n\nclass CMU_Generator:\n <mask token>\n <mask token>\n\n def read_data(self, phase):\n all_data, even_data = [], {}\n for action_idx, action in enumerate(self.actions):\n action_pat... | [
3,
5,
6,
7,
8
] |
import math
import turtle
wn = turtle.Screen()
wn.bgcolor('lightblue')
PI=3.14
R_outer=50
R_inner=200
fred = turtle.Turtle()
fred.speed(99999)
def cycloid(r, k, nos_cycle, direction):
n=36
angle=2*PI/n
x=1
y=0
for i in range(nos_cycle*n):
beta = i * angle
x = r*(beta-math.sin(beta))
... | normal | {
"blob_id": "a62dd287f9fc6f79ef95a3de83f52c794efe00a7",
"index": 7407,
"step-1": "\nimport math\nimport turtle\n\nwn = turtle.Screen()\nwn.bgcolor('lightblue')\nPI=3.14\nR_outer=50\nR_inner=200\n\nfred = turtle.Turtle()\nfred.speed(99999)\n\ndef cycloid(r, k, nos_cycle, direction):\n n=36\n angle=2*PI/n\n ... | [
0
] |
password = '#Garb1122'
| normal | {
"blob_id": "918358f6e8e3f1c601b18a3c08fc6b7c024721ba",
"index": 5547,
"step-1": "<mask token>\n",
"step-2": "password = '#Garb1122'\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
import os
from flask import Flask
from flask.ext.login import LoginManager
from config import basedir
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.openid import OpenID
from momentjs import momentjs
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
lm = LoginManager()
lm.init_app(... | normal | {
"blob_id": "8c1bd4df5f33c433880d6a4becadf88fb922762b",
"index": 6379,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp.config.from_object('config')\n<mask token>\nlm.init_app(app)\n<mask token>\n",
"step-3": "<mask token>\napp = Flask(__name__)\napp.config.from_object('config')\ndb = SQLAlchemy(app)... | [
0,
1,
2,
3
] |
# i have created this file-hitu
from django.http import HttpResponse
from django.shortcuts import render
from .forms import Sign_Up, Login
from .models import Student
# render is used to create and impot the templates
# render takes first arg = request, 2nd arg = name of the file you want to import, 3rd arg = parame... | normal | {
"blob_id": "cbbb314a3262713f6cb2bb2dd90709d7bf1ca8eb",
"index": 6095,
"step-1": "<mask token>\n\n\ndef login_name(request):\n if request.method == 'POST':\n form = Login(request.POST)\n if form.is_valid():\n email = form.cleaned_data['email']\n password = form.cleaned_data... | [
1,
2,
3,
4,
5
] |
# -*- coding: utf-8 -*-
#
# Copyright (C) Red Hat, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | normal | {
"blob_id": "8410ff0806766a09d346e930123a2696bebb4b60",
"index": 2821,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nGERRIT_PORT = 29418\nGERRIT_USERNAME = 'dci-ci-bot'\nGERRIT_HOSTNAME = 'softwarefactory-project.io'\nGERRIT_SSH_KEY_FILENAME = os.getenv('GERRIT_SSH_KEY_FILENAME',\n '/home/dci/dci-ci-... | [
0,
1,
2,
3
] |
# terrascript/spotinst/__init__.py
import terrascript
class spotinst(terrascript.Provider):
pass | normal | {
"blob_id": "0ae626df5a471af77f7361bb765b46b861ee8a2c",
"index": 7142,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass spotinst(terrascript.Provider):\n pass\n",
"step-3": "import terrascript\n\n\nclass spotinst(terrascript.Provider):\n pass\n",
"step-4": "# terrascript/spotinst/__init... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
from math import factorial
F = [factorial(i) for i in range(10)]
#F[9] * 8 = 2903040 > this means no 8 digit numbers
#F[9] * 7 = 2540160 < this is the maximum that I could think of
total = 0
for i in xrange(10, 2540160):
if sum([F[int(d)] for d in str(i)]) == i:
total = total + i
p... | normal | {
"blob_id": "d2e8c95dc144aa83128cc815ad145982f64b1819",
"index": 3206,
"step-1": "#!/usr/bin/env python\n\nfrom math import factorial\n\nF = [factorial(i) for i in range(10)]\n#F[9] * 8 = 2903040 > this means no 8 digit numbers\n#F[9] * 7 = 2540160 < this is the maximum that I could think of\n\ntotal = 0\nfor i ... | [
0
] |
from skimage import data, filters, measure, exposure
from skimage.filters import threshold_mean
from skimage.transform import resize
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import pyfits as pf
import time
import numpy as np
import healpy as hp
from healpy.projector import CartesianProj
f... | normal | {
"blob_id": "d86fd2e6ef5dab4444772192471538842112b3fd",
"index": 2675,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nhp.mollview(fu, title='Full map +50 GLAT', sub=311)\nhp.mollview(se, title='Above threshold (4.0) +50 GLAT', sub=312)\nhp.mollview(ma, title='Diff +50 GLAT', sub=313)\nplt.savefig('figs/d... | [
0,
1,
2,
3,
4
] |
# __ __ __ ______ __
# / | / | / | / \ / |
# $$ | $$ |_$$ |_ ______ ______ _______ /$$$$$$ | ______ $$/ _______ _______
# $$ \/$$// $$ | / \ / \ / \ ... | normal | {
"blob_id": "ae72d832039f36149988da02d8a4174d80a4ecfb",
"index": 2350,
"step-1": "\n # __ __ __ ______ __\n# / | / | / | / \\ / |\n# $$ | $$ |_$$ |_ ______ ______ _______ /$$$$$... | [
0
] |
from django.shortcuts import render
from django.views.generic import TemplateView
# Create your views here.
def index(request):
context = 'Welcome home'
return render(request,'base.html',{'context':context})
class HomePageView(TemplateView):
template_name = 'base.html'
| normal | {
"blob_id": "f0a54feaa165a393c4e87cbac2a38347633acf5a",
"index": 1425,
"step-1": "<mask token>\n\n\nclass HomePageView(TemplateView):\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass HomePageView(TemplateView):\n template_name = 'base.html'\n",
"step-3": "<mask token>\n\n\ndef index(request):\n ... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python
def question():
print("02. 「パトカー」+「タクシー」=「パタトクカシーー」")
print("「パトカー」+「タクシー」の文字を先頭から交互に連結して文字列「パタトクカシーー」を得よ.")
def main():
str1 = "パトカー"
str2 = "タクシー"
print(''.join([x[0] + x[1] for x in zip(str1, str2)]))
if __name__ == '__main__':
question()
main()
| normal | {
"blob_id": "32869a88bb59d47281249b6ebe2357328beb0359",
"index": 3572,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n str1 = 'パトカー'\n str2 = 'タクシー'\n print(''.join([(x[0] + x[1]) for x in zip(str1, str2)]))\n\n\n<mask token>\n",
"step-3": "def question():\n print('02. 「パトカ... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
import os
import logging
import subprocess
import json
import sys
ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(ROOT_PATH)
from src.datafactory.common import json_util
from src.datafactory.config import constant
class SegmentProcess... | normal | {
"blob_id": "96ea9b2b4d892ac88f7fac9594a6d2ad5d69a7c7",
"index": 7479,
"step-1": "# -*- coding: utf-8 -*-\n\nimport os\nimport logging\nimport subprocess\nimport json\nimport sys\n\nROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\nsys.path.append(ROOT_PATH)\n\nfrom src.da... | [
0
] |
#!/usr/bin/env/ python
# -*- coding:utf-8 -*-
# Created by: Vanish
# Created on: 2019/9/25
import numpy as np
from scipy import optimize
def sigmoid(z):
return 1 / (1 + np.exp(-z))
def costReg(theta, X, y, lamda):
theta = np.matrix(theta)
X = np.matrix(X)
y = np.matrix(y)
first = np.multip... | normal | {
"blob_id": "991c361043eb1539a80b5e8e1db44bc365e7e639",
"index": 6345,
"step-1": "<mask token>\n\n\ndef predict(theta, X):\n probability = sigmoid(X * theta.T)\n return [(1 if x >= 0.5 else 0) for x in probability]\n\n\ndef implement_for_LR(X_train, X_test, y_train, y_test, lamda=1):\n n = X_train.shape... | [
2,
3,
5,
6,
7
] |
from threading import Thread, Lock
from utils import reloj
import random
class Imprimidor(Thread):
def __init__(self, nombre, berlin, bolsa_dinero):
super().__init__()
pass
def run(self):
'''
Funcionalidad de iMPRIMIDOR que imprime dinero cada 5 minutos, cada
iteracio... | normal | {
"blob_id": "ab79e2f9584dbbb526c62bde882a1bc9874b56f9",
"index": 7903,
"step-1": "<mask token>\n\n\nclass Imprimidor(Thread):\n\n def __init__(self, nombre, berlin, bolsa_dinero):\n super().__init__()\n pass\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\... | [
2,
4,
5,
6,
7
] |
#!/opt/Python/2.7.3/bin/python
import sys
from collections import defaultdict
import numpy as np
import re
import os
import argparse
from Bio import SeqIO
def usage():
test="name"
message='''
python CircosConf.py --input circos.config --output pipe.conf
'''
print message
def fasta_id(fastafile):
... | normal | {
"blob_id": "fe0d6cc03512d54d2d8722551e3f2a7c1bf43997",
"index": 3581,
"step-1": "#!/opt/Python/2.7.3/bin/python\nimport sys\nfrom collections import defaultdict\nimport numpy as np\nimport re\nimport os\nimport argparse\nfrom Bio import SeqIO\n\ndef usage():\n test=\"name\"\n message='''\npython CircosCon... | [
0
] |
if __name__== '__main__':
with open('./input/day6', 'r') as f:
orbit_input = [l.strip().split(")") for l in f.readlines()]
planets = [planet[0] for planet in orbit_input]
planets1 = [planet[1] for planet in orbit_input]
planets = set(planets+planets1)
system = {}
print(orbit_input)
... | normal | {
"blob_id": "96778a238d8ed8ae764d0cf8ec184618dc7cfe18",
"index": 5790,
"step-1": "<mask token>\n",
"step-2": "if __name__ == '__main__':\n with open('./input/day6', 'r') as f:\n orbit_input = [l.strip().split(')') for l in f.readlines()]\n planets = [planet[0] for planet in orbit_input]\n plane... | [
0,
1,
2
] |
from setuptools import find_packages, setup
NAME = 'compoelem'
VERSION = "0.1.1"
setup(
name=NAME,
packages=['compoelem', 'compoelem.generate', 'compoelem.compare', 'compoelem.visualize', 'compoelem.detect', 'compoelem.detect.openpose', 'compoelem.detect.openpose.lib'],
include_package_data=True,
versio... | normal | {
"blob_id": "4f81eb7218fa1341bd7f025a34ec0677d46151b0",
"index": 6542,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name=NAME, packages=['compoelem', 'compoelem.generate',\n 'compoelem.compare', 'compoelem.visualize', 'compoelem.detect',\n 'compoelem.detect.openpose', 'compoelem.detect.open... | [
0,
1,
2,
3,
4
] |
import string
#takes file as input, outputs a dictionary of keys from the file
#file should be in format (apiName, key/id)
#dictionary key = apiName, value = key/id
def getKeys(f):
keys = {}
f = open(f, 'r')
for line in f:
apiInfo = line.split(',')
keys[apiInfo[0]] = apiInfo[1].strip(string... | normal | {
"blob_id": "3653c6fce33467600a3eea72578ed995606bfc03",
"index": 4100,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef getKeys(f):\n keys = {}\n f = open(f, 'r')\n for line in f:\n apiInfo = line.split(',')\n keys[apiInfo[0]] = apiInfo[1].strip(string.whitespace)\n keys.p... | [
0,
1,
2,
3
] |
import pandas as pd
from pandas import DataFrame
myencoding = 'utf-8'
chikenList = ['pelicana', 'nene', 'cheogajip', 'goobne']
# chikenList = ['pelicana']
newframe = DataFrame()
for onestore in chikenList:
filename = onestore + '.csv'
myframe = pd.read_csv(filename, index_col=0, encoding=myencoding)
# pr... | normal | {
"blob_id": "11a31d3276201105ca7485fa4e4eb711012accd5",
"index": 2190,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor onestore in chikenList:\n filename = onestore + '.csv'\n myframe = pd.read_csv(filename, index_col=0, encoding=myencoding)\n newframe = pd.concat([newframe, myframe], axis=0,... | [
0,
1,
2,
3,
4
] |
#!C:\Python27\python
print('Content-Type:text/html\n\n')
print ("""
<html>
<head>
<link href="iconTech.png" rel="icon"/>
<meta name="viewport" content="width=device-width,intial-scale=1.0"/>
<link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="../css/bootstrap-theme.min.css" rel=... | normal | {
"blob_id": "968cfcfe9d31adcd3a67a88a66e5ebe7b719be8d",
"index": 2841,
"step-1": "<mask token>\n",
"step-2": "print('Content-Type:text/html\\n\\n')\nprint(\n \"\"\"\n<html>\n<head>\n<link href=\"iconTech.png\" rel=\"icon\"/>\n<meta name=\"viewport\" content=\"width=device-width,intial-scale=1.0\"/>\n<link h... | [
0,
1,
2
] |
#!/usr/local/bin/python
i = 0
while i == 0:
try:
print("Let's divide some numbers!")
a1 = input("Enter numerator: ")
b1 = input("Enter denominator: ")
a = int(a1)
b = int(b1)
print(a1 + " divied by " + b1 + " equals: " + str(a/b))
i += 1
except... | normal | {
"blob_id": "dcc1b0decf2fca6309dbb60faebd3f0a6944cd7d",
"index": 9130,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile i == 0:\n try:\n print(\"Let's divide some numbers!\")\n a1 = input('Enter numerator: ')\n b1 = input('Enter denominator: ')\n a = int(a1)\n b ... | [
0,
1,
2,
3
] |
from math import pow
from math import tan
import plotly.figure_factory as ff
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
def euler():
h = 0.1
x = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]
y_eval = [0.0]
delta_y = [0.0]
y_real = [0.0]
eps = [0.0]
for i in range(1, le... | normal | {
"blob_id": "20f0480ee7e0782b23ec8ade150cdd8d8ad718bb",
"index": 783,
"step-1": "<mask token>\n\n\ndef euler():\n h = 0.1\n x = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]\n y_eval = [0.0]\n delta_y = [0.0]\n y_real = [0.0]\n eps = [0.0]\n for i in range(1, len(x)):\n y_eval.append(y_eval[i - 1] +... | [
2,
3,
4,
5,
6
] |
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
BATCH_START=0
TIME_STEPS=20
BATCH_SIZE=50
INPUT_SIZE=1
OUTPUT_SIZE=1
CELL_SIZE=10
LR=0.006
#generate data
def get_batch():
global BATCH_START,TIME_STEPS
xs=np.arange(BATCH_START,BATCH_START+TIME_STEPS*BATCH_SIZE).reshape((BATCH_SIZE,T... | normal | {
"blob_id": "e54078f21176bbb7accb4164e7b56633b13cc693",
"index": 8803,
"step-1": "<mask token>\n\n\nclass LSTMRNN(object):\n\n def __init__(self, n_steps, input_size, output_size, cell_size, batch_size\n ):\n self.n_steps = n_steps\n self.input_size = input_size\n self.output_size ... | [
8,
11,
12,
13,
14
] |
from tkinter import *
global P,M,G,en
P=0
M=0
G=0
en=1
def inicio():
global P,M,G,en
B1=Button(ventana,text="CAJAS PEQUEÑAS",command=A,state="normal",bg="yellow").grid(column=1,row=1)
B2=Button(ventana,text="CAJAS MEDIANAS",command=B,state="normal",bg="orange").grid(column=2,row=1)
B3=Bu... | normal | {
"blob_id": "393af07fa7a5c265dbdd3047ef33a77130edf259",
"index": 1915,
"step-1": "<mask token>\n\n\ndef inicio():\n global P, M, G, en\n B1 = Button(ventana, text='CAJAS PEQUEÑAS', command=A, state='normal',\n bg='yellow').grid(column=1, row=1)\n B2 = Button(ventana, text='CAJAS MEDIANAS', comman... | [
5,
6,
7,
8,
9
] |
from collections import deque
class Solution:
def slidingPuzzle(self, board: List[List[int]]) -> int:
def board2str(board: List[List[int]]) -> str:
return ''.join([str(board[i][j]) for i in range(2) for j in range(3)])
start = board2str(board)
bfs = deque([(start, 0)])
... | normal | {
"blob_id": "dc934f8db4e0c1113e1398b051b58369d909fff8",
"index": 6471,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def slidingPuzzle(self, board: List[List[int]]) ->int:\n\n def board2str(board: List... | [
0,
1,
2,
3,
4
] |
# presentation console
# - a python interpreter for "pseudo-interative" demos
#
# usage: $ python prescons.py <filename>
#
# <filename> should be a file that contains python code as would be entered
# directly in a terminal - see example.py
#
# while running, press 'space' to move through the code
#
# github.com/ingles... | normal | {
"blob_id": "fa531e8b07de6ee3c22146904ee8724cefab9033",
"index": 2732,
"step-1": "# presentation console\n# - a python interpreter for \"pseudo-interative\" demos\n#\n# usage: $ python prescons.py <filename>\n#\n# <filename> should be a file that contains python code as would be entered\n# directly in a terminal... | [
0
] |
#Script to extract features from chess score data file stockfish.csv
import numpy as np
import pandas as pd
#Load in and format raw chess game scoring data
raw_scores = [line.strip().split(",")[1].split() for line in open("stockfish.csv")][1:]
#Initialize containers for features to extract
game_length = []
average_sc... | normal | {
"blob_id": "ad9bb34fdb05ab885f4871693729449f3618603a",
"index": 8321,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor game in raw_scores:\n game_len = len(game) + 1\n total = 0\n prev = None\n player = 1\n max_so_far = -100\n min_so_far = 100\n max_drop = 0\n max_gain = 0\n ... | [
0,
1,
2,
3,
4
] |
data = " Ramya , Deepa,LIRIL ,amma, dad, Kiran, 12321 , Suresh, Jayesh, Ramesh,Balu"
lst = data.split(",")
for name in lst:
name = name.strip().upper()
rname = name[::-1]
if name == rname:
print(name)
girlsdata = "Tanvi,Dhatri,Haadya,Deepthi,Deepa,Ramya"
# Name which start with DEE get those name... | normal | {
"blob_id": "622b388beb56eba85bbb08510c2bcea55f23da9a",
"index": 721,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor name in lst:\n name = name.strip().upper()\n rname = name[::-1]\n if name == rname:\n print(name)\n<mask token>\nprint('-' * 20)\n<mask token>\nfor name in names:\n ... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.