code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
# Copyright 2010 Google Inc. All Rights Reserved.
#
import copy
import logging
import threading
from automation.common import command as cmd
from automation.common import logger
from automation.common.command_executer import CommandExecuter
from automation.common import job
from automation.common import job_group
fro... | normal | {
"blob_id": "720ec6c222659a13d4a0f3cf9096b70ce6e2b2b3",
"index": 175,
"step-1": "<mask token>\n\n\nclass JobGroupManager(object):\n <mask token>\n\n def GetJobGroup(self, group_id):\n with self._lock:\n for group in self.all_job_groups:\n if group.id == group_id:\n ... | [
3,
6,
7,
8,
9
] |
from api.decidim_connector import DecidimConnector
from api.participatory_processes_reader import ParticipatoryProcessesReader
from api.version_reader import VersionReader
API_URL = "https://meta.decidim.org/api"
decidim_connector = DecidimConnector(API_URL)
version_reader = VersionReader(decidim_connector)
version = ... | normal | {
"blob_id": "88a469eba61fb6968db8cc5e1f93f12093b7f128",
"index": 6973,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(version)\n<mask token>\n",
"step-3": "<mask token>\nAPI_URL = 'https://meta.decidim.org/api'\ndecidim_connector = DecidimConnector(API_URL)\nversion_reader = VersionReader(decidim... | [
0,
1,
2,
3,
4
] |
n, imp = list(map(int, input().split()))
villagers = {}
peoples = []
susList = set()
for i in range(n):
peeps = set(list(map(int, input().split()))[1:])
# Initialize the set
villagers[i+1] = villagers.get(i+1, set())
for p in peeps:
if i+1 in peeps:
susList.add(i+1)
break... | normal | {
"blob_id": "3eca3066a6c6484257ca17164d35654812a87b80",
"index": 6636,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(n):\n peeps = set(list(map(int, input().split()))[1:])\n villagers[i + 1] = villagers.get(i + 1, set())\n for p in peeps:\n if i + 1 in peeps:\n ... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 5 09:10:03 2018
@author: User
"""
from urllib.request import urlopen
from urllib.error import HTTPError
from bs4 import BeautifulSoup
import re
url = "http://www.pythonscraping.com/pages/page3.html"
html = urlopen(url)
html_data = BeautifulSoup(html.read(), "lxml")
img... | normal | {
"blob_id": "00609c4972269c36bbfcf5bec2a8648f812b6092",
"index": 9422,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor img in img_list:\n print(img['src'])\n",
"step-3": "<mask token>\nurl = 'http://www.pythonscraping.com/pages/page3.html'\nhtml = urlopen(url)\nhtml_data = BeautifulSoup(html.read... | [
0,
1,
2,
3,
4
] |
__author__ = 'laispace.com'
import sqlite3
dbname = 'alloyteam.db'
def createTable():
conn = sqlite3.connect(dbname)
c = conn.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS posts
(url text primary key,
title text,
date text,
authorLink ... | normal | {
"blob_id": "602df213c0d588404597c566001cd9c96b5034d0",
"index": 4530,
"step-1": "<mask token>\n\n\ndef createPosts(posts):\n conn = sqlite3.connect(dbname)\n c = conn.cursor()\n for post in posts:\n c.execute('INSERT OR REPLACE INTO posts VALUES (?,?,?,?,?,?)', post)\n conn.commit()\n conn... | [
3,
4,
5,
6,
7
] |
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtSql import *
from DatabaseHandler import send_answer
class PW(QWidget):
def __init__(self, index, question, pid):
super().__init__()
self.question = question
self.pid = pid
self.maxim = len(self.questi... | normal | {
"blob_id": "f35569e2d8d26f43d4b2395b5088902c6cd3b826",
"index": 2232,
"step-1": "<mask token>\n\n\nclass PW(QWidget):\n <mask token>\n <mask token>\n\n def ButtonNoAction(self):\n table = 'patient_' + str(self.pid)\n send_answer(self.question[self.index]['qid'], 'Нет', table)\n if ... | [
2,
3,
4,
5,
6
] |
from mlagents_envs.registry import default_registry
from mlagents_envs.envs.pettingzoo_env_factory import logger, PettingZooEnvFactory
# Register each environment in default_registry as a PettingZooEnv
for key in default_registry:
env_name = key
if key[0].isdigit():
env_name = key.replace("3", "Three")... | normal | {
"blob_id": "3bec28561c306a46c43dafc8bdc2e01f2ea06180",
"index": 9491,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor key in default_registry:\n env_name = key\n if key[0].isdigit():\n env_name = key.replace('3', 'Three')\n if not env_name.isidentifier():\n logger.warning(\n ... | [
0,
1,
2,
3
] |
from pybot import usb4butia
u4b = usb4butia.USB4Butia()
while True:
bot = u4b.getButton(6)
print bot
| normal | {
"blob_id": "24b6d33849f034b9f61ffd4aaff90a0f428085fe",
"index": 7473,
"step-1": "from pybot import usb4butia\n\nu4b = usb4butia.USB4Butia()\n\nwhile True:\n bot = u4b.getButton(6)\n print bot\n\n\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
from wtforms import Form, StringField
class SearchForm(Form):
criteria = StringField("Texto a buscar")
| normal | {
"blob_id": "1896f4d5b304915d5cbbb30b0a83854c4a8cc60c",
"index": 7566,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass SearchForm(Form):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass SearchForm(Form):\n criteria = StringField('Texto a buscar')\n",
"step-4": "from wtforms import... | [
0,
1,
2,
3,
4
] |
import numpy as np
import scipy
class node(object):
"""docstring for node"""
def __init__(self, feature_idx):
super(node, self).__init__()
self.children = None
self.j = feature_idx
self.c = None
self.vals = None
class decisionTree(object):
"""docstring for decisionTree"""
def __init__(self, arg):
sup... | normal | {
"blob_id": "c05994471d6608b5e48b71d253304a43100d583f",
"index": 7296,
"step-1": "import numpy as np\nimport scipy\n\n\nclass node(object):\n\t\"\"\"docstring for node\"\"\"\n\tdef __init__(self, feature_idx):\n\t\tsuper(node, self).__init__()\n\t\tself.children = None\n\t\tself.j = feature_idx\n\t\tself.c = Non... | [
0
] |
"""
问题描述
玛莎(Marsha)和比尔(Bill)拥有一系列大理石。他们希望将藏品分开,以使两者获得相等的份额。如果所有的大理石都具有相同的价值,这将很容易,因为那样他们就可以将收藏品分成两半。
但不幸的是,有些大理石比其他大理石更大或更漂亮。因此,玛莎(Marsha)和比尔(Bill)首先为每个大理石分配一个值,即一个介于1到6之间的自然数。
现在,他们希望对大理石进行分割,以使每个大理石都获得相同的总价值。不幸的是,他们意识到以这种方式分割大理石可能是不可能的(即使所有大理石的总价值是均匀的)。
例如,如果存在一个值为1的大理石,值为3的一个,值为4的两个,则不能将它们拆分为相等值的集合。因此,他们要求您编写一个程序来检查... | normal | {
"blob_id": "0d20b75bcc87db8f3e4bdd9d6448cc44c979de1d",
"index": 137,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('输入:')\nwhile True:\n s = input()\n if s == '0 0 0 0 0 0':\n break\n S.append(s)\nprint('\\n输出:')\n<mask token>\nfor k in range(len(S)):\n p = [int(i) for i in S[k... | [
0,
1,
2,
3
] |
from copy import deepcopy
from datetime import date, timedelta
from hashlib import sha256
import starkbank
from starkbank import BoletoPayment
from .boleto import generateExampleBoletosJson
example_payment = BoletoPayment(
line="34191.09008 61713.957308 71444.640008 2 83430000984732",
scheduled="2020-02-29",
... | normal | {
"blob_id": "383d3b35fbfb7921111b28c3160173ce1c200387",
"index": 637,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef generateExampleBoletoPaymentsJson(n=1, next_day=False):\n boletos = generateExampleBoletosJson(n=n)\n boletos = starkbank.boleto.create(boletos)\n payments = []\n for b... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
import os
import sys
import base64
import cdutil
import json
import os
from array import array
from uuid import uuid4
import cdms2
import numpy as np
import matplotlib as mpl
mpl.rcParams['mathtext.default'] = 'regular'
mpl.use('qt4agg')
import matplotlib.pyplot as plt
from mpl_toolkits.ba... | normal | {
"blob_id": "ff9376ab4d6a88849167fb6e180fd9c4f9ab4dad",
"index": 8283,
"step-1": " # -*- coding: utf-8 -*-\nimport os\nimport sys\n\nimport base64\nimport cdutil\nimport json\nimport os\nfrom array import array\nfrom uuid import uuid4\n\nimport cdms2\nimport numpy as np\nimport matplotlib as mpl\nmpl.rcParams... | [
0
] |
start = input()
user_list = start.split()
if user_list[-1] == 'wolf':
print('Please go away and stop eating my sheep')
else:
user_list.reverse()
print(f'Oi! Sheep number {user_list.index("wolf,") }! You are about to be eaten by a wolf!')
| normal | {
"blob_id": "16850d931eec0356f71317cc24461e006fbcd59c",
"index": 6192,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif user_list[-1] == 'wolf':\n print('Please go away and stop eating my sheep')\nelse:\n user_list.reverse()\n print(\n f\"Oi! Sheep number {user_list.index('wolf,')}! You ... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_nukeboxQueue
----------------------------------
Tests for `nukebox2000` module.
"""
import sys
import unittest
from nukebox2000.MongoBox import NukeBoxDB
class TestNukeBoxDB(unittest.TestCase):
'''
'''
def setUp(self):
'''
B{Test... | normal | {
"blob_id": "bf63ceca2347f750cdf38dce620eaa3c73b556f1",
"index": 1733,
"step-1": "<mask token>\n\n\nclass TestNukeBoxDB(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n \"\"\"\n B{Test} Data\n\n - 2 User dict obj.\n - contains basic data required by the MongoDB co... | [
5,
7,
9,
11,
12
] |
import pymongo
import time
client = pymongo.MongoClient('localhost', 27017);
db = client['zhihu']; # 类似dict,若不存在,则新建;
# client.drop_database('zhihu') # 删除db
collection = db['zhihu']; # 若不存在,则新建;
# db.drop_collection('zhihu') # 删除collection
document_test = {'name': 'test', 'time': time.strftime('%Y-%m-%d %H:%M:%... | normal | {
"blob_id": "d1d293a5d2c394e69d93488605f27b5468220286",
"index": 6627,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(test_id)\n",
"step-3": "<mask token>\nclient = pymongo.MongoClient('localhost', 27017)\ndb = client['zhihu']\ncollection = db['zhihu']\ndocument_test = {'name': 'test', 'time': ti... | [
0,
1,
2,
3,
4
] |
a=float.input('Valor da conta')
print('Valor da conta com 10%: R$',(a))
| normal | {
"blob_id": "d1ce6c081dce2e4bdb6087cd61d7f857dbb1348d",
"index": 8781,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Valor da conta com 10%: R$', a)\n",
"step-3": "a = float.input('Valor da conta')\nprint('Valor da conta com 10%: R$', a)\n",
"step-4": "a=float.input('Valor da conta')\nprint('... | [
0,
1,
2,
3
] |
from django.contrib.auth.forms import UserChangeForm
from django.contrib.auth.models import User
from django import forms
class editForm(forms.ModelForm):
username = forms.CharField(max_length=100, widget= forms.TextInput(attrs={'class': 'form-control'}))
first_name = forms.CharField(max_length=100, widget= fo... | normal | {
"blob_id": "ae8add3adc336c9404cd2aeab4aff81c94c8884e",
"index": 7174,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass editForm(forms.ModelForm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n model = User\n fields = 'username', 'firs... | [
0,
1,
2,
3,
4
] |
from django.shortcuts import render
def index(request):
return render(request, 'munchiesfastfood/home.html', {'drinks': [
'Pineapple Juice', 'Green Juice', 'Soft Drinks',
'Carlo Rosee Drinks'], 'dishes': ['Beef Steak',
'Tomato with Chicken', 'Sausages from Italy', 'Beef Grilled']})
| normal | {
"blob_id": "e279ca43ce2c582c702f1c6a0c1acf37eb9bcefe",
"index": 5603,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef index(request):\n return render(request, 'munchiesfastfood/home.html', {'drinks': [\n 'Pineapple Juice', 'Green Juice', 'Soft Drinks',\n 'Carlo Rosee Drinks'], 'd... | [
0,
1,
2
] |
from source import tools, setup
if __name__ == '__main__':
game = tools.Game(setup.STATE_DICT, 'menu')
game.run()
| normal | {
"blob_id": "a7deec1693c411988445528dceb602bf69e47d21",
"index": 2532,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n game = tools.Game(setup.STATE_DICT, 'menu')\n game.run()\n",
"step-3": "from source import tools, setup\nif __name__ == '__main__':\n game = tools.... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
"""Digital Forensics Virtual File System (dfVFS).
dfVFS, or Digital Forensics Virtual File System, is a Python module
that provides read-only access to file-system objects from various
storage media types and file formats.
"""
| normal | {
"blob_id": "f7d3096d669946e13186a893ffc53067e0fd0a0a",
"index": 1065,
"step-1": "<mask token>\n",
"step-2": "# -*- coding: utf-8 -*-\n\"\"\"Digital Forensics Virtual File System (dfVFS).\n\ndfVFS, or Digital Forensics Virtual File System, is a Python module\nthat provides read-only access to file-system objec... | [
0,
1
] |
from django.contrib import admin
from trips.models import Post
admin.site.register(Post)
| normal | {
"blob_id": "a8197a4f0bb84e734696bf43fa976c76732d75b8",
"index": 9863,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(Post)\n",
"step-3": "from django.contrib import admin\nfrom trips.models import Post\nadmin.site.register(Post)\n",
"step-4": null,
"step-5": null,
"step-ids":... | [
0,
1,
2
] |
# model class for a sale record
from app.models.product import Product
class Sale(Product):
def __init__(self,product_name,quantity,unit_price,attendant,date):
super(Sale, self).__init__(product_name, quantity, unit_price)
self.attendant = attendant
self.date = date | normal | {
"blob_id": "8ed14bb9af23055f4689e06df872a1d36185cd09",
"index": 6865,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Sale(Product):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Sale(Product):\n\n def __init__(self, product_name, quantity, unit_price, attendant, date):\n ... | [
0,
1,
2,
3,
4
] |
class Member:
not_allowed_name = ["Shit", "Hell", "Baloot"]
users_num = 0
def __init__(self, first_name, middle_name, last_name, gender):
self.fname = first_name
self.mname = middle_name
self.lname = last_name
self.gender = gender
Member.users_num += 1
@classm... | normal | {
"blob_id": "f276e33cde2e043fc8f81403e499544aa816a639",
"index": 9316,
"step-1": "class Member:\n <mask token>\n <mask token>\n\n def __init__(self, first_name, middle_name, last_name, gender):\n self.fname = first_name\n self.mname = middle_name\n self.lname = last_name\n se... | [
7,
8,
10,
11,
12
] |
import numpy as np
import pandas as pd
import math
import sklearn
import sklearn.preprocessing
import datetime
import os
import matplotlib.pyplot as plt
import yfinance as yf
import math
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.layers impor... | normal | {
"blob_id": "97ea837961c92b5c92a93ec33ac016de7ff1e876",
"index": 2449,
"step-1": "<mask token>\n\n\nclass simpleLSTM:\n <mask token>\n\n def create_dataset(self, dataset, look_back=4):\n dataX, dataY = [], []\n for i in range(len(dataset) - look_back - 1):\n a = dataset.iloc[i:i + ... | [
4,
7,
8,
9,
10
] |
from .import bp as authentication
from app import db
from flask import current_app as app, render_template, request, redirect, url_for, flash, session
from flask_login import login_user, logout_user, current_user, login_required
from .forms import Register, Login, Settings
from .models import User
# route for register... | normal | {
"blob_id": "74faeb1c09fe136ec4d9578173aeebe54b451e33",
"index": 2406,
"step-1": "<mask token>\n\n\n@authentication.route('/register', methods=['GET', 'POST'])\ndef register():\n form = Register()\n if form.validate_on_submit():\n data = {'first_name': request.form.get('first_name'), 'last_name':\n ... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/4/11 16:07
# @Author : LiuZhi
# @Site :
# @File : Function.py
# @Software: PyCharm
#求绝对值的函数
print(abs(100))
print(abs(-20))
print(abs(12.34))
#print(abs(1,2))
#print(abs('q'))
print(max(1,2))
print(max(1,2,3,-5))
print(int('123'))
print(int(12.... | normal | {
"blob_id": "8a6eb2eb746e3b9de92998b70ddff2a39cb1f269",
"index": 6374,
"step-1": "<mask token>\n\n\ndef move(x, y, step, angle=0):\n nx = x + step * math.cos(angle)\n ny = y - step * math.sin(angle)\n return nx, ny\n\n\n<mask token>\n\n\ndef enroll(name, gender, age=6, city='Beijing'):\n print('name:... | [
9,
14,
15,
19,
20
] |
# Copyright 2018 Google LLC
#
# 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, s... | normal | {
"blob_id": "9ce406124d36c2baf09cf0d95fceb2ad63948919",
"index": 4801,
"step-1": "<mask token>\n\n\nclass UnexpectedFormatError(AttributeError):\n pass\n\n\n<mask token>\n\n\ndef get_meals(_mensa, date=None):\n result = requests.get(\n f'https://osnabrueck.my-mensa.de/essen.php?v=5121119&hyp=1&lang=... | [
6,
7,
8,
9,
10
] |
####################################
## Readable code versus less code ##
####################################
import threading
from web_server.general_api import general_api as api
logger = api.__get_logger('ConnTimeout.run')
class ConnTimeout(object):
def __init__(self, timeout, function, servers=5, args=[], ... | normal | {
"blob_id": "ed5ba72443b70c84941af3d112e0246cb3ae97d9",
"index": 5337,
"step-1": "<mask token>\n\n\nclass ConnTimeout(object):\n\n def __init__(self, timeout, function, servers=5, args=[], kwargs=[]):\n self.timeout = timeout\n self.timer = None\n self.count = 0\n self.f = function... | [
5,
6,
7,
8,
11
] |
import sys
n= int(sys.stdin.readline())
dp = {1:'SK', 2: 'CY', 3:'SK', 4:'SK', 5:'SK',6:'SK'}
def sol(k):
if k in dp:
return dp[k]
else:
for i in range(7, k+1):
if dp[i-3]=='SK' and dp[i-1]=='SK' and dp[i-4]=='SK':
dp[i] = 'CY'
else:
dp[... | normal | {
"blob_id": "4b85479af7d65d208fab08c10afbf66086877329",
"index": 8981,
"step-1": "<mask token>\n\n\ndef sol(k):\n if k in dp:\n return dp[k]\n else:\n for i in range(7, k + 1):\n if dp[i - 3] == 'SK' and dp[i - 1] == 'SK' and dp[i - 4] == 'SK':\n dp[i] = 'CY'\n ... | [
1,
2,
3,
4,
5
] |
import time
import math
from wpilib import SmartDashboard
from wpilib.command import Command
import robotmap
import subsystems
class TankDriveResetEncoders(Command):
def __init__(self):
super().__init__('TankDriveTurnToHeading')
self.requires(subsystems.driveline)
self.setInterruptible(... | normal | {
"blob_id": "f73faabe955e3ae05039e58ebabe5c012e080f38",
"index": 9906,
"step-1": "<mask token>\n\n\nclass TankDriveResetEncoders(Command):\n <mask token>\n\n def execute(self):\n subsystems.driveline.resetEncoders()\n print('CMD TankDriveResetEncoders: Reset Completed')\n <mask token>\n",
... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
from optparse import make_option
from django.core.management.base import BaseCommand, LabelCommand, CommandError
from open_coesione import utils
import sys
import logging
import csv
import os
class Command(LabelCommand):
"""
Task to extract data related to a sample of all projects.
... | normal | {
"blob_id": "f0444676d28be27ad2f0f7cdaa58a96b7facc546",
"index": 2193,
"step-1": "# -*- coding: utf-8 -*-\n\nfrom optparse import make_option\nfrom django.core.management.base import BaseCommand, LabelCommand, CommandError\nfrom open_coesione import utils\n\nimport sys\nimport logging\nimport csv\nimport os\n\nc... | [
0
] |
###########################################################################
# This file provides maintenance on the various language files
# 1. Create new "xx/cards_xx.json" files that have entries ordered as:
# a. the card_tag entries in "cards_db.json"
# b. the group_tag entries as found in "cards_db.json"
# ... | normal | {
"blob_id": "cc1b3c3c65e8832316f72cbf48737b21ee4a7799",
"index": 3887,
"step-1": "<mask token>\n\n\ndef get_lang_dirs(path):\n languages = []\n for name in os.listdir(path):\n dir_path = os.path.join(path, name)\n if os.path.isdir(dir_path):\n cards_file = os.path.join(dir_path, 'c... | [
5,
6,
7,
8,
9
] |
"""Step (with Warm up) learning rate scheduler module."""
from typing import Union
import torch
from torch.optim.lr_scheduler import _LRScheduler
from typeguard import check_argument_types
from espnet2.schedulers.abs_scheduler import AbsBatchStepScheduler
class WarmupStepLR(_LRScheduler, AbsBatchStepScheduler):
... | normal | {
"blob_id": "bce16762c0739087a8309872da4ac04298c50893",
"index": 7695,
"step-1": "<mask token>\n\n\nclass WarmupStepLR(_LRScheduler, AbsBatchStepScheduler):\n <mask token>\n <mask token>\n\n def __repr__(self):\n return (\n f'{self.__class__.__name__}(warmup_steps={self.warmup_steps}, ... | [
3,
4,
5,
6,
7
] |
""" Class template
Ipea's Python for agent-based modeling course
"""
import random
# class name typically Capital letter
class Pessoa:
# Usually has an __init__ method called at the moment of instance creation
def __init__(self, name, distancia):
# Armazena os parâmetros de início dentro daqu... | normal | {
"blob_id": "d18bfdb606e4ba8a67acbb07cd9a3a6d2a0855e3",
"index": 6880,
"step-1": "<mask token>\n\n\nclass Pessoa:\n <mask token>\n <mask token>\n\n def compara(self, outro_agente):\n if self.distancia > outro_agente.distancia:\n return True\n else:\n return False\n\n ... | [
4,
6,
7,
8,
9
] |
from django.shortcuts import render
from django.views.generic.base import View
from .models import Article, Tag, Category
from pure_pagination import Paginator, EmptyPage, PageNotAnInteger
class ArticleView(View):
'''文章详情页'''
def get(self, request, article_id):
# 文章详情
article = Article.object... | normal | {
"blob_id": "2fd40f4d69223933d53d8ed2abd5f6d3ccd2f509",
"index": 3850,
"step-1": "<mask token>\n\n\nclass CategoryView(View):\n \"\"\"文章分类页\"\"\"\n\n def get(self, request, category_id):\n category = Category.objects.get(id=int(category_id))\n category_articles = category.article_set.all()\n ... | [
6,
7,
8,
9,
11
] |
import random
def multi():
scc = [6, 5, 4]
sc = [6, 5]
cc = [5, 4]
crew = [4]
captain = [5]
ship = [6]
n = 0
while n <= 2:
inp = input("Hit enter to roll")
if inp == "":
roll5 = random.choices(range(1, 7), k=5)
print(roll5)
if set(scc)... | normal | {
"blob_id": "bb540ba4cd96e2485e77ba099f0a1a9ea03e1120",
"index": 8144,
"step-1": "<mask token>\n\n\ndef multi():\n scc = [6, 5, 4]\n sc = [6, 5]\n cc = [5, 4]\n crew = [4]\n captain = [5]\n ship = [6]\n n = 0\n while n <= 2:\n inp = input('Hit enter to roll')\n if inp == '':... | [
1,
2,
3,
4,
5
] |
import numpy as np
class SampleMemory(object):
def __init__(self, item_shape, max_size):
self.memory = np.zeros((max_size,) + item_shape)
self.item_shape = item_shape
self.num_stored = 0
self.max_size = max_size
self.tail_index = 0
def sample(self, num_sampl... | normal | {
"blob_id": "89dfd9a32b008307eb4c456f2324804c29f3b68f",
"index": 6510,
"step-1": "<mask token>\n\n\nclass SampleMemory(object):\n <mask token>\n <mask token>\n <mask token>\n\n def append(self, item):\n self.memory[self.tail_index, :] = item\n self.tail_index = (self.tail_index + 1) % s... | [
3,
7,
9,
10,
11
] |
import urllib, json
from PyQt4.QtCore import QRectF, Qt
from PyQt4.Qt import QPrinter, QPainter, QFont, QBrush, QColor, QPen, QImage
from PyQt4.QtGui import QApplication
# bkgimg = QImage()
# bkgimg.load("KosyMost.jpg", format = "jpg")
#
# print bkgimg
# exit()
def background(painter, bkgimg):
maxx = painter.d... | normal | {
"blob_id": "47587cce572807922344523d8c5fefb09552fe34",
"index": 8638,
"step-1": "import urllib, json\nfrom PyQt4.QtCore import QRectF, Qt\nfrom PyQt4.Qt import QPrinter, QPainter, QFont, QBrush, QColor, QPen, QImage\nfrom PyQt4.QtGui import QApplication\n\n\n# bkgimg = QImage()\n# bkgimg.load(\"KosyMost.jpg\", ... | [
0
] |
# -*- coding: utf-8 -*-
"""Success request logging.
This logging is used by "CheckZope" to determine the amount
of work performed by Zope (in order not to bother it with monitor
probes when it is heavily active) and to detect an unreasonable
error rate.
This logging writes two files "<base>_good.<date>" and "<base>_b... | normal | {
"blob_id": "2edbf18c90da1ff40fd9abaf25a35dbdaf733bc1",
"index": 2786,
"step-1": "<mask token>\n\n\n@adapter(IProcessStarting)\ndef start_successlogging(unused):\n \"\"\"start successlogging if configured.\"\"\"\n from App.config import getConfiguration\n config = getConfiguration().product_config.get('... | [
2,
3,
4,
5,
6
] |
# https://stackoverflow.com/questions/69473844/can-you-calculate-the-size-of-a-text-annotation-in-matplotlib
from matplotlib.figure import Figure as mpl_Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg as mpl_Canvas
fig = mpl_Figure()
x, y, text = 5, 7, 'My label text'
fig.gca().plot(x, y, 'k.')
ca... | normal | {
"blob_id": "c87f9885e96abdd32df68f9fe1942b2782bd5b96",
"index": 8149,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfig.gca().plot(x, y, 'k.')\n<mask token>\ncanvas.draw()\n<mask token>\nfig.gca().plot([bbox.x0, bbox.x1, bbox.x1, bbox.x0, bbox.x0], [bbox.y0,\n bbox.y0, bbox.y1, bbox.y1, bbox.y0], 'k... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Thibaut Lapierre <git@epheo.eu>. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# ... | normal | {
"blob_id": "c2c1194ed23adda015b23897888d1a4cc11423d5",
"index": 5074,
"step-1": "<mask token>\n\n\nclass Container(object):\n <mask token>\n\n def __init__(self, svc_cfg, containers_all=None):\n self.cfg = svc_cfg\n self.env = dict(self.cfg)\n args_to_delete = ['priority', 'depends-on... | [
9,
10,
12,
13,
14
] |
#!/usr/bin/python
# Original code found at:
# https://github.com/zzeromin/raspberrypi/tree/master/i2c_lcd
# requires I2C_LCD_driver.py
import I2C_LCD_driver
from time import *
import os
mylcd = I2C_LCD_driver.lcd()
mylcd.lcd_clear()
mylcd.lcd_display_string("RAS Hi-Pi shutdown", 1)
mylcd.lcd_display_string(" See yo... | normal | {
"blob_id": "df60d3b829c5702385f59fdefaea04f569fb7db2",
"index": 9058,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmylcd.lcd_clear()\nmylcd.lcd_display_string('RAS Hi-Pi shutdown', 1)\nmylcd.lcd_display_string(' See you again ~', 2)\nmylcd.lcd_display_string('http://rasplay.org', 3)\nmylcd.lcd_displa... | [
0,
1,
2,
3,
4
] |
import json
import unittest
from pathlib import Path
from deepdiff import DeepDiff
from electricitymap.contrib import config
CONFIG_DIR = Path(__file__).parent.parent.joinpath("config").resolve()
class ConfigTestcase(unittest.TestCase):
def test_generate_zone_neighbours_two_countries(self):
exchanges =... | normal | {
"blob_id": "22b8ecfecc0e76d758f14dea865a426db56c6343",
"index": 3538,
"step-1": "<mask token>\n\n\nclass ConfigTestcase(unittest.TestCase):\n <mask token>\n\n def test_generate_zone_neighbours_one_country_one_subzone(self):\n exchanges = {'DE->SE-SE4': {'parsers': {'exchange': 'source'}}}\n ... | [
7,
8,
10,
11,
12
] |
import os
from redis import Redis
try:
if os.environ.get('DEBUG'):
import settings_local as settings
else:
import settings_prod as settings
except ImportError:
import settings
redis_env = os.environ.get('REDISTOGO_URL')
if redis_env:
redis = Redis.from_url(redis_env)
elif getattr(setting... | normal | {
"blob_id": "4c3a27bf1f7e617f4b85dc2b59efa184751b69ac",
"index": 3868,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n if os.environ.get('DEBUG'):\n import settings_local as settings\n else:\n import settings_prod as settings\nexcept ImportError:\n import settings\n<mask toke... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from tensorflow.python.ops.image_ops_impl import ResizeMethod
import sflow.core as tf
from sflow.core import layer
import numpy as np
# region arg helper
def _kernel_shape(nd, k, indim, outdim):
if isinstance(k, int):
k = [k for _ in range(nd)]
k = list(k)
assert len(k) =... | normal | {
"blob_id": "940c3b4a2b96907644c0f12deddd8aba4086a0f0",
"index": 5131,
"step-1": "<mask token>\n\n\ndef _kernel_shape(nd, k, indim, outdim):\n if isinstance(k, int):\n k = [k for _ in range(nd)]\n k = list(k)\n assert len(k) == nd\n k.extend([indim, outdim])\n return k\n\n\n<mask token>\n\n... | [
22,
26,
29,
32,
39
] |
# -*- coding: utf-8 -*-
import requests
import Queue
import codecs
import os
import urllib
import base64
from threading import Thread
from Crypto.Cipher import AES
requests.packages.urllib3.disable_warnings()
def check(q):
while True:
try:
c = q.get()
user = c.split(':')[0]
... | normal | {
"blob_id": "b8ab6b8c111876d6a781c82438f79307a849c47a",
"index": 1353,
"step-1": "# -*- coding: utf-8 -*-\nimport requests\nimport Queue\nimport codecs\nimport os\nimport urllib\nimport base64\nfrom threading import Thread\nfrom Crypto.Cipher import AES\n\nrequests.packages.urllib3.disable_warnings()\n\n\ndef ch... | [
0
] |
import logging
from random import randint
import pygame
from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
from playsound import playsound
app = Flask(__name__)
ask = Ask(app, "/")
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
@ask.launch
def new_game():
p... | normal | {
"blob_id": "e4b6304be10ee5a741c8a193dcf65950299ef11a",
"index": 1477,
"step-1": "<mask token>\n\n\n@ask.launch\ndef new_game():\n pygame.mixer.init()\n pygame.mixer.music.load('haha2.mp3')\n pygame.mixer.music.play()\n welcome_msg = render_template('welcome')\n return question(welcome_msg)\n\n\n@... | [
6,
7,
8,
9,
10
] |
from cmd import Cmd
class CMD(Cmd):
def __init__(self):
pass
def do_move(self, direction):
if direction == "up":
self.game.movePlayer(0, 1)
elif direction == "down":
self.game.movePlayer(0, -1)
elif direction == "left":
self.game.movePlayer(-... | normal | {
"blob_id": "03a024140d8d0136bf9838f8942539f6d19bb351",
"index": 1866,
"step-1": "<mask token>\n\n\nclass CMD(Cmd):\n\n def __init__(self):\n pass\n <mask token>\n <mask token>\n <mask token>\n\n def do_drawCard(self):\n pass\n <mask token>\n\n def do_fight(self):\n pass... | [
7,
11,
12,
13,
15
] |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
class Tweet(models.Model):
owner = models.ForeignKey(User, related_name='tweets')
content = models.CharField(max_length=255)
when_created = models.DateTimeField(auto_no... | normal | {
"blob_id": "28978bc75cb8c5585fd0d145fe0d0c0c5456ad2e",
"index": 6955,
"step-1": "<mask token>\n\n\nclass Tweet(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Tweet(models.Model):\n <mask token>\n <mask token>\n <mask token... | [
1,
2,
3,
4,
5
] |
# -*- coding:utf-8 -*-
# pylint: disable=line-too-long
_BASE_REPRESENTATIONS = [
"Primitive(field='f1', op='eq', value='value')",
"Primitive(field='f1', op='eq', value=42)",
"Primitive(field='f1', op='eq', value=3.14)",
"Primitive(field='f1', op='eq', value=True)",
"Condition(op=Operator.OR, values... | normal | {
"blob_id": "137842d50355563b2df6c2fc48864c01a22afa80",
"index": 5567,
"step-1": "<mask token>\n",
"step-2": "_BASE_REPRESENTATIONS = [\"Primitive(field='f1', op='eq', value='value')\",\n \"Primitive(field='f1', op='eq', value=42)\",\n \"Primitive(field='f1', op='eq', value=3.14)\",\n \"Primitive(fiel... | [
0,
1,
2
] |
import pandas as pd
import pyranges as pr
import numpy as np
import sys
import logging
from methplotlib.utils import file_sniffer
import pysam
class Methylation(object):
def __init__(self, table, data_type, name, called_sites):
self.table = table
self.data_type = data_type
self.name = name... | normal | {
"blob_id": "d654aea3da3e36ccde8a5f4e03798a0dea5aad8a",
"index": 510,
"step-1": "<mask token>\n\n\nclass Methylation(object):\n\n def __init__(self, table, data_type, name, called_sites):\n self.table = table\n self.data_type = data_type\n self.name = name\n self.called_sites = cal... | [
5,
8,
10,
11,
12
] |
import datetime
import os
# os.getcwd()
class LMS: # This class is used to keep records of the books in the Library
def __init__(self, list_of_books, library_name):
self.list_of_books = "List_of_books.txt"
self.library_name = library_name
self.books_dict = {}
Id = 101
w... | normal | {
"blob_id": "1a2616472c8d432c91e2b48260cbae61d3ecfd90",
"index": 1746,
"step-1": "<mask token>\n\n\nclass LMS:\n <mask token>\n <mask token>\n\n def issue_books(self):\n books_id = input(\"Enter book's ID: \")\n current_date = datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')\n ... | [
4,
5,
6,
7,
9
] |
import sys
pdb = open(sys.argv[1])
name = sys.argv[2]
res = []
resid = None
for l in pdb:
if not l.startswith("ATOM"):
continue
if int(l[22:26]) != resid:
res.append([])
resid = int(l[22:26])
res[-1].append(l)
for i in range(len(res)-2):
outp = open("%s%d-%dr.pdb"%(name,i+1,i+... | normal | {
"blob_id": "d867d17b2873de7c63d0ff29eb585cce1a68dda6",
"index": 6081,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor l in pdb:\n if not l.startswith('ATOM'):\n continue\n if int(l[22:26]) != resid:\n res.append([])\n resid = int(l[22:26])\n res[-1].append(l)\nfor i in r... | [
0,
1,
2,
3,
4
] |
from math import log
from collections import Counter
import copy
import csv
import carTreePlotter
import re
def calEntropy(dataSet):
"""
输入:二维数据集
输出:二维数据集标签的熵
描述:
计算数据集的标签的香农熵;香农熵越大,数据集越混乱;
在计算 splitinfo 和通过计算熵减选择信息增益最大的属性时可以用到
"""
entryNum = len(dataSet)
labelsCount... | normal | {
"blob_id": "b051a3dbe1c695fda9a0488dd8986d587bbb24a6",
"index": 5838,
"step-1": "<mask token>\n\n\ndef calEntropy(dataSet):\n \"\"\"\n 输入:二维数据集\n 输出:二维数据集标签的熵\n 描述:\n 计算数据集的标签的香农熵;香农熵越大,数据集越混乱;\n 在计算 splitinfo 和通过计算熵减选择信息增益最大的属性时可以用到\n \"\"\"\n entryNum = len(dataSet)\n labelsCount = ... | [
12,
18,
19,
21,
23
] |
from flask_admin.contrib.sqla import ModelView
from flask_admin import Admin
from flask import abort
import flask_login
import logging
from .models import User, sendUserMail, db as userdb
from .box_models import Box, Image, db as boxdb
from .box_queue import BoxQueue
logger = logging.getLogger('labboxmain')
class Au... | normal | {
"blob_id": "3f86227afd60be560ac3d4ce2bee1f6cf74a744d",
"index": 3509,
"step-1": "<mask token>\n\n\nclass UserModel(AuthModel):\n <mask token>\n <mask token>\n\n def on_model_change(self, form, model, is_created):\n if is_created:\n logger.warning('[Admin] Create for ' + model.email)\n... | [
2,
6,
7,
8,
9
] |
def sort(L):
n = len(L)
if n < 2:
return L
L1, L2 = L[:n // 2], L[n // 2:]
return merge(sort(L1), sort(L2))
def merge(L1, L2):
if L1 == []:
return L2
if L2 == []:
return L1
x1, R1 = L1[0], L1[1:]
x2, R2 = L2[0], L2[1:]
if x1 <= x2:
return [x1] + merg... | normal | {
"blob_id": "056636e2220e529d3f66872a4a48c0984cda1ce4",
"index": 6617,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef merge(L1, L2):\n if L1 == []:\n return L2\n if L2 == []:\n return L1\n x1, R1 = L1[0], L1[1:]\n x2, R2 = L2[0], L2[1:]\n if x1 <= x2:\n return ... | [
0,
1,
2,
3
] |
from flask import render_template, flash, redirect, url_for, request
from flask_login import current_user, login_user, logout_user, login_required
from werkzeug.urls import url_parse
from app import db
# from app.main.forms import [list forms here]
from app.models import User
from app.main import bp
@bp.route('/')
@bp... | normal | {
"blob_id": "495d606304e07a097033366d1a7e1d856a4cf61f",
"index": 1935,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@bp.route('/')\n@bp.route('/index')\n@login_required\ndef index():\n return render_template('index.html')\n",
"step-3": "from flask import render_template, flash, redirect, url_f... | [
0,
1,
2,
3
] |
import unittest
from HTMLTestRunner import HTMLTestRunner
discover = unittest.defaultTestLoader.discover(start_dir='./',
pattern='test*.py',
top_level_dir=None)
f = open('report.html', 'wb+')
runner = HTMLTestRunner(stream=f,... | normal | {
"blob_id": "051062a78d3f8b0caefd15f7a57a8500ddc019a6",
"index": 9290,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nrunner.run(discover)\nf.close()\n",
"step-3": "<mask token>\ndiscover = unittest.defaultTestLoader.discover(start_dir='./', pattern=\n 'test*.py', top_level_dir=None)\nf = open('repo... | [
0,
1,
2,
3,
4
] |
num = int(input())
bull_str = input().split(' ')
bull_list = []
for i in range(len(bull_list)):
bull_list.append(int(bull_str[i]))
flag = 0
while True:
flag += 1
for i in range(len(bull_list)):
if bull_list[i] == 1:
for j in range(bull_list.index(bull_list[i]), len(bull_list)):
... | normal | {
"blob_id": "4d30f4294a9f3aab8cae20dca9d280c53b37ed25",
"index": 1471,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(len(bull_list)):\n bull_list.append(int(bull_str[i]))\n<mask token>\nwhile True:\n flag += 1\n for i in range(len(bull_list)):\n if bull_list[i] == 1:\n ... | [
0,
1,
2
] |
#!/usr/bin/env python3
import sys
from pathlib import Path
def print_usage():
sys.stderr.write('''
Find the length of the biggest line in the file.
Usage: ./biggestLine <delimiter> <field number - first element is 0> <file path>
''')
def main():
if len(sys.argv) != 4:
print_usage()
... | normal | {
"blob_id": "c84175edb88f5b9219c22ec717ec30bb530982a2",
"index": 2861,
"step-1": "<mask token>\n\n\ndef print_usage():\n sys.stderr.write(\n \"\"\"\nFind the length of the biggest line in the file.\nUsage: ./biggestLine <delimiter> <field number - first element is 0> <file path>\n \"\"\"\n ... | [
1,
2,
3,
4,
5
] |
from __future__ import absolute_import
from django.conf.urls import patterns, url
from sentry_plugins.jira_ac.views import JiraConfigView, \
JiraDescriptorView, JiraInstalledCallback, JiraUIWidgetView
urlpatterns = patterns(
'',
url(r'^plugin$', JiraUIWidgetView.as_view()),
url(r'^config$', JiraConfi... | normal | {
"blob_id": "2440f5bc774f2e2f746a246cbb2e305965c9e576",
"index": 7788,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = patterns('', url('^plugin$', JiraUIWidgetView.as_view()), url\n ('^config$', JiraConfigView.as_view()), url(\n '^atlassian-connect\\\\.json$', JiraDescriptorView.as_vi... | [
0,
1,
2,
3
] |
import flask
from flask.ext.classy import FlaskView, route, request
from annotator_supreme.controllers.user_controller import UserController
from annotator_supreme.views import view_tools
from annotator_supreme.views import error_views
from flask import render_template, flash, redirect, url_for
from annotator_supreme i... | normal | {
"blob_id": "a2e77298059104b403555af95430d7995f8a697b",
"index": 1379,
"step-1": "<mask token>\n\n\nclass LoginViewWebApp(FlaskView):\n <mask token>\n\n def __init__(self):\n self.user_controller = UserController()\n\n @route('/register', methods=['GET', 'POST'])\n def register_user(self):\n ... | [
4,
5,
6,
7,
8
] |
# Generated by Django 3.1.7 on 2021-04-16 14:03
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='AuditLog',
fields=[
('id', models.AutoField... | normal | {
"blob_id": "d65d85b4573728ed32ccf987459d5a228e2a8897",
"index": 5196,
"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
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import rospy
import json
import requests
import time
import logging
import numpy as np
from matplotlib import path
from geometry_msgs.msg import PoseWithCovarianceStamped
from std_msgs.msg import String
from people_msgs.msg import People
import rsb
import sys
# -busy stat... | normal | {
"blob_id": "094e7c150456888389c764d4dd7bf3c9a87a022c",
"index": 9006,
"step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport rospy\nimport json\nimport requests\nimport time\nimport logging\nimport numpy as np\nfrom matplotlib import path\nfrom geometry_msgs.msg import PoseWithCovarianceStamped\nfr... | [
0
] |
#!/usr/bin/env python3
import fileinput
mem = [int(n.strip()) for n in next(fileinput.input()).split()]
size = len(mem)
states = set()
states.add('.'.join(str(n) for n in mem))
part2 = None
steps = 0
while True:
i = mem.index(max(mem))
x = mem[i]
mem[i] = 0
while x > 0:
i += 1
mem[i ... | normal | {
"blob_id": "0e7d4b73cedf961677e6b9ea5303cdb3a5afa788",
"index": 3521,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nstates.add('.'.join(str(n) for n in mem))\n<mask token>\nwhile True:\n i = mem.index(max(mem))\n x = mem[i]\n mem[i] = 0\n while x > 0:\n i += 1\n mem[i % size] ... | [
0,
1,
2,
3,
4
] |
#! /usr/bin/env python
#printing the sum of the even Fibonacci numbers
n= int(raw_input("enter your number"))
sumeven=0
# Defining the Fibonacci function
def fib(n):
a,b = 0,1 #first numbers of the sequence
while 1:
yield a
a,b = b,a+b #generator for the next number in the sequence
a = fib(n)
for i in range(n... | normal | {
"blob_id": "24290f3a6cf9a0a272186a505d31c62a6f278c86",
"index": 480,
"step-1": "#! /usr/bin/env python\n#printing the sum of the even Fibonacci numbers\n\nn= int(raw_input(\"enter your number\"))\nsumeven=0\n# Defining the Fibonacci function\ndef fib(n): \n\ta,b = 0,1 #first numbers of the sequence \n\twhile 1:... | [
0
] |
# leetcode 836
# determine if two rectangles overlap
# input is two lists [x1,y1,x2,y2] coordinates
# where x1,y1 are coordinates of bottom left corner
# and x2,y2 are coordinates of top right corner
def overlap_rect(rec1, rec2):
"""Determine if rectangles overlap."""
# true if rec2 is left of rec1
a = rec... | normal | {
"blob_id": "0ef03ed455938bd2001581986c38104bfac395ce",
"index": 8078,
"step-1": "<mask token>\n",
"step-2": "def overlap_rect(rec1, rec2):\n \"\"\"Determine if rectangles overlap.\"\"\"\n a = rec2[2] <= rec1[0]\n b = rec1[2] <= rec2[0]\n c = rec2[3] <= rec1[1]\n d = rec1[3] <= rec2[1]\n retu... | [
0,
1,
2
] |
def word_count(s):
# Your code here
cache = {}
ignore = '":;,.-+=/\\|[]{}()*^&'
lower = s.lower()
for i in lower:
if i in ignore:
lower = lower.replace(i, '')
words = lower.split()
for j in words:
if j not in cache:
cache[j] = 1
else:
... | normal | {
"blob_id": "97d84f99264afa5e7df4b5d22cf4c49b2d14ff7a",
"index": 8291,
"step-1": "<mask token>\n",
"step-2": "def word_count(s):\n cache = {}\n ignore = '\":;,.-+=/\\\\|[]{}()*^&'\n lower = s.lower()\n for i in lower:\n if i in ignore:\n lower = lower.replace(i, '')\n words = l... | [
0,
1,
2,
3
] |
from codar.cheetah import Campaign
from codar.cheetah import parameters as p
from codar.savanna.machines import SummitNode
import copy
def get_shared_node_layout (n_writers, n_readers):
nc = SummitNode()
for i in range(n_writers):
nc.cpu[i] = "writer:{}".format(i)
for i in range(n_readers):
... | normal | {
"blob_id": "475cc5130e847b1a74a33bfa5cbc202a6bf31621",
"index": 6932,
"step-1": "<mask token>\n\n\ndef get_sweeps(ref_params_d, n_writers):\n params_d = copy.deepcopy(ref_params_d)\n params_d['writer']['nprocs'].values = [n_writers]\n params_d['writer']['decomposition'].values = [n_writers]\n all_di... | [
3,
4,
5,
6,
7
] |
# https://kyu9341.github.io/algorithm/2020/03/11/algorithm14226/
# https://developingbear.tistory.com/138
# https://devbelly.tistory.com/108
# 이모티콘 s개 생성
# 3가지 연산 이용
# bfs 이용 => visited를 이모티콘 방문 여부 2차원 배열 => 이모티콘의 수 와 클립보드에 저장된 이모티콘의 갯수를 이용
from collections import deque
s = int(input())
q = deque()
# visited[이모티콘의 수][클... | normal | {
"blob_id": "0c14a6fa8b25e1791a6eb9c71290db8bb316819a",
"index": 5684,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nq.append((1, 0, 0))\nwhile q:\n e, clip, t = q.popleft()\n if e == s:\n print(t)\n exit(0)\n if 0 < e < 1001:\n if visited[e][e] is False:\n visit... | [
0,
1,
2,
3,
4
] |
import copy
import pandas as pd
import numpy as np
from pandas import DataFrame
from collections import Counter
from sklearn.metrics import roc_auc_score, roc_curve
from statsmodels.stats.outliers_influence import variance_inflation_factor
class Get_res_DataFrame:
'''
sheet1:数据概况
sheet2:变量的大小,效果,相关性 ok
... | normal | {
"blob_id": "6336b31e51f0565c6b34ab5148645748fe899541",
"index": 3829,
"step-1": "<mask token>\n\n\nclass Get_res_DataFrame:\n <mask token>\n\n def __init__(self, lr, df, df_bin, df_woe, use_lst, woe_dic, type_train\n ='type_train', y='is_7_p'):\n self.df = df\n self.df_bin = df_bin\n ... | [
11,
12,
13,
14,
15
] |
import os
import unittest
import json
from flask_sqlalchemy import SQLAlchemy
from app import create_app
from models import *
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
# auth tokens should be updated before running tests,
# make sure update the tokens in setup.sh
# read the README to kno... | normal | {
"blob_id": "bae4eb94d561f7aa810718840ff7c2de52cb0d6f",
"index": 3228,
"step-1": "<mask token>\n\n\nclass CastingAgencyTestCase(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n \"\"\"Define test variables and initialize app.\"\"\"\n self.app = create_app()\n self.client = self... | [
21,
30,
31,
35,
39
] |
/Users/alyssaliguori/anaconda3/lib/python3.7/tokenize.py | normal | {
"blob_id": "601ef4e1000348059dcfe8d34eec5f28368f2464",
"index": 8855,
"step-1": "/Users/alyssaliguori/anaconda3/lib/python3.7/tokenize.py",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
# Greedy Algorithm solves a problem by building a solution incrementally
# The algorithm is greedy because it chooses the next step that gives the most benefit
# Can save a lot of time when used correctly since they don't have to look at the entire problem space
# It's either the most optimal solution or it doesn't wor... | normal | {
"blob_id": "f6974c0e5908710031bc3c3bb75c277be426632c",
"index": 2789,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n",
"step-3": "class Solution:\n\n def canJump(self, nums):\n best_index = 0\n for i in range(len(nums)):\n if i > best... | [
0,
1,
2,
3,
4
] |
final=[]
refer={2:'abc',3:'def',4:'ghi',5:'jkl',6:'mno',7:'pqrs',8:'tuv',9:'wxyz'}
##Complete this function
def possibleWords(a,N,index=0,s=''):
##Your code here
if index==N:
final.append(s)
print(s, end=' ')
return
possible_chars=refer[a[0]]
for i in possible_chars:
... | normal | {
"blob_id": "5f237a820832181395de845cc25b661878c334e4",
"index": 9965,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef possibleWords(a, N, index=0, s=''):\n if index == N:\n final.append(s)\n print(s, end=' ')\n return\n possible_chars = refer[a[0]]\n for i in possibl... | [
0,
1,
2,
3
] |
"""DogGroom URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-base... | normal | {
"blob_id": "da062dfe494b363c8ef3ec9f19af912736aaf77b",
"index": 9018,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('admin/', admin.site.urls), url('^$', IndexView.as_view\n (), name='index'), url('^register/', RegistrationView.as_view(), name=\n 'register'), url('^home/', Hom... | [
0,
1,
2,
3
] |
#coding=utf-8
from selenium import webdriver
wd=webdriver.Firefox()
wd.get('https://www.baidu.com/')
wd.find_element_by_id('kw').send_keys(u'哈哈')
wd.quit()
| normal | {
"blob_id": "8de36400f21bfb4e24703d5a65471a961e1afddc",
"index": 9796,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwd.get('https://www.baidu.com/')\nwd.find_element_by_id('kw').send_keys(u'哈哈')\nwd.quit()\n",
"step-3": "<mask token>\nwd = webdriver.Firefox()\nwd.get('https://www.baidu.com/')\nwd.fin... | [
0,
1,
2,
3,
4
] |
from models import Ban
from django.shortcuts import render_to_response
class IPBanMiddleware(object):
"""
Simple middleware for taking care of bans from specific IP's
Redirects the banned user to a ban-page with an explanation
"""
def process_request(self, request):
ip = request.META['REMOTE_ADDR'] # use... | normal | {
"blob_id": "9289eb32db145187c5b4140e32acff520be8366e",
"index": 7620,
"step-1": "<mask token>\n\n\nclass IPBanMiddleware(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass IPBanMiddleware(object):\n <mask token>\n\n def process_request(self, request):\n ip = reque... | [
1,
2,
3,
4,
5
] |
#recapitulare polimorfism
class Caine:
def sunet(self):
print("ham ham")
class Pisica:
def sunet(self):
print("miau")
def asculta_sunet(tipul_animalului):# astapta obiect tipul animalului
tipul_animalului.sunet()#
CaineObj=Caine()#dau obiect
PisicaObj=Pisica()
asculta_sunet(Cain... | normal | {
"blob_id": "594fdec916520014faff80dd06c7a5553320664d",
"index": 4746,
"step-1": "class Caine:\n <mask token>\n\n\nclass Pisica:\n\n def sunet(self):\n print('miau')\n\n\n<mask token>\n",
"step-2": "class Caine:\n\n def sunet(self):\n print('ham ham')\n\n\nclass Pisica:\n\n def sunet(... | [
3,
5,
6,
7,
8
] |
# -*- coding: utf-8 -*-
class FizzBuzz:
def convert(self, number):
# raise NotImplementedError
# for number in range(1, 101):
if number%3 == 0 and number%5 != 0:
return ("Fizz")
elif number%3 != 0 and number%5 == 0:
return("Buzz")
... | normal | {
"blob_id": "fb9d639bca59ecb081e7d9f30f97bdcd35627d34",
"index": 6124,
"step-1": "<mask token>\n",
"step-2": "class FizzBuzz:\n <mask token>\n",
"step-3": "class FizzBuzz:\n\n def convert(self, number):\n if number % 3 == 0 and number % 5 != 0:\n return 'Fizz'\n elif number % 3... | [
0,
1,
2,
3
] |
# Generated by Django 2.1.2 on 2018-10-26 05:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('candidate', '0004_remove_candidate_corrected_loc'),
]
operations = [
migrations.AlterField(
model_name='candidate',
... | normal | {
"blob_id": "eb75f6e959e9153e6588a0322d1ebc75e21e73ef",
"index": 8153,
"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 = [('candidate',... | [
0,
1,
2,
3,
4
] |
N=input()
l=map(int,raw_input().split())
l.sort()
flag=0
if l[0]<0:
print 'False'
else:
for i in l:
if str(i)==str(i)[::-1]:
flag=flag+1
if flag>=1:
print 'True'
else:
print 'False'
| normal | {
"blob_id": "21050d66120787c1260efd42bb6456d7131fcc6b",
"index": 6101,
"step-1": "N=input()\nl=map(int,raw_input().split())\nl.sort()\nflag=0\n\nif l[0]<0:\n print 'False'\nelse:\n for i in l:\n if str(i)==str(i)[::-1]:\n flag=flag+1\n if flag>=1:\n print 'True'\n else:\n ... | [
0
] |
i = 0
real_value = 8
while i <= 3:
guess = int(input('Guess: '))
if guess == real_value:
print('You Win!')
break
else:
print('You lose')
| normal | {
"blob_id": "70f2fc6873a78305c74e3c3ad04cb24d72019d56",
"index": 8738,
"step-1": "i = 0\nreal_value = 8\nwhile i <= 3:\n guess = int(input('Guess: '))\n if guess == real_value:\n print('You Win!')\n break\n else:\n print('You lose')\n \n",
"step-2": null,
"step-3": null,
"step-4": null,
"st... | [
0
] |
"""Create a new Node object and attach it a Linked List."""
class Node(object):
"""Build a node object."""
def __init__(self, data=None, next=None):
"""Constructor for the Node object."""
self.data = data
self.next = next
class LinkedList(object):
"""Build linked list."""
d... | normal | {
"blob_id": "192bd3c783f6f822f8e732ddf47d7fc3b22c032b",
"index": 1618,
"step-1": "<mask token>\n\n\nclass LinkedList(object):\n <mask token>\n\n def __init__(self, iterable=()):\n \"\"\"Constructor for the Linked List object.\"\"\"\n self.head = None\n self._counter = 0\n if isi... | [
6,
10,
12,
14,
15
] |
#!/usr/bin/python3
"""
module that has
fucntions that
shows attributes
"""
def lookup(obj):
"""
function that returns attributes and methods of an object
"""
return(dir(obj))
| normal | {
"blob_id": "67380fb8b1557b0ed6779009e5f9ae93fd81aedd",
"index": 8753,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef lookup(obj):\n \"\"\"\n function that returns attributes and methods of an object\n \"\"\"\n return dir(obj)\n",
"step-3": "#!/usr/bin/python3\n\"\"\"\nmodule that h... | [
0,
1,
2
] |
# -*- encoding: utf-8 -*-
from django.conf.urls import patterns, url
urlpatterns = patterns('apps.profiles.views',
url(r'^$', 'index', name='profiles'),
# Show a specific profile.
url(r'^view/(?P<username>[a-zA-Z0-9_-]+)/$', 'view_profile', name='profiles_view'),
url(r'^edit/$', 'edit_profile', name... | normal | {
"blob_id": "5707e24596dfe2d85e9a7caa93aa3e253a41ae40",
"index": 6620,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = patterns('apps.profiles.views', url('^$', 'index', name=\n 'profiles'), url('^view/(?P<username>[a-zA-Z0-9_-]+)/$', 'view_profile',\n name='profiles_view'), url('^edit... | [
0,
1,
2,
3
] |
class Model:
def derivativesDependsOn(self, models):
return []
def derivedVariablesDependsOn(self, models):
return []
def initializeSimplifiedModel(self, timeHistory, stateHistory, derivedVariablesHistory):
return False
def computeSimplifiedState(self, args, time):
return []
def comput... | normal | {
"blob_id": "b27e89ff799f26b87a61254e1c4a5f782fcbe605",
"index": 2540,
"step-1": "class Model:\n <mask token>\n\n def derivedVariablesDependsOn(self, models):\n return []\n <mask token>\n <mask token>\n\n def computeSimplifiedDerivedVariables(self, args, time):\n return []\n\n def... | [
4,
5,
7,
8,
10
] |
#!/usr/bin/env python3
import unittest
import solution
class TestMethods(unittest.TestCase):
def LinkedListFromArray(self, values):
if len(values) > 0:
headNode = solution.ListNode(values[0], None)
tailPtr = headNode
if len(values) > 1:
for value in val... | normal | {
"blob_id": "2a3f9c4518df337cfc5e4b1816e7b2b4af62c101",
"index": 8020,
"step-1": "<mask token>\n\n\nclass TestMethods(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def checkLinkedListsAreEqual(self, headNodeA, headNodeB):\n valuesA = self.linkedListToArray(headNodeA)\n ... | [
6,
8,
9,
10,
12
] |
'''Instantiate data parsers for all cities.
If additional city parsers are added, the `bikerrawdata` instance in this file should be updated.
Written by: Anders Ohrn 2020
'''
from dataset_creators.cities import parse_taipei_file, taipei_system, \
parse_london_file, london_system, ... | normal | {
"blob_id": "53bf97d66d0b26c6b5639acd0261604082474e7b",
"index": 8163,
"step-1": "<mask token>\n\n\ndef compile_data(city_labels=None):\n \"\"\"Compile all data into common structure\n\n \"\"\"\n pass\n\n\ndef compile_and_save_data(f_out, city_labels=None):\n \"\"\"Compile and save all data\n\n \"... | [
2,
3,
4,
5,
6
] |
from django.urls import path
from . import views
from django.contrib.auth import views as auth_views
urlpatterns = [
path('',views.index,name='index'),
path('sign',views.sign,name='sign'),
# path('password_reset/',auth_views.PasswordResetView.as_view(),name='password_reset'),
# path('password_reset/do... | normal | {
"blob_id": "7e35c35c8ef443155c45bdbff4ce9ad07b99f144",
"index": 9983,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', views.index, name='index'), path('sign', views.sign,\n name='sign'), path('reset_password/', auth_views.PasswordResetView.\n as_view(template_name='password_... | [
0,
1,
2,
3
] |
import os
import sys
import csv
import math
for i in sys.stdin:
i = float(i)
key = math.floor(i * 10)
print('%s\t%s' % (key, i))
| normal | {
"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
] |
from subprocess import check_output
import json
import datetime
date = datetime.datetime.now()
mo = date.month
day = date.day
year = date.year
str = '{0}-{1}-{2}'.format(mo, day, year)
instances = json.loads(check_output("aws lightsail get-instances", shell=True))
inst_names = []
inst_dict = {}
for instance in instan... | normal | {
"blob_id": "2023e0b749338488e63cbbb475b7a915bccccce0",
"index": 7531,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor instance in instances['instances']:\n inst_names.append(instance['name'])\n inst_dict[instance['name']] = []\nprint(inst_names)\n<mask token>\nfor snapshot in snapshots['instanc... | [
0,
1,
2,
3,
4
] |
/home/runner/.cache/pip/pool/f6/0b/37/37d1907955d15568c921a952a47d6e8fcc905cf4f36ab6f99f5fc7315a | normal | {
"blob_id": "002b795f61645ba2023cdb359167d2a65535d768",
"index": 5710,
"step-1": "/home/runner/.cache/pip/pool/f6/0b/37/37d1907955d15568c921a952a47d6e8fcc905cf4f36ab6f99f5fc7315a",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
from azfs.az_file_client import (
AzFileClient,
export_decorator
)
from azfs.az_file_system import AzFileSystem
from azfs.utils import BlobPathDecoder
from .table_storage import (
TableStorage,
TableStorageWrapper
)
# comparable tuple
VERSION = (0, 2, 14)
# generate __version__ via VERSION tuple
__ve... | normal | {
"blob_id": "e7239b4bc3db9bd427b9be888621f66e81b5edeb",
"index": 2242,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nVERSION = 0, 2, 14\n__version__ = '.'.join(map(str, VERSION))\n__all__ = ['AzFileClient', 'AzFileSystem', 'BlobPathDecoder',\n 'TableStorage', 'TableStorageWrapper', 'export_decorator'... | [
0,
1,
2,
3
] |
num = int(input("Enter the number: "))
print("Multiplication Table of", num)
for i in range(1, 10):
print(num,"a",i,"=",num * i)
| normal | {
"blob_id": "15bf84b716caf66a23706e9292b47ddb9bf4d35e",
"index": 4326,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Multiplication Table of', num)\nfor i in range(1, 10):\n print(num, 'a', i, '=', num * i)\n",
"step-3": "num = int(input('Enter the number: '))\nprint('Multiplication Table of... | [
0,
1,
2,
3
] |
from django.db import models
# Login Admin Model
class AdminLoginModel(models.Model):
user_name = models.CharField(max_length=30,unique=True)
password = models.CharField(max_length=16)
# Swiggy Admin State Table
class AdminStateModel(models.Model):
state_id = models.AutoField(primary_key=True)
sta... | normal | {
"blob_id": "5d4ef314bb7169f5de4795e5c1aca62a1a060bae",
"index": 772,
"step-1": "<mask token>\n\n\nclass AdminCityTable(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass AdminAreaModel(models.Model):\n area_id = models.AutoField(primary_key=True)\n area_name ... | [
7,
10,
14,
15,
16
] |
#!/usr/bin/python3
"Places module"
from flask import jsonify, request, Response, abort
from api.v1.views import app_views
from models import storage
from models.place import Place
@app_views.route('cities/<city_id>/places', strict_slashes=False,
methods=['GET'])
def get_all_places(city_id):
''' g... | normal | {
"blob_id": "d67a2eca4e2fde443b99f5133c2657cdf4ac00de",
"index": 4173,
"step-1": "<mask token>\n\n\n@app_views.route('cities/<city_id>/places', strict_slashes=False, methods=[\n 'GET'])\ndef get_all_places(city_id):\n \"\"\" gets all places in a city \"\"\"\n city = storage.get('City', city_id)\n if ... | [
3,
4,
5,
6,
7
] |
from .tacotron_v2_synthesizer import Tacotron2Synthesizer
| normal | {
"blob_id": "cf2fcd013c3e9992da36806ca93aacb4b5399396",
"index": 3172,
"step-1": "<mask token>\n",
"step-2": "from .tacotron_v2_synthesizer import Tacotron2Synthesizer\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
from typing import List
class Solution:
def findSubsequences(self, nums: List[int]) ->List[List[int]]:
res: List[List[int]] = []
s = set()
def deep(pos: int, tmp: List[int]):
if pos == len(nums):
if len(tmp) < 2:
return
for ... | normal | {
"blob_id": "3edfc1098c775fa31456aa3cc938051b2dbb8697",
"index": 1664,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n\n def findSubsequences(self, nums: List[int]) ->List[List[int]]:\n res: List[List[int]] = []\n s = set()\n\n def deep(pos: int, tmp: List[int... | [
0,
2,
3,
4
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.