code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import numpy as np
def output(i, out):
with open('B-large.out', 'a') as outfile:
outfile.write("Case #{0}: {1}\n".format(i, out))
def solve(i, stack):
cursymbol = stack[0]
counter = 0 if stack[-1] == "+" else 1
for symbol in stack:
if symbol != cursymbol:
... | normal | {
"blob_id": "752679d2484b6b91a734c7cbe4a99bd5676661eb",
"index": 9498,
"step-1": "<mask token>\n\n\ndef output(i, out):\n with open('B-large.out', 'a') as outfile:\n outfile.write('Case #{0}: {1}\\n'.format(i, out))\n\n\ndef solve(i, stack):\n cursymbol = stack[0]\n counter = 0 if stack[-1] == '+... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 13 14:52:03 2018
@author: mayn
"""
import matplotlib.pyplot as plt
import DNA_Object
import json
def draw_area(dna, room):
area_center, area = DNA_Object.get_room_area(room)
plt.plot(area['x'], area['y'], linewidth='0.5', color='k',)
plt.xlim((-15000, 20000... | normal | {
"blob_id": "089bdd6d68a69aff6f3c11f7f5ffb75aed73cd24",
"index": 131,
"step-1": "<mask token>\n\n\ndef draw_area(dna, room):\n area_center, area = DNA_Object.get_room_area(room)\n plt.plot(area['x'], area['y'], linewidth='0.5', color='k')\n plt.xlim((-15000, 20000))\n plt.ylim((-15000, 20000))\n t... | [
7,
9,
11,
12,
13
] |
import numpy as np
import pandas as pd
def fetch_data(faultNumber, position):
df1 = pd.read_csv("./data/TEP_CaseStudy_Fault_" + str(faultNumber) + "_Pos_" + str(position) + "%.csv")
df1.set_index(df1.columns[0])
df1 = df1.drop(columns=[df1.columns[0]])
df2 = pd.read_csv("./data/TEP_CaseStudy_Fault_" ... | normal | {
"blob_id": "d71ec86f68cc81c93a39f15c785c75c2a1023f14",
"index": 2129,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef fetch_data(faultNumber, position):\n df1 = pd.read_csv('./data/TEP_CaseStudy_Fault_' + str(faultNumber) +\n '_Pos_' + str(position) + '%.csv')\n df1.set_index(df1.col... | [
0,
1,
2,
3,
4
] |
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import pandas as pd
df = pd.read_csv('games_data.csv')
names = df['game']
driver = webdriver.Chrome('D:/chromedriver.exe')
driver.get('https://www.google.ca/imghp?hl=en&tab=ri&authuser=0&ogbl')
k = 0
for name in names:
box = ... | normal | {
"blob_id": "6375ac80b081b7eafbc5c3fc7e84c4eff2604848",
"index": 4041,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndriver.get('https://www.google.ca/imghp?hl=en&tab=ri&authuser=0&ogbl')\n<mask token>\nfor name in names:\n box = driver.find_element_by_xpath('//*[@id=\"sbtc\"]/div/div[2]/input')\n ... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
""""
Created on Saturday, January 18, 2020
@author: lieur
This test case sets silver and gold to 0, which in most cases prevent the computer from
buying provinces. This tests to see if the game ends when one more supply car hits 0 (since
silver and gold are already at 0 and the game ends when... | normal | {
"blob_id": "fa833e9cd1e624d9ecfb2fcc6d9e22955c9e4b1e",
"index": 6258,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntestUtility.play_game(supply, supply_order, players, trash)\ntestUtility.display_game_results(players)\n",
"step-3": "<mask token>\nplayer_names = ['Annie', '*Ben', '*Carla']\nnV, nC = ... | [
0,
1,
2,
3,
4
] |
"""storeproject URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/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-... | normal | {
"blob_id": "4a8fa195a573f8001e55b099a8882fe71bcca233",
"index": 8335,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nrouter.register('users', views.CategoryView)\n<mask token>\nif settings.DEBUG:\n urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT\n )\n",
"step-3": ... | [
0,
1,
2,
3,
4
] |
x = 25
y = 43
print(x & y)
print(x >> y)
print(x ^ y)
print(x | y)
| normal | {
"blob_id": "34d011727c93bb4c8ccf64017e7185717ef98667",
"index": 2603,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(x & y)\nprint(x >> y)\nprint(x ^ y)\nprint(x | y)\n",
"step-3": "x = 25\ny = 43\nprint(x & y)\nprint(x >> y)\nprint(x ^ y)\nprint(x | y)\n",
"step-4": null,
"step-5": null,
... | [
0,
1,
2
] |
#Task 4 - writing a code that prints all the commit message from repository
import requests
r = requests.get('https://api.github.com/repos/smeiklej/secu2002_2017/commits')
text = r.json()
#asking the code to print out the commit message for all rows in the text
for row in text:
print row['commit']['message']
| normal | {
"blob_id": "d07046e33bbfa404c354fef3e8990a3fa0203060",
"index": 1843,
"step-1": "#Task 4 - writing a code that prints all the commit message from repository\nimport requests\nr = requests.get('https://api.github.com/repos/smeiklej/secu2002_2017/commits')\ntext = r.json()\n\n#asking the code to print out the com... | [
0
] |
from slacker import Slacker
import vk_api
import time
import logging
from settings import SLACK_TOKEN, VK_LOGIN, VK_PASSWORD, GROUP_ID, TOPIC_ID, ICON_URL
slack = Slacker(SLACK_TOKEN)
class Vts:
def __init__(self):
self.last_comment_id = 0
self.vk = None
def update_vk(self):
if s... | normal | {
"blob_id": "885e02cbf78412d77bd17eba64a8a1a52aaed0df",
"index": 5837,
"step-1": "<mask token>\n\n\nclass Vts:\n\n def __init__(self):\n self.last_comment_id = 0\n self.vk = None\n\n def update_vk(self):\n if self.vk is not None:\n return\n vk_session = vk_api.VkApi(V... | [
7,
8,
9,
10,
11
] |
import tensorflow as tf
import tensorflow_io as tfio
import h5py
class GeneratorVGGNet():
def __call__(self, filename, is_test):
with h5py.File(filename, 'r') as hf:
keys = list(hf.keys())
for key in keys:
if not is_test:
for f, g, z in zip(hf[str(key) + "/left-eye"], hf[str(key) +... | normal | {
"blob_id": "f94fcf6ed54f247093050216c0c331ce188da919",
"index": 9228,
"step-1": "<mask token>\n\n\nclass Dataset:\n\n def __init__(self, config, path, batch_size, shuffle, is_training,\n is_testing):\n self.config = config\n self.is_training = is_training\n self.is_testing = is_te... | [
2,
4,
5,
6,
7
] |
# This file is part of the functional_calculator_oop.py Task
# Create a class called Calculator
class Calculator:
def Add(self, num1, num2):
return num1 + num2
def Subtract(self, num1, num2):
return num1 - num2
def Multiply(self, num1, num2):
return num1 * num2
def Divide(sel... | normal | {
"blob_id": "d2972fb7cff08e15957f9baeaa6fd9a6f5bbb006",
"index": 1127,
"step-1": "class Calculator:\n <mask token>\n\n def Subtract(self, num1, num2):\n return num1 - num2\n <mask token>\n\n def Divide(self, num1, num2):\n return num1 / num2\n\n\n<mask token>\n",
"step-2": "class Calc... | [
3,
4,
5,
6,
7
] |
import pandas as pd
def ranked(country, variety, price, num):
data = pd.read_csv("wine_final.csv")
if num == 0:
return None
if country !='':
data = data.query("country==\"{}\"".format(country))
if variety !='':
data = data.query("variety==\"{}\"".format(variety))
if pric... | normal | {
"blob_id": "d983cb4ae79d8370ed0809b86762c1e2ea125320",
"index": 6614,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef ranked(country, variety, price, num):\n data = pd.read_csv('wine_final.csv')\n if num == 0:\n return None\n if country != '':\n data = data.query('country==... | [
0,
1,
2,
3
] |
import shelve
def quantity_posts():
try:
data = shelve.open('data')
except Exception:
print(Exception)
else:
for key, value in sorted(data.items()):
print(key, ': \t', value, '\n')
finally:
data.close()
if __name__ == "__main__":
print('b... | normal | {
"blob_id": "41c44b32ce3329cbba5b9b336c4266bb20de31f0",
"index": 5151,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef quantity_posts():\n try:\n data = shelve.open('data')\n except Exception:\n print(Exception)\n else:\n for key, value in sorted(data.items()):\n ... | [
0,
1,
2,
3,
4
] |
import Tkinter
import random
secret = random.randint(1, 100)
### TKINTER ELEMENTS ###
window = Tkinter.Tk()
# greeting text
greeting = Tkinter.Label(window, text="Guess the secret number!")
greeting.pack()
# guess entry field
guess = Tkinter.Entry(window)
guess.pack()
# submit button
submit = Tkinter.Button(windo... | normal | {
"blob_id": "59eb705d6d388de9afbcc0df3003f4d4f45f1fbd",
"index": 3989,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ngreeting.pack()\n<mask token>\nguess.pack()\n<mask token>\nsubmit.pack()\nwindow.mainloop()\n",
"step-3": "<mask token>\nsecret = random.randint(1, 100)\nwindow = Tkinter.Tk()\ngreeting... | [
0,
1,
2,
3,
4
] |
## More Review + More Linked Lists ##
##Given a pointer to the head node of a linked list whose data elements are in non-decreasing order, you must delete any duplicate nodes and print the updated list.
##Code handling I/O is provided in the editor. Complete the removeDuplicates(Node) function.
##Note: The head poi... | normal | {
"blob_id": "75990147e4a3dae1b590729ed659e2ddcbfb295d",
"index": 1636,
"step-1": "## More Review + More Linked Lists ##\n\n##Given a pointer to the head node of a linked list whose data elements are in non-decreasing order, you must delete any duplicate nodes and print the updated list.\n##Code handling I/O is... | [
0
] |
from pymt_heat import Heatmodel
heat = Heatmodel()
n = heat.get_component_name()
print(n)
| normal | {
"blob_id": "82801ce564f4f29e084e6f842d7868eb60f582cb",
"index": 6225,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(n)\n",
"step-3": "<mask token>\nheat = Heatmodel()\nn = heat.get_component_name()\nprint(n)\n",
"step-4": "from pymt_heat import Heatmodel\nheat = Heatmodel()\nn = heat.get_comp... | [
0,
1,
2,
3
] |
import matplotlib.pyplot as plt
def visualize_data(positive_images, negative_images):
# INPUTS
# positive_images - Images where the label = 1 (True)
# negative_images - Images where the label = 0 (False)
figure = plt.figure()
count = 0
for i in range(positive_images.shape[0]):
... | normal | {
"blob_id": "ebe79cf1b54870055ce8502430f5fae833f3d96d",
"index": 3121,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef visualize_data(positive_images, negative_images):\n figure = plt.figure()\n count = 0\n for i in range(positive_images.shape[0]):\n count += 1\n figure.add_... | [
0,
1,
2,
3
] |
import boto3
from botocore.exceptions import ClientError
import logging
import subprocess
import string
import random
import time
import os
import sys
import time
import json
from ProgressPercentage import *
import logging
def upload_file(file_name, object_name=None):
RESULT_BUCKET_NAME = "worm4047bucket2"
s... | normal | {
"blob_id": "f405a3e9ccabbba6719f632eb9c51809b8deb319",
"index": 999,
"step-1": "<mask token>\n\n\ndef upload_file(file_name, object_name=None):\n RESULT_BUCKET_NAME = 'worm4047bucket2'\n s3_client = get_client('s3')\n max_retries = 5\n while max_retries > 0:\n try:\n response = s3_... | [
4,
5,
6,
7,
8
] |
from base64 import b64decode
import time
from lampost.context.resource import m_requires
from lampost.datastore.dbo import KeyDBO
from lampost.datastore.dbofield import DBOField
from lampost.datastore.exceptions import DataError
from lampost.model.player import Player
from lampost.util.encrypt import make_hash, check_... | normal | {
"blob_id": "210199ed217db0d7a05e280f20e33496c0795f06",
"index": 9472,
"step-1": "<mask token>\n\n\nclass UserManager:\n <mask token>\n\n def validate_user(self, user_name, password):\n user = self.find_user(user_name)\n if not user:\n raise ClientError()\n self.validate_pas... | [
11,
17,
19,
21,
27
] |
import numpy as np
import string
import networkx as nx
import matplotlib.pyplot as plt
def PlotUndirectedGraph(A,color):
NodesNames = list(string.ascii_uppercase);
NNodes = A.shape[0]
G = nx.DiGraph()
for i in range(NNodes):
G.add_node(NodesNames[i])
for i in range(NNodes):
for ... | normal | {
"blob_id": "61388b2edb35055cccbdc98ed52caedcd0b02983",
"index": 5624,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef PlotUndirectedGraph(A, color):\n NodesNames = list(string.ascii_uppercase)\n NNodes = A.shape[0]\n G = nx.DiGraph()\n for i in range(NNodes):\n G.add_node(Nodes... | [
0,
1,
2,
3
] |
import urllib.request
from bs4 import BeautifulSoup
def getTitlesFromAll(amount, rating='all'):
output = ''
for i in range(1, amount+1):
try:
if rating == 'all':
html = urllib.request.urlopen('https://habr.com/all/page'+ str(i) +'/').read()
else:
... | normal | {
"blob_id": "d6cfea95c76021bdbfbb4471878c653564c9accd",
"index": 1816,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef getTitlesFromAll(amount, rating='all'):\n output = ''\n for i in range(1, amount + 1):\n try:\n if rating == 'all':\n html = urllib.request.... | [
0,
1,
2,
3,
4
] |
# vim: tabstop=4 expandtab autoindent shiftwidth=4 fileencoding=utf-8
from django.contrib.auth.decorators import login_required
from django.contrib.auth import models as auth_models
from django.contrib.auth import forms as auth_forms
from django.contrib.auth import authenticate, login
from django.core.urlresolvers i... | normal | {
"blob_id": "22da05d9bf6139a0306bfb2d1df96e9e2cf6a0c6",
"index": 475,
"step-1": "<mask token>\n\n\n@login_required\ndef get_verification_code(request):\n \"\"\"Maybe ajaxify this in the future\n \"\"\"\n if request.user.get_profile().is_verified:\n messages.info(request, 'Olet jo vahvistanut osoi... | [
1,
2,
3,
4,
5
] |
import requests
import json
import hashlib
import os
def pull_from_solr(output_directory):
solr_url = 'http://54.191.81.42:8888/solr/collection1/select?q=*%3A*&wt=json&indent=true'
# TODO: ask about auth for this
req = requests.get(solr_url)
if req.status_code != 200:
raise
new_data = r... | normal | {
"blob_id": "47b40e4311f76cd620b7c6ed6b39216d866fa857",
"index": 8530,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef pull_from_solr(output_directory):\n solr_url = (\n 'http://54.191.81.42:8888/solr/collection1/select?q=*%3A*&wt=json&indent=true'\n )\n req = requests.get(solr... | [
0,
1,
2,
3
] |
'''
PROBLEM N. 5:
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
'''
'''
Greatest common divisior using the Euclidean Algorithm, vide http://en.wikipedia.org/wi... | normal | {
"blob_id": "0f0ded26e115b954a5ef698b03271ddf2b947334",
"index": 9998,
"step-1": "'''\nPROBLEM N. 5:\n2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.\n\nWhat is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?\n''... | [
0
] |
# -*- encoding: utf-8 -*-
from openerp.tests.common import TransactionCase
from openerp.exceptions import ValidationError
class GlobalTestOpenAcademySession(TransactionCase):
'''
Global Test to openacademy session model.
Test create session and trigger constraint
'''
# Pseudo-constructor methods... | normal | {
"blob_id": "7edd833103e1de92e57559c8a75379c26266963b",
"index": 7835,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass GlobalTestOpenAcademySession(TransactionCase):\n <mask token>\n\n def setUp(self):\n super(GlobalTestOpenAcademySession, self).setUp()\n self.session = self.... | [
0,
4,
5,
6,
7
] |
# 遍历(循环) 出字符串中的每一个元素
str01 = "大发放而非asdfasfasdfa,,,,aadfa阿斯顿发水电费&&"
# ----->字符串中的元素都是有索引的,根据索引可以得到对应的元素
# 而---3
a = str01[3]
print(str01[3])
# 发---1
print(str01[1])
#---->计算字符串的长度
# 这个字符串中 有 35个元素 ,长度是35
l01 = len(str01)
print(l01)
str01 = "大放而非asdfasfasdfa,,,,aadfa阿斯顿发水电费&&"
# 最后一个元素的索引:字符串... | normal | {
"blob_id": "7262d7a82834b38762616a30d4eac38078e4b616",
"index": 6724,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(str01[3])\nprint(str01[1])\n<mask token>\nprint(l01)\n<mask token>\nwhile i <= index_last:\n print(str01[i])\n i += 1\nprint()\nprint('上面的循环结束了 执行到这里')\n<mask token>\n",
"st... | [
0,
1,
2,
3
] |
import time
from tests.test_base import BaseTest
from pages.campo_de_treinamento_page import CampoDeTreinamentoPage
class TestCadastro(BaseTest):
def test_cadastro_com_sucesso(self):
self.campoDeTreinamento = CampoDeTreinamentoPage(self.driver)
self.campoDeTreinamento.fill_name("Everton")
... | normal | {
"blob_id": "4e50a7a757bacb04dc8f292bdaafb03c86042e6c",
"index": 1633,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TestCadastro(BaseTest):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TestCadastro(BaseTest):\n\n def test_cadastro_com_sucesso(self):\n self.campoDeTrein... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.constant.ParamConstants import *
from alipay.aop.api.domain.InsureAdmitDTO import InsureAdmitDTO
class AlipayInsSceneEcommerceInsureCheckModel(object):
def __init__(self):
self._insure_admit_dto_list = None
self._partn... | normal | {
"blob_id": "e616d14827beaa08ab08219421cbf7990cf163fd",
"index": 242,
"step-1": "<mask token>\n\n\nclass AlipayInsSceneEcommerceInsureCheckModel(object):\n\n def __init__(self):\n self._insure_admit_dto_list = None\n self._partner_org_id = None\n self._product_code = None\n self._s... | [
8,
10,
11,
12,
16
] |
from sys import argv
from pyspark import SparkContext
import json
import re
import math
from _datetime import datetime
start_time = datetime.now()
input_file = argv[1]
model_file = argv[2]
stopwords = argv[3]
sc = SparkContext(appName='inf553')
lines = sc.textFile(input_file).map(lambda x: json.loads(x))
stopwords = sc... | normal | {
"blob_id": "e877f16e604682488d85142174ce4f3f6cee3f18",
"index": 7882,
"step-1": "<mask token>\n\n\ndef tf_idf(words):\n word_dict = {}\n for w in words:\n if w in word_dict.keys():\n word_dict[w] += 1\n else:\n word_dict[w] = 1\n max_freq = max(word_dict.values())\n ... | [
2,
3,
4,
5,
6
] |
from world.enums import *
from world.content.species import SPECIES
from world.content.chargen import *
from evennia.utils.evmenu import get_input
from evennia.utils.utils import list_to_string
import re
def start(caller):
if not caller:
return
caller.ndb._menutree.points = {
"attributes": 20,
... | normal | {
"blob_id": "99eeb039e1a369e450247d10ba22a1aa0b35dae9",
"index": 6875,
"step-1": "<mask token>\n\n\ndef start(caller):\n if not caller:\n return\n caller.ndb._menutree.points = {'attributes': 20, 'skills': 20}\n caller.ndb._menutree.character = {'home_planet': None, 'full_name':\n None, 'o... | [
14,
15,
19,
22,
27
] |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | normal | {
"blob_id": "5c291dbc241a80e7f2625ba338a4b9b3a3f3b2d0",
"index": 1119,
"step-1": "<mask token>\n\n\nclass TestRedshiftCreateClusterTrigger:\n <mask token>\n\n @pytest.mark.asyncio\n @async_mock.patch(\n 'airflow.providers.amazon.aws.hooks.redshift_cluster.RedshiftHook.async_conn'\n )\n ... | [
1,
3,
4,
5,
6
] |
import time
# Returns time in seconds for func(arg) to run
def time_func(func, arg):
start = time.time()
func(arg)
return time.time() - start
| normal | {
"blob_id": "7f406c1cd4d56da3a7d5f8739e0b65b0e61cf637",
"index": 5290,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef time_func(func, arg):\n start = time.time()\n func(arg)\n return time.time() - start\n",
"step-3": "import time\n\n\ndef time_func(func, arg):\n start = time.time()\... | [
0,
1,
2,
3
] |
"""
eulerian_path.py
An Eulerian path, also called an Euler chain, Euler trail, Euler walk, or "Eulerian" version of any of these
variants, is a walk on the graph edges of a graph which uses each graph edge in the original graph exactly once.
A connected graph has an Eulerian path iff it has at most two graph vertices ... | normal | {
"blob_id": "73e6930c6866d3ccdbccec925bfc5e7e4702feb9",
"index": 8348,
"step-1": "<mask token>\n\n\nclass EulerianPath:\n <mask token>\n\n\n class EEdge(Edge):\n\n def __init__(self, v=0, w=0, is_used=False):\n super().__init__(v, w)\n self._is_used = is_used\n\n def get... | [
7,
8,
10,
11,
12
] |
newList = []
noDuplicate = []
while True:
elem = input("Enter a letter : (type quit to quit) ")
if elem.lower() != "quit":
newList.append(elem)
else:
break
for item in newList:
if item not in noDuplicate:
noDuplicate.append(item)
print(noDuplicate) | normal | {
"blob_id": "7273592ab8fea10d9a3cde58690063690c74b746",
"index": 4635,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n elem = input('Enter a letter : (type quit to quit) ')\n if elem.lower() != 'quit':\n newList.append(elem)\n else:\n break\nfor item in newList:\n i... | [
0,
1,
2,
3
] |
# This defines a new interface, called MyClosedInterface
# which is closed (does not allow new members to be added).
# "eci" is the schema id for this extension.
{"fs": { "eci": {
"info": {
"name": "Example closed Interface extension",
"version": "1.0",
"date": "Sept. 22, 2016",
"author": "Jeff Teete... | normal | {
"blob_id": "892f90edbd8bd54841b815a6bc29d136c5e84a38",
"index": 7175,
"step-1": "<mask token>\n",
"step-2": "{'fs': {'eci': {'info': {'name': 'Example closed Interface extension',\n 'version': '1.0', 'date': 'Sept. 22, 2016', 'author': 'Jeff Teeters',\n 'contact': 'jteeters@berkeley.edu', 'description':... | [
0,
1,
2
] |
class Solution:
def searchRange(self, nums: List[int], target: int) ->List[int]:
res = [-1, -1]
def binary_serach(left, right, target, res):
if left >= right:
return
mid = (left + right) // 2
if nums[mid] == target:
if res[0] == -... | normal | {
"blob_id": "18b82f83d3bf729eadb2bd5a766f731a2c54a93b",
"index": 1607,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def searchRange(self, nums: List[int], target: int) ->List[int]:\n res = [-1, -1]\n\n def binary_serach(left, rig... | [
0,
1,
2
] |
#CartPoleStarter
import gym
## Defining the simulation related constants
NUM_EPISODES = 1000
def simulate():
## Initialize the "Cart-Pole" environment
env = gym.make('CartPole-v0')
for episode in range(NUM_EPISODES):
done = False
# Reset the environment
obv = env.reset()
... | normal | {
"blob_id": "3c79c528cc19380af8f2883b9e35855e29b151a3",
"index": 7975,
"step-1": "<mask token>\n\n\ndef simulate():\n env = gym.make('CartPole-v0')\n for episode in range(NUM_EPISODES):\n done = False\n obv = env.reset()\n initial_action = 0\n total_reward = 0\n steps = 0... | [
1,
2,
3,
4,
5
] |
from kivy.uix.progressbar import ProgressBar
from kivy.animation import Animation
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.image import Image
from kivy.graphics import Color, Rectangle
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy... | normal | {
"blob_id": "35cd1c45294b826784eab9885ec5b0132624c957",
"index": 4028,
"step-1": "<mask token>\n\n\nclass KaliteUI(object):\n\n def __init__(self, kaliteApp):\n dropdown = DropDown()\n dropdown_btn = Button(text='menu', size_hint_x=None, size_hint_y=\n None, size=(150, 40), font_size=... | [
9,
11,
14,
15,
16
] |
from final import getMood
import pickle
def get_mood(username_t,username_i):
mapping={'sadness':'0,0,255','angry':'255,0,0','happy':'0,255,0','surprise':'139,69,19','neutral':'189,183,107','fear':'255,165,0'}
#Sad: Blue, Angry: Red, Happy: Green, Surprise: Brown, Neutral:Yellow,Fear:Orange
... | normal | {
"blob_id": "aa4fd27382119e3b10d2b57c9b87deff32b5c1ab",
"index": 586,
"step-1": "from final import getMood\nimport pickle\ndef get_mood(username_t,username_i):\n mapping={'sadness':'0,0,255','angry':'255,0,0','happy':'0,255,0','surprise':'139,69,19','neutral':'189,183,107','fear':'255,165,0'}\n #Sa... | [
0
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pytest
class TestMark:
@pytest.mark.demo1
def test_case1(self):
print("testcase1")
@pytest.mark.demo1
def test_case2(self):
print("testcase1")
@pytest.mark.demo2
def test_case3(self):
print("testcase1")
@pytest... | normal | {
"blob_id": "f49c15dca26d987e1d578790e077501a504e560b",
"index": 5814,
"step-1": "<mask token>\n\n\nclass TestMark:\n\n @pytest.mark.demo1\n def test_case1(self):\n print('testcase1')\n\n @pytest.mark.demo1\n def test_case2(self):\n print('testcase1')\n <mask token>\n\n @pytest.ma... | [
4,
5,
6,
7,
8
] |
table = None
width = 1000
height = 1000
def setup():
global table
table = loadTable("flights.csv", "header")
size(width, height)
noLoop()
noStroke()
def draw():
global table
background(255, 255, 255)
for row in table.rows():
from_x = map(row.getFloat('from_long'), -180, 1... | normal | {
"blob_id": "a2eabf4dae931d82e4e9eda87d79031711faf1aa",
"index": 2221,
"step-1": "<mask token>\n\n\ndef mouseMoved():\n redraw()\n",
"step-2": "<mask token>\n\n\ndef setup():\n global table\n table = loadTable('flights.csv', 'header')\n size(width, height)\n noLoop()\n noStroke()\n\n\n<mask t... | [
1,
2,
3,
4,
5
] |
import logging
import datetime
import numpy as np
def log_players(game_map):
logging.debug("------Players Info------")
for player in game_map.all_players():
logging.debug("-----Player ID: {}-----".format(player.id))
for ship in player.all_ships():
logging.debug("----Ship ID: {}----"... | normal | {
"blob_id": "879bb8d67c0e1e8b125ac5994fcb142e3366c9d8",
"index": 9094,
"step-1": "<mask token>\n\n\ndef log_all_ships(myMap):\n logging.debug('Logging all ships:')\n for ship_id, ship in myMap.data_ships[myMap.my_id].items():\n logging.debug('ship_id: {}'.format(ship_id))\n for k, v in ship.i... | [
3,
6,
7,
11,
12
] |
'''
# VariableScope.py
#
# Written by leezhm on 13th March, 2012.
#
# Copyright (C) leezhm(c)126.com. All Right Reserved.
#
# For Chapter 6 Dragon Realm
#
# <<Invent Your Own Computer Games with Python>>
'''
print('Why not ?')
print(True and not False)
# A global variable named "spam"
spam = 1208
# This b... | normal | {
"blob_id": "6af5faaaa9d894dd2b882cfe1bb8b8225780743c",
"index": 630,
"step-1": "<mask token>\n\n\ndef funky():\n spam = 302\n print(spam)\n\n\n<mask token>\n\n\ndef sayHello(name):\n print('Hello, ' + name)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef funky():\n spam = 302\n print(spa... | [
2,
3,
4,
5,
6
] |
from typing import List, cast
import numpy as np
from ..dataset import Transition
from .base import TransitionIterator
class RandomIterator(TransitionIterator):
_n_steps_per_epoch: int
def __init__(
self,
transitions: List[Transition],
n_steps_per_epoch: int,
batch_size: in... | normal | {
"blob_id": "3b9193fcd69b0387222feab96c50bf3617606cdd",
"index": 7329,
"step-1": "<mask token>\n\n\nclass RandomIterator(TransitionIterator):\n _n_steps_per_epoch: int\n <mask token>\n\n def _reset(self) ->None:\n pass\n <mask token>\n\n def _has_finished(self) ->bool:\n return self.... | [
4,
5,
6,
7,
8
] |
# Generated by Django 2.2.5 on 2020-01-05 04:05
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='News',
fields=[
('id', models.AutoField(aut... | normal | {
"blob_id": "d40e1cfa2ef43f698e846c25ac9f5471d69e71a0",
"index": 5253,
"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
] |
# https://docs.python.org/3/library/math.html
# https://metanit.com/python/tutorial/6.2.php
# https://habr.com/ru/post/337260/
# https://habr.com/ru/post/112953/
import math
num = 8
float_num = 2.5
power = 8
rad = 0.5
grad = 90
n = 16
n10 = 1000
base = 2
print("math.pow:", math.pow(num, power)) # проблема точности ... | normal | {
"blob_id": "17db8f7a35004a1f2bd8d098aff39928d20511da",
"index": 7026,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('math.pow:', math.pow(num, power))\nprint('pow:', pow(num, power))\nprint('pow:', pow(num, power, 100))\nprint('fmod:', math.fmod(5, 3))\nprint('fmod:', math.fmod(-1e-100, 1e+100))\... | [
0,
1,
2,
3,
4
] |
SOURCE_FILE = "D:\\temp\\twitter\\tweet.js"
TWITTER_USERNAME = 'roytang'
auto_tags = ["mtg"]
syndicated_sources = ["IFTTT", "Tumblr", "instagram.com", "Mailchimp", "Twitter Web", "TweetDeck", "mtgstorm"]
debug_id = None
# debug_id = "11143081155"
import frontmatter
import json
import requests
import urllib.request
fr... | normal | {
"blob_id": "001d2ae89a2d008fdf6621a1be73de94c766c65f",
"index": 4570,
"step-1": "<mask token>\n\n\ndef get_content(t):\n content = t['full_text']\n if 'entities' in t:\n raw_urls = re.findall(\n 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\\\(\\\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'\n ... | [
3,
8,
11,
14,
15
] |
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import requests
import time
driver = webdriver.Chrome(executable_path='/home/bc/桌面/chromedriver')
driver.get('https://www.zhaopin.com/')
time.sleep(5)
driver.find_element_by_id('KeyWord_kw2').send_keys('技术')
driver.find_element_by_class_name... | normal | {
"blob_id": "fc5a4c27a21c2bd3900a6ad0bff68c249fe29d7a",
"index": 1865,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndriver.get('https://www.zhaopin.com/')\ntime.sleep(5)\ndriver.find_element_by_id('KeyWord_kw2').send_keys('技术')\ndriver.find_element_by_class_name('doSearch').click()\ntime.sleep(5)\n",
... | [
0,
1,
2,
3
] |
import random
import time
import unittest
from math import radians
from maciErrType import CannotGetComponentEx
from DewarPositioner.positioner import Positioner, NotAllowedError
from DewarPositioner.cdbconf import CDBConf
from Acspy.Clients.SimpleClient import PySimpleClient
from DewarPositionerMockers.mock_components... | normal | {
"blob_id": "654adc9b77bbad6ba36dd42125e69e1a4ad1312d",
"index": 9296,
"step-1": "import random\nimport time\nimport unittest\nfrom math import radians\nfrom maciErrType import CannotGetComponentEx\nfrom DewarPositioner.positioner import Positioner, NotAllowedError\nfrom DewarPositioner.cdbconf import CDBConf\nf... | [
0
] |
"""
Given a random set of numbers, Print them in sorted order.
Example 1:
Input:
N = 4
arr[] = {1, 5, 3, 2}
Output: {1, 2, 3, 5}
Explanation: After sorting array will
be like {1, 2, 3, 5}.
"""
#complexity--> n*log n
def sortarray(arr):
for i in range(1,len(arr)):
key=arr[i]
j=i-1
while(j>... | normal | {
"blob_id": "70cef88f3fe93d370e5d21a2b00b761ce530a099",
"index": 6366,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef sortarray(arr):\n for i in range(1, len(arr)):\n key = arr[i]\n j = i - 1\n while j >= 0 and arr[j] > key:\n arr[j + 1] = arr[j]\n j ... | [
0,
1,
2,
3
] |
import sqlalchemy
from .base import Base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
class ModelSpellVariantPair(Base):
__tablename__ = "spell_variant_pair"
uuid = Column(
UUID(as_uuid=True),
... | normal | {
"blob_id": "4958d6d88b762e6fbe860123b7274c16b6452605",
"index": 7674,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ModelSpellVariantPair(Base):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ModelSpellVariantPair(Base):\n _... | [
0,
1,
2,
3,
4
] |
from covid import FuzzyNet
import numpy as np
import time
if __name__ == '__main__':
# mx1,mx2,mx3,my1,my2,my3, dx1,dx2,dx3,dy1,dy2,dy3, p1,p2,p3,p4,p5,p6,p7,p8,p9, q1,q2,q3,q4,q5,q6,q7,q8,q9, r1,r2,r3,r4,r5,r6,r7,r8,r9
generations = 100
for generation in range(generations):
population = np.rando... | normal | {
"blob_id": "99f50d393e750bd8fa5bee21d99f08d20b9f5fe9",
"index": 9102,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n generations = 100\n for generation in range(generations):\n population = np.random.randint(0, 255, size=(200, 39), dtype=np.uint8)\n print... | [
0,
1,
2,
3
] |
# -*- coding: utf-8
# @paidatocandeira
# Acessa arquivo do CADASTRO NACIONAL DE EMPRESAS INIDÔNEAS E SUSPENSAS (CEIS) que está no portal da Transparência
#
import pandas as pd
# Parte 2 - pode rodar no Jupyter para ver resultados
# Método lendo direto o arquivo disponível para download (http://www.portaltransparencia... | normal | {
"blob_id": "d2325b07d11e64df0b26d0de9992a6f496e92a30",
"index": 2879,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nceis_arquivo.reset_index()\nceis_arquivo.info()\n<mask token>\nceis_sp.to_csv('ceis_sp.csv')\n",
"step-3": "<mask token>\nceis_arquivo = pd.read_csv('20180225_CEIS.csv', sep=';', encodi... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
#coding:utf-8
import sys
import time
reload(sys)
sys.setdefaultencoding('utf8')
from bs4 import BeautifulSoup
import requests
import csv
import codecs
import xlwt
#from word_power_dict import get_url_dict
#from Vocabulary_Toefl_MP3s_5000_Words_Memory_Course_dict import get_url_dict
#from new_para... | normal | {
"blob_id": "fab1d2270ae906ca92cf3be2c2d9767737ea6083",
"index": 6364,
"step-1": "#!/usr/bin/env python\n#coding:utf-8\n\nimport sys\nimport time\nreload(sys)\nsys.setdefaultencoding('utf8')\nfrom bs4 import BeautifulSoup\nimport requests\nimport csv\nimport codecs\nimport xlwt\n#from word_power_dict import get_... | [
0
] |
#!/usr/bin/env python3
#
# Exploit for "assignment" of GoogleCTF 2017
#
# CTF-quality exploit...
#
# Slightly simplified and shortened explanation:
#
# The bug is a UAF of one or both values during add_assign() if a GC is
# triggered during allocate_value(). The exploit first abuses this to leak a
# pointer into the he... | normal | {
"blob_id": "e4a05cbfd0959402eacf21959c68e449d15b1e74",
"index": 7651,
"step-1": "<mask token>\n\n\ndef e(d):\n \"\"\"Encode the given string instance using UTF-8.\"\"\"\n return d.encode('UTF-8')\n\n\n<mask token>\n\n\ndef u32(d):\n \"\"\"Return the number represented by d when interpreted as a 32-bit ... | [
30,
44,
58,
59,
63
] |
# -*- coding: utf-8 -*-
#!/usr/bin/env python
from subprocess import call
def query_DB_satellites(outputpath="../data/", user="anonimo", passwd="secreto"):
"""
Queries the multidark database to extract all the haloes in the box within a ID range.
The output is stored as an ascii (CSV) file.
"""
#... | normal | {
"blob_id": "f1021bfbf11886a01a84033b880d648c3286856b",
"index": 4311,
"step-1": "# -*- coding: utf-8 -*-\n#!/usr/bin/env python\nfrom subprocess import call\n\n\ndef query_DB_satellites(outputpath=\"../data/\", user=\"anonimo\", passwd=\"secreto\"):\n \"\"\"\n Queries the multidark database to extract all... | [
0
] |
import cv2
import numpy as np
LOWEST_MATCHES_NUMBER = 30
sift = cv2.xfeatures2d.SIFT_create()
bf = cv2.BFMatcher();
train_img = cv2.imread('Photo/demo2.jpg', 0)
train_kp, train_desc = sift.detectAndCompute(train_img, None);
camera = cv2.VideoCapture(0);
while (True):
det, frame_with_color = camera.read();
f... | normal | {
"blob_id": "1a78d9e0807824263fd46547d5b75c61610456d4",
"index": 1912,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n det, frame_with_color = camera.read()\n frame = cv2.cvtColor(frame_with_color, cv2.COLOR_BGR2GRAY)\n frame_kp, frame_desc = sift.detectAndCompute(frame, None)\n ... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
__all__ = "corner"
import logging
import numpy as np
from corner.core import corner_impl
try:
from corner.arviz_corner import arviz_corner
except ImportError:
arviz_corner = None
def corner(
data,
bins=20,
*,
# Original corner parameters
range=None,
axes_sc... | normal | {
"blob_id": "ae998fb17b8d6f4f5c8871a0ebe86a039501ec99",
"index": 5959,
"step-1": "<mask token>\n\n\ndef corner(data, bins=20, *, range=None, axes_scale='linear', weights=None,\n color=None, hist_bin_factor=1, smooth=None, smooth1d=None, labels=None,\n label_kwargs=None, titles=None, show_titles=False, titl... | [
1,
2,
3,
4,
5
] |
from flask import current_app
def get_logger():
return current_app.logger
def debug(msg, *args, **kwargs):
get_logger().debug(msg, *args, **kwargs)
def info(msg, *args, **kwargs):
get_logger().info(msg, *args, **kwargs)
def warn(msg, *args, **kwargs):
get_logger().warning(msg, *args, **kwargs)
... | normal | {
"blob_id": "355e2799e89dfea4f775480ea7d829a075f92473",
"index": 4241,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_logger():\n return current_app.logger\n\n\n<mask token>\n\n\ndef info(msg, *args, **kwargs):\n get_logger().info(msg, *args, **kwargs)\n\n\n<mask token>\n",
"step-3": ... | [
0,
2,
3,
4,
6
] |
import queue
import copy
import heapq
import sys
sys.setrecursionlimit(100000)
dx =[1,0,0,-1]
dy=[0,1,-1,0]
class PriorityQueue:
pq=[]
elements={}
task=0
def insert(self , priority,x_val,y_val):
entry = [priority, self.task,x_val,y_val]
self.elements[self.task]=entry
heapq.hea... | normal | {
"blob_id": "6192099bdecffd9ce3576f4034567478145115a0",
"index": 1291,
"step-1": "<mask token>\n\n\nclass PriorityQueue:\n pq = []\n elements = {}\n task = 0\n\n def insert(self, priority, x_val, y_val):\n entry = [priority, self.task, x_val, y_val]\n self.elements[self.task] = entry\n ... | [
12,
17,
18,
23,
25
] |
import requests as r
import re
class web_scrap:
seed=""
result=""
tag_attr=[]
def __init__(self,seed):
self.seed=seed
self.set_tag()
self.set_attr()
self.fetch_web(self.seed)
self.crawl()
def fetch_web(self,link):
... | normal | {
"blob_id": "f26dc3139413c4ed4b04484c095a433e53039cdb",
"index": 3028,
"step-1": "<mask token>\n\n\nclass web_scrap:\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, seed):\n self.seed = seed\n self.set_tag()\n self.set_attr()\n self.fetch_web(self.seed)... | [
8,
10,
11,
12,
13
] |
if answ[1] == 'дата':
apisay(datetime.date.today(), toho, torep)
| normal | {
"blob_id": "66444047f9e5eea845c8ac2dbaaf16fc2914d6ec",
"index": 370,
"step-1": "<mask token>\n",
"step-2": "if answ[1] == 'дата':\n apisay(datetime.date.today(), toho, torep)\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
def postfix(expression):
operators, stack = '+-*/', []
for item in expression.split():
if item not in operators:
stack.append(item)
else:
operand_1, operand_2 = stack.pop(), stack.pop()
stack.append(str(eval(operand_2 + item + operand_1)))
return int(float... | normal | {
"blob_id": "3ae0149af78216d6cc85313ebaa6f7cd99185c05",
"index": 531,
"step-1": "<mask token>\n",
"step-2": "def postfix(expression):\n operators, stack = '+-*/', []\n for item in expression.split():\n if item not in operators:\n stack.append(item)\n else:\n operand_1,... | [
0,
1
] |
__all__ = ["AddonsRepository", "Addon", "Addons", "Utils"] | normal | {
"blob_id": "054d7e4bd51110e752a18a5c0af4432a818ef3b8",
"index": 7974,
"step-1": "<mask token>\n",
"step-2": "__all__ = ['AddonsRepository', 'Addon', 'Addons', 'Utils']\n",
"step-3": "__all__ = [\"AddonsRepository\", \"Addon\", \"Addons\", \"Utils\"]",
"step-4": null,
"step-5": null,
"step-ids": [
... | [
0,
1,
2
] |
from soln import Solution
import pytest
@pytest.mark.parametrize(
["inp1", "inp2", "res"],
[
("112", 1, "11"),
("11000002000304", 4, "4"),
("9119801020", 6, "20"),
("111111", 3, "111"),
("1432219", 3, "1219"),
("10200", 1, "200"),
("10", 2, "0"),
... | normal | {
"blob_id": "7eb4efb64a5a5b2e8c2dfa965411ff4c7aad6e35",
"index": 6525,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.mark.parametrize(['inp1', 'inp2', 'res'], [('112', 1, '11'), (\n '11000002000304', 4, '4'), ('9119801020', 6, '20'), ('111111', 3, '111'\n ), ('1432219', 3, '1219'), ('1... | [
0,
1,
2,
3
] |
# coding=utf8
from __future__ import unicode_literals, absolute_import, division, print_function
"""This is a method to read files, online and local, and cache them"""
import os
from .Read import read as botread
from .Database import db as botdb
class BotNotes():
def __init__(self):
self.notes = botdb.... | normal | {
"blob_id": "2a062f0c2836850320cdd39eee6a354032ba5c33",
"index": 4565,
"step-1": "<mask token>\n\n\nclass BotNotes:\n\n def __init__(self):\n self.notes = botdb.get_plugin_value('SpiceBot_Release_Notes', 'notes'\n ) or dict()\n self.dir_to_scan = botread.get_config_dirs('SpiceBot_Rele... | [
3,
4,
5,
6,
7
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Brateaqu, Farolflu"
__copyright__ = "Copyright 2019"
__credits__ = ["Quentin BRATEAU", "Luca FAROLFI"]
__license__ = "GPL"
__version__ = "1.0"
__email__ = ["quentin.brateau@ensta-bretagne.org", "luca.farolfi@ensta-bretagne.org"]
# Importing modules
import... | normal | {
"blob_id": "7cb75195df567a5b65fe2385423b0082f3b9de4b",
"index": 1051,
"step-1": "<mask token>\n\n\nclass GameMap(list):\n <mask token>\n\n def __init__(self):\n super().__init__()\n self.xmax = 5\n self.ymax = 5\n self.__nb_elephants = 0\n self.__nb_rhinoceros = 0\n ... | [
8,
9,
11,
15,
18
] |
"""Write a program that asks the user to enter a word and then
capitalizes every other letter of that word. So if the user enters "rhinoceros",
the program should print "rHiNoCeRoS"""
word=str(input("please enter the word\n"))
count=0
for char in word:
if count==0:
print(char.upper(),end="")
count=1
... | normal | {
"blob_id": "bc837d95ef22bd376f8b095e7aeb1f7d15c0e22e",
"index": 941,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor char in word:\n if count == 0:\n print(char.upper(), end='')\n count = 1\n else:\n print(char.lower(), end='')\n count = 0\n",
"step-3": "<mask toke... | [
0,
1,
2,
3
] |
# processing functions for diagrams
import torch
import numpy as np
def remove_filler(dgm, val=np.inf):
"""
remove filler rows from diagram
"""
inds = (dgm[:,0] != val)
return dgm[inds,:]
def remove_zero_bars(dgm):
"""
remove zero bars from diagram
"""
inds = dgm... | normal | {
"blob_id": "ac459bff6d4281ce07b70dbccde3243412ddb414",
"index": 3155,
"step-1": "<mask token>\n\n\ndef remove_zero_bars(dgm):\n \"\"\"\n remove zero bars from diagram\n \"\"\"\n inds = dgm[:, 0] != dgm[:, 1]\n return dgm[inds, :]\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef remove_fil... | [
1,
2,
3,
4,
5
] |
from turtle import *
from freegames import vector
def line(start, end):
"Draw line from start to end."
up()
goto(start.x, start.y)
down()
goto(end.x, end.y)
def square(start, end):
"Draw square from start to end."
up()
goto(start.x, start.y)
down()
begin_fill()
... | normal | {
"blob_id": "803283c9dac78c821373fa1025008b04919df72c",
"index": 5404,
"step-1": "<mask token>\n\n\ndef line(start, end):\n \"\"\"Draw line from start to end.\"\"\"\n up()\n goto(start.x, start.y)\n down()\n goto(end.x, end.y)\n\n\ndef square(start, end):\n \"\"\"Draw square from start to end.\... | [
7,
8,
9,
10,
11
] |
class Solution:
"""
https://leetcode.com/problems/game-of-life/
289. Game of Life
Medium
--------------------
According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."
Given a ... | normal | {
"blob_id": "5b6ed75279b39a1dad1bf92535c4b129bb599350",
"index": 3612,
"step-1": "class Solution:\n <mask token>\n\n def gameOfLife(self, board):\n \"\"\"\n Do not return anything, modify board in-place instead.\n \"\"\"\n self.gameOfLife_2(board)\n\n def gameOfLife_1(self, b... | [
4,
6,
7,
8,
9
] |
from django.contrib import admin
from .models import Profile
from django.contrib.admin.templatetags.admin_list import admin_actions
admin.site.register(Profile)
# Register your models here.
| normal | {
"blob_id": "89c44d35559504501e4333ea6ff4d3528f1a4c4f",
"index": 5171,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(Profile)\n",
"step-3": "from django.contrib import admin\nfrom .models import Profile\nfrom django.contrib.admin.templatetags.admin_list import admin_actions\nadmin.... | [
0,
1,
2,
3
] |
import numpy as np
import csv
class PriceTracker:
def __init__(self):
pass
def getValue(self, i):
pass
class CsvTracker:
def __init__(self, csv_file):
self.current_row = 61
self.csv_file_content = []
self.csv_file = csv.reader(csv_file, delimiter =',')
fo... | normal | {
"blob_id": "eb827998f1ba75ffb95751ddb2b31d4d0e54358b",
"index": 8273,
"step-1": "import numpy as np\nimport csv\n\nclass PriceTracker:\n\n def __init__(self):\n pass\n\n def getValue(self, i):\n pass\n\n\nclass CsvTracker:\n def __init__(self, csv_file):\n self.current_row = 61\n ... | [
0
] |
from setuptools import setup
setup(name='gym_asset_allocation',
version='0.0.1',
install_requires=['gym','numpy','pandas','quandl'] # And any other dependencies
) | normal | {
"blob_id": "952f8341f0fcbe6f3f3d1075ce345e61967a4336",
"index": 4381,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='gym_asset_allocation', version='0.0.1', install_requires=['gym',\n 'numpy', 'pandas', 'quandl'])\n",
"step-3": "from setuptools import setup\nsetup(name='gym_asset_alloca... | [
0,
1,
2,
3
] |
import logging as log
from time import monotonic
import re
from jmap.account import ImapAccount
import jmap.core as core
import jmap.mail as mail
import jmap.submission as submission
import jmap.vacationresponse as vacationresponse
import jmap.contacts as contacts
import jmap.calendars as calendars
from jmap import er... | normal | {
"blob_id": "aac3b2478980d3a5453451cb848afcfd6aca1743",
"index": 1680,
"step-1": "<mask token>\n\n\ndef handle_request(user, data):\n results = []\n resultsByTag = {}\n api = Api(user, data.get('createdIds', None))\n for capability in data['using']:\n CAPABILITIES[capability].register_methods(... | [
6,
7,
8,
9,
10
] |
from django.db import models
# Create your models here.
from django.db import models
# Create your models here.
class Project(models.Model):
project_id = models.IntegerField(primary_key=True)
project_name = models.CharField(max_length=50)
project_description = models.CharField(max_length=200, blank=True, ... | normal | {
"blob_id": "2783fc24806c323ab4ac44fbac55eef73142ab80",
"index": 7710,
"step-1": "<mask token>\n\n\nclass Facility(models.Model):\n facility_id = models.IntegerField(primary_key=True)\n facility_name = models.CharField(max_length=50)\n facility_description = models.CharField(max_length=100, blank=True,\... | [
4,
5,
6,
7,
8
] |
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
] |
from django.contrib import admin
from ticket.models import Ticket, UserTicket, AuxiliaryTicket
@admin.register(Ticket)
class TicketAdmin(admin.ModelAdmin):
pass
@admin.register(AuxiliaryTicket)
class AuxiliaryTicketAdmin(admin.ModelAdmin):
pass
@admin.register(UserTicket)
class UserTicketAdmin(admin.Model... | normal | {
"blob_id": "c73a199d1c1c1867f3d53ceebf614bc9b65c0d5e",
"index": 280,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@admin.register(AuxiliaryTicket)\nclass AuxiliaryTicketAdmin(admin.ModelAdmin):\n pass\n\n\n@admin.register(UserTicket)\nclass UserTicketAdmin(admin.ModelAdmin):\n pass\n",
"st... | [
0,
2,
3,
4
] |
from flask import Flask, jsonify, make_response, request
app = Flask(__name__)
VERSION = (0, 1, 0)
VERSION_STRING = "{}.{}.{}".format(*VERSION)
LANG_ID = "lang.natural.english"
@app.errorhandler(404)
def not_found(error):
return make_response(jsonify({'error': 'Not found'}), 404)
@app.route("/")
def entry()... | normal | {
"blob_id": "49e1dc98ecc2e5c12c6e520721a6c0a7c2665cca",
"index": 3450,
"step-1": "<mask token>\n\n\n@app.errorhandler(404)\ndef not_found(error):\n return make_response(jsonify({'error': 'Not found'}), 404)\n\n\n<mask token>\n\n\n@app.route('/api/{}/reason/apply'.format(VERSION_STRING), methods=['GET',\n '... | [
4,
5,
9,
10,
11
] |
import os
import json
from nltk.corpus import wordnet as wn
from itertools import combinations #計算排列組合
# 需要被計算的分類
myTypes = ['animal', 'vehicle', 'food', 'fashion', 'dog', 'cat', 'car', 'motorcycle']
# 計算完網紅權重存放的位置
scorePath = "..\\data\\score"
# getUsersData.py儲存網紅貼文資料的json檔案,拿來計算分數
usersDataFile = "..\\data\\us... | normal | {
"blob_id": "879482e4df9c3d7f32d9b2a883201ae043e1189f",
"index": 871,
"step-1": "<mask token>\n\n\ndef get_similar_words(words):\n words = [w.lower() for w in words]\n if len(words) > 1:\n maxScore = 0\n firstWord = ''\n secondWord = ''\n labelCom = list(combinations(words, 2))\... | [
1,
3,
4,
5,
6
] |
import shutil
total, used, free = shutil.disk_usage("/")
print("Total: %d MiB" % (total // (2**20)))
print("Used: %d MiB" % (used // (2**20)))
print("Free: %d MiB" % (free // (2**20)))
from Camera import Camera
import time
import cv2
devices = Camera.getDevicesList()
print(devices)
i=0
Cameras = []
for device in... | normal | {
"blob_id": "5cdedce5f984f53b8e26d1580a9040b26023f247",
"index": 2910,
"step-1": "<mask token>\n\n\ndef gen(task_id):\n while True:\n print('Thread runned ' + str(task_id))\n img = Cameras[task_id].getImg()\n ret, jpeg = cv2.imencode('.jpg', img)\n frame = jpeg.tobytes()\n y... | [
6,
7,
8,
9,
10
] |
#!/usr/bin/env python
"""
Usage:
generate-doc <layer-definition>
generate-doc --help
generate-doc --version
Options:
--help Show this screen.
--version Show version.
"""
from docopt import docopt
import openmaptiles
from openmaptiles.tileset import Layer
from openmaptiles.docs import ... | normal | {
"blob_id": "991b894c4c0fb9cb90aef0542227e001a3a3bb0d",
"index": 9651,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n args = docopt(__doc__, version=openmaptiles.__version__)\n layer = Layer.parse(args['<layer-definition>'])\n markdown = collect_documentation(layer)\... | [
0,
1,
2,
3
] |
# coding: utf-8
import logging
def __gen_logger():
result = logging.getLogger('superslick')
return result
logger = __gen_logger() | normal | {
"blob_id": "cee9deeeabfec46ee5c132704e8fd653e55987f3",
"index": 3430,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef __gen_logger():\n result = logging.getLogger('superslick')\n return result\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef __gen_logger():\n result = logging.get... | [
0,
1,
2,
3,
4
] |
print(180 / 4)
| normal | {
"blob_id": "509129052f97bb32b4ba0e71ecd7b1061d5f8da2",
"index": 38,
"step-1": "<mask token>\n",
"step-2": "print(180 / 4)\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
import pygame
pygame.init()
class Tiles:
Size = 32
Blocked = []
Blocked_Types = ["5", "6", "7", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "25", "27", "28", "29"]
def Blocked_At(pos):
if list(pos) in Tiles.Blocked:
return True
else:
... | normal | {
"blob_id": "3d1f7794763b058cc22c543709a97cb021d0fd23",
"index": 8404,
"step-1": "<mask token>\n\n\nclass Tiles:\n <mask token>\n <mask token>\n <mask token>\n\n def Blocked_At(pos):\n if list(pos) in Tiles.Blocked:\n return True\n else:\n return False\n\n def L... | [
3,
4,
5,
6,
7
] |
# RUSH HOUR
m = int(input('Enter number of males:'))
f = int(input('Enter number of females:'))
if m%20 == 0:
m2 = m//20
c = 20
else:
m2 = m//20+1
c = m%20
f2 = f - 10*m2
if f2 <= 0 or f2-(20-c) <=0:
print('Number of trains needed: '+str(m2))
else:
print('Number of trains ... | normal | {
"blob_id": "3c6ef57501e01da79f894b36726a93a3a5e0a8f6",
"index": 8068,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif m % 20 == 0:\n m2 = m // 20\n c = 20\nelse:\n m2 = m // 20 + 1\n c = m % 20\n<mask token>\nif f2 <= 0 or f2 - (20 - c) <= 0:\n print('Number of trains needed: ' + str(m2... | [
0,
1,
2,
3
] |
# Generated by Django 3.0.3 on 2020-04-27 07:06
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('account', '0002_profile_favorites'),
]
operations = [
migrations.RemoveField(
model_name='profile',
name='favorites',
... | normal | {
"blob_id": "1e83fedb8a5ed51704e991aeaa4bde20d5316d11",
"index": 2351,
"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 = [('account', '... | [
0,
1,
2,
3,
4
] |
from Models.AdminPageModel import AdminPageModel
class StudentDebtsController:
def __init__(self, master, model, view):
self._master = master
self._model = model
self._view = view
def BackToAdminPage(self):
from Views.AdminPage import AdminPage
self._master.switch_fra... | normal | {
"blob_id": "8aacc8dbfdd70d24689ae17b9c29b1ffc80fb231",
"index": 9013,
"step-1": "<mask token>\n\n\nclass StudentDebtsController:\n\n def __init__(self, master, model, view):\n self._master = master\n self._model = model\n self._view = view\n <mask token>\n <mask token>\n <mask t... | [
2,
3,
6,
7,
8
] |
import csv
from itertools import chain, combinations
import generation
import time
pi = []
wi = []
di = []
n = input("How many tasks do you want to schedule ? \n")
k=tuple(range(1,n+1))
#la fonction qui supprime un element dans l'ensemble des taches, elle facilite comment retrouver les sous taches de J
def ... | normal | {
"blob_id": "ddab4d014c000dd96bad932adac75e4eec065483",
"index": 9644,
"step-1": "<mask token>\n\n\ndef all_subsets(ss, i):\n return chain(*map(lambda x: combinations(ss, x), range(i, i + 1)))\n\n\n<mask token>\n\n\ndef f1(i):\n return wi[i[0] - 1] * max(0, pi[i[0] - 1] - di[i[0] - 1])\n\n\ndef f2(i):\n ... | [
3,
5,
6,
7,
8
] |
../testing.py | normal | {
"blob_id": "616ff35f818130ebf54bd33f67df79857cd45965",
"index": 6952,
"step-1": "../testing.py",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
from rest_framework import status
from rest_framework.response import Response
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
from playlist.models import Song, AccountSong, Genre, AccountGenre
from account.models import Account
from play... | normal | {
"blob_id": "ff53a549222b0d5e2fcb518c1e44b656c45ce76e",
"index": 5183,
"step-1": "<mask token>\n\n\n@api_view(['POST'])\n@permission_classes((IsAuthenticated,))\ndef create_account_genre_view(request):\n title = request.data.get('title', '0')\n try:\n genre = Genre.objects.get(title=title)\n exce... | [
4,
5,
6,
7,
8
] |
def mais_populoso(dic):
p = 0
sp = 0
for t, i in dic.items():
for m in dic[t].values():
p += m
if p > sp:
sp = p
x = t
return x
| normal | {
"blob_id": "2cbce618d1ec617d1c7dc0e9792b6a49361ec5a4",
"index": 13,
"step-1": "<mask token>\n",
"step-2": "def mais_populoso(dic):\n p = 0\n sp = 0\n for t, i in dic.items():\n for m in dic[t].values():\n p += m\n if p > sp:\n sp = p\n x = t\n return ... | [
0,
1
] |
import csv
from sys import argv
import re
import sys
datasave=[]
if len(argv) is not 3: #stop usage if not correct input
print('Usage: python dna.py data.csv sequence.txt')
sys.exit()
#open CSV file and save
with open (argv[1],'r') as csv_file:
datafile = csv.reader(csv_file)
line_count = 0
for ... | normal | {
"blob_id": "1eeb7a539f43e9fb013494e2aa0d81b4eab0ae1a",
"index": 9353,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif len(argv) is not 3:\n print('Usage: python dna.py data.csv sequence.txt')\n sys.exit()\nwith open(argv[1], 'r') as csv_file:\n datafile = csv.reader(csv_file)\n line_count ... | [
0,
2,
3,
4,
5
] |
#!/usr/bin/env python3
def main():
pass
def handle_result(args, result, target_window_id, boss):
if args[1] == "next":
boss.active_tab_manager.next_tab(1)
elif args[1] == "previous":
boss.active_tab_manager.next_tab(-1)
boss.active_tab.neighboring_window(args[1])
handle_result.no_ui... | normal | {
"blob_id": "3a7f9bf5420b2d3587f1988c35f2f88bd2fa2b32",
"index": 2771,
"step-1": "<mask token>\n",
"step-2": "def main():\n pass\n\n\n<mask token>\n",
"step-3": "def main():\n pass\n\n\ndef handle_result(args, result, target_window_id, boss):\n if args[1] == 'next':\n boss.active_tab_manager.... | [
0,
1,
2,
3,
4
] |
# Generated from /home/mridul/PycharmProjects/BTP_2k18-19/PlSql.g4 by ANTLR 4.7.2
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys
def serializedATN():
with StringIO() as buf:
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\u020e")
buf.write("\u... | normal | {
"blob_id": "b6dbed95b321ac93c712c4735d601a00650b8dc4",
"index": 1552,
"step-1": "<mask token>\n\n\nclass PlSqlLexer(Lexer):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <ma... | [
1,
3,
4,
5,
6
] |
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Andre Anjos <andre.anjos@idiap.ch>
# Sat Dec 17 14:41:56 2011 +0100
#
# Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland
"""Run tests on the libsvm machine infrastructure.
"""
import os
import numpy
import tempfile
import pkg_resources
imp... | normal | {
"blob_id": "c24be05700e5ee043d09d6f2e78cb3de1e7088f1",
"index": 6242,
"step-1": "<mask token>\n\n\ndef F(f):\n \"\"\"Returns the test file on the \"data\" subdirectory\"\"\"\n return pkg_resources.resource_filename(__name__, os.path.join('data', f))\n\n\n<mask token>\n\n\ndef load_expected(filename):\n ... | [
8,
9,
12,
13,
17
] |
#!/usr/bin/env python2.7
# Google APIs
from oauth2client import client, crypt
CLIENT_ID = '788221055258-j59svg86sv121jdr7utnhc2rs9tkb9s4.apps.googleusercontent.com'
def fetchIdToken():
url = 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='
f = urllib.urlopen(url + urllib.urlencode(CLIENT_ID))
i... | normal | {
"blob_id": "2251a6064998f25cca41b018a383053d73bd09eb",
"index": 2321,
"step-1": "<mask token>\n\n\ndef getIdInfo(token):\n try:\n idinfo = client.verify_id_token(token, CLIENT_ID)\n if idinfo['aud'] not in [CLIENT_ID]:\n return None\n if idinfo['iss'] not in ['accounts.google.... | [
1,
2,
3,
4,
5
] |
# Generated by Django 3.1.2 on 2020-10-29 06:04
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
ope... | normal | {
"blob_id": "87e17eb6fa91be09ac9afa43c4e58054faa77477",
"index": 5944,
"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
] |
from django.db import models
from django.core.validators import RegexValidator, MaxValueValidator
# from Delivery.models import Delivery
# from Customers.models import Customer, Address, Order, Item
# Create your models here.
class Restaurant(models.Model):
Restaurant_ID = models.AutoField(primary_key=True)
... | normal | {
"blob_id": "7ea1ee7c55cd53f7137c933790c3a22957f0ffea",
"index": 4987,
"step-1": "<mask token>\n\n\nclass Food(models.Model):\n Food_ID = models.AutoField(primary_key=True)\n Food_Name = models.CharField(max_length=250)\n Food_Pic = models.ImageField(upload_to='Restaurants/Pictures/Food')\n Food_Cate... | [
2,
4,
5,
6,
8
] |
#
# PySNMP MIB module AN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:22:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
... | normal | {
"blob_id": "b16e64edd0ff55a424ce3d4589321ee4576e930c",
"index": 3965,
"step-1": "<mask token>\n\n\nclass DisplayString(OctetString):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass DisplayString(OctetString):\n subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 255)\n... | [
1,
2,
3,
4,
5
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.