code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
from __future__ import division
import numpy as np
table = open("Tables\\table1.txt", "w")
table.write("\\begin{tabular}{|c|c|c|c|} \\hline\n")
table.write("Hidden Neurons & Loss & Training Acc. & Valid. Acc. \\\\ \\hline\n")
H = [1,5,10,11,12,20,40]
for h in H:
file = open("Out\\out-h"+str(h)+".txt", "r")
line = ... | normal | {
"blob_id": "3cace66ddf8484d285c2b2a8fabbb83778a2c4af",
"index": 4352,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntable.write('\\\\begin{tabular}{|c|c|c|c|} \\\\hline\\n')\ntable.write(\n 'Hidden Neurons & Loss & Training Acc. & Valid. Acc. \\\\\\\\ \\\\hline\\n')\n<mask token>\nfor h in H:\n f... | [
0,
1,
2,
3,
4
] |
a=eval(input('enter a list: '))
n=len(a)
if (n%2==0):
for i in range(0,n//2):
a[i],a[n//2+i]=a[n//2+i],a[i]
print('after swap:',a)
else:
for i in range(0,n//2):
a[i],a[n//2+i+1]=a[n//2+i+1],a[i]
print('after swap:',a)
| normal | {
"blob_id": "18435f43e2f52e3d2e9ff6411f8dd0510d2da54d",
"index": 656,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif n % 2 == 0:\n for i in range(0, n // 2):\n a[i], a[n // 2 + i] = a[n // 2 + i], a[i]\n print('after swap:', a)\nelse:\n for i in range(0, n // 2):\n a[i], a[n // ... | [
0,
1,
2,
3
] |
''' Compress images '''
from PIL import Image
def resizeImage(image_file):
try:
# get the image's width and height in pixels
img = Image.open(image_file)
width, height = img.size
# get the largest dimension
max_dim = max(img.size)
if max_dim > 1000:
# resize the image using the largest side as dime... | normal | {
"blob_id": "1b43125c2ebffd0a268a4a0ffdbbf407de7b0374",
"index": 7486,
"step-1": "''' Compress images '''\n\nfrom PIL import Image\n\n\ndef resizeImage(image_file):\n\ttry:\n\t\t# get the image's width and height in pixels\n\t\timg = Image.open(image_file)\n\t\twidth, height = img.size\n\n\t\t# get the largest d... | [
0
] |
# -*- coding: utf-8 -*-
import socket
import os
def http_header_parser(request):
headers = {}
lines = request.split('\n')[1:]
for string in lines:
first_pos = string.find(":")
headers[string[:first_pos]] = string[first_pos + 2:]
return headers
def create_response(http_code, http_co... | normal | {
"blob_id": "41350714ce13e3627b9bd56eb934846a99f8e1b3",
"index": 7047,
"step-1": "# -*- coding: utf-8 -*-\nimport socket\nimport os\n\n\ndef http_header_parser(request):\n headers = {}\n\n lines = request.split('\\n')[1:]\n for string in lines:\n first_pos = string.find(\":\")\n headers[st... | [
0
] |
from django.contrib import admin
from .models import User, UserProfile, Lead, Agent, Category
admin.site.register(User)
admin.site.register(UserProfile)
admin.site.register(Lead)
admin.site.register(Agent)
admin.site.register(Category)
| normal | {
"blob_id": "55d184a9342b40fe027913e46933325bb00e33a6",
"index": 5386,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(User)\nadmin.site.register(UserProfile)\nadmin.site.register(Lead)\nadmin.site.register(Agent)\nadmin.site.register(Category)\n",
"step-3": "from django.contrib impo... | [
0,
1,
2
] |
from sqlalchemy import Column, ForeignKey
from sqlalchemy.types import Integer, Text, String, DateTime, Float
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
Model = declarative_base()
class User(Model):
__tablename__ = "users"
id = Column(Integer,
... | normal | {
"blob_id": "e73c4a99c421b3eca08c941ff1f83cb03faee97d",
"index": 2558,
"step-1": "<mask token>\n\n\nclass User(Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Product(Model):\n __tablename__ = 'products'\n id = Column(Integer, p... | [
7,
8,
9,
10,
12
] |
#!/usr/bin/env python
import h5py
class HDF5_Parser(object): # noqa: N801
"""
Examples
--------
>>> import h5py
>>> indata = h5py.File('test.hdf5')
>>> dataset = indata.create_dataset("mydataset", (10,), dtype='i')
>>> indata.close()
>>> with open('test.hdf5') as f:
... da... | normal | {
"blob_id": "0beb5c5c5db9247d66a5a49cfff7282ead52a9b7",
"index": 716,
"step-1": "<mask token>\n\n\nclass HDF5_Parser(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def read_file(self, file_obj, **kwargs):\n return h5py.File(file_obj.name, mode='r')\n",
"step-2": ... | [
2,
3,
4,
5,
6
] |
from celery_app import celery_app
@celery_app.task
def demo_celery_run():
return 'result is ok'
| normal | {
"blob_id": "4bb973b598a9c35394a0cd78ed9ba807f3a595d7",
"index": 2323,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@celery_app.task\ndef demo_celery_run():\n return 'result is ok'\n",
"step-3": "from celery_app import celery_app\n\n\n@celery_app.task\ndef demo_celery_run():\n return 'resul... | [
0,
1,
2
] |
import json
from flask import current_app, request, jsonify, make_response
from flask_cors import cross_origin
from alerta.auth.utils import is_authorized, create_token, get_customer
from alerta.utils.api import absolute_url, deepmerge
from . import auth
try:
import saml2
import saml2.entity
import saml... | normal | {
"blob_id": "b233d212f3a6c453786dc54b2d43578e1faae417",
"index": 7292,
"step-1": "<mask token>\n\n\ndef spConfig():\n return saml2.config.Config()\n\n\ndef saml_client():\n saml2_config_default = {'entityid': absolute_url(), 'service': {'sp': {\n 'endpoints': {'assertion_consumer_service': [(absolut... | [
4,
5,
6,
7,
8
] |
# coding: utf-8
## ROC for CLEF-IP2010 patents
####### ROC for clef-ip2010 patents
# In[ ]:
def vectorize_corpus(corpus,tokenizer,vocabulary,max_ngram_size):
# tokenize text
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from... | normal | {
"blob_id": "08e5e8515528eae400a59bfc0c58b8d7b4affd7e",
"index": 5921,
"step-1": "\n# coding: utf-8\n\n## ROC for CLEF-IP2010 patents\n\n####### ROC for clef-ip2010 patents\n\n# In[ ]:\n\ndef vectorize_corpus(corpus,tokenizer,vocabulary,max_ngram_size):\n # tokenize text\n from sklearn.feature_extraction.t... | [
0
] |
import sys
import math
from random import randrange
from utilities import *
from EffectiveThueLemma import *
def getZ(value):
s = str(value)
p10 = 1
if s[0] != '0':
p10 = 10
for i in range(1, len(s)):
if s[i] == '.':
break
p10 *= 10
z = []
first = int(s[0] == '0')
for i in range(first, len(s)):
if s... | normal | {
"blob_id": "2b3a7d0c28d1bf7d4400b0e5558b0527a96af781",
"index": 7658,
"step-1": "<mask token>\n\n\ndef Theorem4_9(n, b, R):\n if R >= n:\n raise ValueError('r* >= n')\n if b < 0 or b >= n:\n raise ValueError('b < 0 or b >= n')\n r, rr = n, b\n s, ss = 1, 0\n t, tt = 0, 1\n if r <... | [
3,
5,
6,
7,
8
] |
#!/usr/bin/python
import sys
import os
import sqlite3
from matplotlib import pyplot as plt
import numpy as np
def main():
if len(sys.argv) < 2:
print('usage: sqlite_file ...')
sys.exit()
db_filenames = sys.argv[1:]
num_of_dbs = len(db_filenames)
conn = sqlite3.connect(":memory:")
c... | normal | {
"blob_id": "b24ce9ed2df11df4cbf47949915685c09ec7543a",
"index": 7070,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n if len(sys.argv) < 2:\n print('usage: sqlite_file ...')\n sys.exit()\n db_filenames = sys.argv[1:]\n num_of_dbs = len(db_filenames)\n conn = sq... | [
0,
1,
2,
3,
4
] |
class Solution:
# This would generate all permutations, but that's not what this question asks for
# def combo(self, cur, n, ret, arr):
# if cur == n:
# arr.append(ret)
# return
# self.combo(cur+1, n, ret + "1", arr)
# self.combo(cur+1, n, ret + "0", arr)
def c... | normal | {
"blob_id": "e9a929dfef327737b54723579d3c57884fe61057",
"index": 7061,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n <mask token>\n",
"step-3": "class Solution:\n\n def combo(self, n):\n if n == 0:\n return ['0']\n elif n == 1:\n return [... | [
0,
1,
2,
3,
4
] |
def contador_notas(multiplo, numero):
if(numero % multiplo == 0):
notas = numero / multiplo
return notas
else:
return -1
entrada = int(input())
resultado = contador_notas(100, entrada)
if (resultado != -1):
print("{} nota(s) de R$ {}".format(resultado, 100)) | normal | {
"blob_id": "a5c19ad60ac6312631273858cebaae944a2008ec",
"index": 8876,
"step-1": "<mask token>\n",
"step-2": "def contador_notas(multiplo, numero):\n if numero % multiplo == 0:\n notas = numero / multiplo\n return notas\n else:\n return -1\n\n\n<mask token>\n",
"step-3": "def conta... | [
0,
1,
2,
3,
4
] |
from .scheduler import Scheduler
MyScheduler = Scheduler()
| normal | {
"blob_id": "d472a15d6fa826e50a550996369b00b6c599a1c7",
"index": 5401,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nMyScheduler = Scheduler()\n",
"step-3": "from .scheduler import Scheduler\nMyScheduler = Scheduler()\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 22 19:29:50 2017
@author: marcos
"""
from sklearn.cluster import KMeans
from sklearn.utils import shuffle
from classes.imagem import Imagem
import numpy as np
def mudaCor(img, metodo='average', nTons=256):
nova = Imagem((img.altura, img.largura))
for x in rang... | normal | {
"blob_id": "1f7007fcea490a8b28bd72163f99b32e81308878",
"index": 4834,
"step-1": "<mask token>\n\n\ndef balanco(img, ar, ag, ab):\n nova = Imagem((img.altura, img.largura))\n for y in range(img.altura):\n for x in range(img.largura):\n r, g, b = img[y][x]\n R = int(ar * r)\n ... | [
4,
5,
6,
7,
8
] |
d = {
1 : 'I',
5 : 'V',
10: 'X',
50: 'L',
100: 'C',
500: 'D',
1000: 'M'
}
e = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
... | normal | {
"blob_id": "1a29b3138f6a33fbe2781f044c1bcccd03ecd48d",
"index": 7590,
"step-1": "<mask token>\n\n\ndef convert2numeral(rom):\n cur = 0\n num = 0\n while cur < len(rom):\n if cur + 1 == len(rom):\n num += e[rom[cur]]\n elif e[rom[cur]] > e[rom[cur + 1]]:\n num += e[ro... | [
1,
2,
3,
4,
5
] |
"""
You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.
Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the stri... | normal | {
"blob_id": "5efb8151375d705f3591921654f847e45b6927c9",
"index": 3614,
"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 areAlmostEqual(self, s1, s2):\n if not len(s1) == len(s2):\n ... | [
0,
1,
2,
3,
4
] |
# -*-coding:utf-8 -*-
#
# Created on 2016-04-01
# __ __
# - /__) _ /__) __/
# / / ( (/ / ( /
# /
from core.views import BaseView
class TestView(BaseView):
"""
测试页面
"""
# template_name = 'test/blog-1.html'
template_name = 'test/music-1.html'
| normal | {
"blob_id": "dc2b074d7d0e87105b2479bb60b46c73dce6c069",
"index": 6113,
"step-1": "<mask token>\n\n\nclass TestView(BaseView):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass TestView(BaseView):\n <mask token>\n template_name = 'test/music-1.html'\n",
"step-3": "<mask token>\n... | [
1,
2,
3,
4,
5
] |
import mysql.connector
import json
mysql_user = 'root'
mysql_pass = 'funwfats'
mysql_host = 'localhost'
mysql_base = 'sys'
wn8_file = "wn8exp.json"
def fill_wn8_table():
with open(wn8_file, encoding="utf-8") as file:
wn8_dict = json.loads(file.read())
cnx_wn8 = mysql.connector.connect(us... | normal | {
"blob_id": "291052c22059b32f3f300c323a10b260fbd0c20f",
"index": 9210,
"step-1": "import mysql.connector\r\nimport json\r\n\r\nmysql_user = 'root'\r\nmysql_pass = 'funwfats'\r\nmysql_host = 'localhost'\r\nmysql_base = 'sys'\r\nwn8_file = \"wn8exp.json\"\r\n\r\n\r\ndef fill_wn8_table():\r\n with open(wn8_file,... | [
0
] |
import urllib.request, urllib.parse, urllib.error
import json
import ssl
# Retrieve json data into Python dictionary
url = "http://py4e-data.dr-chuck.net/comments_147422.json"
handle = urllib.request.urlopen(url)
data = handle.read().decode()
data = json.loads(data)
# Calculate total sum of counts
sum = 0
for item in... | normal | {
"blob_id": "01b9706966007c44aa19d8249fbcaee5b511786a",
"index": 1111,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor item in data['comments']:\n sum = sum + int(item['count'])\nprint(sum)\n",
"step-3": "<mask token>\nurl = 'http://py4e-data.dr-chuck.net/comments_147422.json'\nhandle = urllib.re... | [
0,
1,
2,
3,
4
] |
from typing import List
import pandas as pd
import numpy as np
import pickle
from catboost import CatBoostRegressor
from sklearn.preprocessing import MinMaxScaler
def calculate_probable_age(usersEducationFeatures):
prob_age = {}
grads_count = {}
age_diff1 = 17 # age difference for school
... | normal | {
"blob_id": "ee0ed255b6851696dc57c01100cd67f5f959cf01",
"index": 7437,
"step-1": "<mask token>\n\n\ndef get_prob_age(uids, prob_age) ->List[int]:\n res = [0] * len(uids)\n for i, uid in enumerate(uids):\n res[i] = prob_age.setdefault(uid, 0)\n return res\n\n\ndef get_grads_count(uids, grads_count... | [
5,
6,
7,
9,
10
] |
"""I referred below sample.
https://ja.wikipedia.org/wiki/Adapter_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3#:~:text=Adapter%20%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3%EF%BC%88%E3%82%A2%E3%83%80%E3%83%97%E3%82%BF%E3%83%BC%E3%83%BB%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3%EF%BC%89,%E5%A4%89%E6%9B%B4%E3%81%99%E3%82%8B%E3%81%93%E3%81%A... | normal | {
"blob_id": "829e23ce2388260467ed159aa7e1480d1a3d6045",
"index": 6546,
"step-1": "<mask token>\n\n\nclass Product:\n <mask token>\n\n def __init__(self, cost: int) ->None:\n self.__cost = cost\n\n def get_yen(self) ->int:\n return self.__cost\n\n\nclass ProductAdapter(ProductPrice):\n \... | [
7,
9,
12,
13,
14
] |
def warshall_floyd(N):
INF = 10 ** 20
path = [[INF for _ in range(N + 1)] for _ in range(N + 1)]
graph = get_graph()
for i in range(N + 1):
path[i][i] = 0
for g in graph:
x = g[0]
y = g[1]
l = g[2]
path[x][y] = path[y][x] = l
for start in range(N + 1):
... | normal | {
"blob_id": "1e1f918ba24f5a5f13b9b01289ebfda65bae572d",
"index": 301,
"step-1": "def warshall_floyd(N):\n INF = 10 ** 20\n path = [[INF for _ in range(N + 1)] for _ in range(N + 1)]\n graph = get_graph()\n for i in range(N + 1):\n path[i][i] = 0\n for g in graph:\n x = g[0]\n ... | [
2,
3,
4,
5
] |
from random import randint
in_file = open("vocabulary.txt", "r")
voca_dic = {}
for line in in_file:
data = line.strip().split(": ")
eng_word = data[0]
kor_word = data[1]
voca_dic[eng_word] = kor_word
while True:
keys = list(voca_dic.keys())
index = randint(1, len(keys) - 1)
input_val ... | normal | {
"blob_id": "be64c981e7ea70dfcbd840988a633b4a71a43783",
"index": 9814,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in in_file:\n data = line.strip().split(': ')\n eng_word = data[0]\n kor_word = data[1]\n voca_dic[eng_word] = kor_word\nwhile True:\n keys = list(voca_dic.keys())... | [
0,
1,
2,
3,
4
] |
#coding: utf-8
import numpy as np
import cv2
leftgray = cv2.imread('../image/1.jpg')
rightgray = cv2.imread('../image/2.jpg')
hessian=500
surf=cv2.xfeatures2d.SURF_create(hessian) #将Hessian Threshold设置为400,阈值越大能检测的特征就越少
kp1,des1=surf.detectAndCompute(leftgray,None) #查找关键点和描述符
kp2,des2=surf.detectAndCompute(rightgr... | normal | {
"blob_id": "60953878c377382f1c7f25ce284c9fa12b8eb25f",
"index": 4667,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncv2.namedWindow('mathches', 1)\ncv2.imshow('mathches', a)\ncv2.waitKey()\n<mask token>\nfor m, n in matches:\n if m.distance < 0.45 * n.distance:\n good.append(m)\nprint(len(goo... | [
0,
1,
2,
3,
4
] |
import pymysql
import logging
import socket
from models.platformconfig import Pconfig
class ncbDB(Pconfig):
# I have to retrieve basic configuration attributes, listed below, from system config file
# on ApplSrv, for example : /etc/ncb_applsrv/ncb_applsrv.conf
hostname = None
conferenceMediaStoragePa... | normal | {
"blob_id": "257a4d0b0c713624ea8452dbfd6c5a96c9a426ad",
"index": 8344,
"step-1": "<mask token>\n\n\nclass ncbDB(Pconfig):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def ncb_getQuery(self, querySQL):\n result = []\n try:\n with self.co... | [
4,
7,
8,
9,
10
] |
from api import url, key, opposite
import requests
import json
import time
import os
from miner import mine
from cpu import *
class Player:
def __init__(self):
data = self._get_status()
time.sleep(data['cooldown'])
self.name = data['name']
self.cooldown = data['cooldown']
s... | normal | {
"blob_id": "edd70f55e76418911d304d6eb41a6d2a93005a58",
"index": 890,
"step-1": "<mask token>\n\n\nclass Player:\n\n def __init__(self):\n data = self._get_status()\n time.sleep(data['cooldown'])\n self.name = data['name']\n self.cooldown = data['cooldown']\n self.encumbranc... | [
11,
15,
17,
19,
21
] |
# @Time : 2019/6/2 8:42
# @Author : Xu Huipeng
# @Blog : https://brycexxx.github.io/
class Solution:
def isPalindrome(self, x: int) -> bool:
num_str = str(x)
i, j = 0, len(num_str) - 1
while i < j:
if num_str[i] == num_str[j]:
i += 1
j -= 1... | normal | {
"blob_id": "40f57ccb1e36d307b11e367a2fb2f6c97051c65b",
"index": 6759,
"step-1": "class Solution:\n\n def isPalindrome(self, x: int) ->bool:\n num_str = str(x)\n i, j = 0, len(num_str) - 1\n while i < j:\n if num_str[i] == num_str[j]:\n i += 1\n j ... | [
3,
4,
5,
6,
7
] |
from .data_processing import make_request_data, clear_request_data, get_token_from_text
from .review import Review
| normal | {
"blob_id": "5d654c056e6ef01e72821427c4f8dcb285755ee9",
"index": 2933,
"step-1": "<mask token>\n",
"step-2": "from .data_processing import make_request_data, clear_request_data, get_token_from_text\nfrom .review import Review\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
... | [
0,
1
] |
# Title: K번째 수
# Link: https://www.acmicpc.net/problem/11004
import sys
sys.setrecursionlimit(10 ** 6)
def read_list_int():
return list(map(int, sys.stdin.readline().strip().split(' ')))
def read_single_int():
return int(sys.stdin.readline().strip())
def selection_sort(nums, k):
sor... | normal | {
"blob_id": "f4ab6df8efc334fa338ade7deecd36d8cd859e96",
"index": 4174,
"step-1": "<mask token>\n\n\ndef read_list_int():\n return list(map(int, sys.stdin.readline().strip().split(' ')))\n\n\n<mask token>\n\n\ndef selection_sort(nums, k):\n sorted_index = 0\n while True:\n minimum = 9999999999\n ... | [
5,
6,
7,
8,
9
] |
# -*- coding: utf-8 -*-
"""
:Author: Dominic Hunt
"""
import numpy as np
import logging
import itertools
import copy
import types
import utils
class FitSubsetError(Exception):
pass
class ActionError(Exception):
pass
class StimuliError(Exception):
pass
class FitSim(object)... | normal | {
"blob_id": "1d5db3db319e67e050036e718bbe0c538365d229",
"index": 1976,
"step-1": "<mask token>\n\n\nclass FitSim(object):\n <mask token>\n\n def __init__(self, participant_choice_property='Actions',\n participant_reward_property='Rewards', model_fitting_variable=\n 'ActionProb', task_stimuli_... | [
12,
15,
16,
17,
19
] |
import os, gc, random
from time import time
import pickle
import numpy as np
import pandas as pd
from sklearn.metrics import log_loss, f1_score, accuracy_score
from collections import Counter
from IPython.display import clear_output
import torch
from transformers import (
AutoTokenizer, RobertaTokenizerFast,
B... | normal | {
"blob_id": "458124aa0d6f04268ad052f74d546b12d3f3f5f7",
"index": 8989,
"step-1": "<mask token>\n\n\nclass Timer:\n\n def __init__(self):\n self._time = 0\n self.is_stopped = False\n self._start()\n <mask token>\n <mask token>\n\n @property\n def time(self):\n self._stop... | [
23,
29,
31,
33,
35
] |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""Project Euler: 0010
https://projecteuler.net/problem=10
Summation of primes
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
"""
import math
import sys
PROBLEM = 10
SOLVED = True
SPEED = 29.16
TAGS = ['primes']... | normal | {
"blob_id": "adf8b52f6e71546b591ceb34a9425c28f74883fa",
"index": 6288,
"step-1": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\"\"\"Project Euler: 0010\n\nhttps://projecteuler.net/problem=10\n\nSummation of primes\n\nThe sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.\n\nFind the sum of all the primes belo... | [
0
] |
import unittest
from display import Display
class TestDisplay(unittest.TestCase):
def setUp(self):
self.display = Display(None)
def test_set_pixels(self):
self.display.clear_buffer()
self.display.set_pixel(0, 1, 1)
self.assertEqual(self.display.get_pixel(0, 1), 1, "pixel was n... | normal | {
"blob_id": "75d2dcbb0c131930602e3c1f2cf30c0e4c5e3c42",
"index": 8262,
"step-1": "<mask token>\n\n\nclass TestDisplay(unittest.TestCase):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass TestDisplay(unittest.TestCase):\n\n def setUp(self):\n self.display = Display(None)\n ... | [
1,
2,
3,
4,
5
] |
from telethon import events
from var import Var
from pathlib import Path
from ub.config import Config
import re, logging, inspect, sys, json, os
from asyncio import create_subprocess_shell as asyncsubshell, subprocess as asyncsub
from os import remove
from time import gmtime, strftime
from traceback import format_exc
f... | normal | {
"blob_id": "4b672ad420bb67b8e2726102939ed6d369683150",
"index": 7267,
"step-1": "<mask token>\n\n\ndef load_module(shortname):\n if shortname.startswith('__'):\n pass\n elif shortname.endswith('_'):\n import ub.events\n import sys\n import importlib\n from pathlib import... | [
4,
7,
9,
13,
15
] |
from ddt import ddt, data, unpack
import sys
sys.path.append("..")
from pages.homepage import HomePage
from base.basetestcase import BaseTestCase
from helpers.filedatahelper import get_data
@ddt
class QuickSearchTest(BaseTestCase):
testingdata = get_data('testdata/QuickSearchTestData.xlsx')
@data(*testingdata... | normal | {
"blob_id": "4ba0f7e947830018695c8c9e68a96426f49b4b5b",
"index": 3326,
"step-1": "<mask token>\n\n\n@ddt\nclass QuickSearchTest(BaseTestCase):\n <mask token>\n\n @data(*testingdata)\n @unpack\n def test_QuickSearch(self, search_value, expected_result, notes):\n homepage = HomePage(self.driver)... | [
2,
3,
4,
5,
6
] |
import sys
sys.stdin = open("input.txt", "r")
stick = input()
cnt = 0
temp =[]
for i,s in enumerate(stick):
#'('나오면 무조건 추가
if s == '(':
temp.append(s)
else:
#절단인 경우
if stick[i-1] == '(':
temp.pop()
cnt += len(temp)
#길이가 짧아 아웃
els... | normal | {
"blob_id": "9f38148c19f0cb9522725d9eb27c91f70055cba1",
"index": 4998,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i, s in enumerate(stick):\n if s == '(':\n temp.append(s)\n elif stick[i - 1] == '(':\n temp.pop()\n cnt += len(temp)\n else:\n temp.pop()\n ... | [
0,
1,
2,
3,
4
] |
#HOW TO BUILD A SIMPLE CALCULATOR
#1.ADD
#2.SUBTRACT
#3.MULTIPLY
#4.DIVIDE
print("Select an operation to perform: ")
print("1.ADD")
print("2.SUBTRACT")
print("3.MULTIPLY")
print("4.DIVIDE")
print("5.SQUARE ROOT")
operation=input()
if operation=="1":
a=input("Enter first number: ")
b=input("Enter sec... | normal | {
"blob_id": "ea35180daecb8ca4b9bd351a949a4757b97322ec",
"index": 2819,
"step-1": "<mask token>\n",
"step-2": "print('Select an operation to perform: ')\nprint('1.ADD')\nprint('2.SUBTRACT')\nprint('3.MULTIPLY')\nprint('4.DIVIDE')\nprint('5.SQUARE ROOT')\n<mask token>\nif operation == '1':\n a = input('Enter ... | [
0,
1,
2,
3
] |
from face_recognition.model import Backbone
import torch
import numpy
class face_verifier():
def __init__(self, net_depth=50, drop_ratio=0.6, net_mode="ir_se", device="cuda"):
# create model
self.model = Backbone(net_depth, drop_ratio, net_mode).to(device)
save_path = "face_recognit... | normal | {
"blob_id": "0659df48bb150582917e333a7a25d2d25395dfda",
"index": 1381,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass face_verifier:\n <mask token>\n\n def verify_person(self, f1, f2):\n batch_tensor = torch.cat([f1, f2], 0)\n output_feat = self.model(batch_tensor.cuda())\n ... | [
0,
2,
3,
4,
5
] |
def lcs(X, Y, m, n):
dp = [[0]*(n+1) for i in range(m+1)]
for i in range(1,m+1):
for j in range(1,n+1):
if X[i-1] == Y[j-1]:
dp[i][j] = 1 + dp[i-1][j-1]
else:
dp[i][j] = max(dp[i-1][j], dp[i][j-1])
index = dp[m][n]
s = ""
... | normal | {
"blob_id": "247e352b7772a1da74a26f007228355f5af8d3b3",
"index": 191,
"step-1": "<mask token>\n",
"step-2": "def lcs(X, Y, m, n):\n dp = [([0] * (n + 1)) for i in range(m + 1)]\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if X[i - 1] == Y[j - 1]:\n dp[i][j] =... | [
0,
1,
2,
3,
4
] |
import httplib
def get_status_code(host, path="/"):
try:
connect = httplib.HTTPConnection(host)
connect.request("HEAD", path)
return connect.getresponse().status
except StandardError:
return None
if __name__ == '__main__':
print get_status_code("google.com")
| normal | {
"blob_id": "891a490410fd8c7b8879f1e71f24df2db62ff85d",
"index": 7748,
"step-1": "import httplib\n\ndef get_status_code(host, path=\"/\"):\n try:\n connect = httplib.HTTPConnection(host)\n connect.request(\"HEAD\", path)\n return connect.getresponse().status\n except StandardError:\n ... | [
0
] |
import hashlib
def createMD5(str):
# 创建md5对象
hl = hashlib.md5()
hl.update(str.encode(encoding='utf-8'))
return hl.hexdigest() | normal | {
"blob_id": "ea78f754ffff26bac1e53ed1e842fd79112b8ee7",
"index": 6811,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef createMD5(str):\n hl = hashlib.md5()\n hl.update(str.encode(encoding='utf-8'))\n return hl.hexdigest()\n",
"step-3": "import hashlib\n\n\ndef createMD5(str):\n hl = ... | [
0,
1,
2,
3
] |
import re
# Class with static regex compilations
class RegexCompiles:
# regex for finding product-id in an EMAG link
re_compile_product_id = re.compile('Product-Id=[0-9]*')
# regex for finding the first number
re_compile_id = re.compile('[0-9]+')
# Verifies if a word exists in a text
def find_whole_... | normal | {
"blob_id": "b1c06e9c5516a378c0bbce2ce9e17afaeae01928",
"index": 668,
"step-1": "<mask token>\n\n\nclass RegexCompiles:\n re_compile_product_id = re.compile('Product-Id=[0-9]*')\n re_compile_id = re.compile('[0-9]+')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass RegexCompiles:\n re_compile_... | [
2,
4,
5,
6,
7
] |
# Given an array of integers, return indices of the two numbers such that they add up to a specific target.
# You may assume that each input would have exactly one solution, and you may not use the same element twice.
# Example:
# Given nums = [2, 7, 11, 15], target = 9,
# Because nums[0] + nums[1] = 2 + 7 = 9,
# retu... | normal | {
"blob_id": "16cc85324b555f0cfec8d577b776b86872578822",
"index": 6016,
"step-1": "class Solution:\n <mask token>\n\n\n<mask token>\n",
"step-2": "class Solution:\n\n def twoSum(self, nums, target):\n d = dict([(nums[i], i) for i in range(len(nums))])\n for n in range(len(nums)):\n ... | [
1,
2,
3,
4,
5
] |
print("Convertidor de pies y pulgadas a centímetros")
pies = float(input("Escriba una cantidad de pies: "))
pulgadas = float(input("Escriba una cantidad de pulgadas: "))
cm = (pies * 12 + pulgadas) * 2.54;
print("{} pies y {} pulgadas son {} cm".format(pies, pulgadas, cm))
| normal | {
"blob_id": "b0ab97f5c05cdeee4c01460109a76cef75ac72ce",
"index": 5342,
"step-1": "<mask token>\n",
"step-2": "print('Convertidor de pies y pulgadas a centímetros')\n<mask token>\nprint('{} pies y {} pulgadas son {} cm'.format(pies, pulgadas, cm))\n",
"step-3": "print('Convertidor de pies y pulgadas a centíme... | [
0,
1,
2,
3
] |
from django.contrib.auth.decorators import login_required
from django.contrib.auth import login, authenticate
from django.shortcuts import render, redirect
from mysite.core.forms import SignUpForm,UserProfileForm
from django.views.generic import UpdateView
from .models import Profile
from django.contrib.auth.mixins im... | normal | {
"blob_id": "21d261dec6668a24030f37b7dcb87c0132e63528",
"index": 1365,
"step-1": "<mask token>\n\n\nclass EditUserProfileView(LoginRequiredMixin, UpdateView):\n model = Profile\n form_class = UserProfileForm\n template_name = 'profile.html'\n",
"step-2": "<mask token>\n\n\n@login_required\ndef home(re... | [
2,
3,
4,
5,
6
] |
from django.urls import path
from .consumers import NotificationsConsumer
websocket_urlpatterns = [
path('ws/notifications', NotificationsConsumer),
]
| normal | {
"blob_id": "31e5b249516f4e9d57d8fd82713966a69e0516b4",
"index": 9185,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwebsocket_urlpatterns = [path('ws/notifications', NotificationsConsumer)]\n",
"step-3": "from django.urls import path\nfrom .consumers import NotificationsConsumer\nwebsocket_urlpattern... | [
0,
1,
2,
3
] |
two_digit_number=input("Type a two digit number: ")
first_digit=two_digit_number[0]
second_digit=two_digit_number[1]
print(int(first_digit)+int(second_digit)) | normal | {
"blob_id": "7d65e4e925e90d6b013ae2c059cde58538884d22",
"index": 7239,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(int(first_digit) + int(second_digit))\n",
"step-3": "two_digit_number = input('Type a two digit number: ')\nfirst_digit = two_digit_number[0]\nsecond_digit = two_digit_number[1]\n... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-04 13:16
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0007_alter_validators_add_error_... | normal | {
"blob_id": "71662ff8c68559bf08e1da7f1a1504bfe842c950",
"index": 7430,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
"""
generalised behaviour for actors and vacancies
"""
from mesa import Agent
from random import shuffle
import numpy as np
class Entity(Agent):
"""
superclass for vacancy and actor agents
not intended to be used on its own, but to inherit its methods to multiple other agents
"""
def __init__(sel... | normal | {
"blob_id": "68b967ecf18d576758cf05e889919944cfc34dcd",
"index": 250,
"step-1": "<mask token>\n\n\nclass Entity(Agent):\n <mask token>\n\n def __init__(self, unique_id, model):\n super().__init__(unique_id, model)\n self.type = ''\n self.position = ''\n self.log = []\n se... | [
5,
6,
7,
9,
10
] |
import numpy as np
import pandas as pd
INPUT_FILE = 'data_full.csv'
data = pd.read_csv(INPUT_FILE)
data['date'] = pd.to_datetime(data['date'], format='%d-%m-%Y %H:%M:%S')
# Wyodrębnienie użytkowników i stron na jakie wchodzili do postaci <USER> [<SITES>]
data = data[['ip', 'address']]
data['sites'] = data.groupby(['i... | normal | {
"blob_id": "3b61d389eda85ddb4c96f93c977a33b91da579ce",
"index": 7900,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndata.drop_duplicates(subset='ip', inplace=True, keep='first')\ndata.reset_index(drop=True, inplace=True)\n<mask token>\ncols.extend(sites)\n<mask token>\nattributes.set_index('userID', in... | [
0,
1,
2,
3,
4
] |
import re, os, nltk, pymorphy2, sys
from suffix_trees.STree import STree
def make_rules(folder):
rules_dictionary = {}
try:
path = os.path.join(os.getcwd(), 'rules', 'data', folder)
files = os.listdir(path)
except:
path = os.path.join(os.getcwd(), 'data', folder)
files = os... | normal | {
"blob_id": "1bf9785135f6105301d02602e54cbbcbdd249144",
"index": 9283,
"step-1": "<mask token>\n\n\ndef make_rules(folder):\n rules_dictionary = {}\n try:\n path = os.path.join(os.getcwd(), 'rules', 'data', folder)\n files = os.listdir(path)\n except:\n path = os.path.join(os.getcwd... | [
4,
5,
7,
8,
9
] |
import os, sys
top=sys.argv[1]
max=int(sys.argv[2])
cnts={}
for d, dirs, files in os.walk(top):
for f in files:
i=f.find(".")
if i ==-1: i=0
suf=f[i:]
rec=cnts.setdefault(suf, [0,0])
fn=d+'/'+f
if os.path.islink(fn):
sz=0
else:
sz=o... | normal | {
"blob_id": "06aa2d261e31dfe2f0ef66dca01c1fe3db1ca94e",
"index": 7940,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor d, dirs, files in os.walk(top):\n for f in files:\n i = f.find('.')\n if i == -1:\n i = 0\n suf = f[i:]\n rec = cnts.setdefault(suf, [0, 0])\... | [
0,
1,
2,
3,
4
] |
__all__ = ['language']
from StringTemplate import *
| normal | {
"blob_id": "e70c25ce1d61437aacfe7fad0a51e096e1ce4f5d",
"index": 5212,
"step-1": "<mask token>\n",
"step-2": "__all__ = ['language']\n<mask token>\n",
"step-3": "__all__ = ['language']\nfrom StringTemplate import *\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
from typing import Dict, List
pilha = list()
print(pilha)
| normal | {
"blob_id": "f3f3bbb715f16dc84221f3349aa5f26e9a6dc7c8",
"index": 2726,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(pilha)\n",
"step-3": "<mask token>\npilha = list()\nprint(pilha)\n",
"step-4": "from typing import Dict, List\npilha = list()\nprint(pilha)\n",
"step-5": null,
"step-ids": [... | [
0,
1,
2,
3
] |
# Generated by Django 2.0.3 on 2018-03-24 07:53
import django.core.files.storage
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('printers', '0001_initial'),
('devices', '0002_url'),
]
operations = [
migration... | normal | {
"blob_id": "d8df9a9f95a1d4a9aa34987ec1244cc6c0c7c610",
"index": 8048,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
a = 10
b = 20
c = a + b
d = b - a
print(c)
print(d)
| normal | {
"blob_id": "632fdb95874f0beeb6d178788f7c7e7c9e8512e5",
"index": 8239,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(c)\nprint(d)\n",
"step-3": "a = 10\nb = 20\nc = a + b\nd = b - a\nprint(c)\nprint(d)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
from django import template
import ast
register = template.Library()
@register.simple_tag()
def multiplication(value, arg, *args, **kwargs):
return value * arg
@register.filter
def in_category(things, category):
return things.filter(category=category)
@register.simple_tag()
def division(value, arg, *args,... | normal | {
"blob_id": "9339d3bc0c3005880b1c8d1c9914d6e28d39dbbd",
"index": 7285,
"step-1": "<mask token>\n\n\n@register.simple_tag()\ndef multiplication(value, arg, *args, **kwargs):\n return value * arg\n\n\n@register.filter\ndef in_category(things, category):\n return things.filter(category=category)\n\n\n@registe... | [
3,
4,
5,
6
] |
# GERALDO AMELIO DE LIMA JUNIOR
# UNIFIP - Patos
# 05 de março de 2020
# Questão 08 - Escreva um programa que leia um valor inteiro e calcule o seu cubo.
n = int(input('Digite um numero:'))
t = n*3
print('O triplo de {} vale {}.'.format(n, t))
| normal | {
"blob_id": "8f311e15c15fe3309218dfaed5eefa4a8fc3f453",
"index": 3234,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('O triplo de {} vale {}.'.format(n, t))\n",
"step-3": "n = int(input('Digite um numero:'))\nt = n * 3\nprint('O triplo de {} vale {}.'.format(n, t))\n",
"step-4": "# GERALDO AME... | [
0,
1,
2,
3
] |
# coding: utf-8
"""
最简单的计数器,仅仅为了展示基本方式
"""
import tensorflow as tf
# 创建一个变量, 初始化为标量 0
state = tf.Variable(0, name="counter")
# 创建一个operation, 其作用是使state 增加 1
one = tf.constant(1)
new_value = tf.add(state, one)
update = tf.assign(state, new_value) # 这样才能重复执行+1的操作,实际上就代表:state=new_value
# 启动图后, 变量必须先经过`初始化` (init) o... | normal | {
"blob_id": "cf4582f4d0c6c94e617270a45425fe0b770142e0",
"index": 2937,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith tf.Session() as sess:\n sess.run(init_op)\n print(sess.run(state))\n for _ in range(10):\n sess.run(new_value)\n print(sess.run(new_value))\n",
"step-3": "<m... | [
0,
1,
2,
3,
4
] |
from wasserstoff.wasserstoff import Config, Environment
__all__ = ['Config', 'Environment']
| normal | {
"blob_id": "862b529741d9c3e6cf7ca50272c8af724c56ac62",
"index": 404,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['Config', 'Environment']\n",
"step-3": "from wasserstoff.wasserstoff import Config, Environment\n__all__ = ['Config', 'Environment']\n",
"step-4": null,
"step-5": null,
... | [
0,
1,
2
] |
# -*- coding:utf-8 -*-
from flask import redirect, url_for, render_template
from flask.globals import request, session
from flask_admin import BaseView, expose
from util import navigator, common
class Billings(BaseView):
@expose('/')
def index(self):
return redirect(url_for('.billingHistory'))
... | normal | {
"blob_id": "a9344151a997842972aa68c417a77b3ca80e6cfa",
"index": 3174,
"step-1": "<mask token>\n\n\nclass Billings(BaseView):\n\n @expose('/')\n def index(self):\n return redirect(url_for('.billingHistory'))\n <mask token>\n <mask token>\n <mask token>\n\n @expose('/billingsDetail')\n ... | [
3,
5,
6,
7,
8
] |
import os
# didnt endup using this
import time
# from django.contrib.gis.utils import LayerMapping
from django.contrib.gis.geos import fromstr
# from models import Harbord
import csv
from pygeocoder import Geocoder
# from django.contrib.gis.geos import (Point, fromstr, fromfile,
# GEOSGeometry, Multi... | normal | {
"blob_id": "40b9114e4348bab5d76d68a937b3abe95a90c230",
"index": 4130,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(tree_csv, 'rU') as csvinput:\n with open('../harbordvillage/outfile.csv', 'w+') as csvoutput:\n writer = csv.writer(csvoutput, quoting=csv.QUOTE_NONNUMERIC)\n r... | [
0,
1,
2,
3,
4
] |
"""
This type stub file was generated by pyright.
"""
import editobj3.introsp as introsp
import editobj3.editor as editor
from owlready2 import *
from editobj3.observe import *
from typing import Any, Optional
__all__ = ["EditedInstances", "OntologyInstanceEditor"]
class EditedInstances(object):
def __init__(self, ... | normal | {
"blob_id": "440c116327ee587b5a305953772523011ece5dda",
"index": 9641,
"step-1": "<mask token>\n\n\nclass TabPaneRepartitor(editor.PaneRepartitor):\n\n def __init__(self, instance_editor, tab_edited_class):\n self.instance_editor = ...\n self.tab_edited_class = ...\n\n def is_displayed_in_oth... | [
13,
16,
20,
23,
25
] |
from arnold import config
class TestMicrophone:
def setup_method(self, method):
self.config = config.SENSOR['microphone']
def test_config(self):
required_config = [
'card_number', 'device_index', 'sample_rate', 'phrase_time_limit',
'energy_threshold'
]
... | normal | {
"blob_id": "164167590051fac3f3fd80c5ed82621ba55c4cc4",
"index": 9597,
"step-1": "<mask token>\n\n\nclass TestMicrophone:\n <mask token>\n\n def test_config(self):\n required_config = ['card_number', 'device_index', 'sample_rate',\n 'phrase_time_limit', 'energy_threshold']\n for co... | [
3,
4,
5,
6,
7
] |
import random
import sys
import numpy
from gensim import corpora
from coherence.wn import WordNetEvaluator
from topic.topic import Topic
from nltk.corpus import wordnet as wn
from nltk.corpus import reuters
from nltk.corpus import brown
# python random_tc.py <dname> <word_count> <sample_times> <output>
# <word_count>... | normal | {
"blob_id": "2d7e3a70f1c25bbc7ad5eafa006ab12c978eaec4",
"index": 1115,
"step-1": "import random\nimport sys\n\nimport numpy\nfrom gensim import corpora\n\nfrom coherence.wn import WordNetEvaluator\nfrom topic.topic import Topic\nfrom nltk.corpus import wordnet as wn\nfrom nltk.corpus import reuters\nfrom nltk.co... | [
0
] |
import os
from flask import (
Flask,
render_template,
request
)
# from flask_jwt_extended import JWTManager
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from flask_wtf.csrf import CSRFError, CSRFProtect
from config import Config
from log_con... | normal | {
"blob_id": "9d142e8de5235d55cd99371c9884e8dc7a10c947",
"index": 8111,
"step-1": "<mask token>\n\n\n@app.errorhandler(404)\ndef not_found(error):\n logger.warning(f'page not found {error} - {request.url}')\n return render_template('error_pages/404.html'), 404\n\n\n@app.errorhandler(500)\ndef server_error(e... | [
2,
3,
4,
5,
6
] |
#Проверяем, является ли введенная пользователем строка полиндромом
list_1 = input('Enter something: ')
list_1_rev = list_1[::-1]
if list_1 == list_1_rev:
print('You entered a polindrom!')
else: print('Your string is not a polindrom')
| normal | {
"blob_id": "45b56103db0a72ebbc7de340c4293e1f70552414",
"index": 5254,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif list_1 == list_1_rev:\n print('You entered a polindrom!')\nelse:\n print('Your string is not a polindrom')\n",
"step-3": "list_1 = input('Enter something: ')\nlist_1_rev = list... | [
0,
1,
2,
3
] |
import AVFoundation
from PyObjCTools.TestSupport import TestCase
class TestAVAssetSegmentReport(TestCase):
def test_enum_types(self):
self.assertIsEnumType(AVFoundation.AVAssetSegmentType)
def test_constants(self):
self.assertEqual(AVFoundation.AVAssetSegmentTypeInitialization, 1)
se... | normal | {
"blob_id": "5ee667e8394ccacf83bfe4baec228373619b4edb",
"index": 2658,
"step-1": "<mask token>\n\n\nclass TestAVAssetSegmentReport(TestCase):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass TestAVAssetSegmentReport(TestCase):\n\n def test_enum_types(self):\n self.assertIsEn... | [
1,
2,
3,
4
] |
#!/usr/bin/env python
import sys
import ROOT
from ROOT import TTree
from ROOT import TChain
import numpy as np
import yaml
import xml.etree.ElementTree as ET
import datetime
#sys.path.append("/disk/gamma/cta/store/takhsm/FermiMVA/AllSky")
#sys.path.append("/home/takhsm/FermiMVA/python")
ROOT.gROOT.SetBatch()
from arra... | normal | {
"blob_id": "66cdeaa106a8f22dbfd64c12c4cb04fdb9f5b453",
"index": 5160,
"step-1": "#!/usr/bin/env python\n\nimport sys\nimport ROOT\nfrom ROOT import TTree\nfrom ROOT import TChain\nimport numpy as np\nimport yaml\nimport xml.etree.ElementTree as ET\nimport datetime\n#sys.path.append(\"/disk/gamma/cta/store/takhs... | [
0
] |
# Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,... | normal | {
"blob_id": "e11c479a99ab68755de8ab565e3d360d557129cf",
"index": 6036,
"step-1": "# Copyright 2010 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://w... | [
0
] |
from sys import stdin
read = lambda: stdin.readline().strip()
class Trie:
def __init__(self, me, parent=None):
self.me = me
self.parent = parent
self.children = {}
def get_answer(trie, count):
print(("--" * count) + trie.me)
trie.children = dict(sorted(trie.children.items(), key... | normal | {
"blob_id": "c5605f4770d61d435cc1817bad4d5cbe0aaf1d18",
"index": 8824,
"step-1": "<mask token>\n\n\nclass Trie:\n\n def __init__(self, me, parent=None):\n self.me = me\n self.parent = parent\n self.children = {}\n\n\n<mask token>\n\n\ndef main():\n trie_dict = {}\n for i in range(in... | [
3,
5,
6,
7,
8
] |
#!C:/Users/Tarang/AppData/Local/Programs/Python/Python37-32/python.exe -u
print("Content-Type: text/html")
print()
import cgi,cgitb
cgitb.enable() #for debugging
form = cgi.FieldStorage()
name = form.getvalue('fname')
print("Name of the user is:",name)
import pymysql
db = pymysql.connect("localhost","roo... | normal | {
"blob_id": "cb28e8bb98cbeed0b703fbfcf7cf30ebca52aa25",
"index": 4247,
"step-1": "<mask token>\n",
"step-2": "print('Content-Type: text/html')\nprint()\n<mask token>\ncgitb.enable()\n<mask token>\nprint('Name of the user is:', name)\n<mask token>\ncursor.execute(name)\n<mask token>\nprint(name)\ndb.close()\n",... | [
0,
1,
2,
3,
4
] |
# This script is for character creation.
print ("Welcome to the character wizard creation!")
# Here you will select your race from the list.
race = ["human", "ork", "elf"]
print race
race = raw_input("Please choose your race: ")
print "You have choosen %r" %race
# Here you will select your gender.
gender = ... | normal | {
"blob_id": "243016b14f503a09147f434e7bec31dc204fafdf",
"index": 1158,
"step-1": "# This script is for character creation.\r\nprint (\"Welcome to the character wizard creation!\")\r\n\r\n# Here you will select your race from the list.\r\nrace = [\"human\", \"ork\", \"elf\"]\r\nprint race\r\nrace = raw_input(\"Pl... | [
0
] |
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel
class Sizes(str, Enum):
one_gram = "1g"
two_and_half_gram = "2.5g"
one_ounce = "1oz"
five_ounce = "5oz"
ten_ounce = "10oz"
class PriceSort(str, Enum):
gte = "gte"
lte = "lte"
class Metals(str, Enum):... | normal | {
"blob_id": "442c6c4894fc01d0f8142f3dcedfd51ba57aedd1",
"index": 3304,
"step-1": "<mask token>\n\n\nclass Metals(str, Enum):\n gold = 'gold'\n silver = 'silver'\n\n\nclass PriceFilter(BaseModel):\n type: PriceSort\n price: float\n\n\nclass ProductSearch(BaseModel):\n price: Optional[PriceFilter]\n... | [
4,
5,
8,
9,
10
] |
import urllib2
import csv
from bs4 import BeautifulSoup
url = {
"Home ": 'https://www.moneycontrol.com/',
# "Market": 'https://www.moneycontrol.com/stocksmarketsindia/',
# "Mf Home": 'https://www.moneycontrol.com/mutualfundindia/'
}
def get_last_element_timestamp(url):
conn = urllib2.urlopen(url)
html ... | normal | {
"blob_id": "81f75498afcca31e38ea7856c81c291af3ef6673",
"index": 7151,
"step-1": "<mask token>\n\n\ndef historic_data(url):\n csv_data = urllib2.urlopen(url)\n csv_reader = list(csv.reader(csv_data, delimiter=','))\n return csv_reader[-1]\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_last... | [
1,
3,
4,
5,
6
] |
from platform_class import *
from player_class import *
from functions import *
delay = 3000
startOfGame = False
# def keyPressed():
# startOfGame = True
# print(startOfGame)
# if (keyCode == 'B'):
# print("I am pressed")
# startOfGame = True
def mousePressed():
global platforms
... | normal | {
"blob_id": "850251338e8af841a5214b37610d1b6fba572aa5",
"index": 1138,
"step-1": "<mask token>\n\n\ndef setup():\n size(500, 800)\n rectMode(CENTER)\n global atStartUp\n atStartUp = True\n global startTimeMs\n startTimeMs = millis()\n global bg, go, sb\n bg = loadImage('assets\\\\backgrou... | [
3,
4,
5,
6,
7
] |
def fibonacci(quantidade):
resultado = [1, 2]
# while True:
# substituir o while pelo for, em um range do 2° valor da lista, correr até
# o valor definido na função "Quantidade"
for _ in range(2, quantidade):
# desta forma ele irá realizar a função do 2° da lista até atingir
# o valor ... | normal | {
"blob_id": "83c7bb2e109f8affd9e2a12e8c5370b0f5a34048",
"index": 653,
"step-1": "<mask token>\n",
"step-2": "def fibonacci(quantidade):\n resultado = [1, 2]\n for _ in range(2, quantidade):\n resultado.append(sum(resultado[-2:]))\n return resultado\n\n\n<mask token>\n",
"step-3": "def fibonac... | [
0,
1,
2,
3
] |
import json
from examtool.api.database import get_exam, get_roster
from examtool.api.extract_questions import extract_questions
from examtool.api.scramble import scramble
from google.cloud import firestore
import warnings
warnings.filterwarnings("ignore", "Your application has authenticated using end user credentials"... | normal | {
"blob_id": "b74c759b51fb6591477757e2ff54b545f225991c",
"index": 7470,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwarnings.filterwarnings('ignore',\n 'Your application has authenticated using end user credentials')\n<mask token>\nfor exam in exams:\n print('checking', exam)\n exam_json = jso... | [
0,
1,
2,
3,
4
] |
"""This is a collection of utilities for httpy and httpy applications.
"""
import cgi
import linecache
import mimetypes
import os
import stat
import sys
from Cookie import SimpleCookie
from StringIO import StringIO
from urllib import unquote
from httpy.Response import Response
def uri_to_fs(config, resource_uri_pat... | normal | {
"blob_id": "472cdca501890d1d07c7363a48532ed3a184727c",
"index": 8516,
"step-1": "\"\"\"This is a collection of utilities for httpy and httpy applications.\n\"\"\"\n\nimport cgi\nimport linecache\nimport mimetypes\nimport os\nimport stat\nimport sys\nfrom Cookie import SimpleCookie\nfrom StringIO import StringIO... | [
0
] |
import random
import string
import datetime
from app import db
from dateutil.parser import parse as date_parse
from flask_security import UserMixin, RoleMixin
roles_users = db.Table('roles_users',
db.Column('user_id', db.Integer(), db.ForeignKey('users.id')),
db.Column('role_id', db.Integer(), db.Forei... | normal | {
"blob_id": "06b07045fcfafd174bb78ff5c3a36bed11e36e54",
"index": 9616,
"step-1": "<mask token>\n\n\nclass Studies(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n d... | [
42,
44,
53,
54,
60
] |
# Given an integer, convert it to a roman numeral.
# Input is guaranteed to be within the range from 1 to 3999.
class Solution:
# @param {integer} num
# @return {string}
def intToRoman(self, num):
normalDic = {
1000: 'M',
500: 'D',
100: 'C',
50: 'L',... | normal | {
"blob_id": "7de06772a1024a81193ac69a1110ad2e8b7f64ac",
"index": 9085,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def intToRoman(self, num):\n normalDic = {(1000): 'M', (500): 'D', (100): 'C', (50): 'L', (10):\n 'X', (5): '... | [
0,
1,
2,
3
] |
from os import chdir
from os.path import dirname, realpath
import random
from flask import Flask, render_template, send_from_directory
app = Flask(__name__)
# gets list of list of all classes
def get_data():
class_list = []
with open('counts.tsv') as fd:
for line in fd.read().splitlines():
... | normal | {
"blob_id": "af8a3fbce35685cd89dee72449a8be2a133b4a3f",
"index": 4684,
"step-1": "<mask token>\n\n\ndef get_data():\n class_list = []\n with open('counts.tsv') as fd:\n for line in fd.read().splitlines():\n class_data = line.split('\\t')\n class_list.append(class_data)\n ... | [
17,
19,
24,
26,
27
] |
import ConfigParser
''' Merge as many as ConfigParser as you want'''
def Config_Append(SRC_Config ,DST_Config):
import tempfile
temp_src = tempfile.NamedTemporaryFile(delete=True)
temp_dst = tempfile.NamedTemporaryFile(delete=True)
with open(temp_src.name,'wb') as src, open(temp_dst.name,'wb') as dst:
... | normal | {
"blob_id": "d17f1176ac60a3f6836c706883ab1847b61f50bf",
"index": 1857,
"step-1": "import ConfigParser\n''' Merge as many as ConfigParser as you want'''\n\ndef Config_Append(SRC_Config ,DST_Config):\n import tempfile\n temp_src = tempfile.NamedTemporaryFile(delete=True)\n temp_dst = tempfile.NamedTempora... | [
0
] |
array = [1, 2, 3, 4, 5]
for x in array:
print(x)
| normal | {
"blob_id": "224e13331ad93278f47a5582bbd24208d9ce5dcc",
"index": 3705,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor x in array:\n print(x)\n",
"step-3": "array = [1, 2, 3, 4, 5]\nfor x in array:\n print(x)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
#! /user/bin/env python
import requests
from getpass import getpass
import csv
# Set up the variables
with open("ACI PostMan Variable Values.csv", encoding='utf-8-sig') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print(row)
print("Let's configure the subnets... | normal | {
"blob_id": "bdc9856bfc61127d6bca31658b1faf3da09f5b86",
"index": 161,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('ACI PostMan Variable Values.csv', encoding='utf-8-sig') as csvfile:\n reader = csv.DictReader(csvfile)\n for row in reader:\n print(row)\nprint(\"Let's configure th... | [
0,
1,
2,
3,
4
] |
# Generated by Django 2.2.5 on 2019-10-28 08:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('user', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='user',
name='my_resume',
field... | normal | {
"blob_id": "32c28c7a1e1572744387b509fc6a448554ed565e",
"index": 3445,
"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 = [('user', '000... | [
0,
1,
2,
3,
4
] |
__author__ = 'Erwin'
class usuario:
def __init__(self, nombre, user, pasw, permiso, foto):
self.nombre = nombre
self.login = user
self.pasw = pasw
self.permiso = permiso
self.foto=foto
self.database=True
class medicamento:
def __init__(self, nombre , descripcion... | normal | {
"blob_id": "b46a14c821777873eb60df609d9f112c737a3635",
"index": 6255,
"step-1": "<mask token>\n\n\nclass animal:\n\n def __init__(self, nombre, descripcion, foto):\n self.nombre = nombre\n self.descripcion = descripcion\n self.foto = foto\n self.database = True\n\n def tipo(sel... | [
10,
11,
12,
15,
17
] |
#d
#b
#c
#b,c | normal | {
"blob_id": "8ecd1d6b43027153e05c771eb7183c062319eebc",
"index": 2716,
"step-1": "#d\n#b\n#c\n#b,c",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
1
]
} | [
1
] |
# 代码3-14 pandas累积统计特征函数、移动窗口统计函数示例
import pandas as pd
D = pd.Series(range(0, 20)) # 构造Series,内容为0~19共20个整数
print(D.cumsum()) # 给出前n项和
print(D.rolling(2).sum()) # 依次对相邻两项求和
| normal | {
"blob_id": "7639b80c9e6e1b2e1e55a47a862c433b64168cf6",
"index": 7475,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(D.cumsum())\nprint(D.rolling(2).sum())\n",
"step-3": "<mask token>\nD = pd.Series(range(0, 20))\nprint(D.cumsum())\nprint(D.rolling(2).sum())\n",
"step-4": "import pandas as pd\... | [
0,
1,
2,
3,
4
] |
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ... | normal | {
"blob_id": "a83230e71cc1bcc843d00487746f16114d304eec",
"index": 4908,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef mge_to_caffe(mge_fpath, prototxt='out.prototxt', caffemodel=\n 'out.caffemodel', outspec=None, use_empty_blobs=False):\n assert isinstance(mge_fpath, str), 'mge_fpath must b... | [
0,
1,
2,
3
] |
import os
import sys
import winreg
import zipfile
class RwpInstaller:
railworks_path = None
def extract(self, target):
with zipfile.ZipFile(target) as z:
if z.testzip():
return self.output('Corrupt file {}\n'.format(target))
self.output('{} file valid\n\n'.form... | normal | {
"blob_id": "9c751dece67ef33ba8e5cb8281f024d2143e0808",
"index": 8811,
"step-1": "<mask token>\n\n\nclass RwpInstaller:\n <mask token>\n\n def extract(self, target):\n with zipfile.ZipFile(target) as z:\n if z.testzip():\n return self.output('Corrupt file {}\\n'.format(targ... | [
4,
6,
7,
8
] |
from flask import Flask
from apis import api
app = Flask(__name__)
app.config.from_object('config')
api.init_app(app)
if __name__ == "__main__":
app.run() | normal | {
"blob_id": "f4ea36c3154f65c85647da19cfcd8a058c507fe1",
"index": 4992,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp.config.from_object('config')\napi.init_app(app)\nif __name__ == '__main__':\n app.run()\n",
"step-3": "<mask token>\napp = Flask(__name__)\napp.config.from_object('config')\napi.... | [
0,
1,
2,
3,
4
] |
import sgc
import multiprocessing as mp
# import json
import argparse
import os
import re
#Process argument passed to the script
parser = argparse.ArgumentParser(description='Execute commands parallel on remote servers')
parser.add_argument('-f', action='store', required=True, dest='file', help='servers list')
group... | normal | {
"blob_id": "ace7e5676fcb01c3542952eaacdada9963b8467a",
"index": 5168,
"step-1": "<mask token>\n\n\ndef worker(server, commands):\n output = {}\n output['server'] = server\n session = sgc.Ssh(server=server)\n if session.ping == 'Alive':\n session.connect()\n if session.connection == Fal... | [
1,
2,
3,
4,
5
] |
# Number Guessing Game
import random
#assign secrectNumber to random number from range 1-10, inclusive of 10
secrectNumber = random.randint (1, 11)
#initialize number or guesses to 1 and call it guess
numGuesses = 1
#prompt user to enter their name and enter their guess
name = int (input("Enter your name: ))
print(... | normal | {
"blob_id": "d2da346e11fa9508cab22a3a2fd3ca57a0a755e6",
"index": 5420,
"step-1": "# Number Guessing Game\nimport random\n#assign secrectNumber to random number from range 1-10, inclusive of 10\nsecrectNumber = random.randint (1, 11)\n#initialize number or guesses to 1 and call it guess\nnumGuesses = 1\n#prompt ... | [
0
] |
class Solution:
def calculate(self, s: str) ->int:
nums = []
ops = []
def cal():
a = nums.pop()
b = nums.pop()
c = ops.pop()
if c == '+':
nums.append(b + a)
elif c == '-':
nums.append(b - a)
... | normal | {
"blob_id": "0ff8743e54509a76e9a7add4be9da279bdee82a6",
"index": 5032,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def calculate(self, s: str) ->int:\n nums = []\n ops = []\n\n def cal():\n a = nums.pop()\n ... | [
0,
1,
2
] |
#tkinter:Label 、Button 、标签、按钮
#详见:
#1、os:https://blog.csdn.net/xxlovesht/article/details/80913193
#2、shutil:https://www.jb51.net/article/157891.htm
#3、tkinter:https://blog.csdn.net/mingshao104/article/details/79591965
# https://blog.csdn.net/sinat_41104353/article/details/79313424
# https:/... | normal | {
"blob_id": "6c0ca72d7f5d2373a50cd344991ad9f9e3046e8d",
"index": 4087,
"step-1": "<mask token>\n\n\ndef File_Open_EventC():\n FilePath = filedialog.askopenfilename(filetypes=(('C file', '*.c*'), (\n 'Text file', '*.txt*'), ('HTML files', '*.html;*.htm')))\n fp = open(FilePath, 'r')\n flag_1 = 0\n... | [
1,
2,
3,
4,
5
] |
def inplace_quick_sort(S, start, end):
if start > end:
return
pivot = S[end]
left = start
right = end - 1
while left <= right:
while left <= right and S[left] < pivot:
left += 1
while left <= right and pivot < S[right]:
right -= 1
if left <= ri... | normal | {
"blob_id": "2a09711e3e487c5d7790af592ff2eb03bb53cff2",
"index": 5068,
"step-1": "<mask token>\n",
"step-2": "def inplace_quick_sort(S, start, end):\n if start > end:\n return\n pivot = S[end]\n left = start\n right = end - 1\n while left <= right:\n while left <= right and S[left]... | [
0,
1,
2,
3
] |
from django.urls import path
from . import apiviews
from rest_framework.authtoken.views import obtain_auth_token
urlpatterns = [path('contacts', apiviews.ContactsView.as_view(), name=
'contacts'), path('contact/<int:pk>', apiviews.ContactView.as_view(),
name='contact'), path('signup', apiviews.create_user_with_... | normal | {
"blob_id": "5f56838ad0717c4f7a2da6b53f586a88b0166113",
"index": 8629,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('contacts', apiviews.ContactsView.as_view(), name=\n 'contacts'), path('contact/<int:pk>', apiviews.ContactView.as_view(),\n name='contact'), path('signup', apiv... | [
0,
1,
2
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.