code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def add_attribute(obj, name, value):
""" add an attribute to a class if possible"""
if hasattr(obj, '__dict__'):
setattr(obj, name, value)
else:
raise TypeError("can't add new attribute")
<|reserved... | flexible | {
"blob_id": "bee7f3acdb103f3c20b6149407854c83ad367a6b",
"index": 2621,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef add_attribute(obj, name, value):\n \"\"\" add an attribute to a class if possible\"\"\"\n if hasattr(obj, '__dict__'):\n setattr(obj, name, value)\n else:\n ... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def filter_long_words(word_lng, words_list):
return [word for word in words_list if len(word) > word_lng]
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def filter_long_words(word_lng, words_list):
return [word for word in words_list i... | flexible | {
"blob_id": "e221b840239b6e9af735238760fd1157f333c1a4",
"index": 9014,
"step-1": "<mask token>\n",
"step-2": "def filter_long_words(word_lng, words_list):\n return [word for word in words_list if len(word) > word_lng]\n\n\n<mask token>\n",
"step-3": "def filter_long_words(word_lng, words_list):\n retur... | [
0,
1,
2
] |
from flask import Flask
from threading import Timer
from crypto_crawler.const import BITCOIN_CRAWLING_PERIOD_SEC, COIN_MARKET_CAP_URL
from crypto_crawler.crawler import get_web_content, filter_invalid_records
app = Flask(__name__)
crawl_enabled = True
def crawl_bitcoin_price():
print("start crawling!")
bitc... | normal | {
"blob_id": "ebbc6f9115e6b4ca7d1050a59cf175d123b6f3aa",
"index": 4871,
"step-1": "<mask token>\n\n\ndef crawl_bitcoin_price():\n print('start crawling!')\n bitcoin_prices = get_web_content(COIN_MARKET_CAP_URL)\n bitcoin_prices = filter_invalid_records(bitcoin_prices)\n if crawl_enabled:\n Time... | [
3,
4,
5,
6,
8
] |
import sys
import cv2
import numpy as np
import matplotlib.pyplot as plt
from .caffe_path import caffe
from .timer import Timer
__all__ = ['Detector']
# VOC Class list
CLASSES = dict(
voc = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car',
'cat', 'chair', 'cow', 'diningtable', 'dog', 'h... | normal | {
"blob_id": "de12c6d78c0144978ffc651829364de16930b173",
"index": 2078,
"step-1": "<mask token>\n\n\nclass Detector(object):\n <mask token>\n\n def __init__(self, prototxt, caffemodel, gpu_id, dataset='coco', scale=\n 600, max_size=1000, transpose=(2, 0, 1), mean=[102.9801, 115.9465, \n 122.77... | [
6,
7,
8,
9,
10
] |
from django.contrib import admin
from .models import Wbs, Equipment_Type
class WbsAdmin(admin.ModelAdmin):
list_display = ('code','description','equipment_type')
list_filter = ('code','description','equipment_type')
readonly_fields = ('code','description')
class Equipment_TypeAdmin(admin.ModelAdmi... | normal | {
"blob_id": "292c66bd5b7f56ee8c27cabff01cd97ff36a79dc",
"index": 8885,
"step-1": "<mask token>\n\n\nclass WbsAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Equipment_TypeAdmin(admin.ModelAdmin):\n list_display = 'type',\n list_filter = 'type',\n\n\n<mask token>\n"... | [
3,
4,
5,
6,
7
] |
from typing import List
from fastapi import Depends, APIRouter
from sqlalchemy.orm import Session
from attendance.database import get_db
from attendance import schemas
from attendance.models import User
from attendance import crud
from attendance.dependency import get_current_user
router = APIRouter()
#BASE_SALARY
#... | normal | {
"blob_id": "f10e20d5c409930d697c36d1897ebcb648511e27",
"index": 3694,
"step-1": "<mask token>\n\n\n@router.get('/salary/{user_id}', status_code=200)\ndef read_base_salary(user_id: int, db: Session=Depends(get_db),\n current_user: User=Depends(get_current_user)):\n return crud.get_base_salarys(db, user_id=... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class announcement:
def __init__(eps_df, revenue_df):
conn = sqlite3.connect('earnings.db', timeout=120)
cur = conn.cursor()
symbol_href = self.driver.find_element_by_class_name('lfkTWp')
symbol = symbol_href.text
eps_history_df = pd.read_sql(
... | flexible | {
"blob_id": "b7738c27e11e9566d90157717633312031cdffd6",
"index": 818,
"step-1": "<mask token>\n\n\nclass announcement:\n\n def __init__(eps_df, revenue_df):\n conn = sqlite3.connect('earnings.db', timeout=120)\n cur = conn.cursor()\n symbol_href = self.driver.find_element_by_class_name('l... | [
6,
7,
8,
9,
11
] |
from ..lib import read_input, write_output
def link_bits(num: str = None, bit_i: str = '0', bit_j: str = '0', write: bool = True) -> int:
if num is None:
num, bit_i, bit_j = read_input()
num = int(num, 2)
num_len = num.bit_length()
mask = 2 ** num_len - 1
first_i = (num >> (num_len - int(b... | normal | {
"blob_id": "113572682ca83408b7c22e0e178f29945d741142",
"index": 6672,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef link_bits(num: str=None, bit_i: str='0', bit_j: str='0', write: bool=True\n ) ->int:\n if num is None:\n num, bit_i, bit_j = read_input()\n num = int(num, 2)\n ... | [
0,
1,
2,
3,
4
] |
from trapezoidal import trapezoidal
from midpoint import midpoint
from math import pi, sin
def integrate_sine(f, a, b, n = 2):
I_t = trapezoidal(f, a, b, n)
I_m = midpoint()
return None
a = 0.0; b = pi
f = lambda x: sin(x) | normal | {
"blob_id": "d99278c8f539322fd83ae5459c3121effc044b88",
"index": 5193,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef integrate_sine(f, a, b, n=2):\n I_t = trapezoidal(f, a, b, n)\n I_m = midpoint()\n return None\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef integrate_sine(f, ... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from twython import Twython
import random
tweetStr = "None"
#twitter consumer and access information goes here
api = Twython(apiKey,apiSecret,accessToken,accessTokenSecret)
timeline = api.get_user_timeline()
lastEntry = timeline[0]
sid = str(lastEntry['id']... | normal | {
"blob_id": "88e1eb4cbfe346c663cca23836c23346e18a8488",
"index": 7444,
"step-1": "\n#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\nfrom twython import Twython\nimport random\n\ntweetStr = \"None\"\n\n#twitter consumer and access information goes here\n\n\napi = Twython(apiKey,apiSecret,accessToken,a... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "2c4fe8015968b8a78c7b2ea33ac5e21e01c82e6e",
"index": 2818,
"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 = [('book', '000... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
from .exenv import *
| flexible | {
"blob_id": "9fea76b1612bd02f512072692090f8ef60e8a0fe",
"index": 1498,
"step-1": "<mask token>\n",
"step-2": "from .exenv import *\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
class Product(models.Model):
title = models.CharField(max_length=32)
description = models.TextField(max_length=360)
price = models.IntegerField()
image = models.CharField(max_length=255, null=True)
brand = models.ForeignKey(Brand, on_delete=models.CASCADE)
user = m... | flexible | {
"blob_id": "6de9fffd91d2f7602f7c681253211077704ba8c4",
"index": 2039,
"step-1": "<mask token>\n\n\nclass Product(models.Model):\n title = models.CharField(max_length=32)\n description = models.TextField(max_length=360)\n price = models.IntegerField()\n image = models.CharField(max_length=255, null=T... | [
6,
7,
9,
10,
12
] |
from dagster import job, op
@op
def do_something():
return "foo"
@job
def do_it_all():
do_something()
| normal | {
"blob_id": "53cf6e97c3b71b1063d5b6bce5aa444933b69809",
"index": 3229,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@job\ndef do_it_all():\n do_something()\n",
"step-3": "<mask token>\n\n\n@op\ndef do_something():\n return 'foo'\n\n\n@job\ndef do_it_all():\n do_something()\n",
"step-4"... | [
0,
1,
2,
3,
4
] |
import librosa
import librosa.display
import matplotlib.pyplot as plt
import os
import numpy as np
import time
import multiprocessing as mp
from tempfile import TemporaryFile
class DataSet():
def __init__(self,training_folder):
self.training_folder = training_folder
print("load Data")
def load... | normal | {
"blob_id": "ba09dbe3fbca51ece8a7d482324a2dec32e7dc8a",
"index": 5016,
"step-1": "<mask token>\n\n\nclass DataSet:\n\n def __init__(self, training_folder):\n self.training_folder = training_folder\n print('load Data')\n <mask token>\n\n def readFiles(self, queue, file_list, start, end):\n ... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class Scope(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def name(self):
return self.name
class SymbolTable(object):
def __init__(self, scope_name):
root_scope = Sco... | flexible | {
"blob_id": "6cc23e370d1ec1e3e043c3fa6819f9166b6e3b40",
"index": 4434,
"step-1": "<mask token>\n\n\nclass Scope(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def name(self):\n return self.name\n\n\nclass SymbolTable(object):\n\n def __init__(self, scope_name):\... | [
14,
17,
19,
22,
24
] |
import numpy as np
labels = np.load('DataVariationOther/w1_s500/targetTestNP.npy')
for lab in labels:
print(lab)
| normal | {
"blob_id": "a83988e936d9dee4838db61c8eb8ec108f5ecd3f",
"index": 4669,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor lab in labels:\n print(lab)\n",
"step-3": "<mask token>\nlabels = np.load('DataVariationOther/w1_s500/targetTestNP.npy')\nfor lab in labels:\n print(lab)\n",
"step-4": "impo... | [
0,
1,
2,
3
] |
import sys
import pandas as pd
from components.helpers.Logger import Logger
class DataFrameCreatorBase:
"""
DataFrameCreatorBase
"""
START_DATE = "03/16/2020"
def __init__(self, input_file):
self._input_file = input_file
self.df = self._read_raw_csv()
self._clean_df()
... | normal | {
"blob_id": "f4fa7563d2cce5ee28198d4974a4276d9f71f20b",
"index": 4329,
"step-1": "<mask token>\n\n\nclass DataFrameCreatorBase:\n <mask token>\n <mask token>\n\n def __init__(self, input_file):\n self._input_file = input_file\n self.df = self._read_raw_csv()\n self._clean_df()\n ... | [
4,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def create_app():
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
@app.route('/process_game', methods=['POST'])
def process_game():
move_sequence = json.loads... | flexible | {
"blob_id": "60ca8b1d7307a9d8183e3617f238efcfb9d707dd",
"index": 1950,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef create_app():\n app = Flask(__name__)\n\n @app.route('/')\n def hello_world():\n return 'Hello, World!'\n\n @app.route('/process_game', methods=['POST'])\n d... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
model.load(MODEL_NAME)
<|reserved_special_token_0|>
for num, data in enumerate(test_data[:12]):
img_num = data[1]
img_data = data[0]
y = fig.add_subplot(3, 4, num + 1)
orig = img_data
data = img_data.reshape(IM... | flexible | {
"blob_id": "02d7022c7d864354379009577d64109601190998",
"index": 7034,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmodel.load(MODEL_NAME)\n<mask token>\nfor num, data in enumerate(test_data[:12]):\n img_num = data[1]\n img_data = data[0]\n y = fig.add_subplot(3, 4, num + 1)\n orig = img_da... | [
0,
1,
2,
3,
4
] |
from sys import stdin
def get_time(d, sp, dists, i, d_old, sp_old):
if i == len(dists):
return 0
times = []
d_new = d[i]
sp_new = sp[i]
if d_new >= dists[i]:
res1 = get_time(d, sp, dists, i + 1, d_new - dists[i], sp_new)
if res1 is not None:
times.append(res1 + (... | normal | {
"blob_id": "3b99cc0eb163f4a94bc47429ad3627a6ecad4818",
"index": 2774,
"step-1": "from sys import stdin\n\ndef get_time(d, sp, dists, i, d_old, sp_old):\n if i == len(dists):\n return 0\n times = []\n d_new = d[i]\n sp_new = sp[i]\n if d_new >= dists[i]:\n res1 = get_time(d, sp, dist... | [
0
] |
tabela = [[1,-45,-20,0,0,0,0],[0,20,5,1,0,0,9500],[0,0.04,0.12,0,1,0,40],[0,1,1,0,0,1,551]]
colunas = ["Z","A","B","S1","S2","S3","Solução"]
linhas = ["Z","S1","S2","S3"]
n_colunas=7
n_linhas=4
#Inicio do algoritmo
#Buscar o menor numero negativo na linha 0
menor_posicao=-1
menor_valor=0
for coluna in rang... | normal | {
"blob_id": "785dcaf7de68174d84af3459cde02927bc2e10cc",
"index": 8951,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor coluna in range(0, n_colunas):\n if tabela[0][coluna] < menor_valor:\n menor_valor = tabela[0][coluna]\n menor_posicao = coluna\n<mask token>\nwhile menor_posicao != ... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
from io import StringIO
import sys
from contextlib import redirect_stdout
import pytest
# test input_name():
from mailroom3 import input_name
def test_1(monkeypatch): # tests "list"
monkeypatch.setattr('builtins.input', lambda x: "list")
f = StringIO()
with redirect_stdout(f):
... | normal | {
"blob_id": "286a47cece7002a88f34ace3e08d013e2d14801a",
"index": 2793,
"step-1": "<mask token>\n\n\ndef test_1(monkeypatch):\n monkeypatch.setattr('builtins.input', lambda x: 'list')\n f = StringIO()\n with redirect_stdout(f):\n input_name()\n testdata = f.getvalue()\n assert testdata == '\... | [
9,
11,
14,
17,
20
] |
# Enunciado: faça um programa que leia um ano qualquer e mostre se ele é BISEXTO.
ano = int(input('\nInforme o ano: '))
ano1 = ano % 4
ano2 = ano % 100
if ano1 == 0 and ano2 != 0:
print('\nO ano de {} é Bissexto !!'.format(ano))
else:
print('\nO ano de {} não foi Bissexto !!'.format(ano))
| normal | {
"blob_id": "daeb11000978d14a05ea62113dcf6e30d6a98b15",
"index": 3590,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif ano1 == 0 and ano2 != 0:\n print('\\nO ano de {} é Bissexto !!'.format(ano))\nelse:\n print('\\nO ano de {} não foi Bissexto !!'.format(ano))\n",
"step-3": "ano = int(input('\\... | [
0,
1,
2,
3
] |
s = 'Daum KaKao'
# s_split = s.split()
# s = s_split[1] + ' ' + s_split[0]
s = s[5:] + ' ' + s[:4]
print(s) | normal | {
"blob_id": "32c62bb8b6e4559bb7dfc67f4311bc8e71e549c9",
"index": 6942,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(s)\n",
"step-3": "s = 'Daum KaKao'\ns = s[5:] + ' ' + s[:4]\nprint(s)\n",
"step-4": "s = 'Daum KaKao'\n# s_split = s.split()\n# s = s_split[1] + ' ' + s_split[0]\ns = s[5:] + ' ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def lift_calculations(df):
df['sample_num'] = range(len(df))
df['actual_sum'] = df['actual'].cumsum()
df['per_sample_covered'] = (df['sample_num'] + 1) * 100 / len(df)
df['per_pos_captured'] = df['actual_sum'] / len(df[df['actual'] == 1]
) * 100
df['prop_pos_ca... | flexible | {
"blob_id": "8e71ea23d04199e8fb54099c404c5a4e9af6c4b1",
"index": 9336,
"step-1": "<mask token>\n\n\ndef lift_calculations(df):\n df['sample_num'] = range(len(df))\n df['actual_sum'] = df['actual'].cumsum()\n df['per_sample_covered'] = (df['sample_num'] + 1) * 100 / len(df)\n df['per_pos_captured'] = ... | [
5,
7,
8,
10,
11
] |
<|reserved_special_token_0|>
class MySubClass(MyClass):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class MyClass2:
stuff = 123
def __init_subclass__(cls):
super().__init_subclass__()
print(f'* Running {cls.__name__}.__init_subclass__')
... | flexible | {
"blob_id": "8f3abc5beaded94b6d7b93ac2cfcd12145d75fe8",
"index": 522,
"step-1": "<mask token>\n\n\nclass MySubClass(MyClass):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass MyClass2:\n stuff = 123\n\n def __init_subclass__(cls):\n super().__init_subclass__()\n print(f'* Runn... | [
8,
12,
14,
15,
17
] |
t = int(input())
while t:
x = list(map(int, input().split()))
x.sort()
if(x[0]+x[1]==x[2]):
print("YES")
else:
print("NO")
t-=1 | normal | {
"blob_id": "d1200006b8d7a18b11b01eff4fbf38d9dfd8958e",
"index": 5758,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile t:\n x = list(map(int, input().split()))\n x.sort()\n if x[0] + x[1] == x[2]:\n print('YES')\n else:\n print('NO')\n t -= 1\n",
"step-3": "t = int(inp... | [
0,
1,
2,
3
] |
import mock
def exc():
print 'here should raise'
def recursion():
try:
print 'here'
return exc()
except StandardError:
print 'exc'
return recursion()
def test_recursion():
global exc
exc = mock.Mock(side_effect = [StandardError, StandardError, mock.DEFAULT])
r... | normal | {
"blob_id": "5ef7c838d8e9a05a09bd974790a85ff36d56a336",
"index": 990,
"step-1": "import mock\n\ndef exc():\n print 'here should raise'\n\ndef recursion():\n try:\n print 'here'\n return exc()\n except StandardError:\n print 'exc'\n return recursion()\n\n\ndef test_recursion()... | [
0
] |
from rllab.envs.base import Env
from rllab.spaces import Discrete
from rllab.spaces import Box
from rllab.envs.base import Step
import numpy as np
import sys, pickle, os
sys.path.append(os.path.dirname(os.getcwd()))
from os.path import dirname
sys.path.append(dirname(dirname(dirname(os.getcwd()))))
from simulation impo... | normal | {
"blob_id": "21974274b1e7800b83eb9582ab21714f04230549",
"index": 4299,
"step-1": "<mask token>\n\n\nclass PinEnvDiscrete(Env):\n <mask token>\n\n def __init__(self, simulation, x, y, trajectory, scorer=0,\n max_displacement=False, predict=False, original=False, sample=False):\n self.simulatio... | [
8,
9,
10,
12,
13
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [url('^login/$', login_page, name='login'), url('^logout/$',
logout_page, name='logout'), url('^register/$', register_page, name=
'register'), url('^product/$', product_list_view, name='product'), url(
'^... | flexible | {
"blob_id": "0de735647cf87f64ab64af081da6e11b0ed8a7a7",
"index": 1173,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('^login/$', login_page, name='login'), url('^logout/$',\n logout_page, name='logout'), url('^register/$', register_page, name=\n 'register'), url('^product/$', pr... | [
0,
1,
2,
3
] |
from django import forms
from basic_app_new.models import *
class UpdateFood(forms.ModelForm):
class Meta:
model = Old_Food_Diary
fields = ['mfg_code', 'food_name', 'description', 'food_type',
'calories', 'fats', 'protein', 'carbohydrates', 'link_of_image',
'link_of_recip... | normal | {
"blob_id": "3a1b0b9891fec7b3d722f77cd2f3f6efa878a7a0",
"index": 4255,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass UpdatePurchaseFood(forms.ModelForm):\n\n\n class Meta:\n model = purchase_cards\n fields = ['food_name', 'description', 'ss_code', 'calorie', 'fat',\n ... | [
0,
1,
2,
3
] |
from five import grok
from zope.formlib import form
from zope import schema
from zope.interface import implements
from zope.component import getMultiAdapter
from plone.app.portlets.portlets import base
from plone.memoize.instance import memoize
from plone.portlets.interfaces import IPortletDataProvider
from Products.Fi... | normal | {
"blob_id": "214585956e44ce006db0702fd23692b11459f9e1",
"index": 7664,
"step-1": "<mask token>\n\n\nclass Renderer(base.Renderer):\n render = ViewPageTemplateFile('twitterportlet.pt')\n\n def __init__(self, context, request, view, manager, data):\n self.context = context\n self.request = requ... | [
9,
10,
13,
15,
16
] |
from datetime import date
from django.conf import settings
from django.utils.decorators import decorator_from_middleware_with_args
from django.views.decorators.cache import cache_page
from django.middleware.cache import CacheMiddleware
lt_cache = cache_page(settings.CACHES['eregs_longterm_cache']['TIMEOUT'],
cache=... | normal | {
"blob_id": "5b440484c5d7f066c54837c2812967a0ff360399",
"index": 9905,
"step-1": "<mask token>\n\n\nclass DailyCacheMiddleware(CacheMiddleware):\n <mask token>\n\n @property\n def key_prefix(self):\n return date.today().isoformat() + '/' + (self.__key_prefix or '')\n\n @key_prefix.setter\n ... | [
3,
4,
5,
6
] |
from flask import Flask, render_template, request, url_for, redirect,jsonify,json,request
from pymongo import MongoClient
#conexão bd
app = Flask(__name__)
conexao = MongoClient('localhost',27017)
db = conexao['teste_db']
#inserindo contatos iniciais
contato1 = {'nome': 'Lucas', 'email': 'lucas@gmail.com', 'telefone... | normal | {
"blob_id": "05ca16303d0eb962249793164ac91795c45cc3c2",
"index": 9974,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef showMachineList():\n return render_template('list.html')\n\n\n@app.route('/insert_records', methods=['POST'])\ndef insert_records():\n json_data = request.json['info']\n nome = json_d... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class TestMotionPrimitive(unittest.TestCase):
<|reserved_special_token_0|>
def testItems(self):
m = IECoreScene.MotionPrimitive()
m[0] = IECoreScene.PointsPrimitive(1)
m[1] = IECoreScene.PointsPrimitive(2)
self.assertEqual(m.items(), [(0, IECoreSce... | flexible | {
"blob_id": "d4c297af395581c6d955eb31a842ab86e599d23c",
"index": 4576,
"step-1": "<mask token>\n\n\nclass TestMotionPrimitive(unittest.TestCase):\n <mask token>\n\n def testItems(self):\n m = IECoreScene.MotionPrimitive()\n m[0] = IECoreScene.PointsPrimitive(1)\n m[1] = IECoreScene.Poi... | [
4,
5,
6,
7,
8
] |
'''
Sample Input
1
5
1 2 3 2 1
Sample Output
3
'''
for _ in range(int(input())):
noe = int(input())
arr = [int(x) for x in input().split()]
left = arr[0]
rite = sum(arr) - left
mins = abs(rite - left)
for i in range(1, noe-1):
left += arr[i]
rite -= arr[i]
print(left, rit... | normal | {
"blob_id": "825f3b930fee319314d520a32c2f9dcd718505ab",
"index": 2424,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(int(input())):\n noe = int(input())\n arr = [int(x) for x in input().split()]\n left = arr[0]\n rite = sum(arr) - left\n mins = abs(rite - left)\n for i i... | [
0,
1,
2
] |
#!/usr/bin/python
import os
import sys
fdatadir = "/fdata/hepx/store/user/taohuang/NANOAOD/"
datasets = []; NumSample = []; sampleN_short = []
Nanodatasets = []; localdirs = {}
MCxsections = []
#doTT=True; doDY=True; doVV=True; doSingleT=True; doWjets=True; dottV=True
##DoubleEG
datasets.append('/DoubleEG/Run2016B-0... | normal | {
"blob_id": "72b5e76f63e347d7275b0b711fa02b7f327785f6",
"index": 7369,
"step-1": "#!/usr/bin/python\nimport os\nimport sys\n\nfdatadir = \"/fdata/hepx/store/user/taohuang/NANOAOD/\"\ndatasets = []; NumSample = []; sampleN_short = []\nNanodatasets = []; localdirs = {}\nMCxsections = []\n#doTT=True; doDY=True; do... | [
0
] |
'''
Author: Allen Chen
This is an example of entry point to CORE. Pay close attention to the import syntax - they're relative to this repo.
Don't try to run this by doing 'python3 main.py' under this directory. Try to add your Target in Makefile under the root dir,
and call './run YOUR_TARGET_NAME' from root.
'''
fr... | normal | {
"blob_id": "18eed41cbc419ecbb215f77235be99f15f86ea9a",
"index": 7468,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlog_info(f'Just initialized a bot named {bot.name}')\nlog_ok(f'Bot is given cash: {bot.cash}')\nlog_error('Nothing else to do ! :(')\n",
"step-3": "<mask token>\nbot = TradeBot()\nlog_i... | [
0,
1,
2,
3,
4
] |
#pymongo and mongo DB search is like by line inside in a document then it moves to the other document
from enum import unique
import pymongo
from pymongo import MongoClient
MyClient = MongoClient() # again this is connecting to deault host and port
db = MyClient.mydatabase #db is a variable to store the database ... | normal | {
"blob_id": "31f302775ef19a07137622ef9d33495cc2a8eed2",
"index": 5775,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndb.users.create_index([('names', pymongo.ASCENDING)])\n",
"step-3": "<mask token>\nMyClient = MongoClient()\ndb = MyClient.mydatabase\nusers = db.users\ndb.users.create_index([('names',... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def count_days(start_date, end_date, ref_date, target_day):
month = start_date[0]
day = start_date[1]
year = start_date[2]
end_month = end_date[0]
end_day = end_date[1]
end_year = end_date[2]
ref_year = ref_date[2]
ref_day_of_week = ref_date[3]
if (ref_... | flexible | {
"blob_id": "9843f957435b74e63a6fe4827cc17c824f11c7d6",
"index": 5372,
"step-1": "<mask token>\n\n\ndef count_days(start_date, end_date, ref_date, target_day):\n month = start_date[0]\n day = start_date[1]\n year = start_date[2]\n end_month = end_date[0]\n end_day = end_date[1]\n end_year = end... | [
1,
2,
3,
4,
5
] |
#the method of same name present in any class, it is call by anywhere
#object of different type is responds to same methods
class pycharm:
def execute(self):
print("COde check")
print("compile")
class MyEditor:
def execute(self):
print("Spell Cheack")
print("Auto COmpile")
... | normal | {
"blob_id": "3ec162070f79ae38d6ae3ceb858c15b6e39f7027",
"index": 9870,
"step-1": "<mask token>\n\n\nclass MyEditor:\n\n def execute(self):\n print('Spell Cheack')\n print('Auto COmpile')\n print('COde check')\n print('compile')\n\n\nclass laptop:\n\n def code(self, ide):\n ... | [
4,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
a.append('sarika')
print(a[2])
print(a)
<|reserved_special_token_1|>
a = ['somesh', 'aakash', 'sarika', 'datta', 'rudra', '4mridula']
a[2] = 'nandini'
a.append('sarika')
print(a[2])
print(a)
<|reserved_special_token_1|>
#lis... | flexible | {
"blob_id": "5c643dfce9cf7a9f774957ff4819d3be8ac4f1da",
"index": 7376,
"step-1": "<mask token>\n",
"step-2": "<mask token>\na.append('sarika')\nprint(a[2])\nprint(a)\n",
"step-3": "a = ['somesh', 'aakash', 'sarika', 'datta', 'rudra', '4mridula']\na[2] = 'nandini'\na.append('sarika')\nprint(a[2])\nprint(a)\n"... | [
0,
1,
2,
3
] |
#! /usr/bin python3
# -*- coding: utf-8 -*-
from scrapy import Request
from scrapy.linkextractors.lxmlhtml import LxmlLinkExtractor
from scrapy.spiders import CrawlSpider
from scrapy.spiders import Rule
from xici_bbs.spiders.author import get_author_item
from xici_bbs.spiders.comment import get_comment_list, get_comme... | normal | {
"blob_id": "f1eaba91e27dc063f3decd7b6a4fe4e40f7ed721",
"index": 7948,
"step-1": "<mask token>\n\n\nclass XiciSpider(CrawlSpider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def parse_author(self, response):\n author_item = get_author... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in sys.stdin:
i = float(i)
key = math.floor(i * 10)
print('%s\t%s' % (key, i))
<|reserved_special_token_1|>
import os
import sys
import csv
import math
for i in sys.stdin:
i = float(i)
key = math.floor... | flexible | {
"blob_id": "ba2f8598ec7e107ac71786cf9191777a93ae2c7a",
"index": 2145,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in sys.stdin:\n i = float(i)\n key = math.floor(i * 10)\n print('%s\\t%s' % (key, i))\n",
"step-3": "import os\nimport sys\nimport csv\nimport math\nfor i in sys.stdin:\n... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class LineBreaker(EmailInterpreter):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class LineBreaker(EmailInterpreter):
def split_file(self, file_name):
with open(os... | flexible | {
"blob_id": "1c6077d965f5bc8c03344b53d11851f5cd50bca8",
"index": 3346,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass LineBreaker(EmailInterpreter):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass LineBreaker(EmailInterpreter):\n\n def split_file(self, file_name):\n with op... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class MaskedGlobalAveragePooling1D(GlobalAveragePooling1D):
def __init__(self, **kwargs):
super(MaskedGlobalAveragePooling1D, self).__init__(**kwargs)
self.supports_masking = True
class MaskableFlatten(Flatten):
def __init__(self, **kwargs):
super(Maska... | flexible | {
"blob_id": "0b125e7e9e763d4fd71e381ca823f9e9aa8ea606",
"index": 8198,
"step-1": "<mask token>\n\n\nclass MaskedGlobalAveragePooling1D(GlobalAveragePooling1D):\n\n def __init__(self, **kwargs):\n super(MaskedGlobalAveragePooling1D, self).__init__(**kwargs)\n self.supports_masking = True\n\n\ncla... | [
7,
11,
13,
14,
15
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
DEBUG = True
ADMINS = frozenset(['briandowe@gmail.com'])
<|reserved_special_token_1|>
DEBUG = True
ADMINS = frozenset(["briandowe@gmail.com"]) | flexible | {
"blob_id": "68bade5767d4f418bcae07485a179df5e47e652c",
"index": 9066,
"step-1": "<mask token>\n",
"step-2": "DEBUG = True\nADMINS = frozenset(['briandowe@gmail.com'])\n",
"step-3": "DEBUG = True\nADMINS = frozenset([\"briandowe@gmail.com\"])",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1... | [
0,
1,
2
] |
'''
Binary_to_C
Converts any binary data to an array of 'char' type to be used inside of a C program.
The reason to want to do that, is to emulate a 'Windows Resource System' on Linux.
Linux does not allow inclusion of binary data in application (I am OK with that, I like that actually).
Windows, however, does. On... | normal | {
"blob_id": "c9f29a92ec8627593b54f7d9569dcfd589fa7fff",
"index": 5811,
"step-1": "'''\nBinary_to_C\n\tConverts any binary data to an array of 'char' type to be used inside of a C program.\n\tThe reason to want to do that, is to emulate a 'Windows Resource System' on Linux.\n\tLinux does not allow inclusion of bi... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
__all__ = ['Config', 'Environment']
<|reserved_special_token_1|>
from wasserstoff.wasserstoff import Config, Environment
__all__ = ['Config', 'Environment']
| flexible | {
"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
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(file.read())
print(file.closed)
file.close()
print(file.closed)
<|reserved_special_token_1|>
file = open('../_datasets/moby_dick.txt', mode='r')
print(file.read())
print(file.closed)
file.close()
print(file.closed)
| flexible | {
"blob_id": "dfe0ee5bbb906e5a23adcf06d2d704700fa1567d",
"index": 1179,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(file.read())\nprint(file.closed)\nfile.close()\nprint(file.closed)\n",
"step-3": "file = open('../_datasets/moby_dick.txt', mode='r')\nprint(file.read())\nprint(file.closed)\nfile... | [
0,
1,
2
] |
import logging
import numpy as np
from deprecated import deprecated
from pycqed.measurement.randomized_benchmarking.clifford_group import clifford_lookuptable
from pycqed.measurement.randomized_benchmarking.clifford_decompositions import gate_decomposition
from pycqed.measurement.randomized_benchmarking.two_qubit_clif... | normal | {
"blob_id": "038b8206f77b325bf43fc753f6cee8b4278f4bc9",
"index": 785,
"step-1": "<mask token>\n\n\ndef calculate_recovery_clifford(cl_in, desired_cl=0):\n \"\"\"\n Extracts the clifford that has to be applied to cl_in to make the net\n operation correspond to desired_cl from the clifford lookuptable.\n\... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
# -*- coding:utf-8 -*-
"""
Author:xufei
Date:2021/1/21
"""
| flexible | {
"blob_id": "d39e3a552a7c558d3f5b410e0b228fb7409d732a",
"index": 928,
"step-1": "<mask token>\n",
"step-2": "# -*- coding:utf-8 -*-\n\"\"\"\nAuthor:xufei\nDate:2021/1/21\n\"\"\"\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
numpy.random.seed(42)
<|reserved_special_token_0|>
file_json.close()
<|reserved_special_token_0|>
model.load_weights('weights.h5')
print('Model loaded')
<|reserved_special_token_0|>
model.compile(loss='categorical_crossentropy', o... | flexible | {
"blob_id": "05021c3b39a0df07ca3d7d1c3ff9d47be6723131",
"index": 4084,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnumpy.random.seed(42)\n<mask token>\nfile_json.close()\n<mask token>\nmodel.load_weights('weights.h5')\nprint('Model loaded')\n<mask token>\nmodel.compile(loss='categorical_crossentropy',... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(c)
print(d)
<|reserved_special_token_1|>
a = 10
b = 20
c = a + b
d = b - a
print(c)
print(d)
| flexible | {
"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
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def is_inside(polygon, point):
return True or False
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def is_inside(polygon, point):
return True or False
if __name__ == '__main__':
assert is_inside(((1, 1), (1, 3), (3, 3), (3, 1)), ... | flexible | {
"blob_id": "548c4dbfc1456fead75c22927ae7c6224fafeace",
"index": 7893,
"step-1": "<mask token>\n",
"step-2": "def is_inside(polygon, point):\n return True or False\n\n\n<mask token>\n",
"step-3": "def is_inside(polygon, point):\n return True or False\n\n\nif __name__ == '__main__':\n assert is_insid... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
model.compile(optimizer='sgd', loss='mean_squared_error')
<|reserved_special_token_0|>
model.fit(xs, ys, epochs=500)
<|reserved_special_token_0|>
print(model.predict(dataIn, 1, 1))
<|reserved_special_token_1|>
<|reserved_specia... | flexible | {
"blob_id": "c8fecb6bfbd39e7a82294c9e0f9e5eaf659b7fed",
"index": 1610,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmodel.compile(optimizer='sgd', loss='mean_squared_error')\n<mask token>\nmodel.fit(xs, ys, epochs=500)\n<mask token>\nprint(model.predict(dataIn, 1, 1))\n",
"step-3": "<mask token>\nmod... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class TDPWDataset(object):
def __init__(self, path, center_2d=False, load_metrics=None, skel_norm=
False):
super(TDPWDataset, self).__init__()
self.cameras = None
self._data_train = {'2d': np.zeros((0, 14, 2), dtype=np.float32),
'3d': np.ze... | flexible | {
"blob_id": "cf6dffb28e37003212d3e3402dee58a57a7d9869",
"index": 5192,
"step-1": "<mask token>\n\n\nclass TDPWDataset(object):\n\n def __init__(self, path, center_2d=False, load_metrics=None, skel_norm=\n False):\n super(TDPWDataset, self).__init__()\n self.cameras = None\n self._d... | [
5,
8,
10,
11,
15
] |
<|reserved_special_token_0|>
def evaluate(model, val_loader, nms_thresh, device):
model.eval()
stats = data_helper.AverageMeter('fscore', 'diversity')
json_file = []
with torch.no_grad():
for test_key, seq, gt, cps, n_frames, nfps, picks, user_summary, name in val_loader:
seq_len =... | flexible | {
"blob_id": "dd3419f42a3b1aafd1d4f5d88189fb3c6bd0c67e",
"index": 4233,
"step-1": "<mask token>\n\n\ndef evaluate(model, val_loader, nms_thresh, device):\n model.eval()\n stats = data_helper.AverageMeter('fscore', 'diversity')\n json_file = []\n with torch.no_grad():\n for test_key, seq, gt, cp... | [
4,
5,
7,
8,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@auth_blueprint.route('/Login', methods=['POST'])
@meross_http_api(login_required=False)
def login(api_payload: Dict, *args, **kwargs):
email = api_payload.get('email')
password = api_payload.get('password')
if email... | flexible | {
"blob_id": "afccd33e4c6bc5b7907a6af4ab698489fc9ea70d",
"index": 5299,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@auth_blueprint.route('/Login', methods=['POST'])\n@meross_http_api(login_required=False)\ndef login(api_payload: Dict, *args, **kwargs):\n email = api_payload.get('email')\n pa... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
net.load()
<|reserved_special_token_0|>
plt.plot(x, y)
<|reserved_special_token_0|>
for ii in range(1001):
c = net.retarded_training(x, y)
print(ii, c)
net.save()
<|reserved_special_token_0|>
plt.plot(X, Y, 'ro')
<|res... | flexible | {
"blob_id": "cf07344808f2d91d8949cfc4beb9f923926e6851",
"index": 6208,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnet.load()\n<mask token>\nplt.plot(x, y)\n<mask token>\nfor ii in range(1001):\n c = net.retarded_training(x, y)\n print(ii, c)\n net.save()\n<mask token>\nplt.plot(X, Y, 'ro')\n... | [
0,
1,
2,
3,
4
] |
from flask import Flask
from flask_mongoengine import MongoEngine
db = MongoEngine()
def create_app(**config_overrides):
app = Flask(__name__)
app.config.from_pyfile('settings.py')
app.config.update(config_overrides)
db.init_app(app)
from user.views import user_app
app.register_blueprint(user_... | normal | {
"blob_id": "8b7fb0789d197e50d7bdde2791b6fac964782469",
"index": 4001,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef create_app(**config_overrides):\n app = Flask(__name__)\n app.config.from_pyfile('settings.py')\n app.config.update(config_overrides)\n db.init_app(app)\n from user... | [
0,
1,
2,
3
] |
import random
import numpy as np
import os
import torch
class Agent:
def __init__(self):
self.model = torch.load(__file__[:-8] + "/agent.pkl")
def act(self, state):
state = torch.tensor(state)
with torch.no_grad():
return self.model(state.unsqueeze(0)).max(1)[1].it... | normal | {
"blob_id": "50a4084dd3028acc2e6788e77794c100efcb3fac",
"index": 132,
"step-1": "<mask token>\n\n\nclass Agent:\n\n def __init__(self):\n self.model = torch.load(__file__[:-8] + '/agent.pkl')\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Agent:\n\n def __init__(self):\... | [
2,
3,
4,
5,
6
] |
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
__author__ = 'alexglenday'
def group(list_df: list, df_col_index: int=0, seaborn_context: str='poster'):
sns.set_context(seaborn_context)
df_labels = []
for df in list_df:
df_labels.append(df.columns[df_col_index])
df_al... | normal | {
"blob_id": "d2632461fcdc39509610b96d43dd1ec42dae362f",
"index": 5229,
"step-1": "<mask token>\n\n\ndef individual(list_df: list, seaborn_context: str='poster'):\n sns.set_context(seaborn_context)\n for df in list_df:\n df.plot()\n",
"step-2": "<mask token>\n\n\ndef group(list_df: list, df_col_ind... | [
1,
2,
3,
4
] |
import PyInstaller.__main__
import os
import shutil
# Paths
basePath = os.path.realpath(os.path.join(os.path.dirname(__file__), os.path.pardir))
srcPath = os.path.join(basePath, 'src')
outPath = os.path.join(basePath, 'out')
workPath = os.path.join(outPath, 'work')
# Bundle
PyInstaller.__main__.run([
'--clean',
... | normal | {
"blob_id": "16a95573c4fccc10bdc5e37b307d0c85714b328c",
"index": 3548,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nPyInstaller.__main__.run(['--clean', '--onefile', '--workpath', workPath,\n '--distpath', outPath, '--hidden-import', 'win32timezone', os.path.join\n (srcPath, 'service.py'), os.pat... | [
0,
1,
2,
3,
4
] |
def divisible_by(numbers, divisor):
res = []
for e in numbers:
if e % divisor == 0:
res.append(e)
return res
| normal | {
"blob_id": "d7ff5bf5d8f397500fcac30b73f469316c908f15",
"index": 5042,
"step-1": "<mask token>\n",
"step-2": "def divisible_by(numbers, divisor):\n res = []\n for e in numbers:\n if e % divisor == 0:\n res.append(e)\n return res\n",
"step-3": null,
"step-4": null,
"step-5": nul... | [
0,
1
] |
import collections
import datetime
import os
import pickle
import random
import time
from lastfm_utils import PlainRNNDataHandler
from test_util import Tester
reddit = "subreddit"
lastfm = "lastfm"
instacart = "instacart"
#
# Choose dataset here
#
dataset = lastfm
#
# Specify the correct path to the dataset
#
datase... | normal | {
"blob_id": "9e8ddf6c35ebad329e1f5a48513e4bfaae0d9a6f",
"index": 4925,
"step-1": "<mask token>\n\n\ndef log_config(baseline):\n message = (\n '------------------------------------------------------------------------'\n )\n message += '\\nDATASET: ' + dataset\n message += '\\nBASELINE: ' + ... | [
4,
6,
7,
8,
9
] |
import os
import shutil
import configparser
beatmap_dir = os.path.abspath(os.environ['LOCALAPPDATA']+'\\osu!\\Songs\\')
beatmaps = []
bm_osu = []
with os.scandir(os.path.abspath(beatmap_dir)) as it:
for entry in it:
if entry.is_dir():
try:
beatmap_id = int(str(entry.name).split... | normal | {
"blob_id": "cd34f9ef100ae6d116f02258d22c114ec3f3e3e6",
"index": 1581,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith os.scandir(os.path.abspath(beatmap_dir)) as it:\n for entry in it:\n if entry.is_dir():\n try:\n beatmap_id = int(str(entry.name).split(' ')[0])\n... | [
0,
1,
2,
3,
4
] |
import os
def log(text, level=2, outFile='log.txt'):
text = str(text)
if level == 0:
return True
if level == 3:
with open(outFile, 'a') as logger:
logger.write(text)
logger.close()
print(text)
return True
if level == 2:
print(text)
if... | normal | {
"blob_id": "015b06d7f08f9de60a46d8428820333621732c53",
"index": 6425,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef log(text, level=2, outFile='log.txt'):\n text = str(text)\n if level == 0:\n return True\n if level == 3:\n with open(outFile, 'a') as logger:\n ... | [
0,
1,
2,
3
] |
from numpy import *
from numpy.linalg import*
preco = array(eval(input("Alimentos: ")))
alimento = array([[ 2, 1 ,4 ],
[1 , 2 , 0],
[2 , 3 , 2 ]])
r = dot(inv(alimento),preco.T) #
print("estafilococo: ", round(r[0] , 1))
print("salmonela: ", round(r[1], 1))
print("coli: ", round(r[2], 1))
if r[0] ... | normal | {
"blob_id": "0f3e12f35cc29a71be5b8e6d367908e31c200c38",
"index": 3896,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('estafilococo: ', round(r[0], 1))\nprint('salmonela: ', round(r[1], 1))\nprint('coli: ', round(r[2], 1))\nif r[0] == min(r):\n print('estafilococo')\nelif r[1] == min(r):\n pr... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class TestCase(TransactionCase):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class TestCase(TransactionCase):
def setUp(self):
super(TestCase, self).setUp()
... | flexible | {
"blob_id": "29ec576d1fe04108eeb03a5d1b167671d3004570",
"index": 4403,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TestCase(TransactionCase):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TestCase(TransactionCase):\n\n def setUp(self):\n super(TestCase, self).setUp()\n... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
@login_required
def Lojanisima(request):
return render(request, 'lojanisima/ruta_lojanisima.html')
@login_required
def Identiarte(request):
return render(request, 'identiarte/ruta_identiarte.html')
@login_required
def Raices(request):
return render(request, 'raice/ruta_rai... | flexible | {
"blob_id": "08712e050bd90408ed9d22bba9f62fafacd64d99",
"index": 9671,
"step-1": "<mask token>\n\n\n@login_required\ndef Lojanisima(request):\n return render(request, 'lojanisima/ruta_lojanisima.html')\n\n\n@login_required\ndef Identiarte(request):\n return render(request, 'identiarte/ruta_identiarte.html'... | [
3,
4,
5,
6,
7
] |
from django.test import TestCase
# Create your tests here.
def Add_course(self,user):
| normal | {
"blob_id": "7fc239e7f44c5f6a8e5bebe3e4910aee4d8e4af3",
"index": 9266,
"step-1": "from django.test import TestCase\n\n# Create your tests here.\n\ndef Add_course(self,user):\n\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
<|reserved_special_token_0|>
class exchange(ctypes.Structure):
<|reserved_special_token_0|>
class TestSturcture(ctypes.Structure):
_fields_ = [('a', ctypes.c_int), ('n', ctypes.c_int)]
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class stock(ctypes.Structure)... | flexible | {
"blob_id": "7491a17256b9bc7af0953202e45f0fd9d5c34c40",
"index": 8376,
"step-1": "<mask token>\n\n\nclass exchange(ctypes.Structure):\n <mask token>\n\n\nclass TestSturcture(ctypes.Structure):\n _fields_ = [('a', ctypes.c_int), ('n', ctypes.c_int)]\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass... | [
3,
5,
6,
8,
12
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
spark = SparkSession.builder.appName('StructedSocketWordCount').master(
'local[4]').getOrCreate()
sc = spark.sparkContext
sc.setLogLevel('WARN')
lines = spark.readStream.format('s... | flexible | {
"blob_id": "991260c268d53fbe73e9bff9990ac536ed802d7a",
"index": 6887,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n spark = SparkSession.builder.appName('StructedSocketWordCount').master(\n 'local[4]').getOrCreate()\n sc = spark.sparkContext\n sc.setLogLevel... | [
0,
1,
2,
3
] |
from azureml.core import Workspace
from azureml.pipeline.core import Pipeline
from azureml.core import Experiment
from azureml.pipeline.steps import PythonScriptStep
import requests
ws = Workspace.from_config()
# Step to run a Python script
step1 = PythonScriptStep(
name = "prepare data",
source_di... | normal | {
"blob_id": "4a7f8221208e8252c7f5c0adff2949f0e552def1",
"index": 775,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(rest_endpoint)\n<mask token>\nprint(run_id)\n",
"step-3": "<mask token>\nws = Workspace.from_config()\nstep1 = PythonScriptStep(name='prepare data', source_directory='scripts',\n ... | [
0,
1,
2,
3,
4
] |
import deform
import deform.widget
from deform import (widget) # decorator, default_renderer, field, form,
import colander
# import htmllaundry
# from htmllaundry import sanitize
from validators import (cyber_validator,
phone_validator,
stor_validator,
... | normal | {
"blob_id": "3a3400426b054b2fc3d060141a1f84e5db553e59",
"index": 3424,
"step-1": "<mask token>\n\n\n@colander.deferred\ndef deferred_country_widget(node, kw):\n country_codes_data = kw.get('country_codes_data', [])\n return widget.Select2Widget(values=country_codes_data)\n\n\n<mask token>\n\n\n@colander.de... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def product_sum_helper(array, depth):
sum = 0
for ele in array:
if type(ele) is int:
sum += ele
else:
sum += product_sum_helper(ele, depth + 1)
return depth * sum
<|reserved_... | flexible | {
"blob_id": "87e5a615157db59d1eac4967c321829c878d00a5",
"index": 2234,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef product_sum_helper(array, depth):\n sum = 0\n for ele in array:\n if type(ele) is int:\n sum += ele\n else:\n sum += product_sum_helper(e... | [
0,
1,
2,
3
] |
def decimal_to_binary(num):
if num == 0: return '0'
binary = ''
while num != 0:
binary = str(num % 2) + binary
num = num // 2
return binary
def modulo(numerator, exp, denominator):
binary = decimal_to_binary(exp)
prev_result = numerator
result = 1
for i in range(len(bi... | normal | {
"blob_id": "4e202cf7d7da865498ef5f65efdf5851c62082ff",
"index": 6764,
"step-1": "<mask token>\n",
"step-2": "def decimal_to_binary(num):\n if num == 0:\n return '0'\n binary = ''\n while num != 0:\n binary = str(num % 2) + binary\n num = num // 2\n return binary\n\n\n<mask tok... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class BannerHandler(BaseHandler):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
@expose('/banner/action.html', methods=('POST',))
... | flexible | {
"blob_id": "d80cb5ea57faa0f9e3a8dd5d40c9852c2f7f83e4",
"index": 4586,
"step-1": "<mask token>\n\n\nclass BannerHandler(BaseHandler):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @expose('/banner/action.html', methods=('POST',))\n @login_re... | [
6,
8,
9,
13,
16
] |
# -*- coding: utf-8 -*-
"""
Neverland2 Colorscheme
~~~~~~~~~~~~~~~~~~~~~~
Converted by Vim Colorscheme Converter
"""
from pygments.style import Style
from pygments.token import Token, Keyword, Comment, Number, Generic, Operator, Name, String
class Neverland2Style(Style):
background_color = '#121212'
... | normal | {
"blob_id": "9dccc19abb6dac9e9606dc1fd83a227b4da9bf1f",
"index": 4047,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Neverland2Style(Style):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Neverland2Style(Style):\n background_color = '#121212'\n styles = {Tok... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
@app.route('/html')
def html():
return '<h1> 태그 사용할 수 있어요! <h1>'
<|reserved_special_token_0|>
@app.route('/ping')
def ping():
return render_template('ping.html')
@app.route('/pong')
def pong():
user_name = request.args.get('user_name')
return render_template('pong.ht... | flexible | {
"blob_id": "9fa3a7c57b311a47e67de73bf6083f1f151d73f4",
"index": 8554,
"step-1": "<mask token>\n\n\n@app.route('/html')\ndef html():\n return '<h1> 태그 사용할 수 있어요! <h1>'\n\n\n<mask token>\n\n\n@app.route('/ping')\ndef ping():\n return render_template('ping.html')\n\n\n@app.route('/pong')\ndef pong():\n us... | [
7,
10,
14,
16,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
while answer == 'y':
user_choice = input('rock,paper,scissors ?')
if user_choice in liste:
prog = random.choice(liste)
print("computer's choice :", prog)
if prog == 'rock':
if user_choic... | flexible | {
"blob_id": "61232ec951cf378798220c00280ef2d351088d06",
"index": 8633,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile answer == 'y':\n user_choice = input('rock,paper,scissors ?')\n if user_choice in liste:\n prog = random.choice(liste)\n print(\"computer's choice :\", prog)\n ... | [
0,
1,
2,
3,
4
] |
#! /usr/bin/env python3
# -*- coding:utf-8 -*-
"""
企查查-行政许可[工商局]
"""
import json
import time
import random
import requests
from lxml import etree
from support.use_mysql import QccMysql as db
from support.others import DealKey as dk
from support.others import TimeInfo as tm
from support.headers import GeneralHeaders a... | normal | {
"blob_id": "63822d60ef9dcc1e123a3d20874e9f492b439c6d",
"index": 3313,
"step-1": "<mask token>\n\n\nclass AdmLicenseBc(AdmLicense):\n\n def bc_judge(self):\n global com_id, com_name\n alb = AdmLicenseBc()\n count_bc = 0\n count = 0\n while count_bc == 0:\n result ... | [
7,
9,
10,
11,
14
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def clone(url: str, dest: Union[Path, str]):
Path(dest).mkdir(parents=True, exist_ok=True)
run(['git', 'clone', url, str(dest)], {'GIT_SSH_COMMAND':
'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=n... | flexible | {
"blob_id": "d85261268d9311862e40a4fb4139158544c654b3",
"index": 2394,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef clone(url: str, dest: Union[Path, str]):\n Path(dest).mkdir(parents=True, exist_ok=True)\n run(['git', 'clone', url, str(dest)], {'GIT_SSH_COMMAND':\n 'ssh -o UserKno... | [
0,
1,
2,
3
] |
import requests
# qq推送 申请参考https://cp.xuthus.cc/
key = ''
def main():
try:
api = 'http://t.weather.itboy.net/api/weather/city/' # API地址,必须配合城市代码使用
city_code = '101070201' # 进入https://where.heweather.com/index.html查询你的城市代码
tqurl = api + city_code
response = requests.get(tqurl)
... | normal | {
"blob_id": "4048d7bfc7922ef76d98d43e1ea266e732e0982e",
"index": 9111,
"step-1": "<mask token>\n\n\ndef main():\n try:\n api = 'http://t.weather.itboy.net/api/weather/city/'\n city_code = '101070201'\n tqurl = api + city_code\n response = requests.get(tqurl)\n d = response.j... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class UrlLongRequest(serializers.Serializer):
url = serializers.CharField(required=True, max_length=64)
def validate_url(self, url):
if url.startswith(HOST):
return url
else:
return serializers.ValidationError('Invalid short URL')
class U... | flexible | {
"blob_id": "6c16afe89d5d0fd6aa6911e3de9e9cebb57bf35e",
"index": 1752,
"step-1": "<mask token>\n\n\nclass UrlLongRequest(serializers.Serializer):\n url = serializers.CharField(required=True, max_length=64)\n\n def validate_url(self, url):\n if url.startswith(HOST):\n return url\n e... | [
4,
5,
6,
7,
8
] |
import sys
def main(stream=sys.stdin):
"""
Input, output, and parsing, etc. Yeah.
"""
num_cases = int(stream.readline().strip())
for i in xrange(num_cases):
rows, cols = map(int, stream.readline().strip().split())
board = []
for r in xrange(rows):
board = board +... | normal | {
"blob_id": "5bcfb0d4fd371a0882dd47814935700eed7885ec",
"index": 6925,
"step-1": "import sys\n\ndef main(stream=sys.stdin):\n \"\"\"\n Input, output, and parsing, etc. Yeah.\n \"\"\"\n num_cases = int(stream.readline().strip())\n for i in xrange(num_cases):\n rows, cols = map(int, stream.re... | [
0
] |
def factorial(num):
assert num >= 0 and int(num) == num, 'Only positive integer accept'
if num in [0, 1]:
return 1
else:
return num * factorial(num - 1)
print(factorial(4.4))
| normal | {
"blob_id": "2a799d81d963f73d8018a99cbd963af166681b35",
"index": 9416,
"step-1": "<mask token>\n",
"step-2": "def factorial(num):\n assert num >= 0 and int(num) == num, 'Only positive integer accept'\n if num in [0, 1]:\n return 1\n else:\n return num * factorial(num - 1)\n\n\n<mask toke... | [
0,
1,
2
] |
import brainlit.algorithms.generate_fragments
from brainlit.algorithms.generate_fragments import *
| normal | {
"blob_id": "a52743fc911beb7e51644073131b25c177d4ad29",
"index": 852,
"step-1": "<mask token>\n",
"step-2": "import brainlit.algorithms.generate_fragments\nfrom brainlit.algorithms.generate_fragments import *\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
def get_discipline_with_more_female():
docs = table.aggregate([{'$match': {'gender': {'$exists': 1}}}, {
'$unwind': '$labels'}, {'$group': {'_id': {'label': '$labels',
'gender': '$gender'}, 'count': {'$sum': 1}}}])
d = {}
for doc in docs:
if doc['_id'][... | flexible | {
"blob_id": "c585b1439217fff42945eeb9e02512d73f8ba19f",
"index": 5805,
"step-1": "<mask token>\n\n\ndef get_discipline_with_more_female():\n docs = table.aggregate([{'$match': {'gender': {'$exists': 1}}}, {\n '$unwind': '$labels'}, {'$group': {'_id': {'label': '$labels',\n 'gender': '$gender'}, ... | [
5,
6,
7,
8,
9
] |
from unittest import TestCase
from utils.fileutils import is_empty_dir, clear_attributes
class FileUtilsTest(TestCase):
def test_is_empty_dir(self):
self.assertFalse(is_empty_dir(r'c:\Windows'))
def test_clear_attributes(self):
clear_attributes(__file__)
| normal | {
"blob_id": "89059915df8891efcbe742174bd468a1390598e3",
"index": 3001,
"step-1": "<mask token>\n\n\nclass FileUtilsTest(TestCase):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass FileUtilsTest(TestCase):\n <mask token>\n\n def test_clear_attributes(self):\n clear_attribu... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class Racer(turtle.Turtle):
def __init__(self, color, x, y):
super().__init__(shape='turtle')
self.color(color)
self.penup()
self.goto(x=x, y=y)
def race(self):
self.forward(random.randint(0, 10))
<|reserved_special_token_0|>
<|reserve... | flexible | {
"blob_id": "f3aaa6ae7a9a57946bdb035a4d52e84541c1a292",
"index": 5934,
"step-1": "<mask token>\n\n\nclass Racer(turtle.Turtle):\n\n def __init__(self, color, x, y):\n super().__init__(shape='turtle')\n self.color(color)\n self.penup()\n self.goto(x=x, y=y)\n\n def race(self):\n ... | [
3,
4,
5,
6,
7
] |
from collections import deque
warp = dict()
u, v = map(int, input().split())
for _ in range(u + v):
s, e = map(int, input().split())
warp[s] = e
q = deque()
q.append(1)
check = [-1] * 101
check[1] = 0
while q:
now = q.popleft()
for k in range(1, 7):
if now + k <= 100 and check[now + k] == -1:
... | normal | {
"blob_id": "dd792c502317288644d4bf5d247999bb08d5f401",
"index": 5369,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(u + v):\n s, e = map(int, input().split())\n warp[s] = e\n<mask token>\nq.append(1)\n<mask token>\nwhile q:\n now = q.popleft()\n for k in range(1, 7):\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Vocabulary:
"""
Helper class that maps words to unique indices and the other way around
"""
def __init__(self, tokens: List[str]):
self.word_to_idx = {'<PAD>': 0}
for idx, tok in enumerate(tokens, 1):
self.word_to_idx[tok] = idx
s... | flexible | {
"blob_id": "9c653719ea511d78de9ddcc19442d9f9f7dc11dc",
"index": 4560,
"step-1": "<mask token>\n\n\nclass Vocabulary:\n \"\"\"\n Helper class that maps words to unique indices and the other way around\n \"\"\"\n\n def __init__(self, tokens: List[str]):\n self.word_to_idx = {'<PAD>': 0}\n ... | [
20,
23,
25,
30,
31
] |
# -*- coding: utf-8 -*-
pessoas=int(input('Digite o numero de pessoas que passa pela esada rolante:'))
for i in range(1,n+1,1):
tempo=int(input('Digite o tempo:'))
if i==1:
tempo1=tempo
elif i==n:
f=tempo+10
X=f-tempo1
print(x) | normal | {
"blob_id": "f98120d191e9e4b92984a6b59b25b1331b5d8c3a",
"index": 1970,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, n + 1, 1):\n tempo = int(input('Digite o tempo:'))\n if i == 1:\n tempo1 = tempo\n elif i == n:\n f = tempo + 10\n<mask token>\nprint(x)\n",
"st... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Csvcalc:
def __init__(self, cont):
self._cont = cont
def row_count(self):
return len(self._cont)
def get_row(self, row_no):
return self._cont[row_no]
def col_count(self):
return len(self._cont[1])
def get_colum(self, no_col):
... | flexible | {
"blob_id": "67793c8851e7107c6566da4e0ca5d5ffcf6341ad",
"index": 8867,
"step-1": "<mask token>\n\n\nclass Csvcalc:\n\n def __init__(self, cont):\n self._cont = cont\n\n def row_count(self):\n return len(self._cont)\n\n def get_row(self, row_no):\n return self._cont[row_no]\n\n de... | [
7,
10,
11,
13,
15
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "0c7f2412fe9a83d70d41fbc4bbaf135e6bc4149a",
"index": 8129,
"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 = [('drchrono', ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
assert str(sys.argv[1]) is not None
<|reserved_special_token_0|>
for k in ALPHA_VALS:
total_train_error = 0
total_train_variance = 0
total_test_error = 0
total_test_variance = 0
dumb_total_train_error = 0
d... | flexible | {
"blob_id": "36682c4ab90cdd22b644906e22ede71254eb42ff",
"index": 2091,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nassert str(sys.argv[1]) is not None\n<mask token>\nfor k in ALPHA_VALS:\n total_train_error = 0\n total_train_variance = 0\n total_test_error = 0\n total_test_variance = 0\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
# block-comments.py
'''
Block comments generally apply to some (or all) code that follows them, and are
indented to the same level as that code. Each line of a block comment starts
with a # and a single space (unless it is indented text inside the comment).
... | flexible | {
"blob_id": "83bac8176caafc5551089c4bef5c1f38e1e8d4da",
"index": 5952,
"step-1": "<mask token>\n",
"step-2": "# block-comments.py\n'''\nBlock comments generally apply to some (or all) code that follows them, and are\nindented to the same level as that code. Each line of a block comment starts\nwith a # and a s... | [
0,
1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.