code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
"""AOC Day 13""" import pathlib import time TEST_INPUT = """6,10 0,14 9,10 0,3 10,4 4,11 6,0 6,12 4,1 0,13 10,12 3,4 3,0 8,4 1,10 2,14 8,10 9,0 fold along y=7 fold along x=5""" def read_input(input_path: str) -> str: """take input file path and return a str with the file's content""" with open(input_path, '...
normal
{ "blob_id": "bda28e5a0cb8a3dddea58c9c59a165b31274ac03", "index": 5225, "step-1": "<mask token>\n\n\ndef extract(input_data: str) ->tuple:\n \"\"\"take input data and return the appropriate data structure\"\"\"\n sheet = set()\n folds = list()\n s_instr, f_instr = input_data.split('\\n\\n')\n for l...
[ 5, 8, 10, 11, 12 ]
# Generated by Django 3.2 on 2021-05-22 06:54 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Recuerdos', fields=[ ('id', models.BigAutoFie...
normal
{ "blob_id": "89d0d5d13c5106c504c6727c7784f048a30495dc", "index": 5560, "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 ]
# -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> # <codecell> import pylab as pl import pymc as mc import book_graphics reload(book_graphics) # <markdowncell> # Uniform points in an $n$-dimensional ball # ========================================= # # This notebook implements and compares samplers ...
normal
{ "blob_id": "8283bdab023e22bba3d8a05f8bda0014ee19adee", "index": 4286, "step-1": "<mask token>\n\n\nclass UniformBall(mc.Gibbs):\n\n def __init__(self, stochastic, others, verbose=None):\n self.others = others\n self.conjugate = True\n mc.Gibbs.__init__(self, stochastic, verbose)\n\n d...
[ 3, 6, 7, 8, 11 ]
# p.85 (문자 갯수 카운팅) message = \ 'It was a bright cold day in April, and the clocks were striking thirteen.' print(message, type(message)) msg_dict = dict() #빈 dict() 생성 for msg in message: print(msg, message.count(msg)) msg_dict[msg] = message.count(msg) print(msg_dict)
normal
{ "blob_id": "20671470c087719fa9ea8ffa25be55e9ade67681", "index": 5373, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(message, type(message))\n<mask token>\nfor msg in message:\n print(msg, message.count(msg))\n msg_dict[msg] = message.count(msg)\nprint(msg_dict)\n", "step-3": "message = (\...
[ 0, 1, 2, 3 ]
n = int(input()) a = sorted([int(input()) for _ in range(n)]) x = a[:n//2] y = a[(n + 1)//2:] ans = 0 for i in range(len(x)): ans += abs(x[i] - y[i]) for i in range(1, len(y)): ans += abs(x[i - 1] - y[i]) if n % 2 == 1: ans += max( abs(a[n // 2] - x[-1]), abs(a[n // 2] - y[0]), ) print...
normal
{ "blob_id": "0e9d0927e8d69b0c0fad98479d47f2409c95a751", "index": 794, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(x)):\n ans += abs(x[i] - y[i])\nfor i in range(1, len(y)):\n ans += abs(x[i - 1] - y[i])\nif n % 2 == 1:\n ans += max(abs(a[n // 2] - x[-1]), abs(a[n // 2] - y[...
[ 0, 1, 2, 3 ]
from pyNastran.bdf.fieldWriter import print_card from pyNastran.bdf.bdfInterface.assign_type import (integer, integer_or_blank, double_or_blank, string_or_blank) class NLPARM(object): """ Defines a set of parameters for nonlinear static analysis iteration strategy. +--------+--------+------+-----...
normal
{ "blob_id": "7701a98d836dc9551a4e2eb4b7d9c10307b3f665", "index": 1411, "step-1": "<mask token>\n\n\nclass NLPARM(object):\n <mask token>\n <mask token>\n\n def __init__(self):\n pass\n\n def add(self, card=None, comment=''):\n if comment:\n self._comment = comment\n se...
[ 6, 7, 8, 9, 10 ]
import pandas as pd import numpy as np df1 = pd.DataFrame(np.ones((3, 4))*0, columns=['a', 'b', 'c', 'd']) df2 = pd.DataFrame(np.ones((3, 4))*1, columns=['a', 'b', 'c', 'd']) df3 = pd.DataFrame(np.ones((3, 4))*2, columns=['a', 'b', 'c', 'd']) # 竖向合并 # ignore_index对行索引重新排序 res1 = pd.concat([df1, df2, df3], axis=0, ig...
normal
{ "blob_id": "0a38cf6e0518a08895ed7155069aa2257c7b352e", "index": 4662, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(res1)\n<mask token>\nprint(res2)\n<mask token>\nprint(res3)\n<mask token>\nprint(res4)\n<mask token>\nprint(res5)\n<mask token>\nprint(res6)\n", "step-3": "<mask token>\ndf1 = pd....
[ 0, 1, 2, 3, 4 ]
import logging from utils import Utils from block import Block from message import Message from transaction import Transaction class Response: def __init__(self, node, data): self.node = node self.data = data self.selector() def selector(self): if self.data['flag'] == 1: ...
normal
{ "blob_id": "55b8590410bfe8f12ce3b52710238a79d27189a7", "index": 5125, "step-1": "<mask token>\n\n\nclass Response:\n <mask token>\n <mask token>\n\n def chain_size(self):\n server_chain_size = self.node.get_ledger_size()\n self.return_response(1, server_chain_size)\n\n def chain_sync(s...
[ 5, 6, 8, 9, 10 ]
import time import pigpio class Car: def __init__(self, STBY, PWMA, AIN2, AIN1, BIN1, BIN2, PWMB, sensorTrig=0, sensors=[]): self.pi = pigpio.pi() if not self.pi.connected: print("Pi not connected to pigpio.") return # GPIO Drive Pin locations ...
normal
{ "blob_id": "5b9f1b3ca4b50a4e9e8bd6715e73c62b4f778929", "index": 1594, "step-1": "<mask token>\n\n\nclass Car:\n <mask token>\n\n def activate(self):\n self.deactivate()\n self.pi.write(self.STBY, 1)\n <mask token>\n\n def setDrive(self, direction, dutycycle=100):\n dc = int(255....
[ 4, 6, 7, 8, 10 ]
# -*- coding: utf-8 -*- from django.test import TestCase from django.contrib.auth.models import User from ..models import Todo class MyTestCase(TestCase): def test_mark_done(self): user = User.objects.create_user(email='user@…', username='user', password='somepasswd') todo = Todo(title='SomeTitl...
normal
{ "blob_id": "5c81ddbc8f5a162949a100dbef1c69551d9e267a", "index": 37, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MyTestCase(TestCase):\n\n def test_mark_done(self):\n user = User.objects.create_user(email='user@…', username='user',\n password='somepasswd')\n todo ...
[ 0, 2, 3, 4, 5 ]
from pymongo import MongoClient from modules.linkedinSearch import SearchClass from config import Config class LinkedinSearch: def __init__(self): self.client = MongoClient(Config.MONGO_URI) db = self.client.linkedin_db self.collection = db.search self.dict = {} self.obj ...
normal
{ "blob_id": "3e8860c22ff3092304df57aa7f5dbcb6ccda7dd8", "index": 5249, "step-1": "<mask token>\n\n\nclass LinkedinSearch:\n <mask token>\n <mask token>\n\n def db_fetch(self, query):\n self.collection.create_index([('name', 'text')])\n lst = []\n cursor = self.collection.find({'$tex...
[ 2, 4, 5, 6, 7 ]
import pickle from absl import flags from absl import app from absl import logging import time import numpy as np FLAGS = flags.FLAGS flags.DEFINE_string('sent2vec_dir', '2020-04-10/sent2vec/', 'out path') flags.DEFINE_integer('num_chunks', 36, 'how many files') flags.DEFINE_string('out_dir', '2020-04-10/', 'out pat...
normal
{ "blob_id": "8aa35bcaa4e564306125b37c70a8a92f26da736d", "index": 7418, "step-1": "<mask token>\n\n\ndef load_all_vectors(num_chunks):\n all_vectors = []\n meta_data = []\n for chunk_id in range(num_chunks):\n logging.info('Processing file %s', chunk_id)\n t = time.time()\n vectors =...
[ 2, 3, 4, 5, 6 ]
lista = [x for x in range(11)] ##todo: wazne kwadraty = [i**2 for i in lista] kwadraty = [(i, i**2, i**3) for i in range(-10, 11)] zbior_wyr = {'aa', '1233', '111111'} slownik = {i : len(i)for i in zbior_wyr} print(kwadraty, slownik, sep='\n')
normal
{ "blob_id": "248b9b9d613f71e0130353f0792083b7d3f6ccd6", "index": 7000, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(kwadraty, slownik, sep='\\n')\n", "step-3": "lista = [x for x in range(11)]\nkwadraty = [(i ** 2) for i in lista]\nkwadraty = [(i, i ** 2, i ** 3) for i in range(-10, 11)]\nzbior_...
[ 0, 1, 2, 3 ]
import http.server import socketserver from http.server import BaseHTTPRequestHandler, HTTPServer import time import json import io import urllib import requests from lib.Emby_ws import xnoppo_ws from lib.Emby_http import * from lib.Xnoppo import * from lib.Xnoppo_TV import * import lib.Xnoppo_AVR import shutil import ...
normal
{ "blob_id": "2ff85ac059f160fcc6b39b4298e8216cbad77ab3", "index": 504, "step-1": "<mask token>\n\n\ndef get_version():\n return '2.01'\n\n\n<mask token>\n\n\ndef restart():\n print('restart')\n try:\n emby_wsocket.stop()\n except:\n sys.exit()\n sys.exit()\n print('fin restart')\n\...
[ 21, 24, 25, 27, 28 ]
n = int(input()) A = list(map(int, input().split())) g = 1000 for s1, s2 in zip(A[:-1], A[1:]): if s1 < s2: stockNum = g // s1 g += stockNum * (s2 - s1) print(g)
normal
{ "blob_id": "da903409d75ba2a07443317e30bce568444fbca5", "index": 9956, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor s1, s2 in zip(A[:-1], A[1:]):\n if s1 < s2:\n stockNum = g // s1\n g += stockNum * (s2 - s1)\nprint(g)\n", "step-3": "n = int(input())\nA = list(map(int, input().sp...
[ 0, 1, 2 ]
# -*- coding: UTF-8 -*- ''' Evaluate trained PredNet on KITTI sequences. Calculates mean-squared error and plots predictions. ''' import os import numpy as np from six.moves import cPickle import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec from keras import ...
normal
{ "blob_id": "a3507019ca3310d7ad7eb2a0168dcdfe558643f6", "index": 1615, "step-1": "<mask token>\n", "step-2": "<mask token>\nmatplotlib.use('Agg')\n<mask token>\nf.close()\n<mask token>\ntrain_model.load_weights(weights_file)\n<mask token>\nif data_format == 'channels_first':\n X_test = np.transpose(X_test, ...
[ 0, 1, 2, 3, 4 ]
import numpy as np from cost_functions import trajectory_cost_fn import time class Controller(): def __init__(self): pass # Get the appropriate action(s) for this state(s) def get_action(self, state): pass class RandomController(Controller): def __init__(self, env): """ YOUR CODE HERE """ ...
normal
{ "blob_id": "7112eb52aea9be6f8e682b4dacc6b615365c8cea", "index": 7510, "step-1": "<mask token>\n\n\nclass Controller:\n <mask token>\n <mask token>\n\n\nclass RandomController(Controller):\n\n def __init__(self, env):\n \"\"\" YOUR CODE HERE \"\"\"\n pass\n\n def get_action(self, state)...
[ 8, 9, 10, 11, 12 ]
from kafka import KafkaConsumer import csv users = set() # returns string of title given a ConsumerRecord def parse_cr(cr): binary = cr.value string = binary.decode('utf-8') # [time, user id, GET request] return string.split(',') # returns string of title given a ConsumerRecord in name+name+year for...
normal
{ "blob_id": "374fbb986524f28cc86f6e579f504eeb8ddc9701", "index": 1122, "step-1": "<mask token>\n\n\ndef parse_cr(cr):\n binary = cr.value\n string = binary.decode('utf-8')\n return string.split(',')\n\n\ndef get_title(cr):\n get = parse_cr(cr)[2]\n head = get[5:9]\n if head == 'data':\n ...
[ 4, 5, 6, 7, 8 ]
import psycopg2 from .configuration import ConfigurationException DB_CONNECT_STRING = "host='{host}' dbname='{dbname}' user='{user}' password='{passwd}'" class DBItemCompany: def __init__(self, _id, tweeter, category, categoryUrl, provenScore, ranking, location, url, categoryId): self.id = _id se...
normal
{ "blob_id": "31b87a3ceca1f48665ecc9754d5f87bb9b7bbf13", "index": 7579, "step-1": "<mask token>\n\n\nclass DBException(Exception):\n \"\"\"\n Represents a generic exception thrown by the Database Manager\n \"\"\"\n pass\n\n\nclass DBManager:\n\n def __init__(self, cfg):\n self.cfg = cfg\n ...
[ 15, 17, 18, 19, 22 ]
import os import json import codecs import markdown from flask import current_app def get_json_file(filename, lang='en'): """ Get the contents of a JSON file. """ filepath = os.path.join(current_app.config['APP_PATH'], 'data', filename) with open(filepath, 'r') as f: return json.loads(...
normal
{ "blob_id": "213ab22a269abc8180524462a8966e5d929ef7d1", "index": 322, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_markdown_file(name, lang='en'):\n \"\"\"\n Get the contents of a markdown file.\n \"\"\"\n filename_temp = '{0}_{1}.markdown'\n md_dir = os.path.join(current_app...
[ 0, 1, 2, 3, 4 ]
''' swea 2806 N-Queen ''' def nqueen(depth, n, history): global cnt if depth == n: cnt += 1 else: for i in range(n): if i not in history: for index, value in enumerate(history): if abs(depth - index) == abs(i - value): b...
normal
{ "blob_id": "b35686f7feec2c4a905007f3c105b6fa05b87297", "index": 5365, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef nqueen(depth, n, history):\n global cnt\n if depth == n:\n cnt += 1\n else:\n for i in range(n):\n if i not in history:\n for inde...
[ 0, 1, 2, 3 ]
# Generated by Django 2.2.3 on 2019-07-27 10:41 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('beerFriends', '0006_auto_20190726_1504'), ] operations = [ migrations.AlterField( model_name='beer', name='rating', ...
normal
{ "blob_id": "68f3d3fce52d08381adc522ee032ef3181aec82a", "index": 400, "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 = [('beerFriends'...
[ 0, 1, 2, 3, 4 ]
import text nan="" section_words = {'start': -1, '1.1': 17, '1.2': 38, '1.3': 55, '1.4': 76, '1.5': 95, '1.6': 114, '1.7': 133, '1.8': 151, '1.9': 170, '1.10': 190, '1.11': 209, '1.12': 233, '1.13': 257, '1.14': 277, '1.15': 299, '1.16': 320, '1.17': 341, '1.18': 364, '1.19': 385, '1.20': 405, '1.21': 428, '2.1': 451, ...
normal
{ "blob_id": "8a0c0f5ca6a965e07f59a6c88d4dd335310cbdfc", "index": 9530, "step-1": "<mask token>\n", "step-2": "<mask token>\nnan = ''\nsection_words = {'start': -1, '1.1': 17, '1.2': 38, '1.3': 55, '1.4': 76,\n '1.5': 95, '1.6': 114, '1.7': 133, '1.8': 151, '1.9': 170, '1.10': 190,\n '1.11': 209, '1.12': ...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """TODO """ import logging import numpy import evo.gp.support import evo.sr import evo.utils.stats class RegressionFitness(evo.Fitness): LOG = logging.getLogger(__name__ + '.RegressionFitness') def __init__(self, train_inputs, train_output, error_fitness, handled_e...
normal
{ "blob_id": "e53d4bb853eb54e4dfedf7126480e2c3e1af1378", "index": 2825, "step-1": "<mask token>\n\n\nclass RegressionFitness(evo.Fitness):\n <mask token>\n\n def __init__(self, train_inputs, train_output, error_fitness,\n handled_errors, stats: evo.utils.stats.Stats=None, store_bsfs: bool\n =T...
[ 5, 6, 7, 9, 11 ]
import time import json from threading import Thread try: with open('file.json') as f: name = json.load(f) except: f = open("file.json", "w+") name = {} def create(k, v, t='0'): if k in name: print("ERROR:The data already exists") else: if k.isalpha(): ...
normal
{ "blob_id": "430dff54da986df4e3a68018d930735c757d49d0", "index": 6794, "step-1": "<mask token>\n\n\ndef create(k, v, t='0'):\n if k in name:\n print('ERROR:The data already exists')\n elif k.isalpha():\n if v.isnumeric() and t.isnumeric():\n v = int(v)\n t = int(t)\n ...
[ 2, 3, 4, 5, 6 ]
# Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from telemetry.web_perf.metrics import timeline_based_metric from telemetry.web_perf.metrics.trace_event_stats import TraceEventStats from telemetry.web_per...
normal
{ "blob_id": "47f88bc3836490e08f464f71351096b54118420e", "index": 5297, "step-1": "<mask token>\n\n\nclass IndexedDBTimelineMetric(timeline_based_metric.TimelineBasedMetric):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass IndexedDBTimelineMetric(timeline_based_metri...
[ 1, 3, 4, 5, 6 ]
sentence = "Practice Problems to Drill List Comprehension in Your Head." sentence = sentence.split() sentence = [i.replace(".", "") for i in sentence] [print(i) for i in sentence if len(i)<5]
normal
{ "blob_id": "c0e349be45cd964e8e398baaed64eae792189dd1", "index": 5723, "step-1": "<mask token>\n", "step-2": "<mask token>\n[print(i) for i in sentence if len(i) < 5]\n", "step-3": "sentence = 'Practice Problems to Drill List Comprehension in Your Head.'\nsentence = sentence.split()\nsentence = [i.replace('....
[ 0, 1, 2, 3 ]
# Generated by Django 2.2.6 on 2020-06-18 14:16 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('gestionadmin', '0133_auto_20200618_1339'), ] operations = [ migrations.RemoveField( model_name='comprasenc', name='empleado'...
normal
{ "blob_id": "f96a7bef48e7df2899343029a2fae9697125a5b2", "index": 5203, "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 = [('gestionadmi...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # @COPYRIGHT_begin # # Copyright [2015] Michał Szczygieł, M4GiK Software # # 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...
normal
{ "blob_id": "9f2105d188ac32a9eef31b21065e9bda13a02995", "index": 6735, "step-1": "<mask token>\n\n\n@register.inclusion_tag('tags/fieldsetForm.html')\ndef show_fieldsetform(form):\n \"\"\"\n Renders given form without marking required fields.\n @param form:\n @return:\n \"\"\"\n return {'form':...
[ 4, 5, 6, 7, 8 ]
#!/usr/bin/env python3 from nmigen import * from nmigen.build import * from nmigen_boards.icebreaker import ICEBreakerPlatform class SSDigitDecoder(Elaboratable): def __init__(self): self.i_num = Signal(4) self.o_disp = Signal(7) self.lut = { 0: 0b011_1111, 1: 0b000...
normal
{ "blob_id": "74bb511a9ec272020693db65a2e708f3db56931e", "index": 9954, "step-1": "<mask token>\n\n\nclass SSDigitDecoder(Elaboratable):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Blinky(Elaboratable):\n\n def __init__(self):\n self.dd0 = SSDigitDecoder()\n self.dd1 = SSDigi...
[ 4, 6, 7, 8, 10 ]
# -*- coding: UTF-8 -*- from keywords.httpkeys1 import HTTP http1 = HTTP() # ip = '10.68.170.184:8080' ip = '10.68.170.184:8080' http1.post('http://'+ip+'/music_download/api/login','username=admin&password=123456') # http1.savejson('result','id') # http1.get('http://47.101.197.102:8080/music/api/user','{id}') # dat...
normal
{ "blob_id": "68e09f72e8338efbef108ffd0c93eff067bf7b07", "index": 135, "step-1": "<mask token>\n", "step-2": "<mask token>\nhttp1.post('http://' + ip + '/music_download/api/login',\n 'username=admin&password=123456')\nhttp1.upload('http://' + ip + '/music_download/api/song/upload',\n 'speed=0&styleId=c0a4...
[ 0, 1, 2, 3, 4 ]
from behave import given, when, then from pages.LoginPage import LoginPage from pages.ProductsPage import ProductsPage class ProductsListSteps: @given("Prepare classes products list") def prepare_class(context): context.login = LoginPage(context.driver) context.products = ProductsPage(context....
normal
{ "blob_id": "a74a880039bad030d665e001da74075bd61fcc23", "index": 1593, "step-1": "<mask token>\n\n\nclass ProductsListSteps:\n\n @given('Prepare classes products list')\n def prepare_class(context):\n context.login = LoginPage(context.driver)\n context.products = ProductsPage(context.driver)\...
[ 2, 3, 4, 5, 6 ]
# -*- coding:utf-8 -*- import time import random import numpy as np from collections import defaultdict class Simulator(object): ALLOCATION_INTERVAL_MEAN = 150 ALLOCATION_INTERVAL_STDEV = 30 AFTER_ALLOCATION_INTERVAL_MEAN = 150 AFTER_ALLOCATION_INTERVAL_STDEV = 30 CLICK_INTERVAL_MEAN = 30 CLICK_INTERVAL_STDEV = ...
normal
{ "blob_id": "7378f76b4c1f67d8a549aa2a88db8caa9b05338e", "index": 4441, "step-1": "# -*- coding:utf-8 -*-\nimport time\nimport random\nimport numpy as np\nfrom collections import defaultdict\n\nclass Simulator(object):\n\tALLOCATION_INTERVAL_MEAN = 150\n\tALLOCATION_INTERVAL_STDEV = 30\n\tAFTER_ALLOCATION_INTERVA...
[ 0 ]
class Solution(object): def maxSubArrayLen(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """ sums = [0] * (len(nums) + 1) seen = {} seen[0] = -1 res = 0 for idx, n in enumerate(nums): sums[idx + 1] = su...
normal
{ "blob_id": "1ccaedb6e79101764db1907634ba627a0f9f2bb2", "index": 5500, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def maxSubArrayLen(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n ...
[ 0, 1, 2 ]
# Ejercicio 1 print('Pepito') print('Cumpleaños: 22 de enero') edad = 42 print('Tengo', edad, 'años') cantante = 'Suzanne Vega' comida = 'rúcula' ciudad = 'Barcelona' print('Me gusta la música de', cantante) print('Me gusta cenar', comida) print('Vivo en', ciudad)
normal
{ "blob_id": "f26c624e8ae9711eb835e223407256e60dfc6d6e", "index": 8945, "step-1": "<mask token>\n", "step-2": "print('Pepito')\nprint('Cumpleaños: 22 de enero')\n<mask token>\nprint('Tengo', edad, 'años')\n<mask token>\nprint('Me gusta la música de', cantante)\nprint('Me gusta cenar', comida)\nprint('Vivo en', ...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python from math import ceil, floor, sqrt def palindromes(n: int) -> int: """yield successive palindromes starting at n""" # 1 -> 2 -> 3 ... 9 -> 11 -> 22 -> 33 -> 44 .. 99 -> 101 # 101 -> 111 -> 121 -> 131 -> ... -> 191 -> 202 -> 212 # 989 -> 999 -> 1001 -> 1111 -> 1221 # 9889 -> 9...
normal
{ "blob_id": "b07073a7f65dbc10806b68729f21a8bc8773a1ab", "index": 3836, "step-1": "<mask token>\n\n\nclass Solution:\n\n def primePalindrome(self, N: int) ->int:\n \"\"\"return lowest prime palindrome >= N\"\"\"\n for p in palindromes(N):\n if isPrime(p):\n return p\n", ...
[ 2, 3, 4, 5, 6 ]
stevila = [5, 2, 8, 3] #Izpis vseh števil print(stevila) #Izpis števila na mestu 1 print(stevila[1])
normal
{ "blob_id": "6e845f2543b548fb936cc3719eb150e530281945", "index": 9505, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(stevila)\nprint(stevila[1])\n", "step-3": "stevila = [5, 2, 8, 3]\nprint(stevila)\nprint(stevila[1])\n", "step-4": "stevila = [5, 2, 8, 3]\n\n#Izpis vseh števil\nprint(stevila)\...
[ 0, 1, 2, 3 ]
from liver_tumor_segmentation.CGBS_Net import * from liver_tumor_segmentation.loss import * from keras.optimizers import * from liver_tumor_segmentation.CGBS_data_generator import * from keras.callbacks import * import os from keras.callbacks import ReduceLROnPlateau from keras import losses from configuration...
normal
{ "blob_id": "8c17f2c770c24bbf8c73628c6740c0b866e6b1c0", "index": 9047, "step-1": "<mask token>\n\n\ndef train():\n batch_size = 4\n os.environ['CUDA_VISIBLE_DEVICES'] = '0'\n trainGene = trainGenerator(batch_size, data_path='/data', folder=\n 'train', aug_dict=aug_args, seed=1, interaction='RECIS...
[ 1, 2, 3, 4, 5 ]
from django.db import models from django.contrib.auth.models import User from Event.models import Event from University.models import University from django.core.validators import validate_email class Person(models.Model): user = models.ForeignKey(User, related_name='person', on_delete=models. CASCADE, bl...
normal
{ "blob_id": "28f4f14c3c29ee96c370ffe71c268549552b915e", "index": 2419, "step-1": "<mask token>\n\n\nclass PersonTemporaryCode(models.Model):\n person = models.ForeignKey(Person, on_delete=models.CASCADE)\n code = models.IntegerField()\n expiration_date = models.DateTimeField()\n\n def __str__(self):\...
[ 3, 4, 6, 7 ]
""" Question 39: Define a function which can generate a list where the values are square of numbers between 1 and 20 (both included). Then the function needs to print the last 5 elements in the list. """ #To get a value from console input. input_num = input("Write number:") lis1=[] lis2=[] def lis(n1,n2): """ Gener...
normal
{ "blob_id": "24c1f5195bad17f995fb97a03218fc9bbe5ce4cd", "index": 2476, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lis(n1, n2):\n \"\"\"\n\tGenerate and print last 5 element in list.\n\tparam:n1,n2\n\t\"\"\"\n i = 0\n if n1 and n2 <= 20:\n for x in range(n1, n2 + 1):\n ...
[ 0, 1, 2, 3, 4 ]
from django.conf.urls import url, include from api.resources import PlayerResource, GameResource from . import views player_resource = PlayerResource() game_resource = GameResource() urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^api/', include(player_resource.urls)), url(r'^api/', include(...
normal
{ "blob_id": "ff959a388438a6d9c6d418e28c676ec3fd196ea0", "index": 6076, "step-1": "<mask token>\n", "step-2": "<mask token>\nplayer_resource = PlayerResource()\ngame_resource = GameResource()\nurlpatterns = [url('^$', views.index, name='index'), url('^api/', include(\n player_resource.urls)), url('^api/', in...
[ 0, 1, 2, 3 ]
from typing import List import pytest from raiden import waiting from raiden.api.python import RaidenAPI from raiden.raiden_service import RaidenService from raiden.tests.utils.detect_failure import raise_on_failure from raiden.tests.utils.network import CHAIN from raiden.tests.utils.transfer import block_offset_time...
normal
{ "blob_id": "c4a13069b5add538589886b5e282d4fc9f2b72ad", "index": 6807, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@raise_on_failure\n@pytest.mark.parametrize('channels_per_node', [CHAIN])\n@pytest.mark.parametrize('number_of_nodes', [3])\ndef test_leave_token_network(raiden_network: List[RaidenSe...
[ 0, 1, 2, 3 ]
import pymongo import os,sys import re from db_User import * from db_Event import * class ClassRoom: # 链接本地客户端 __myclient = pymongo.MongoClient("mongodb://localhost:27017") # 创建数据库 __mydb = __myclient["MMKeyDB"] # 创建新的集合 __mycol = __mydb["ClassRoom"] # 判断是否输入id或是输入name,如果有输入则转译 def ...
normal
{ "blob_id": "8dae8a89d08bc522f9a5fdde8aeb9e322fafcbec", "index": 3251, "step-1": "<mask token>\n\n\nclass ClassRoom:\n <mask token>\n <mask token>\n <mask token>\n\n def Name2Id(room_id, name):\n bool_n = bool(re.match('教\\\\d{1}-\\\\d{3}', name))\n bool_id = bool(re.match('B\\\\d{1}R\\...
[ 7, 8, 10, 11, 12 ]
""" The MIT License (MIT) Copyright (c) 2021-present Pycord Development Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, ...
normal
{ "blob_id": "a73dcfc21c31d4e984db39c072d11cb9a9c3d5e5", "index": 2470, "step-1": "<mask token>\n\n\nclass ScheduledEventSubscriber(TypedDict):\n guild_scheduled_event_id: Snowflake\n user: User\n member: Member | None\n", "step-2": "<mask token>\n\n\nclass ScheduledEvent(TypedDict):\n id: Snowflake...
[ 1, 3, 4, 5, 6 ]
import requests # url="http://www.google.com" # response=requests.get(url) # print(response.status_code) url = "http://icanhazdadjoke.com/" response = requests.get(url, headers={"Accept": "application/json"}) data = response.text print(type(data)) data = response.json() print(data)
normal
{ "blob_id": "f94894e5d3e6a0ff367911c72f4d863ac32c8baa", "index": 1435, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(type(data))\n<mask token>\nprint(data)\n", "step-3": "<mask token>\nurl = 'http://icanhazdadjoke.com/'\nresponse = requests.get(url, headers={'Accept': 'application/json'})\ndata ...
[ 0, 1, 2, 3, 4 ]
#coding: utf-8 from flask import Flask, redirect, url_for, request from werkzeug.utils import secure_filename import torch, torchvision # Setup detectron2 logger import detectron2 from detectron2.utils.logger import setup_logger setup_logger() # import some common libraries import numpy as np import os, json, cv2, ...
normal
{ "blob_id": "a18e98db417fe234e3d8d5d1321203fbac18751c", "index": 8174, "step-1": "<mask token>\n\n\ndef init_setup():\n cfg = get_cfg()\n cfg.merge_from_file(model_zoo.get_config_file(\n 'COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml'))\n cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5\n cf...
[ 4, 5, 6, 7, 8 ]
class TrieNode: def __init__(self): self.children: Dict[str, TrieNode] = collections.defaultdict(TrieNode) self.word: Optional[str] = None class Solution: def findWords(self, board: List[List[str]], words: List[str]) ->List[str]: m = len(board) n = len(board[0]) ans =...
normal
{ "blob_id": "f996dffcb9650663278ec1e31d9f88d50142f4ea", "index": 4491, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n\n def findWords(self, board: List[List[str]], words: List[str]) ->List[str]:\n m = len(board)\n n = len(board...
[ 1, 2, 3, 4 ]
#!/usr/bin/env python3 # coding: utf-8 """ Blaise de Vigenère (1523–1596) mathematician, developed encryption scheme, VigenereCipher algorithm is implemented based on his work, with a utility of relative strength index for encryption and decryption. VERSION : 1.0 LICENSE : GNU GPLv3 ...
normal
{ "blob_id": "38906a31ab96e05a9e55a51260632538872ed463", "index": 6889, "step-1": "<mask token>\n\n\nclass VigenereCipher(object):\n\n def __init__(self, key):\n print('Vigenere Cipher Encription')\n self.key = key\n\n def encode(self, text):\n key = self.key\n ans = ''\n ...
[ 8, 9, 11, 12, 13 ]
#!/usr/bin/python # -*- coding:utf-8 -*- import importlib def import_string(path): """ 根据字符串的形式去导入路径中的对象 :param path: 'src.engine.agent.AgentHandler' :return: """ module_path,cls_name = path.rsplit('.',maxsplit=1) module = importlib.import_module(module_path) return getattr(module,cls...
normal
{ "blob_id": "8502ebdb13c68a9a56a1a4ba51370d8458ca81dc", "index": 7944, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef import_string(path):\n \"\"\"\n 根据字符串的形式去导入路径中的对象\n :param path: 'src.engine.agent.AgentHandler'\n :return:\n \"\"\"\n module_path, cls_name = path.rsplit('.', ...
[ 0, 1, 2, 3 ]
from django.apps import AppConfig class TermserviceConfig(AppConfig): name = 'termservice'
normal
{ "blob_id": "f0168a737b9215520ce600470f9b27837dafb593", "index": 4183, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TermserviceConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TermserviceConfig(AppConfig):\n name = 'termservice'\n", "step-4": "from django.app...
[ 0, 1, 2, 3 ]
from package import * class mysql(MakePackage): dependencies = ["cmake"] fetch="http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from/http://cdn.mysql.com/" config='cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=%(prefix)s -DWITH_READLINE=1'
normal
{ "blob_id": "ec90c731a0e546d9d399cbb68c92be1acca8cbe0", "index": 518, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass mysql(MakePackage):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass mysql(MakePackage):\n dependencies = ['cmake']\n fetch = ...
[ 0, 1, 2, 3, 4 ]
from time import time import threading import os #hh:mm:ss movie1Time = "00:00:00" movie2Time = "00:00:00" movie3Time = "00:00:00" movie4Time = "00:00:00" movie5Time = "00:00:00" timer1Start = None timer1Time = "00:00:00" timer1Running = False timer2Start = None timer2Time = "00:00:00" timer2Running = False timer3Star...
normal
{ "blob_id": "cef4568b4568bceeedca6d57c0ccacfaae67c061", "index": 147, "step-1": "<mask token>\n\n\nclass Ui_Form1(QtGui.QWidget):\n\n def __init__(self):\n QtGui.QWidget.__init__(self)\n self.setupUi(self)\n if os.path.exists(os.getcwd() + '\\\\settings.ini') and os.path.getsize(\n ...
[ 15, 20, 21, 22, 28 ]
from math import log2 from egosplit.benchmarks.data_structures.cover_benchmark import * from egosplit.benchmarks.evaluation.utility import create_line from networkit.stopwatch import clockit # Analyse the result cover of a benchmark run @clockit def analyze_cover(benchmarks, result_dir, calc_f1, append): if not app...
normal
{ "blob_id": "dc5b9600828857cc5ea434a7b010cd8aa2589d22", "index": 6568, "step-1": "<mask token>\n\n\n@clockit\ndef analyze_cover(benchmarks, result_dir, calc_f1, append):\n if not append:\n print_headers(result_dir)\n for benchmark in benchmarks:\n count_benchmark_cover(result_dir, calc_f1, be...
[ 2, 3, 5, 6, 7 ]
from django.db import models # Create your models here. class Author(models.Model): AuthorID = models.IntegerField(primary_key=True) Name = models.CharField(max_length=200) Age = models.IntegerField(max_length=50) Country = models.CharField(max_length=100) class Book(models.Model): ISBN = models.C...
normal
{ "blob_id": "817d7259b3607f3a94d2f363c9684f733ee87d37", "index": 2124, "step-1": "<mask token>\n\n\nclass Book(models.Model):\n ISBN = models.CharField(primary_key=True, max_length=100)\n Title = models.CharField(max_length=200)\n AuthorID = models.IntegerField(max_length=100)\n Publisher = models.Ch...
[ 2, 3, 4, 5, 6 ]
import backtrader as bt class RSIStrategy(bt.Strategy): def __init__(self): self.order = None self.position.size = 0 self.sellAlert1 = False self.sellAlert2 = False self.buyAlert = False self.failureNum = 0 self.successNum = 0 self.rsi_...
normal
{ "blob_id": "9119fc1c75de980bbcf74f1e06a36ba587fc490b", "index": 102, "step-1": "<mask token>\n\n\nclass RSIStrategy(bt.Strategy):\n\n def __init__(self):\n self.order = None\n self.position.size = 0\n self.sellAlert1 = False\n self.sellAlert2 = False\n self.buyAlert = False...
[ 3, 4, 5, 6, 7 ]
from scrapera.image.duckduckgo import DuckDuckGoScraper scraper = DuckDuckGoScraper() scraper.scrape('spongebob squarepants', 1, r'path/to/output/directory')
normal
{ "blob_id": "d234034f7f232e842d0b4e465ea6ec314af6964d", "index": 4209, "step-1": "<mask token>\n", "step-2": "<mask token>\nscraper.scrape('spongebob squarepants', 1, 'path/to/output/directory')\n", "step-3": "<mask token>\nscraper = DuckDuckGoScraper()\nscraper.scrape('spongebob squarepants', 1, 'path/to/ou...
[ 0, 1, 2, 3, 4 ]
# common methods to delete data from list fruits = ['orange', ' apple', 'pear', 'banana', 'kiwi'] #pop method # fruits.pop(1) # del # del fruits[1] # remove # fruits.remove('banana') # append, extend, insert # pop, remove, del print(fruits)
normal
{ "blob_id": "a245cb1f232b152edf40b6399686c6811c522d99", "index": 6458, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(fruits)\n", "step-3": "fruits = ['orange', ' apple', 'pear', 'banana', 'kiwi']\nprint(fruits)\n", "step-4": "# common methods to delete data from list\r\nfruits = ['orange', ' a...
[ 0, 1, 2, 3 ]
message = input() vowel = 'aeiouAEIOU' consonant = 'bcdfghjklmnpqrstvwxyz' consonant += consonant.upper() vowel_count = 0 consonant_count = 0 for c in message: if c in vowel: vowel_count += 1 elif c in consonant: consonant_count += 1 print(vowel_count, consonant_count)
normal
{ "blob_id": "edf704d720abdb09d176937664c9ba98bcd253a5", "index": 8320, "step-1": "<mask token>\n", "step-2": "<mask token>\nconsonant += consonant.upper()\n<mask token>\nfor c in message:\n if c in vowel:\n vowel_count += 1\n elif c in consonant:\n consonant_count += 1\nprint(vowel_count, c...
[ 0, 1, 2 ]
import hlp import pdb class Nnt(list): """ Generic layer of neural network """ def __init__(self): """ Initialize the neural network base object. """ self.tag = None def y(self, x): """ build sybolic expression of output {y} given input {x} t...
normal
{ "blob_id": "fb53ea6a7184c0b06fb8a4cbfaf2145cc5c2e8e2", "index": 9468, "step-1": "<mask token>\n\n\nclass Nnt(list):\n <mask token>\n\n def __init__(self):\n \"\"\"\n Initialize the neural network base object.\n \"\"\"\n self.tag = None\n\n def y(self, x):\n \"\"\"\n ...
[ 5, 6, 7, 8, 9 ]
import torch import numpy as np import h5py from torch.utils.data import Dataset, DataLoader from config import PARAS """ Be careful: We use log mel-spectrogram for training, while the mask generated is for power mel-spectrogram """ def create_gt_mask(vocal_spec, bg_spec): """ Take in log spectrogram and ret...
normal
{ "blob_id": "1133d3cf900e31278dc491565c99969a116e6c83", "index": 1998, "step-1": "<mask token>\n\n\nclass TorchData(Dataset):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef create_gt_mask(vocal_spec, bg_spec):\n \"\"\"\n Take in log spectrogra...
[ 1, 6, 8, 9, 10 ]
# -*- coding: utf-8 -*- """ CST 383, measles simulation homework # Here's a question. Suppose 1% of people have measles, that the # test for measles if 98% accurate if you do have measles, and 98% # accurate if you don't have measles. Then what is the probability # that you have measles, given that you have...
normal
{ "blob_id": "076d9f0c14a8070993039bbda2ffe4d52c8d2273", "index": 1512, "step-1": "<mask token>\n\n\ndef t200():\n return np.random.choice(2, 200, p=[0.1, 0.9])\n\n\n<mask token>\n\n\ndef t1000():\n return np.random.choice(2, 1000, p=[0.1, 0.9])\n\n\n<mask token>\n\n\ndef prob_cond_given_pos(prob_cond, prob...
[ 4, 6, 7, 8, 9 ]
# Import this.
normal
{ "blob_id": "1f69bcd204c9be26756d964f4deb61296e40ff10", "index": 9658, "step-1": "# Import this.\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 1 ] }
[ 1 ]
from app.request import send_tor_signal from app.utils.session_utils import generate_user_keys from app.utils.gen_ddg_bangs import gen_bangs_json from flask import Flask from flask_session import Session import json import os from stem import Signal app = Flask(__name__, static_folder=os.path.dirname( os...
normal
{ "blob_id": "26fb607623fda333c37e254470ca6d07708671a8", "index": 5877, "step-1": "<mask token>\n", "step-2": "<mask token>\nif not os.path.exists(app.config['CONFIG_PATH']):\n os.makedirs(app.config['CONFIG_PATH'])\nif not os.path.exists(app.config['SESSION_FILE_DIR']):\n os.makedirs(app.config['SESSION_...
[ 0, 1, 2, 3, 4 ]
from splinter import Browser from time import sleep from datetime import datetime, timedelta import os, sys import urllib import cv2 import numpy as np from PIL import Image import imutils import csv class Scraper(): start_date = datetime(2018, 1, 8) url = 'http://spaceweather.com/' def scrape(self): ...
normal
{ "blob_id": "c55991e738c89ee09dabd79d514e710e0fcbac85", "index": 422, "step-1": "<mask token>\n\n\nclass Scraper:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Entry:\n folder = None\n date = None\n sunspots = -1\n image_path = None\n counted_...
[ 10, 11, 12, 17, 18 ]
class Solution(object): def sortArrayByParityII(self, A): """ :type A: List[int] :rtype: List[int] """ i = 0 for j in range(1, len(A), 2): if A[j] % 2 == 1: continue else: while i + 2 < len(A) and A[i] % 2 == 0:...
normal
{ "blob_id": "429af603bf8f1c003799c3d94c0ce9a2c2f80dfc", "index": 3835, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def sortArrayByParityII(self, A):\n \"\"\"\n :type A: List[int]\n :rtype: List[int]\n ...
[ 0, 1, 2 ]
''' This program will simulate leveling a DnD character, showing their ending HP, and stats. ''' import argparse import csv import json import re import time from openpyxl import load_workbook from pandas import DataFrame from src import classes, util def import_race_data(file_path): ''' This method imports d...
normal
{ "blob_id": "022c8d6c31ad5494b03bfe93d17396eac25b011e", "index": 8706, "step-1": "<mask token>\n\n\ndef update_mode(args):\n \"\"\"\n This method is the main method for running this program in Update mode.\n\n Update mode takes in a specifically formated XLSX file and outputs a JSON\n file containing...
[ 2, 3, 4, 5, 6 ]
from collections import namedtuple from os import getenv from pathlib import Path TMP = getenv("TMP", "/tmp") PYBITES_FAKER_DIR = Path(getenv("PYBITES_FAKER_DIR", TMP)) CACHE_FILENAME = "pybites-fake-data.pkl" FAKE_DATA_CACHE = PYBITES_FAKER_DIR / CACHE_FILENAME BITE_FEED = "https://codechalleng.es/api/bites/" BLOG_FE...
normal
{ "blob_id": "7336b8dec95d23cbcebbff2a813bbbd5575ba58f", "index": 2327, "step-1": "<mask token>\n", "step-2": "<mask token>\nTMP = getenv('TMP', '/tmp')\nPYBITES_FAKER_DIR = Path(getenv('PYBITES_FAKER_DIR', TMP))\nCACHE_FILENAME = 'pybites-fake-data.pkl'\nFAKE_DATA_CACHE = PYBITES_FAKER_DIR / CACHE_FILENAME\nBI...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ 测试如何使用python的pymongo模块操作MongoDB @author: hch @date : 2020/10/8 """ import logging import time import traceback from pprint import pprint from pymongo import MongoClient from pymongo.cursor import Cursor from pymongo.results import DeleteResult, InsertOneResult, UpdateResult class MongoT...
normal
{ "blob_id": "b46fe26f1a3c9e93e735b752e54132bd95408251", "index": 2451, "step-1": "<mask token>\n\n\nclass MongoTest:\n <mask token>\n try:\n client = MongoClient(\n 'mongodb://root:root@localhost:27017/test?authSource=admin')\n print('init mongo client:', client)\n except Except...
[ 6, 7, 8, 9, 10 ]
from django.db import models from django.utils import timezone from pprint import pprint class Cast(models.Model): name = models.CharField(max_length=50, blank=True, null=True) image = models.ImageField(upload_to='cast', blank=True, null=True) description = models.CharField(max_length=400, blank=True, null...
normal
{ "blob_id": "45dc9d362a2ddfd408f93452bda0b7338057ca81", "index": 8322, "step-1": "<mask token>\n\n\nclass Comic(models.Model):\n MAX_PAGES_PER_ISSUE = 1000\n sort_number = models.IntegerField(blank=True, null=True)\n page_number = models.IntegerField(blank=True, null=True)\n last_page = models.Intege...
[ 12, 13, 14, 19, 20 ]
import boto3 import json region = 'us-east-2' ec2 = boto3.resource('ec2',region) ImageId = 'ami-07efac79022b86107' KeyName = 'aws_keypair' InstanceType = 't2.micro' #IamInstanceProfile = instances = ec2.create_instances( ImageId =ImageId, MinCount = 1, MaxCount = 5, KeyName = KeyName, InstanceTyp...
normal
{ "blob_id": "b7606befe123c4fb6840a1bc62e43e6721edfcc3", "index": 5005, "step-1": "<mask token>\n", "step-2": "<mask token>\nregion = 'us-east-2'\nec2 = boto3.resource('ec2', region)\nImageId = 'ami-07efac79022b86107'\nKeyName = 'aws_keypair'\nInstanceType = 't2.micro'\ninstances = ec2.create_instances(ImageId=...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-26 20:13 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('Cbrowser', '0002_links_l_title'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "ffd11d49f8499b4bfec8f17d07b66d899dd23d2e", "index": 6924, "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 = [('Cbrowser', ...
[ 0, 1, 2, 3, 4 ]
import math def hipotenusa(a,b): return math.sqrt((a*a)+(b*b)) def main(): cateto1=input('dime un cateto') cateto2=input('dime el otro cateto') print ('la hipotenusa es: '),hipotenusa(cateto1,cateto2) main()
normal
{ "blob_id": "50ae2b4c6d51451031fc31ebbc43c820da54d827", "index": 7898, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n cateto1 = input('dime un cateto')\n cateto2 = input('dime el otro cateto')\n print('la hipotenusa es: '), hipotenusa(cateto1, cateto2)\n\n\n<mask token>\n", "...
[ 0, 1, 2, 3, 5 ]
import jiml.cli def write_file(path, text): path.write_text(text) return path def test_argparse(tmp_path): tmpl = write_file(tmp_path / 't.yaml', 'key: {{ var }}') inp = write_file(tmp_path / 'i.json', '{"var": "Hello!"}') out = tmp_path / 'o.json' jiml.cli.main(jiml.cli.parse_args( ...
normal
{ "blob_id": "700d35f9e941fe9325821a377ec1ca1c245ddaec", "index": 176, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef write_file(path, text):\n path.write_text(text)\n return path\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef write_file(path, text):\n path.write_text(text)\n ...
[ 0, 1, 2, 3, 4 ]
import tempfile import unittest from unittest.mock import mock_open, patch, MagicMock, call import compare_apple_music_and_spotify as music_compare class get_apple_music_data(unittest.TestCase): def test_open_file(self): with patch("builtins.open", mock_open(read_data="data")) as mock_file: a...
normal
{ "blob_id": "eec08b3fdd4beb7d88ac0dc6d2e8776cf54fda35", "index": 2727, "step-1": "<mask token>\n\n\nclass spotify_data_parser(unittest.TestCase):\n\n def test_open_file_and_return_formated_data_split_by_coma(self):\n with patch('builtins.open', mock_open(read_data='split,by,')):\n result = m...
[ 20, 23, 27, 28, 29 ]
# Copyright 2011 Isaku Yamahata # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
normal
{ "blob_id": "d56e313318635788ae5b3d3a3f767450ab2f2296", "index": 4985, "step-1": "<mask token>\n\n\nclass BlockDeviceTestCase(test.NoDBTestCase):\n <mask token>\n\n def test_properties(self):\n root_device0 = '/dev/sda'\n root_device1 = '/dev/sdb'\n mappings = [{'virtual': 'root', 'dev...
[ 37, 38, 43, 46, 55 ]
from django.shortcuts import render from django.views.generic import ListView from auth_person.models import Post_news, User # Create your views here. def blog(request, foo): inf = {'login': foo} return render(request, 'blog/blog.html', context=inf) class feed(ListView): template_name = 'blog/feed.html'...
normal
{ "blob_id": "b216c0f92bcf91fd538eabf0239cf149342ef2eb", "index": 4493, "step-1": "from django.shortcuts import render\nfrom django.views.generic import ListView\nfrom auth_person.models import Post_news, User\n\n# Create your views here.\n\n\ndef blog(request, foo):\n inf = {'login': foo}\n return render(r...
[ 0 ]
import re import requests import numpy as np import json import os from collections import OrderedDict import pandas as pd import json import datetime import time #将数组写入json文件方便pandas的读取 def write_list_to_json(list, json_file_name, json_file_save_path): os.chdir(json_file_save_path) with open(json_file_name, 'w...
normal
{ "blob_id": "0677e12bc9733c76bff7ed3fe83e3800e64e9a10", "index": 7633, "step-1": "<mask token>\n\n\ndef getworld_data(url, header):\n headers = header\n res = requests.get(url, headers=headers)\n res.encoding = 'UTF-8'\n pattern = re.compile(\n '(\\'\\\\{\"(\\\\w+)\":{\"active\":(.*?),\"confir...
[ 2, 3, 4, 5, 6 ]
from ocr_helpers import FilePathResolver, ProblemsWriter from ocr_google_client import CfaProblemsBuilder from ocr_google_client_2016 import ParserTwoThousandSixteenAnswers, ParserTwoThousandSixteenQuestions def resolve_build_and_write(year, day_part, file_part, nb_blocks_footer=0, nb_words_footer=0, headers=None, sk...
normal
{ "blob_id": "ab3d443c60ca8ee82f594ae04e9b485a53d53f36", "index": 5665, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef resolve_build_and_write(year, day_part, file_part, nb_blocks_footer=0,\n nb_words_footer=0, headers=None, skip_nb_page=0, parser=None,\n indentation_threshold=15):\n reso...
[ 0, 1, 2, 3, 4 ]
from django.db import models from django.utils.text import slugify import misaka from django.urls import reverse from django.contrib.auth import get_user_model from django import template register=template.Library() User=get_user_model() #call things out of users current session # Create your models here. class G...
normal
{ "blob_id": "51563f52e700a286451663a6e837d56e104c2c72", "index": 2849, "step-1": "<mask token>\n\n\nclass Group(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.name\n <mask token>\n <mask token>\n\n\ncla...
[ 5, 7, 8, 9, 11 ]
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>) # Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>) # # This program is f...
normal
{ "blob_id": "d9538c030c0225c4255100da70d6bf23f550a64f", "index": 734, "step-1": "<mask token>\n\n\nclass SaleOrderLine(osv.osv):\n <mask token>\n _inherit = 'sale.order.line'\n _columns = {'promotion_line': fields.boolean('Promotion Line', help=\n 'Indicates if the line was created by promotions'...
[ 2, 4, 6, 9, 10 ]
from . import mongo col = mongo.cli['Cupidbot']['timer'] async def add_time(chat, time): return col.insert_one({'chat': chat, 'time': time}) async def get_time(chat): return col.find_one({'chat': chat}) async def update_time(chat, time): return col.update_one({'chat': chat}, {'$set': {'chat': chat, 't...
normal
{ "blob_id": "e4ce10f5db56e4e2e1988da3cee542a4a09785a8", "index": 5381, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nasync def add_time(chat, time):\n return col.insert_one({'chat': chat, 'time': time})\n\n\nasync def get_time(chat):\n return col.find_one({'chat': chat})\n\n\nasync def update_...
[ 0, 1, 2, 3 ]
import sqlite3 conn = sqlite3.connect("blog.db") c = conn.cursor() q = "CREATE TABLE users(Username text, Password text, UserID integer)" c.execute(q) q = "CREATE TABLE blogs(Title text, Content text, BlogID integer, UserID integer)" c.execute(q) q = "CREATE TABLE comments(Content text, CommentID integer, BlogID i...
normal
{ "blob_id": "8afaa69d3a20c5e39e6321869f25dbd9020a5b3a", "index": 2460, "step-1": "<mask token>\n", "step-2": "<mask token>\nc.execute(q)\n<mask token>\nc.execute(q)\n<mask token>\nc.execute(q)\nconn.commit()\n", "step-3": "<mask token>\nconn = sqlite3.connect('blog.db')\nc = conn.cursor()\nq = 'CREATE TABLE ...
[ 0, 1, 2, 3, 4 ]
from django.db import models class Author(models.Model): author = models.CharField( "Author", max_length=30, blank=False, null=False ) biography = models.TextField( "About author", max_length=500, blank=True, null=True ) def __str__...
normal
{ "blob_id": "b34ad8d7fc8df0ab86c5930ab2b5aa1f86d13ae3", "index": 7580, "step-1": "<mask token>\n\n\nclass Series(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Genre(models.Model):\n genre = models.CharField('Genre', max_length=50, blank=False, null=False)\n description = m...
[ 7, 9, 11, 12, 14 ]
from django.conf import settings from django.db import models def get_image_filename(instance, filename): a = f'post_images/{instance.post.title}.svg' return a def get_main_image_filename(instance, filename): a = f'post_images/{instance.title}_main.svg' return a # Create your models here. class Po...
normal
{ "blob_id": "1bbadf02c4b9ca22a0099bcc09fa4c62c9901c39", "index": 1069, "step-1": "<mask token>\n\n\nclass Styles(models.Model):\n <mask token>\n\n @staticmethod\n def make_style():\n index_list = ['모던', '미니멀리즘', '한국', '스칸다나비아', '인더스트리얼', '프로방스',\n '로맨틱', '클래식', '엔틱']\n for i in ...
[ 9, 15, 23, 27, 32 ]
# 4. Пользователь вводит целое положительное число. # Найдите самую большую цифру в числе. Для решения используйте цикл while и арифметические операции. income_number = int(input('Введите, пожалуйста, целое положительное число ')) max_number = 0 # в другую сторону решение, не так как Вы на вебинаре советовали, но тож...
normal
{ "blob_id": "18e0ece7c38169d2de91a07dddd4f40b7427848f", "index": 3759, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile income_number != 0:\n num_exp = 10 ** (len(str(income_number)) - 1)\n deleted_number = int(income_number / num_exp)\n if max_number < deleted_number:\n max_number = ...
[ 0, 1, 2, 3 ]
from timeit import default_timer as timer import numpy as np bets1 = [ # lowest config possible 0.00000001, 0.00000004, 0.0000001, 0.0000005, 0.00000150, 0.00000500, 0.00001000 ] bets2 = [ # 2 is 10x 1 0.0000001, 0.0000004, 0.000001, 0.000005, 0.0000150, 0.0000500,...
normal
{ "blob_id": "4c66ab6110e81bb88fc6916a1695e0f23e6e0e9d", "index": 6754, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor seed in range(start_position, start_position + max_seeds):\n cur_wins = 0\n max_wins = 0\n cur_losses = 0\n max_losses = 0\n win_streak = []\n loss_streak = []\n ...
[ 0, 1, 2, 3, 4 ]
from __future__ import annotations from typing import TYPE_CHECKING import abc import tcod.event if TYPE_CHECKING: from tcodplus.canvas import Canvas from tcodplus.event import CanvasDispatcher class IDrawable(abc.ABC): @property @abc.abstractmethod def force_redraw(self) -> bool: pass ...
normal
{ "blob_id": "e37f958191c9481c6664e90c17f43419a0b5b606", "index": 8131, "step-1": "<mask token>\n\n\nclass IDrawable(abc.ABC):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass IFocusable(abc.ABC):\n\n @property\n @abc.abstractmethod\n def focus_dispatcher(self) ->CanvasD...
[ 14, 15, 17, 18, 21 ]
from flask import request, Flask import lock, shelve app = Flask(__name__) @app.route("/unlock") def web_unlock(): if not (request.args.get("token") and request.args.get("state")): return "Error" else: with shelve.open("Settings.conf") as settings: if "token" in settings: ...
normal
{ "blob_id": "ee0f90b84df73ae5783ca0b8a52fe6fe9c979f15", "index": 2576, "step-1": "<mask token>\n\n\n@app.route('/unlock')\ndef web_unlock():\n if not (request.args.get('token') and request.args.get('state')):\n return 'Error'\n else:\n with shelve.open('Settings.conf') as settings:\n ...
[ 2, 3, 4, 5, 6 ]
# 多角色认证装饰器 def auth(role): from core import admin_view,student_view,teacher_view def deco(func): def wrapper(*args,**kwargs): if role == 'admin': if admin_view.admin_user == None: admin_view.login() else: res = func(...
normal
{ "blob_id": "e247ffb5b6e4319ff17d0b8ae9f67e10c282c4ff", "index": 7348, "step-1": "<mask token>\n", "step-2": "def auth(role):\n from core import admin_view, student_view, teacher_view\n\n def deco(func):\n\n def wrapper(*args, **kwargs):\n if role == 'admin':\n if admin_v...
[ 0, 1, 2 ]
# Copyright 2015 Cisco Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing...
normal
{ "blob_id": "21cfe1ca606d18763fbfb8ff6862c382b3321adc", "index": 8511, "step-1": "<mask token>\n\n\ndef firmware_pack_create(handle, org_name, name, rack_bundle_version,\n blade_bundle_version, descr='', mode='staged', org_parent='org-root'):\n \"\"\"\n This method creates Host Firmware pack.\n\n Arg...
[ 2, 3, 4, 5, 6 ]
""" 爱丽丝和鲍勃有不同大小的糖果棒:A[i] 是爱丽丝拥有的第 i 根糖果棒的大小,B[j] 是鲍勃拥有的第 j 根糖果棒的大小。 因为他们是朋友,所以他们想交换一根糖果棒,这样交换后,他们都有相同的糖果总量。(一个人拥有的糖果总量是他们拥有的糖果棒大小的总和。) 返回一个整数数组 ans,其中 ans[0] 是爱丽丝必须交换的糖果棒的大小,ans[1] 是 Bob 必须交换的糖果棒的大小。 如果有多个答案,你可以返回其中任何一个。保证答案存在。 """ def fairCandySwap(A, B): sumA, sumB = sum(A), sum(B) setA, setB = set(A), se...
normal
{ "blob_id": "9abc5f18e2eb07afe6bc31d6bd27298350707d1d", "index": 962, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fairCandySwap(A, B):\n sumA, sumB = sum(A), sum(B)\n setA, setB = set(A), set(B)\n delta = (sumA - sumB) // 2\n for j in setB:\n if j + delta in setA:\n ...
[ 0, 1, 2, 3 ]
from django.apps import AppConfig from django.conf import settings import importlib import importlib.util class RestAdminAppConfig(AppConfig): name = 'libraries.django_rest_admin' verbose_name = 'Rest Admin' loaded = False def ready(self): autodiscover() def autodiscover(): """ Auto...
normal
{ "blob_id": "a41d00c86d0bdab1bced77c275e56c3569af4f4e", "index": 921, "step-1": "<mask token>\n\n\nclass RestAdminAppConfig(AppConfig):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass RestAdminAppConfig(AppConfig):\n name = 'li...
[ 1, 3, 4, 5, 6 ]
import numpy as np import heapq class KdNode: """ node of kdtree. """ def __init__(self, depth, splitting_feature, splitting_value, idx, parent): """ :param depth: depth of the node. :param splitting_feature: split samples by which feature. :param splitting_value: split...
normal
{ "blob_id": "2f16c74e51789dd06bfc1fe1c6173fa5b0ac38cd", "index": 4747, "step-1": "<mask token>\n\n\nclass KdTree:\n <mask token>\n\n def __init__(self):\n self.root = None\n\n def create(self, X, dimensions=None):\n \"\"\"\n create a kd-tree on data X.\n :param X: shape is (n...
[ 6, 7, 10, 12, 13 ]
#encoding:utf-8 class Employee(): def __int__(self,name,sex,salary): self.name = name self.sex = sex self.salary = salary def give_raise(self): 222
normal
{ "blob_id": "014509170b98a38838859d3ca48c74ca6be0bd46", "index": 7190, "step-1": "#encoding:utf-8\nclass Employee():\n def __int__(self,name,sex,salary):\n self.name = name\n self.sex = sex\n self.salary = salary\n def give_raise(self):\n 222", "step-2": null, "step-3": null, ...
[ 0 ]
from aiogram import Dispatcher from create_bot import bot from data_base import sqlite_db # new user in group async def new_member(message): new_user = message.new_chat_members[0] user_id = new_user['id'] if new_user['username']: user_name = new_user['username'] elif new_user['first_name']: ...
normal
{ "blob_id": "dfcfa4fa036fe8c058d66fc0b9ea73ddb9d4446e", "index": 7524, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef register_handlers_for_other(dp: Dispatcher):\n dp.register_message_handler(new_member, content_types=['new_chat_members'])\n dp.register_message_handler(left_member, content...
[ 0, 1, 2, 3, 4 ]
from typing import List def sift_up(heap: List, pos: int = None): if pos is None: pos = len(heap) - 1 current, parent = pos, (pos - 1) // 2 while current > 0: if heap[current] > heap[parent]: heap[current], heap[parent] = heap[parent], heap[current] else: b...
normal
{ "blob_id": "9cc6700ab14bed9d69d90c1540f6d42186033a19", "index": 5052, "step-1": "<mask token>\n\n\ndef sift_up(heap: List, pos: int=None):\n if pos is None:\n pos = len(heap) - 1\n current, parent = pos, (pos - 1) // 2\n while current > 0:\n if heap[current] > heap[parent]:\n h...
[ 4, 6, 7, 8, 9 ]
import pandas as pd import numpy as np import random import copy class Node(object): ''' Defines a Node Class for storing characteristics and CPT of each node ''' def __init__(self,name): self.parents = [] self.children = [] self.name = name self.cpt=[] self...
normal
{ "blob_id": "eb4bc008b7e68f8a6e80e837fa970d77a5ed3547", "index": 8218, "step-1": "<mask token>\n\n\nclass Node(object):\n \"\"\"\n Defines a Node Class for storing characteristics and CPT of each node\n \"\"\"\n\n def __init__(self, name):\n self.parents = []\n self.children = []\n ...
[ 12, 13, 15, 17, 20 ]
# Percy's playground. from __future__ import print_function import sympy as sp import numpy as np import BorderBasis as BB np.set_printoptions(precision=3) from IPython.display import display, Markdown, Math sp.init_printing() R, x, y = sp.ring('x,y', sp.RR, order=sp.grevlex) I = [ x**2 + y**2 - 1.0, x + y ] R, x, y...
normal
{ "blob_id": "88af8b4eeb40ecf19622ecde1a5dea9a078bb66c", "index": 8817, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.set_printoptions(precision=3)\n<mask token>\nsp.init_printing()\n<mask token>\nI.extend([(v ** 2 - 1) for v in vs])\nprint('Generating')\n<mask token>\nprint('Done')\nprint('=== Genera...
[ 0, 1, 2, 3, 4 ]
import ordenador import pytest import contatempo class TestaOrdenador: @pytest.fixture def ordenad(self): return ordenador.Ordenador() @pytest.fixture def list_quase_ord(self): c = contatempo.ContaTempos() return c.lista_quase_ordenada(100) @pytest.fixture def list_al...
normal
{ "blob_id": "32bb6d5ad0a1398c9ab89190c087fe3916631878", "index": 7750, "step-1": "<mask token>\n\n\nclass TestaOrdenador:\n\n @pytest.fixture\n def ordenad(self):\n return ordenador.Ordenador()\n <mask token>\n <mask token>\n <mask token>\n\n def test_selecao_bolha_melhorada_aleatoria(se...
[ 5, 6, 8, 9, 11 ]
from django.db import models from django.utils import timezone from django.contrib.auth.models import User, Group # Create your models here. def default_expiration(): return timezone.now() + timezone.timedelta(days=10) class Category(models.Model): name = models.CharField(max_length=200) description = ...
normal
{ "blob_id": "33b6a4c76079ed698809b29772abb59a34831472", "index": 5900, "step-1": "<mask token>\n\n\nclass Survey(models.Model):\n name = models.CharField(max_length=200)\n description = models.TextField()\n category = models.ForeignKey(Category, blank=True, null=True, on_delete\n =models.CASCADE)...
[ 16, 17, 18, 19, 22 ]