code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
class Thing3: def __init__(self): self.letters = 'xyz' # print(Thing3.letters) th = Thing3() print(th.letters)
normal
{ "blob_id": "22bf65a20f7398b82f528112d2ba50f1dccd465c", "index": 6487, "step-1": "class Thing3:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Thing3:\n\n def __init__(self):\n self.letters = 'xyz'\n\n\n<mask token>\n", "step-3": "class Thing3:\n\n def __init__(self):\n self.let...
[ 1, 2, 3, 4, 5 ]
# Copyright (c) 2019 Uber Technologies, 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...
normal
{ "blob_id": "64b254db6d8f352b2689385e70f2ea7d972c9191", "index": 4797, "step-1": "<mask token>\n\n\ndef bsigs():\n S = lists(floats(allow_infinity=False, allow_nan=False), min_size=N_SIG,\n max_size=N_SIG)\n return S\n\n\ndef sigs():\n S = lists(bsigs(), min_size=1)\n return S\n\n\n<mask token...
[ 4, 6, 7, 9, 10 ]
from time import sleep import RPi.GPIO as gpio #GPIO.setmode(GPIO.BCM) gpio.setwarnings(False) def init(): gpio.setmode(gpio.BCM) gpio.setup(26, gpio.OUT) gpio.setup(19, gpio.OUT) gpio.setup(13, gpio.OUT) gpio.setup(6, gpio.OUT) def turn_left(tf): gpio.output(26, False) gpio.output(19, Tru...
normal
{ "blob_id": "a7cbd595b86908fb399bf11e1522588e0b0475c3", "index": 9226, "step-1": "<mask token>\n\n\ndef init():\n gpio.setmode(gpio.BCM)\n gpio.setup(26, gpio.OUT)\n gpio.setup(19, gpio.OUT)\n gpio.setup(13, gpio.OUT)\n gpio.setup(6, gpio.OUT)\n\n\ndef turn_left(tf):\n gpio.output(26, False)\n ...
[ 4, 6, 7, 8, 10 ]
from __future__ import absolute_import from __future__ import division from __future__ import print_function import os.path import re import sys import tarfile import numpy as np from six.moves import urllib import tensorflow as tf from sklearn.model_selection import train_test_split from sklearn import datasets fro...
normal
{ "blob_id": "8ef20a7a93d6affabe88dad4e5d19613fe47dd0f", "index": 5399, "step-1": "<mask token>\n\n\ndef create_graph():\n \"\"\"Creates a graph from saved GraphDef file and returns a saver.\"\"\"\n with tf.gfile.FastGFile(os.path.join('/home/ubuntu/hdd/tensorFlowDic/',\n 'classify_image_graph_def.pb...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- __doc__ = """\ A MiniFrame is a Frame with a small title bar. It is suitable for floating toolbars that must not take up too much screen area. In other respects, it's the same as a wx.Frame. """ __wxPyOnlineDocs__ = 'https://wxpython.org/Phoenix/docs/html/wx.MiniFrame.htm...
normal
{ "blob_id": "b041e9577af72d2bcee3dda0cc78fa12800d53bd", "index": 2286, "step-1": "<mask token>\n\n\nclass TestPanel(wx.Panel):\n\n def __init__(self, parent, log):\n self.log = log\n wx.Panel.__init__(self, parent, -1)\n b1 = wx.Button(self, -1, 'Create and Show a MiniFrame', (50, 50))\n ...
[ 12, 14, 16, 19, 22 ]
import testr import testg import time def run(): parser = testg.OptionParser(description='Autonomous grasp and manipulation planning example.') parser.add_option('--scene', action="store",type='string',dest='scene',default='/home/user/experiment/data/lab1.env.xml', h...
normal
{ "blob_id": "62857a015087500fec534ba1297d42a33ae61927", "index": 7153, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run():\n parser = testg.OptionParser(description=\n 'Autonomous grasp and manipulation planning example.')\n parser.add_option('--scene', action='store', type='string...
[ 0, 1, 2, 3, 4 ]
#header import matplotlib.pyplot as pmf import random p = 0.5 # Probablility of success for original system n = 18 # Number of trials Y = [] # Contains binomial RVs b = [0] * (n+1) # List of n + 1 zeroes N = 100 # Number of experiments performed for j in range(N): # Bernoulli random variable for i in ra...
normal
{ "blob_id": "9a1b268386b4652bf50af0365892ef7338329727", "index": 9631, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor j in range(N):\n for i in range(n):\n r = random.uniform(0, 1)\n if r < p:\n x = 1\n else:\n x = 0\n Y.append(x)\n outcome = su...
[ 0, 1, 2, 3, 4 ]
import unittest import shapely.geometry as gm from alphaBetaLab.abRectangularGridBuilder import abRectangularGridBuilder class testAbRectangularGridBuilder(unittest.TestCase): def getMockHiResAlphaMtxAndCstCellDet(self, posCellCentroids = None): class _mockClass: def __init__(self, posCellCentroids): ...
normal
{ "blob_id": "6175ce6534d44d703df6cdef94fc2b1285e25f49", "index": 2202, "step-1": "<mask token>\n\n\nclass testAbRectangularGridBuilder(unittest.TestCase):\n\n def getMockHiResAlphaMtxAndCstCellDet(self, posCellCentroids=None):\n\n\n class _mockClass:\n\n def __init__(self, posCellCentroids):...
[ 6, 7, 8, 9, 10 ]
# coding: utf-8 from __future__ import ( absolute_import, division, print_function, unicode_literals, ) import time from urllib import urlencode from urlparse import parse_qs, urlparse, urlunparse from flask import current_app as app from flask import url_for from jose import jwt from oauth2client.cl...
normal
{ "blob_id": "fe73a80b15cad025a33930ddd9abb31524cd0244", "index": 9404, "step-1": "<mask token>\n\n\ndef create_oauth_flow():\n \"\"\"Prepare Google OAuth workflow from config file.\"\"\"\n app.flow = flow_from_clientsecrets(str(Path(app.config['ROOT_DIR'],\n 'configs/client_secrets.json')), scope=['...
[ 4, 5, 6, 7, 8 ]
#!/usr/bin/env python # coding: utf-8 # MIT Licensed # http://opensource.org/licenses/MIT led_dir = "/sys/class/gpio/gpio40/" led_pin = led_dir + "value" led_mode = led_dir + "direction" with open(led_mode, "wb") as f: f.write("out") with open(led_pin, "wb") as f: f.write(__import__("sys").argv[1]) """ Contrib...
normal
{ "blob_id": "1a9cad6e49e5ed2bb7781f9fec930d48ec048b3b", "index": 5061, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(led_mode, 'wb') as f:\n f.write('out')\nwith open(led_pin, 'wb') as f:\n f.write(__import__('sys').argv[1])\n<mask token>\n", "step-3": "led_dir = '/sys/class/gpio/gpio4...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # coding: utf-8 # In[19]: import numpy as np import pandas as pd class simple_nn(): ''' This is simple nn class with 3 layers NN. In this class additional layer was added to the original layers from notebook given by Julian Stier and Sahib Julka. Moreover those functions were...
normal
{ "blob_id": "cdc32e7c767097a0eb0def71e55f0276982d6a96", "index": 5235, "step-1": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[19]:\n\n\nimport numpy as np\nimport pandas as pd\n\nclass simple_nn():\n '''\n This is simple nn class with 3 layers NN. In this class additional layer was added to the origin...
[ 0 ]
from datetime import datetime from iohelpers import lines_to_textfile from typing import Iterator, List, Sequence from zhmodules import ZhTopolectSynonyms, MandarinPronunciations, ZhTopolectPronunciations def missing_philippine_hokkien_words_generator(synonyms: ZhTopolectSynonyms, hokprons: ZhTopolectPronunciations):...
normal
{ "blob_id": "18366633489d905c96b0c30d65442bc2e2b188ea", "index": 4703, "step-1": "<mask token>\n\n\ndef missing_philippine_hokkien_words_generator(synonyms: ZhTopolectSynonyms,\n hokprons: ZhTopolectPronunciations):\n all_hokkien = set()\n for word, syn_data in synonyms.all_words():\n minnan = se...
[ 1, 2, 3, 4, 5 ]
s = 'ejp mysljylc kd kxveddknmc re jsicpdrysirbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcdde kr kd eoya kw aej tysr re ujdr lkgc jv' sa = 'our language is impossible to understandthere are twenty six factorial possibilitiesso it is okay if you want to just give up' ans = {} for i in range(len(s)): ans[s[i]] = sa[i]; ...
normal
{ "blob_id": "77b9b111cfb4d0b54e14b2aab81b7b05fd6bbccd", "index": 8552, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(s)):\n ans[s[i]] = sa[i]\n<mask token>\nfor k in ans:\n S.add(k)\n<mask token>\nfor i in range(1, len(L)):\n s = L[i]\n S = ''\n for j in range(len(s)):\...
[ 0, 1, 2, 3 ]
from flask import render_template, request, Response from flask.views import MethodView, View from flask.views import View from repo import ClassifierRepo from services import PredictDigitService from settings import CLASSIFIER_STORAGE class IndexView(View): def dispatch_request(self): return render_temp...
normal
{ "blob_id": "3ea42e7ad5301314a39bf522280c084342cd18c5", "index": 332, "step-1": "<mask token>\n\n\nclass PredictDigitView(MethodView):\n\n def post(self):\n repo = ClassifierRepo(CLASSIFIER_STORAGE)\n service = PredictDigitService(repo)\n image_data_uri = request.json['image']\n pr...
[ 2, 3, 4, 5 ]
import os import sys try: from setuptools import setup, find_packages except ImportError: from distutils.core import setup, find_packages setup( name='stripe-requests', version='1.9.1-dev', description='Stripe python bindings using requests', author='Allan Lei', author_email='allanlei@hel...
normal
{ "blob_id": "a6ee2be7bed59b419fa66fd6cfe4b5fff3fac260", "index": 2596, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n from setuptools import setup, find_packages\nexcept ImportError:\n from distutils.core import setup, find_packages\nsetup(name='stripe-requests', version='1.9.1-dev', descrip...
[ 0, 1, 2, 3 ]
# 1로 만들기 import sys N = int(sys.stdin.readline()) dp_table = [0 for _ in range(10**6 + 1)] dp_table[2], dp_table[3] = 1, 1 for i in range(4,N+1): two_per = 10**6 three_per = 10**6 if i % 3 ==0: three_per = dp_table[i//3] + 1 if i % 2 ==0: two_per = dp_table[i//2] + 1 minus = dp_tabl...
normal
{ "blob_id": "34a8fc38ed875e1c564f535348dc0d5d88c76ab1", "index": 7281, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(4, N + 1):\n two_per = 10 ** 6\n three_per = 10 ** 6\n if i % 3 == 0:\n three_per = dp_table[i // 3] + 1\n if i % 2 == 0:\n two_per = dp_table[i /...
[ 0, 1, 2, 3, 4 ]
# ------------------------------------------------------------------------- # File: mb_trap.py # Created: Tue Feb 7 20:51:32 2006 # ------------------------------------------------------------------------- import random import mb_io import mb_subs from mb_go import GameObject class Trap(GameObject): """ ...
normal
{ "blob_id": "f2a94f6bfe86af439a8248b40732340c45d89b93", "index": 9925, "step-1": "<mask token>\n\n\nclass Trap(GameObject):\n <mask token>\n\n def __init__(self, gamedir, filename=None):\n self.attacks = list()\n self.x = 0\n self.y = 0\n self.radius = 0\n self.is_first_r...
[ 3, 4, 5, 6, 7 ]
from selenium import webdriver from selenium.common.exceptions import WebDriverException from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By SELENIUM_TIMEOUT = 12 def get_browser_driver(): """获取浏览器服务...
normal
{ "blob_id": "5ab877ef15cdcd52463b1567c28327dc2eeea2de", "index": 1204, "step-1": "<mask token>\n\n\ndef get_browser_driver():\n \"\"\"获取浏览器服务 使用后记得 driver.quit() 否则容易引起状态污染\"\"\"\n try:\n driver = webdriver.PhantomJS(service_args=['--load-images=no'])\n except WebDriverException:\n chrome_...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/python from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, ForeignKey from sqlalchemy.orm import sessionmaker, relationship engine = create_engine("sqlite:///banco.db") Base = declarative_base() Session = sessionmaker(...
normal
{ "blob_id": "6d5257158a7d2eef63faf2fea27f36721d4349ae", "index": 4273, "step-1": "#!/usr/bin/python\n\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy import Column, Integer, String, ForeignKey\nfrom sqlalchemy.orm import sessionmaker, relationship\n...
[ 0 ]
#processes are described by generator functions #during the lifetime of a process, the process function(generator function) #creates events and yields them #when a process yields an event, it gets suspended #Simpy resumes the process when the event is triggered #multiple processes waiting on the same event is resumed...
normal
{ "blob_id": "892eb8d1802b01c035993232cc80c710211ab102", "index": 802, "step-1": "<mask token>\n\n\ndef car(env):\n while True:\n print('The car will start parking at: ', env.now)\n parking_timeout = 5\n yield env.timeout(parking_timeout)\n print('The car will start driving at: ', e...
[ 1, 2, 3, 4, 5 ]
def main(): num = int(input('dia: ')) dia(num) def dia(a): if a == 1: print('Domingo !') elif a == 2: print('Segunda !') else: print('valor invalido !') main()
normal
{ "blob_id": "07332e2da5458fda2112de2507037a759d3c62db", "index": 3382, "step-1": "<mask token>\n", "step-2": "def main():\n num = int(input('dia: '))\n dia(num)\n\n\n<mask token>\n", "step-3": "def main():\n num = int(input('dia: '))\n dia(num)\n\n\ndef dia(a):\n if a == 1:\n print('Dom...
[ 0, 1, 2, 3 ]
import math import time t1 = time.time() # n(3n-1)/2 def isPentagon(item): num = math.floor(math.sqrt(item*2//3))+1 if num*(3*num-1)//2 == item: return True return False # n(2n-1) def isHexagon(item): num = math.floor(math.sqrt(item//2))+1 if num*(2*num-1) == item: return True ...
normal
{ "blob_id": "0aec3fbc9f4b9f33aee021fa417c43f0feb0e3d1", "index": 3296, "step-1": "<mask token>\n\n\ndef isPentagon(item):\n num = math.floor(math.sqrt(item * 2 // 3)) + 1\n if num * (3 * num - 1) // 2 == item:\n return True\n return False\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef i...
[ 1, 3, 4, 5, 6 ]
g7 = int(input()) h7 = g7 / 2 i = g7 - 1 print(int(h7 * i))
normal
{ "blob_id": "abb08956f55fd1e8af27ce12fa94a4137d7d908e", "index": 7251, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(int(h7 * i))\n", "step-3": "g7 = int(input())\nh7 = g7 / 2\ni = g7 - 1\nprint(int(h7 * i))\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
import nltk from nltk import bigrams from lm import * # Oppgave 1: # opretter LM klasse til aa perpleksitere news og adventure m = LM() # Henter news og adventure for videre bruk news=nltk.corpus.brown.sents(categories='news') adventure=nltk.corpus.brown.sents(categories='adventure') # initial parametre perpNews = 0...
normal
{ "blob_id": "d268f8d563aac28852457f6f130b2fb4ea6269a2", "index": 907, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Perpleksitet til news: %.2f' % perpNews)\nprint('Perpleksitet til adventure: %.2f' % perpAdventure)\n<mask token>\nfor sekvens in zippy:\n print('Ord: %4s Antall: %4d Sekvens: %...
[ 0, 1, 2, 3, 4 ]
IS_ZERO = lambda x: x == 0 ONE = 1 SUB1 = lambda x: x - 1 MULT = lambda x: lambda y: x * y IF = lambda cond: lambda t_func: lambda f_func: t_func(None) if cond else f_func(None) print( ( lambda myself: ( lambda n: ( IF( IS_ZERO(n) )( ...
normal
{ "blob_id": "f8601ed7ba7c2b8d2dd8d5f74f7b5ae8e99dad78", "index": 186, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint((lambda myself: lambda n: IF(IS_ZERO(n))(lambda _: ONE)(lambda _:\n MULT(n)(myself(myself)(SUB1(n)))))(lambda myself: lambda n: IF(IS_ZERO(\n n))(lambda _: ONE)(lambda _: MULT(...
[ 0, 1, 2, 3 ]
from __future__ import annotations from VersionControl.Branch import Branch from Branches.Actions.Actions import Actions from VersionControl.Git.Branches.Develop.Init import Init class Develop(Branch): def process(self): if self.action is Actions.INIT: self.start_message('Develop Init') ...
normal
{ "blob_id": "338bf2406c233d857e1a688391161d58e1dab23c", "index": 8910, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Develop(Branch):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Develop(Branch):\n\n def process(self):\n if self.action is Actions.INIT:\n self...
[ 0, 1, 2, 3 ]
import cv2 as cv import numpy as np img = np.zeros((512, 512, 3), np.uint8) cv.line(img, (0, 0), (511, 511), (255, 255, 255), 10) cv.rectangle(img, (384, 0), (510, 128), (255, 0, 0), 3) cv.circle(img, (200, 60), 20, (0, 100, 255), 3) cv.ellipse(img, (250, 250), (100, 50), 90, 0, 180, (255, 0, 255), 3) font = cv.FONT_HE...
normal
{ "blob_id": "08c5f5ac568b7575d8082976336a5893951b53c2", "index": 9269, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv.line(img, (0, 0), (511, 511), (255, 255, 255), 10)\ncv.rectangle(img, (384, 0), (510, 128), (255, 0, 0), 3)\ncv.circle(img, (200, 60), 20, (0, 100, 255), 3)\ncv.ellipse(img, (250, 250)...
[ 0, 1, 2, 3 ]
#!/usr/bin/python # Developed by Hector Cobos import sys import csv import datetime def mapper(): # Using a reader in order to read the whole file reader = csv.reader(sys.stdin, delimiter='\t') # Jump to the next line. We want to avoid the line with the name of the fields reader.next() # loop for line in reade...
normal
{ "blob_id": "d959ed49a83fb63e0bce31b5c81c013f0986706b", "index": 4314, "step-1": "#!/usr/bin/python\n\n# Developed by Hector Cobos\n\nimport sys\nimport csv\nimport datetime\n\ndef mapper():\n\t# Using a reader in order to read the whole file\n\treader = csv.reader(sys.stdin, delimiter='\\t')\n\t# Jump to the ne...
[ 0 ]
''' Created on Nov 16, 2013 @author: mo ''' import unittest from Board import TicTacToe_Board from ComputerPlayer import ComputerPlayer from utils import debug_print as d_pr from main import StartNewGame class Test(unittest.TestCase): def setUp(self): self.the_board = TicTacToe_Board() de...
normal
{ "blob_id": "1968923cd923e68dc5ff2148802f18e40a5e6c33", "index": 939, "step-1": "<mask token>\n\n\nclass Test(unittest.TestCase):\n <mask token>\n\n def tearDown(self):\n pass\n\n def test_these_should_win_for_x(self):\n self.assertEqual(TicTacToe_Board.IsWinningBoard_static([['x', 'x',\n ...
[ 9, 12, 13, 14, 16 ]
import collections import copy import threading import typing as tp from ..decorators.decorators import wraps from ..typing import K, V, T class Monitor: """ Base utility class for creating monitors (the synchronization thingies!) These are NOT re-entrant! Use it like that: >>> class MyProtec...
normal
{ "blob_id": "0528d7761cbbf3dbe881ff05b81060f3d97e7f6c", "index": 742, "step-1": "<mask token>\n\n\nclass MonitorList(tp.Generic[T], collections.UserList, Monitor):\n <mask token>\n\n def __init__(self, *args):\n collections.UserList.__init__(self, *args)\n Monitor.__init__(self)\n <mask to...
[ 17, 20, 22, 23, 33 ]
############################################################################## # Nombre : import.py # Descripción : It takes the information from Transfom.sh Initial Node # Final Node and HAVERSINE Formule # # Parámetros: # Realizado Por : # # HISTORIAL DE CAMB...
normal
{ "blob_id": "0018cbb1d945ad1b6469804e7993afee44406fd1", "index": 2895, "step-1": "<mask token>\n\n\ndef transform_to_my_format(data):\n d = defaultdict(dict)\n for i1, i2, i3 in re.findall('([\\\\d\\\\.]+)\\\\s+([\\\\d\\\\.]+)\\\\s+([\\\\d\\\\.]+)',\n data):\n d[i1].update({i2: float(i3)})\n ...
[ 2, 3, 4, 5, 6 ]
import torch from torchvision import transforms from torch.autograd import Variable class NormalizeImageDict(object): """ Normalize image in dictionary normalize range is True, the image is divided by 255 """ def __init__(self, image_keys, normalizeRange=True): self.image_keys = image_key...
normal
{ "blob_id": "4293ad0b2a4a352d6bdc4b860448c4a3b14ca629", "index": 8648, "step-1": "<mask token>\n\n\nclass NormalizeImageDict(object):\n <mask token>\n <mask token>\n\n def __call__(self, sample):\n for key in self.image_keys:\n if self.normalizeRange:\n sample[key] /= 25...
[ 2, 3, 4, 5 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Oct 25 19:21:32 2019 @author: Nikos """ import torch import torch.optim as optim from utilities import * from model import * from torch.autograd import Variable import numpy as np import random class A2C_agent(object): def __init__(self, env, actor_h...
normal
{ "blob_id": "72b086e833ab3ee4ec3102869d74513ef3657675", "index": 1926, "step-1": "<mask token>\n\n\nclass A2C_agent(object):\n <mask token>\n\n def act(self, state):\n action_distribution = self.actor_network.forward(state)\n action = np.random.choice(self.num_of_actions, p=\n acti...
[ 3, 4, 5, 6, 7 ]
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np def plot3D(xValues, labels, figure = 0): minClass = min(labels) numberOfClasses = int(max(labels) - minClass) fig = plt.figure(figure) ax = plt.axes(projection='3d') colors = ["r", "b", "y", "c", "m"] fo...
normal
{ "blob_id": "8dfd92ab0ce0e71b41ce94bd8fcf057c8995a2a4", "index": 1668, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef plot3D(xValues, labels, figure=0):\n minClass = min(labels)\n numberOfClasses = int(max(labels) - minClass)\n fig = plt.figure(figure)\n ax = plt.axes(projection='3d')...
[ 0, 1, 2, 3 ]
from math import pi from root_regula_falsi import * r = 1.0 ρs = 200.0 ρw = 1000.0 def f(h): Vw = 4*pi*r**3/3 - pi*h**2/3*(3*r - h) # displaced volume of water Vs = 4*pi*r**3/3 return ρw*Vw - ρs*Vs xr = root_regula_falsi(f, 0.0, 2*r)
normal
{ "blob_id": "3e7d2bacb15c39658ef5044685b73068deb1c145", "index": 6060, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef f(h):\n Vw = 4 * pi * r ** 3 / 3 - pi * h ** 2 / 3 * (3 * r - h)\n Vs = 4 * pi * r ** 3 / 3\n return ρw * Vw - ρs * Vs\n\n\n<mask token>\n", "step-3": "<mask token>\nr ...
[ 0, 1, 2, 3, 4 ]
from __future__ import print_function import os from twisted.internet.task import react from twisted.internet.defer import Deferred, inlineCallbacks from twisted.internet.protocol import Factory from twisted.internet.protocol import Protocol from twisted.internet.endpoints import TCP4ClientEndpoint, connectProtocol f...
normal
{ "blob_id": "532bcf8ae0ee40dc3eb4bd7170acfcb5d21cc4b9", "index": 1984, "step-1": "<mask token>\n\n\nclass StdIOFactory(Factory):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass StandardInput(LineReceiver, StandardIO):\n \"\"\"\n Reads stdin and writes every line received as a message to th...
[ 7, 12, 13, 14, 16 ]
string="Rutuja MaluSare" print(string.casefold()) print(len(string)) """string1=input("enter string 1") print("string1") print(len(string1)) string2=input("enter string 2") print("string2") print(len(string2)) string3=string1+string2 print(len(string3))""" #lower case print(string.lower()) #upper case print(string...
normal
{ "blob_id": "024bc95f7255bb8be5c3c4ade9d212c9555a4f01", "index": 3034, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(string.casefold())\nprint(len(string))\n<mask token>\nprint(string.lower())\nprint(string.upper())\n<mask token>\nprint(a)\nprint(a.strip())\n<mask token>\nprint(b)\n", "step-3": ...
[ 0, 1, 2, 3 ]
import API.enum as enum import re class ObjectValidator(): def __init__(self, validationData={}, *args, **kwargs): self.data = validationData self.statusCode = 200 self.validationPipeline = [] self.errors = {} self.invalidFields = [] def flush(self): self = Obj...
normal
{ "blob_id": "e8daf03f987c7512ff245bfbe16c447acd6b5986", "index": 7574, "step-1": "<mask token>\n\n\nclass FieldValidator:\n\n def __init__(self, validationData={}, *args, **kwargs):\n self.data = validationData\n self.validationPipeline = []\n self.statusCode = 200\n self.errors = ...
[ 40, 58, 62, 63, 65 ]
from accounts.models import User from django.forms import ModelForm from django import forms from django.contrib.auth.forms import UserCreationForm class UserRegistrationForm(UserCreationForm): email = forms.EmailField(required=True) password1 = forms.CharField( widget=forms.PasswordInput, # help_text=password_...
normal
{ "blob_id": "e50517910e191594034f60a021647f4415b6f1c4", "index": 2822, "step-1": "<mask token>\n\n\nclass UserRegistrationForm(UserCreationForm):\n <mask token>\n <mask token>\n\n\n class Meta:\n model = User\n fields = 'first_name', 'last_name', 'email', 'password1', 'password2'\n <mas...
[ 3, 4, 5, 6, 7 ]
import boto3 import json from botocore.exceptions import ClientError # upload_to_s3("abc.png", 1) def upload_to_s3(file_name, node_number): try: key_info_json = open("awsinfo.json").read() except FileNotFoundError: print("awsinfo.json is not exist in dir.") exit(-1) dat...
normal
{ "blob_id": "2f0d611fecdb5717029938d2ec2cd2db345b8f3a", "index": 8176, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef upload_to_s3(file_name, node_number):\n try:\n key_info_json = open('awsinfo.json').read()\n except FileNotFoundError:\n print('awsinfo.json is not exist in di...
[ 0, 1, 2, 3 ]
from fabric.api import local,run INSTALL_STEPS = ['yes | sudo apt-get install libmysqlclient-dev python-dev python-mysqldb python-virtualenv', 'virtualenv --no-site-packages env', '. env/bin/activate;pip install -r requirements.txt'] def deps_local(): for step in INSTALL_STEPS: ...
normal
{ "blob_id": "d64140466e62b78506d0f200f451649023697a3b", "index": 1386, "step-1": "<mask token>\n\n\ndef deps_remote():\n for step in INSTALL_STEPS:\n run(step)\n", "step-2": "<mask token>\n\n\ndef deps_local():\n for step in INSTALL_STEPS:\n local(step)\n\n\ndef deps_remote():\n for step...
[ 1, 2, 3, 4, 5 ]
''' @Description: @Version: 1.0 @Autor: Henggao @Date: 2020-02-20 16:17:05 @LastEditors: Henggao @LastEditTime: 2020-02-20 16:32:45 ''' name = "henggao" def change(): name = "Brill" print(name) print(locals()) print(globals()) change() print(name)
normal
{ "blob_id": "6c7162a9bd81d618abda204c24031c5a5acc61b4", "index": 7967, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef change():\n name = 'Brill'\n print(name)\n print(locals())\n print(globals())\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef change():\n name = 'Brill'\n ...
[ 0, 1, 2, 3, 4 ]
# binary search # iterative def Iter_BinarySearch(array,b,e,value): while(b<=e):#pay attention to the judgement! mid=(b+e)/2#floor if (array[mid]<value):#value in [mid,e] b=mid+1 elif (array[mid]>value):#value in [b,mid] e=mid-1 else: print "find ...
normal
{ "blob_id": "f2d7f0b0d27bd43223d0eb6a6279b67968461dad", "index": 9499, "step-1": "# binary search\n\n# iterative\ndef Iter_BinarySearch(array,b,e,value):\n while(b<=e):#pay attention to the judgement!\n mid=(b+e)/2#floor\n if (array[mid]<value):#value in [mid,e]\n b=mid+1\n eli...
[ 0 ]
''' python open() 函数用于打开一个文件,创建一个 file 对象,相关的方法才可以调用它进行读写。 更多文件操作可参考:Python 文件I/O。 函数语法 open(name[, mode[, buffering]]) 参数说明: name : 一个包含了你要访问的文件名称的字符串值。 mode : mode 决定了打开文件的模式:只读,写入,追加等。所有可取值见如下的完全列表。这个参数是非强制的,默认文件访问模式为只读(r)。 buffering : 如果 buffering 的值被设为 0,就不会有寄存。如果 buffering 的值取 1,访问文件时会寄存行。如果将 buffering 的值设为大于 1 的...
normal
{ "blob_id": "3a65565af4c55fa5479e323a737c48f7f2fdb8ce", "index": 596, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f.read())\n<mask token>\n", "step-3": "<mask token>\nf = open('1.txt', 'r', encoding='utf-8')\nprint(f.read())\n<mask token>\n", "step-4": "'''\npython open() 函数用于打开一个文件,创建一个 fil...
[ 0, 1, 2, 3 ]
from django.db import models from django.contrib.auth.models import User from django.utils.encoding import smart_unicode from django.core.validators import MinValueValidator from django.utils import timezone from concurrency.fields import IntegerVersionField class ProductCategory(models.Model): name = models.Char...
normal
{ "blob_id": "9bb15842b39c7fd3e6f6c0048a51c2b2112ddb94", "index": 8082, "step-1": "<mask token>\n\n\nclass Auction(models.Model):\n title = models.CharField(max_length=20)\n current_price = models.DecimalField(max_digits=10, decimal_places=2,\n default=0, null=True, blank=True, verbose_name='current ...
[ 15, 20, 23, 25, 26 ]
# DISCLAIMER # The "Math" code was taken from http://depado.markdownblog.com/2015-09-29-mistune-parser-syntax-highlighter-mathjax-support-and-centered-images # The HighlightRenderer code was taken from https://github.com/rupeshk/MarkdownHighlighter # MarkdownHighlighter is a simple syntax highlighter for Markdown syn...
normal
{ "blob_id": "a6c45ab3df0a692cd625d8203e1152e942a4cd6c", "index": 5908, "step-1": "<mask token>\n\n\nclass MathBlockLexer(mistune.BlockLexer):\n <mask token>\n\n def __init__(self, rules=None, **kwargs):\n if rules is None:\n rules = MathBlockGrammar()\n super(MathBlockLexer, self)....
[ 15, 17, 19, 24, 25 ]
import time from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC def open_browser(browser="chrome"): driver = None if browser == "chrome": driver = webdriver.Chrome() elif browser == "firefox": ...
normal
{ "blob_id": "82fc86e44d02c45d7904139e4dfdff069e2bdb90", "index": 5634, "step-1": "<mask token>\n\n\nclass Base:\n <mask token>\n\n def open_url(self, url):\n self.driver.get(url)\n self.driver.maximize_window()\n\n def find_element(self, locator, timeout=10):\n element = WebDriverWa...
[ 6, 9, 11, 12, 13 ]
""" Test /cohort/:id/user/:id """ import re from unittest.mock import patch from django.urls.base import reverse_lazy from rest_framework import status from breathecode.tests.mocks import ( GOOGLE_CLOUD_PATH, apply_google_cloud_client_mock, apply_google_cloud_bucket_mock, apply_google_cloud_blob_mock, )...
normal
{ "blob_id": "937711546271c145d0f0df2981bdd7d1e9297e3a", "index": 3788, "step-1": "<mask token>\n\n\nclass CohortIdUserIdTestSuite(AdmissionsTestCase):\n <mask token>\n\n @patch(GOOGLE_CLOUD_PATH['client'], apply_google_cloud_client_mock())\n @patch(GOOGLE_CLOUD_PATH['bucket'], apply_google_cloud_bucket_...
[ 9, 13, 14, 15, 16 ]
# Evolutionary Trees contains algorithms and methods used in determining phylogenetic inheritance of various species. # Main algos UPGMA and CLUSTALW from dataclasses import dataclass import FormattingET @dataclass class Node: age: int num: int label: str alignment: [] def __init__(self, child1=Non...
normal
{ "blob_id": "53cf2dfe3319c39ca6f1dc890eea578fae654b5b", "index": 8847, "step-1": "<mask token>\n\n\n@dataclass\nclass Node:\n age: int\n num: int\n label: str\n alignment: []\n\n def __init__(self, child1=None, child2=None):\n self.child1 = child1\n self.child2 = child2\n\n\n<mask to...
[ 9, 12, 16, 17, 21 ]
import numpy as np import math import random from numpy.linalg import inv from scipy.optimize import minimize from Util import to_vector class TS_RLR: def __init__(self, alpha): self.d = 6 self.k = 6 self.alpha = alpha self.batch_size = 1000 self.training_size = 1000 self.impressions = 0 self.batch_...
normal
{ "blob_id": "49df9db508637ce5914aa6591178a03c609b6bc7", "index": 659, "step-1": "<mask token>\n\n\nclass TS_RLR:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TS_RLR:\n\n def __init__(self,...
[ 1, 6, 7, 8, 10 ]
# Copyright 2021 QuantumBlack Visual Analytics Limited # # 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 # # THE SOFTWARE IS PROVIDED "AS IS",...
normal
{ "blob_id": "0069a61127c5968d7014bdf7f8c4441f02e67df0", "index": 6541, "step-1": "<mask token>\n\n\nclass WaitForException(Exception):\n \"\"\"WaitForException: if func doesn't return expected result within the specified time\"\"\"\n\n\ndef _wait_for(func: Callable, expected_result: Any=True, timeout: int=10,...
[ 4, 5, 6, 7, 10 ]
# 1 use the operators to solve for the following equation: # (a) number = ((30*39) + 300) **10 print(number) # find the value of C. X + Y = C Given: x = 0.0050 y = 0.1000 c = x + y print(c) """ what is the result of the following: (a) take the sentence: the study or use of the systems (especially computers and...
normal
{ "blob_id": "c2f82cf73d095979d1da346b7dd7779bcc675805", "index": 4045, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(number)\n<mask token>\nprint(c)\n<mask token>\nprint(word1, ' ' + word2, ' ' + word3)\n<mask token>\nprint(word[:4])\n", "step-3": "number = (30 * 39 + 300) ** 10\nprint(number)\n...
[ 0, 1, 2, 3 ]
from classes.Board import Board class Visualiser: coordinate_map = ("a", "b", "c", "d", "e", "f", "g", "h") __dimensions = 8 def __init__(self): self.map = [] self.__build_map() def __build_map(self): """ Creates the array of the battlefield. Should never be used for ...
normal
{ "blob_id": "e5e012e40a71dee9f4dbd9913590aef125b758df", "index": 223, "step-1": "<mask token>\n\n\nclass Visualiser:\n <mask token>\n <mask token>\n <mask token>\n\n def __build_map(self):\n \"\"\"\n Creates the array of the battlefield. Should never be used for logical operations\n ...
[ 4, 5, 6, 7, 8 ]
from django.contrib.postgres.fields import JSONField from django.db import models from core.utils.time import get_now class BaseManager(models.Manager): """ Our basic manager is used to order all child models of AbstractLayer by created time (descending), therefore it creates a LIFO order, causing th...
normal
{ "blob_id": "5a33aeffa740a41bd0bd1d80f45796ae37377a4c", "index": 757, "step-1": "<mask token>\n\n\nclass AbstractLayer(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @classmethod\n def filter(cls, *args, **kwa...
[ 12, 17, 18, 19, 22 ]
# Takes in a word and makes a list containing individual characters def split(word): return [char for char in word] # Removes empty strings from a list def removeEmptyStrings(lst): while "" in lst: lst.remove("") ints = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] tokenList = [] class Token:...
normal
{ "blob_id": "8d5b75dc945844d48f52159be08fc1e6aa51fdf5", "index": 497, "step-1": "<mask token>\n\n\nclass Lexer:\n\n def __init__(self, items):\n self.items = split(items)\n self.index = 0\n self.item = ''\n self.stringOn = False\n self.stringList = ''\n self.intOn = F...
[ 8, 10, 14, 18, 19 ]
import sys sys.stdin = open('input.txt', 'rt') BLOCK_0 = 1 BLOCK_1 = 2 BLOCK_2 = 3 N = int(input()) X, Y = 10, 10 # x: 행 , y: 열A GRN = 0 BLU = 1 maps = [[0]*Y for _ in range(X)] dx = [1, 0] dy = [0, 1] def outMaps(x, y): global X, Y if 0<=x<X and 0<=y<Y: return False else: return True def meetBlock(x, y, ...
normal
{ "blob_id": "937d01eaa82cbfe07b20fae9320c554a0960d7b1", "index": 571, "step-1": "<mask token>\n\n\ndef meetBlock(x, y, maps):\n if maps[x][y] == 1:\n return True\n else:\n return False\n\n\ndef onlyUpdate(n_blocks, xs, ys, maps):\n for i in range(n_blocks):\n maps[xs[i]][ys[i]] = 1\...
[ 9, 10, 11, 12, 14 ]
class Solution: def toGoatLatin(self, S: str) -> str: def exchange(str2): if str2[0] in "aeiou": str2 = str2+"ma" else: str2 = str2[1:]+str2[0]+"ma" list2 = S.split(" ") for i in list2: res.append(exchange(i)) ...
normal
{ "blob_id": "398c28265e61831ba65b4ae2a785e57c0fa5b6d2", "index": 8311, "step-1": "\n\n\nclass Solution:\n def toGoatLatin(self, S: str) -> str:\n \n def exchange(str2):\n if str2[0] in \"aeiou\":\n str2 = str2+\"ma\"\n else:\n str2 = str2[1:]+s...
[ 0 ]
# -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ # import models from apps.qa.models.coupon import Coupon from apps.qa.models.coupon_type import CouponType COUPONTYPE_CHOICES = ( ('text', _("text")), ('url', _("url")), ('questionnaire', ...
normal
{ "blob_id": "a0f83f0a2c6ddaa2fc641bd4fa48a6f50fd1d978", "index": 1755, "step-1": "<mask token>\n\n\nclass CouponForm(forms.ModelForm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def clean(self):\n cleaned_type = self.cleaned_data.get(...
[ 2, 3, 4, 5, 6 ]
import numpy as np import dl_style_transfer.workspace.data_helpers import os here = os.path.dirname(os.path.abspath(__file__)) sents = list(open(os.path.join(here, 'yelp_sentences.txt'))) + list(open(os.path.join(here, 'shake_sentences.txt'))) thresh = 5 col = dict() word_to_ind = dict() ind_to_word = dict() def...
normal
{ "blob_id": "2317a2fff493588ad6cc3a4ac2b600fbf1c5583c", "index": 8594, "step-1": "<mask token>\n\n\ndef __line_into_col__(line):\n tokens = dl_style_transfer.workspace.data_helpers.clean_str(line).split(' '\n )\n for wor in tokens:\n if col.get(wor) is None:\n col[wor] = 1\n ...
[ 2, 4, 6, 8, 10 ]
def adder(x, y): return x + y adder('one', 'two') adder([3, 4], [9, 0, 33]) adder(4.3, 3.5)
normal
{ "blob_id": "1ee5139cb1613977f1c85619404b3dcc6e996382", "index": 5364, "step-1": "<mask token>\n", "step-2": "def adder(x, y):\n return x + y\n\n\n<mask token>\n", "step-3": "def adder(x, y):\n return x + y\n\n\nadder('one', 'two')\nadder([3, 4], [9, 0, 33])\nadder(4.3, 3.5)\n", "step-4": null, "st...
[ 0, 1, 2 ]
"""""" import random import nbformat from textwrap import dedent from pybryt.preprocessors import IntermediateVariablePreprocessor def test_preprocessor(): """ """ nb = nbformat.v4.new_notebook() nb.cells.append(nbformat.v4.new_code_cell(dedent("""\ a = True b = False f = la...
normal
{ "blob_id": "d9f08e770dacaa86a03d553afd78fdcd725efb62", "index": 5204, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_preprocessor():\n \"\"\"\n \"\"\"\n nb = nbformat.v4.new_notebook()\n nb.cells.append(nbformat.v4.new_code_cell(dedent(\n \"\"\" a = True\n b...
[ 0, 1, 2, 3 ]
# Copyright (C) 2014 Abhay Vardhan. All Rights Reserved. """ Author: abhay.vardhan@gmail.com We have not yet added tests which exercise the HTTP GET directly. """ __author__ = 'abhay' from nose.tools import * import test_data import search_index class TestClass: def setUp(self): search_index.buildIndex(tes...
normal
{ "blob_id": "a9c0251b3422457b2c0089b70308a70b09cfa0e0", "index": 7276, "step-1": "<mask token>\n\n\nclass TestClass:\n\n def setUp(self):\n search_index.buildIndex(test_data.sample_food_trucks_data)\n\n def tearDown(self):\n pass\n\n def test_case_query_index(self):\n assert_equals(...
[ 11, 13, 14, 18, 19 ]
# -*- coding: utf-8 -*- import base64 import logging from decimal import Decimal import requests from django import forms from django.conf import settings from django.utils.translation import ugettext_lazy as _ from currencies.currencies import decimal_round from payments.systems import base from payments.systems.ban...
normal
{ "blob_id": "15c1db535beb115c45aeba433a946255f70fa86e", "index": 7845, "step-1": "<mask token>\n\n\nclass DepositForm(base.DepositForm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @classmethod\n def is_automatic(cls, instance):\n r...
[ 9, 10, 11, 13, 17 ]
from django.shortcuts import render from django.contrib import messages from django.contrib.auth import logout from django.contrib.auth.decorators import login_required # Create your views here. # def login(request): # return render(request, 'login.html') # def validar_login(request): # usuario= request.POST['...
normal
{ "blob_id": "08712e050bd90408ed9d22bba9f62fafacd64d99", "index": 9671, "step-1": "<mask token>\n\n\n@login_required\ndef Lojanisima(request):\n return render(request, 'lojanisima/ruta_lojanisima.html')\n\n\n@login_required\ndef Identiarte(request):\n return render(request, 'identiarte/ruta_identiarte.html'...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtGui import * from PyQt5.QtCore import * class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.s...
normal
{ "blob_id": "65264f52f641b67c707b6a827ecfe1bf417748e8", "index": 2379, "step-1": "<mask token>\n\n\nclass Ui_MainWindow(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Ui_MainWindow(object):\n\n def setupUi(self, MainWindow):\n MainWindow.setObjectName('MainWindow'...
[ 1, 2, 3, 4, 5 ]
line_numbers = input().split(", ") print("Positive:", ", ".join(list(filter((lambda x: int(x) > -1), line_numbers)))) print("Negative:", ", ".join((list(filter((lambda x: int(x) < 0), line_numbers))))) print("Even:", ", ".join((list(filter((lambda x: int(x) % 2 == 0), line_numbers))))) print("Odd:", ", ".join((list(fil...
normal
{ "blob_id": "e4845e5aa949ec523515efc4d7996d647fddabdb", "index": 7060, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Positive:', ', '.join(list(filter(lambda x: int(x) > -1, line_numbers)))\n )\nprint('Negative:', ', '.join(list(filter(lambda x: int(x) < 0, line_numbers))))\nprint('Even:', ', ...
[ 0, 1, 2, 3 ]
import gc import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from tqdm import tqdm import cv2 import torch from torch.utils.data import DataLoader from torch import optim from torch.optim import lr_scheduler from dataset.car_dataset import CarDataset from nn.netw...
normal
{ "blob_id": "1861c394fb02643d2e6ac8362f3340f512ef6d72", "index": 6402, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n ROOT_PATH = '/media/andreis/storage/datasets/pku-autonomous-driving/'\n df = pd.read_csv(ROOT_PATH + 'train.csv')\n df_test = pd.read_csv(ROOT_PATH +...
[ 0, 1, 2, 3, 4 ]
from flask import Flask, request, render_template, redirect from pymongo import MongoClient from envparse import env from flask_httpauth import HTTPDigestAuth import os.path # Get env vars stored either in an env file or on the machine def get_env(name): if (os.path.exists('./env')): env.read_envfile('./env') ret...
normal
{ "blob_id": "ad813216ba8162a7089340c677e47c3e656f7c95", "index": 6198, "step-1": "<mask token>\n\n\n@app.route('/')\ndef show_home():\n return render_template('index.html')\n\n\n@app.route('/addhost', methods=['GET', 'POST'])\ndef hosts():\n if request.method == 'POST':\n db = mongo_login()\n ...
[ 6, 7, 10, 13, 14 ]
import requests import json class Parser: init_url = r'https://www.joom.com/tokens/init' products_url = r'https://api.joom.com/1.1/search/products?language=ru-RU&currency=RUB' def __init__(self, links_list): self.links = links_list self.product_info_dict = {} access_token = json.l...
normal
{ "blob_id": "00c6899b9d49cbbd0f1980eada77ad91562211a0", "index": 4471, "step-1": "<mask token>\n\n\nclass Parser:\n <mask token>\n <mask token>\n <mask token>\n\n def get_description(self, id_str, headers):\n link = ('https://api.joom.com/1.1/products/' + id_str +\n '?language=ru-RU...
[ 2, 3, 4, 5, 6 ]
__doc__ def fizz_buzz(num1, num2, end_range): if not ( isinstance(num1, int) and isinstance(num2, int) and isinstance(end_range, int) ) or (num1 < 0 or num2 < 0 or end_range < 0): return "Input should be a positive integer" # I'm storing the result to test the returned value aka a list of...
normal
{ "blob_id": "d00873c3ee72b55cb5b74f78a98de61a25b3cc21", "index": 7227, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_answer():\n import sys\n answer1 = None\n answer2 = None\n answer3 = None\n try:\n answer1 = fizz_buzz(3, 5, 16)\n answer2 = fizz_buzz(2, 7, 20)\...
[ 0, 1, 2, 3, 4 ]
from django.apps import AppConfig class FosAppConfig(AppConfig): name = 'fos_app'
normal
{ "blob_id": "d83f2d9bb25a46bc7344b420ce65bf729165e6b9", "index": 278, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass FosAppConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass FosAppConfig(AppConfig):\n name = 'fos_app'\n", "step-4": "from django.apps import AppCon...
[ 0, 1, 2, 3 ]
import unittest from textwrap import dedent from simplesat import InstallRequirement, Repository from simplesat.test_utils import packages_from_definition from ..compute_dependencies import (compute_dependencies, compute_leaf_packages, compute_re...
normal
{ "blob_id": "fcf19c49bb161305eaa5ba8bc26e276a8e8db8ea", "index": 3925, "step-1": "<mask token>\n\n\nclass TestComputeReverseDependencies(unittest.TestCase):\n\n def setUp(self):\n repo_0 = Repository(packages_from_definition(PACKAGE_DEF_0))\n repo_1 = Repository(packages_from_definition(PACKAGE_...
[ 5, 12, 13, 14, 18 ]
import pandas as pd df = pd.DataFrame({'col1':[1,2,3,4],'col2':[444,555,666,444],'col3':['abc','def','ghi','xyz']}) print(df.head()) #print(df['col2'].unique()) #print(df['col1'] > 2) newdf = df[(df['col1']>0) & (df['col2'] == 444)] print("========================") print(newdf) def times2(x): return x*2 print("=...
normal
{ "blob_id": "422a4945ebf453d3e09e9e7e76dd32b30488680e", "index": 3011, "step-1": "<mask token>\n\n\ndef times2(x):\n return x * 2\n\n\n<mask token>\n", "step-2": "<mask token>\nprint(df.head())\n<mask token>\nprint('========================')\nprint(newdf)\n\n\ndef times2(x):\n return x * 2\n\n\nprint('=...
[ 1, 2, 3, 4, 5 ]
import sys def solution(input): k = 1 for v in sorted(input): if v >= k: k += 1 return k - 1 testcase = sys.stdin.readline() for i in range(int(testcase)): sys.stdin.readline() line1 = sys.stdin.readline().rstrip('\n') line2 = sys.stdin.readline().rstrip('\n') ans = sol...
normal
{ "blob_id": "a89724be31b4ccc1a3d83305509d9624da364a0c", "index": 6004, "step-1": "<mask token>\n\n\ndef solution(input):\n k = 1\n for v in sorted(input):\n if v >= k:\n k += 1\n return k - 1\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef solution(input):\n k = 1\n for ...
[ 1, 2, 3, 4, 5 ]
def main(): ' main entry point for module execution\n ' argument_spec = dict(src=dict(type='path'), replace_src=dict(), lines=dict(aliases=['commands'], type='list'), parents=dict(type='list'), before=dict(type='list'), after=dict(type='list'), match=dict(default='line', choices=['line', 'strict', 'exact', '...
normal
{ "blob_id": "99b5ac74da95dff399c31d58e19bac65e538a34b", "index": 8012, "step-1": "<mask token>\n", "step-2": "def main():\n \"\"\" main entry point for module execution\n \"\"\"\n argument_spec = dict(src=dict(type='path'), replace_src=dict(), lines=\n dict(aliases=['commands'], type='list'), p...
[ 0, 1, 2 ]
#coding: utf-8 #/usr/bin/python __author__='julia sayapina' ### Use db_reset.py to drop the db and recreate it, then use 'migrate' --> 'createsuperuser' --> 'makemigrations' --> 'migrate' as usual. ### This will create the DB structure as it has to be from django ### Then use test_db_fullfill.py to fullfill the db wit...
normal
{ "blob_id": "3240310653930662dcc4d79646b1a75c2994cda7", "index": 9063, "step-1": "<mask token>\n\n\ndef db_create():\n cur.execute(\n \"\"\"\n create table if not exists Offshores_asset (\n id INTEGER PRIMARY KEY AUTO_INCREMENT,\n asset_name VARCHA...
[ 2, 4, 5, 6, 7 ]
from django.apps import AppConfig class ProjectrolesConfig(AppConfig): name = 'projectroles'
normal
{ "blob_id": "6a4585e0e2f5ebbd0f9a7fa203f76bb88ff9c2a0", "index": 2920, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ProjectrolesConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ProjectrolesConfig(AppConfig):\n name = 'projectroles'\n", "step-4": "from django....
[ 0, 1, 2, 3 ]
import sys from Decks.Virtual_World.vw_sets import * from tools import * hand_3playable_hts = ["Nibiru, the Primal Being", "Effect Veiler", "Fantastical Dragon Phantazmay", "Dragon Buster Destruction Sword", "Dragon Buster Destruction Sword"] hand_2playable_hts = ["Nibiru, the Primal Being", "Nibiru, the Primal Being"...
normal
{ "blob_id": "43179b8b096836758271a791b4aacb7bbe398ea9", "index": 1807, "step-1": "<mask token>\n\n\ndef test_playable_hts_in_hand():\n assert playable_hts_in_hand(hand_3playable_hts) == 3\n assert playable_hts_in_hand(hand_2playable_hts) == 2\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef test_pl...
[ 1, 2, 3, 4, 5 ]
def pixels_generator(w, h): i = 0 while i < (w * h): yield divmod(i, w) i = i + 1
normal
{ "blob_id": "bb481fa038835abc6d61a4985b1e30c7c00bff96", "index": 158, "step-1": "<mask token>\n", "step-2": "def pixels_generator(w, h):\n i = 0\n while i < w * h:\n yield divmod(i, w)\n i = i + 1\n", "step-3": "def pixels_generator(w, h):\n i = 0\n while i < (w * h):\n yield...
[ 0, 1, 2 ]
#!/usr/bin/env python import rospy import cv2 import numpy as np from cv_bridge import CvBridge from matplotlib import pyplot as plt from sensor_msgs.msg import Image from drone_app_msgs.msg import BBox, Drone, DroneArray from rospy.numpy_msg import numpy_msg # --------------------------------------- # This is an impl...
normal
{ "blob_id": "e864dad3f46fc9c6c472823bd06ce74fb5cb3f41", "index": 462, "step-1": "<mask token>\n\n\ndef processFrame(image_message):\n frame = CvBridge().imgmsg_to_cv2(image_message)\n frame_hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)\n mask = cv2.inRange(frame_hsv, (0, 0, 0, 0), (180, 255, 30, 0))\n ...
[ 1, 2, 3, 4, 5 ]
import argparse import pickle import pandas as pd from pyspark.sql.session import SparkSession parser = argparse.ArgumentParser() parser.add_argument('--rs', type=str, nargs='+') args = parser.parse_args() ss = SparkSession.builder.getOrCreate() post_df = None for f in args.rs: df = ss.read.json(f).select('id', 'su...
normal
{ "blob_id": "e6b3def6ed6f2523d88912832a876caf2742b786", "index": 7572, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('--rs', type=str, nargs='+')\n<mask token>\nfor f in args.rs:\n df = ss.read.json(f).select('id', 'subreddit', 'subreddit_id', 'title')\n post_df = df if post_df...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # USAGE: day_22_01.py # Michael Chambers, 2017 class Grid: def __init__(self, startFile): # Load initial infected sites # Origin is top-left of input file self.infected = set() posx = 0 with open(startFile, 'r') as fo: for i, line in enumerate(fo): line = line.rstrip() posx...
normal
{ "blob_id": "f840624ec11679d576fbb80f8e753c59663a7ee2", "index": 9168, "step-1": "<mask token>\n\n\nclass ComplexGrid:\n\n def __init__(self, startFile):\n self.weakened = set()\n self.infected = set()\n self.flagged = set()\n posx = 0\n with open(startFile, 'r') as fo:\n ...
[ 6, 7, 11, 13, 14 ]
import gc import unittest import numpy as np from pydrake.autodiffutils import AutoDiffXd from pydrake.common import RandomDistribution, RandomGenerator from pydrake.common.test_utilities import numpy_compare from pydrake.common.test_utilities.deprecation import catch_drake_warnings from pydrake.common.value import Va...
normal
{ "blob_id": "f17ae8a44f8b032feac7c18fe39663054fea40c0", "index": 5282, "step-1": "<mask token>\n\n\nclass TestGeneral(unittest.TestCase):\n\n def _check_instantiations(self, template, supports_symbolic=True):\n default_cls = template[None]\n self.assertTrue(template[float] is default_cls)\n ...
[ 25, 26, 28, 30, 35 ]
from datetime import * dd=int(input("enter number day: ")) nn=int(datetime.now().strftime("%w"))+1 # print(dd) # print(nn) print((datetime.now().date())+(timedelta(days=dd-nn)))
normal
{ "blob_id": "d3342507cb1966e14380ff28ae12b5c334abd20a", "index": 5430, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(datetime.now().date() + timedelta(days=dd - nn))\n", "step-3": "<mask token>\ndd = int(input('enter number day: '))\nnn = int(datetime.now().strftime('%w')) + 1\nprint(datetime.no...
[ 0, 1, 2, 3, 4 ]
import pygame import serial import time ser1 = serial.Serial('/dev/ttyACM0', 115200) #Right ser1.write('?\n') time.sleep(0.5) if ser1.readline()[4] == 0: ser2 = serial.Serial('/dev/ttyACM1', 115200) #Left, negative speeds go forward else: ser1 = serial.Serial('/dev/ttyACM1', 115200) ser2 = serial.Serial('/...
normal
{ "blob_id": "e6d4d12d47391927364fdc9765c68690d42c5d8d", "index": 8950, "step-1": "<mask token>\n\n\ndef write_spd(write1, write2):\n ser1.write('sd' + str(write1) + '\\n')\n ser2.write('sd' + str(-write2) + '\\n')\n\n\n<mask token>\n", "step-2": "<mask token>\nser1.write('?\\n')\ntime.sleep(0.5)\nif ser1...
[ 1, 2, 3, 4, 5 ]
import serial import mysql.connector ser = serial.Serial('/dev/serial0', 9600) while True: data = ser.readline() if data[0]==";": print(data) data = data.split(";") if data[1] == "1": fonction = data[1] add = data[2] tmp = data[3] debit = data[4] ser.write([123]) #test affichage print "Sa...
normal
{ "blob_id": "b1a6593e7b528238e7be5ea6da4d1bfee0d78067", "index": 7824, "step-1": "import serial\nimport mysql.connector\n\nser = serial.Serial('/dev/serial0', 9600)\n\nwhile True:\n\tdata = ser.readline()\n\tif data[0]==\";\":\n\t\tprint(data)\n\t\tdata = data.split(\";\")\n\t\tif data[1] == \"1\":\n\t\t\tfoncti...
[ 0 ]
# Time: O(|V| + |E|) # Space: O(|V|) class Solution(object): def eventualSafeNodes(self, graph): """ :type graph: List[List[int]] :rtype: List[int] """ WHITE, GRAY, BLACK = range(3) def dfs(graph, node, lookup): if lookup[node] != WHITE: ...
normal
{ "blob_id": "5c5cfcd240c8b05970dc8dff57bfbbdc98f1d100", "index": 9838, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def eventualSafeNodes(self, graph):\n \"\"\"\n :type graph: List[List[int]]\n :rtype: List...
[ 0, 1, 2, 3 ]
''' Author: Iris Peng. Date: Feb 21, 2016 Usage: Scrape Weibo posts from Zhongsou for the first time for a query In the terminal, type $ python3 scrape_weibo.py and follow the prompts ''' import requests from bs4 import BeautifulSoup from pandas import DataFrame import time import pandas import glob, os global QUE...
normal
{ "blob_id": "ed3fbae19c88100690dd5c558c0dc6d36a4849c8", "index": 1451, "step-1": "<mask token>\n\n\nclass NewScrape:\n\n def scrape_main(self):\n \"\"\"\n Top-level function.\n Use links from below, scrape a page, sleep for 5s, and restart on the next link.\n \"\"\"\n for i ...
[ 9, 12, 13, 14, 15 ]
# def add(a,b): # x = a + b # # # the return value gets assigned to the "result" variable # result = add(3,5) # print result # this should print 8 # # def multiply(arr,num): # for x in range(len(arr)): # arr[x] *= num # return arr # # a = [2,4,10,16] # b = multiply(a,5) # print b # # # dog = ("Canis F...
normal
{ "blob_id": "e24c3f6ce2e65305f955dcede9edc0b497f6e74c", "index": 2880, "step-1": "# def add(a,b):\n# x = a + b\n#\n# # the return value gets assigned to the \"result\" variable\n# result = add(3,5)\n# print result # this should print 8\n#\n# def multiply(arr,num):\n# for x in range(len(arr)):\n# ar...
[ 0 ]
# import random module from Python standard library # define a dictionary with image urls and number of flucks # set the served img variable to be a random element from imgs # hints: # to put dict keys in a list: list(dict.keys()) # to choose a random item from a list: random.choice(lst) # keep asking user if they ...
normal
{ "blob_id": "4ae611ee8c019c76bb5d7c1d733ffb4bd06e2e8d", "index": 5508, "step-1": "<mask token>\n", "step-2": "<mask token>\nrandom.choice(imgs)\n<mask token>\nprint(served_img)\n<mask token>\nif input == 'yes':\n print('YOU FLUCKED IT')\nelif input == 'no':\n print('WHAT ARE YOU???..')\n", "step-3": "<...
[ 0, 1, 2, 3, 4 ]
from django.contrib import admin from basic_app.models import UserProfileInfo admin.site.register(UserProfileInfo) # we do not need to register User() default form since it comes # with the default admin site in Django itself.
normal
{ "blob_id": "624212a1d73ff3a3b3092ffa27912a6ae25a2484", "index": 6826, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(UserProfileInfo)\n", "step-3": "from django.contrib import admin\nfrom basic_app.models import UserProfileInfo\nadmin.site.register(UserProfileInfo)\n", "step-4": ...
[ 0, 1, 2, 3 ]
from pymongo import MongoClient import Config DB = Config.DB COLLECTION = Config.COLLECTION def connectMongo(): uri = "mongodb://localhost" client = MongoClient(uri) return client[DB] def connectMongoCollection(collection = COLLECTION): uri = "mongodb://localhost" client = MongoClient(uri) db = client[DB] re...
normal
{ "blob_id": "7a5106456d0fdd905829c5aa1f4a69b027f3a04c", "index": 4198, "step-1": "<mask token>\n\n\ndef connectMongoCollection(collection=COLLECTION):\n uri = 'mongodb://localhost'\n client = MongoClient(uri)\n db = client[DB]\n return db[collection]\n", "step-2": "<mask token>\n\n\ndef connectMong...
[ 1, 2, 3, 4, 5 ]
from app import config from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker engine = create_engine(config.DB_URI) Session = scoped_session(sessionmaker(bind=engine))
normal
{ "blob_id": "86c1aee21639958f707f99bc2468e952ad6c1859", "index": 9352, "step-1": "<mask token>\n", "step-2": "<mask token>\nengine = create_engine(config.DB_URI)\nSession = scoped_session(sessionmaker(bind=engine))\n", "step-3": "from app import config\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.o...
[ 0, 1, 2 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # This file is part of CbM (https://github.com/ec-jrc/cbm). # Author : Konstantinos Anastasakis # Credits : GTCAP Team # Copyright : 2021 European Commission, Joint Research Centre # License : 3-Clause BSD import os import glob from ipywidgets import (Text, Label...
normal
{ "blob_id": "2f9a081845685a4748c8b028ae4ee3a056a10284", "index": 9779, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef foi_tab_v1():\n path_foi = f\"{config.get_value(['paths', 'temp'])}/foi/\"\n path_foi_func = foi_v1.path_foi_func\n progress = Output()\n\n def outlog(*text):\n ...
[ 0, 2, 3, 4, 5 ]
#!/usr/bin/env python #-*- coding:utf8 -*- # Power by null 2018-09-19 18:41:17 from codebase.mod.mod_test import test_f
normal
{ "blob_id": "7c4709eaa5123b44e6355c6a60932f286e3b1cf5", "index": 7450, "step-1": "<mask token>\n", "step-2": "from codebase.mod.mod_test import test_f\n", "step-3": "#!/usr/bin/env python\n#-*- coding:utf8 -*-\n# Power by null 2018-09-19 18:41:17\n\nfrom codebase.mod.mod_test import test_f\n", "step-4": nu...
[ 0, 1, 2 ]
"""" You are given a tree-like data structure represented as nested dictionaries. Implement a function collect_leaves that accepts a tree and returns a list of all its leaves. A leaf is a bottom-most node in a tree. Implement a kind of unit tests via assert operator. """ from typing import Union def collect...
normal
{ "blob_id": "603cce951dd0f78ef3ca9dce587042b3b7f6b449", "index": 8001, "step-1": "<mask token>\n\n\ndef collect_leaves(u: Union[dict, list]) ->list:\n flatten_list = []\n if isinstance(u, dict):\n for item in u.values():\n flatten_list.extend(collect_leaves(item))\n return flatten_...
[ 1, 2, 3, 4, 5 ]
""" pytest.mark.parametrize(“变量参数名称”,变量数据列表[‘123’,‘34’,‘567’,‘78’]) 上面的变量个数有4个,测试用例传入变量名称后,会依序4次使用变量的数据,执行4次测试用例 def test001(self,"变量参数名称") assert 变量名称 """
normal
{ "blob_id": "24f3284a7a994951a1f0a4ef64c951499bbba1b4", "index": 6958, "step-1": "<mask token>\n", "step-2": "\"\"\"\n pytest.mark.parametrize(“变量参数名称”,变量数据列表[‘123’,‘34’,‘567’,‘78’])\n 上面的变量个数有4个,测试用例传入变量名称后,会依序4次使用变量的数据,执行4次测试用例\n def test001(self,\"变量参数名称\")\n assert 变量名称\n\n\"\"\"", "step...
[ 0, 1 ]
import sqlite3 from flask_restful import Resource, reqparse from flask_jwt import JWT, jwt_required #import base64 import datetime import psycopg2 class User: def __init__(self, _id, username, password, user_name, address, contact): self.id = _id self.username = username self.password =...
normal
{ "blob_id": "84d154afe206fd2c7381a2203affc162c28e21c1", "index": 5863, "step-1": "<mask token>\n\n\nclass PresOrder(Resource):\n <mask token>\n parser.add_argument('username', type=str, required=True, help=\n 'This field cannot be left blank.')\n parser.add_argument('pres', type=str, required=Tru...
[ 5, 8, 9, 10, 12 ]
# 引入基础的工作表 from openpyxl import Workbook # 引入增强的修改功能 from openpyxl.styles import Font,Alignment,Border,Side,PatternFill,colors # import openpyxl def make_example(): # 设定文件目录 addr = './example.xlsx' # 初始化文件,切换到活动的工作表 work_book = Workbook() # 读取文件采用 # work_book = openpyxl.load_workbook...
normal
{ "blob_id": "d7524a455e62594e321b67f0a32a5c3a7437c1d6", "index": 1093, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef make_example():\n addr = './example.xlsx'\n work_book = Workbook()\n work_sheet = work_book.active\n work_sheet['A1'] = 'Hello World!'\n select_cell = work_sheet.ce...
[ 0, 1, 2, 3, 4 ]
import numpy.random as rnd import numpy as np B=100000 N1=50 N2=50 p1mle=0.3 p2mle=0.4 taumle=p2mle-p1mle estimate=[] for i in range(B): p1=0.0 for j in range(N1): if(rnd.uniform(0,1)<p1mle): p1+=1 p1/=N1 p2=0.0 for j in range(N2): if(rnd.uniform(0,1)<p2mle): p2+=1 p2/=N2 estimate.append(p2-p...
normal
{ "blob_id": "0db0daf9bea254cffaec1280cd13b2d70368cd94", "index": 289, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(B):\n p1 = 0.0\n for j in range(N1):\n if rnd.uniform(0, 1) < p1mle:\n p1 += 1\n p1 /= N1\n p2 = 0.0\n for j in range(N2):\n if rnd.u...
[ 0, 1, 2, 3, 4 ]