code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
# -*- coding: utf-8 -*- from datetime import datetime, timedelta import math import re import copy from lcs import lcs # Create your models here. keywords=["int","long","for","while","if","else","break","continue","return","true","false","double","do","signed","unsigned"] symbol=["[","]","{","}","(",")","&","|","^",...
normal
{ "blob_id": "ebd510bcd0caded03c5bcc36a11945710d5e644b", "index": 5591, "step-1": "# -*- coding: utf-8 -*-\n\nfrom datetime import datetime, timedelta\nimport math\nimport re\nimport copy\nfrom lcs import lcs\n# Create your models here.\n\n\nkeywords=[\"int\",\"long\",\"for\",\"while\",\"if\",\"else\",\"break\",\...
[ 0 ]
#!/usr/bin/env python """ Checker of generated packages. - [x] import generated package - [x] flake8 - [x] pyright - [x] mypy """ import argparse import json import logging import subprocess import sys import tempfile from dataclasses import dataclass from pathlib import Path from typing import List, Optional ROOT_PA...
normal
{ "blob_id": "f3466fd38ecf472a4342aad4d10410d6f2a67d47", "index": 1779, "step-1": "<mask token>\n\n\nclass SnapshotMismatchError(Exception):\n \"\"\"\n Main snapshot mismatch exception.\n \"\"\"\n\n\ndef setup_logging(level: int) ->logging.Logger:\n \"\"\"\n Get Logger instance.\n\n Arguments:\n...
[ 13, 14, 16, 17, 19 ]
# Generated by Django 3.0.8 on 2020-07-12 19:05 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('CRUD', '0001_initial'), ] operations = [ migrations.RenameField( model_name='employee', old_name='eAdddress', ne...
normal
{ "blob_id": "b1d8a454e590dfa4afa257ca665376c320a4acb5", "index": 5264, "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 = [('CRUD', '000...
[ 0, 1, 2, 3, 4 ]
from lib.appData import driver_queue from lib.pyapp import Pyapp import threading from appium.webdriver.common.touch_action import TouchAction from lib.logger import logger import time local = threading.local() class BasePage(object): def __init__(self, driver=None): if driver is None: local.d...
normal
{ "blob_id": "aa51c8f736461f147704c1ec0669c265348fcb80", "index": 6869, "step-1": "<mask token>\n\n\nclass QQ_Login_Page(BasePage):\n\n def login(self):\n local.pyapp.click('android=>new UiSelector().text(\"登 录\")')\n\n def username(self):\n local.pyapp.type('content=>请输入QQ号码或手机或邮箱', 340846750...
[ 15, 16, 18, 20, 24 ]
n = input() n = list(n) n.sort() alph = [] num = [] for i in range(n): if i.isalpha(): alpa.append(i) else: num.append(i) result.append(str(alpa)) result.append(str(num)) print(n)
normal
{ "blob_id": "e364a4e6e1c4e0fd6805515a1149adaf92e9c8fb", "index": 5584, "step-1": "<mask token>\n", "step-2": "<mask token>\nn.sort()\n<mask token>\nfor i in range(n):\n if i.isalpha():\n alpa.append(i)\n else:\n num.append(i)\nresult.append(str(alpa))\nresult.append(str(num))\nprint(n)\n", ...
[ 0, 1, 2 ]
# SPDX-FileCopyrightText: 2021 John Park for Adafruit Industries # SPDX-License-Identifier: MIT import time import random import board import audiomp3 import audiopwmio from adafruit_crickit import crickit ss = crickit.seesaw # Crickit seesaw setup button = crickit.SIGNAL1 # momentary switch to trigger animation ss...
normal
{ "blob_id": "608c116cd42132bd63be5056f0aaf5c78933886e", "index": 7536, "step-1": "<mask token>\n\n\ndef open_lid():\n motor_lid.throttle = 1\n time.sleep(0.25)\n motor_lid.throttle = 0\n\n\ndef close_lid():\n motor_lid.throttle = -1\n time.sleep(0.25)\n motor_lid.throttle = 0\n\n\ndef blink(tim...
[ 3, 5, 6, 7, 8 ]
# python /Users/lawrie_6strings/be_professional_pythonist/control_string.py # -*- coding: utf-8 -*- # 文字列を3行で書いてみたい場合 """ どないやねん。 最近の若いもんは、 ようやるやんけ。 """ # 文字列の特定の文字を取得したい場合は,インデックスを指定してあげることでなんとかする。 word = "what's up" print(word[0]) # 書式化 name = "lady gaga" print("こんにちわ、私の名前は {} です。".format(name)) "複数の文字列を挿入することもできる...
normal
{ "blob_id": "0e05eed2d6bc723fd8379e436621a6eba4aa5ab2", "index": 1929, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(word[0])\n<mask token>\nprint('こんにちわ、私の名前は {} です。'.format(name))\n<mask token>\nprint('{}/{}/{}'.format(year, month, day))\nfor i in range(0, 5):\n print('kamyu'[i])\nprint('aldo...
[ 0, 1, 2, 3 ]
import unittest2 as unittest from zope.component import getUtility from plone.registry.interfaces import IRegistry from plone.testing.z2 import Browser from plone.app.testing import SITE_OWNER_NAME, SITE_OWNER_PASSWORD from openmultimedia.imagewatchdog.configlet import IImageWatchDogSettings from openmultimedia.image...
normal
{ "blob_id": "ce5f91aa04065aac4d4bc7bdbaab3b74c5a85a93", "index": 8752, "step-1": "<mask token>\n\n\nclass TestConfiglet(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_default_config(self):\n \"\"\" Validate the default values\n \"\"\"\n registry = getUtility(IRegistr...
[ 4, 6, 7, 8, 9 ]
/home/pushkar/anaconda3/lib/python3.6/_bootlocale.py
normal
{ "blob_id": "ea4e4c8067d9e910b8d4c6a1c4c01f1ef70d7341", "index": 7410, "step-1": "/home/pushkar/anaconda3/lib/python3.6/_bootlocale.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
# coding: utf-8 """ Negotiation API The <b>Negotiations API</b> gives sellers the ability to proactively send discount offers to buyers who have shown an \"interest\" in their listings. <br><br>By sending buyers discount offers on listings where they have shown an interest, sellers can increase the velocity ...
normal
{ "blob_id": "a93818440410bde004f0203f18112fa1b666959c", "index": 9615, "step-1": "<mask token>\n\n\nclass OfferApi(object):\n <mask token>\n <mask token>\n <mask token>\n\n def find_eligible_items_with_http_info(self, x_ebay_c_marketplace_id,\n **kwargs):\n \"\"\"find_eligible_items # ...
[ 4, 5, 6, 8, 9 ]
#/usr/share/python3 from sklearn.linear_model import LogisticRegression from sklearn.ensemble import GradientBoostingClassifier from sklearn.model_selection import train_test_split import numpy as np import seaborn as sb import pandas as pd from pmlb import fetch_data, classification_dataset_names import util # f...
normal
{ "blob_id": "4c010f9d9e7813a4ae4f592ade60130933b51958", "index": 6125, "step-1": "<mask token>\n\n\ndef score_model(X, y, model):\n train_X, test_X, train_y, test_y = train_test_split(X, y)\n model.fit(train_X, train_y)\n return model.score(test_X, test_y)\n\n\n<mask token>\n\n\ndef main():\n ds_name...
[ 2, 3, 4, 5, 6 ]
# Copyright (c) 2008 Johns Hopkins University. # All rights reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose, without fee, and without written # agreement is hereby granted, provided that the above copyright # notice, the (updated) modification history ...
normal
{ "blob_id": "4af53bf9cbe136dec7dcc609e28cdd013911c385", "index": 7421, "step-1": "# Copyright (c) 2008 Johns Hopkins University.\n# All rights reserved.\n#\n# Permission to use, copy, modify, and distribute this software and its\n# documentation for any purpose, without fee, and without written\n# agreement is h...
[ 0 ]
# Copyright 2019-2020 the ProGraML authors. # # Contact Chris Cummins <chrisc.101@gmail.com>. # # 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": "09788cf04ab5190a33b43e3756f4dbd7d78977a5", "index": 581, "step-1": "<mask token>\n\n\nclass GraphTupleData(Base, sqlutil.PluralTablenameFromCamelCapsClassNameMixin):\n <mask token>\n id: int = sql.Column(sql.Integer, sql.ForeignKey('graph_tuples.id',\n onupdate='CASCADE', ondelete='CASC...
[ 40, 44, 48, 54, 63 ]
from .authenticators import CookieAuthenticator, HeaderAuthenticator from .paginators import LimitOffsetPaginator, PageNumberPaginator from .views import * # pylint:disable=W0401
normal
{ "blob_id": "dab53d10958b36cf75ab53bf30f744b1ed8a09b6", "index": 6475, "step-1": "<mask token>\n", "step-2": "from .authenticators import CookieAuthenticator, HeaderAuthenticator\nfrom .paginators import LimitOffsetPaginator, PageNumberPaginator\nfrom .views import *\n", "step-3": "from .authenticators impor...
[ 0, 1, 2 ]
# Copyright 2016 Huawei, Inc. 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 by appli...
normal
{ "blob_id": "cc9485dea0975a0974f037b129816a9359b2b622", "index": 2875, "step-1": "<mask token>\n\n\nclass TestConsoleUrlShow(TestConsole):\n _server = compute_fakes.create_one_server()\n\n def setUp(self):\n super(TestConsoleUrlShow, self).setUp()\n self.sdk_client.find_server.return_value = ...
[ 10, 15, 18, 19, 20 ]
def domain_sort_key(domain): """Key to sort hosts / domains alphabetically, by domain name.""" import re domain_expr = r'(.*\.)?(.*\.)(.*)' # Eg: (www.)(google.)(com) domain_search = re.search(domain_expr, domain) if domain_search and domain_search.group(1): # sort by domain name and then...
normal
{ "blob_id": "c581d9714681e22c75b1eeb866ea300e87b883f1", "index": 2972, "step-1": "<mask token>\n", "step-2": "def domain_sort_key(domain):\n \"\"\"Key to sort hosts / domains alphabetically, by domain name.\"\"\"\n import re\n domain_expr = '(.*\\\\.)?(.*\\\\.)(.*)'\n domain_search = re.search(doma...
[ 0, 1, 2, 3, 4 ]
# Copyright 2017 Battelle Energy Alliance, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed t...
normal
{ "blob_id": "5456fb2938ae4d0f69414c153390f86437088114", "index": 4475, "step-1": "<mask token>\n\n\nclass Metric(utils.metaclass_insert(abc.ABCMeta, BaseType)):\n <mask token>\n\n def __init__(self):\n \"\"\"\n This is the basic method initialize the metric object\n @ In, none\n @ Out...
[ 4, 5, 6, 8, 9 ]
''' Created on Jan 19, 2014 @author: felix ''' import sys from PyPDF2 import PdfFileReader from pytagcloud import create_tag_image, make_tags, LAYOUT_HORIZONTAL from pytagcloud.lang.counter import get_tag_counts def main(): for i in range(0, len(sys.argv)): if (sys.argv[i] == '-f'): try: ...
normal
{ "blob_id": "899cdb5cbdbd0a57af76a5044d54e1fe2a497847", "index": 7144, "step-1": "'''\nCreated on Jan 19, 2014\n\n@author: felix\n'''\nimport sys\nfrom PyPDF2 import PdfFileReader\nfrom pytagcloud import create_tag_image, make_tags, LAYOUT_HORIZONTAL\nfrom pytagcloud.lang.counter import get_tag_counts\n\ndef mai...
[ 0 ]
import glob import os import xml.etree.ElementTree as ET file_dirs = ["train/","test/"] for file_dir in file_dirs: fdir = "custom_dataset/" + file_dir for directory in os.listdir(fdir): new_location = "/content/gdrive/My Drive/project/custom_dataset/" + file_dir + directory xml_file...
normal
{ "blob_id": "3a053c2c8a2b9123974183e65914dc0f73d2e078", "index": 6368, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor file_dir in file_dirs:\n fdir = 'custom_dataset/' + file_dir\n for directory in os.listdir(fdir):\n new_location = ('/content/gdrive/My Drive/project/custom_dataset/' +\n...
[ 0, 1, 2, 3, 4 ]
# -*- coding: UTF-8 -*- ''' model = DQN,DDQN,PDQN,PDDQN,DQN_PER,DDQN_PER,DQN_InAday,DQN_PER_Ipm... ''' # -----------ContolGame------------ # CartPole - v1, MountainCar - v0, Acrobot - v1, Pendulum - v0 # from run_ContolGame import run_Game # run_Game('DQN', 'CartPole-v1', episodes=400) # model,env,episodes # --------...
normal
{ "blob_id": "f49a133fa94aae791ef0f1eec54cf0629f45a0ed", "index": 5153, "step-1": "<mask token>\n", "step-2": "<mask token>\nrun_Game('DQN_PER', 'Breakout', lifes=5, episodes=40001)\n", "step-3": "<mask token>\nfrom run_AtariGame import run_Game\nrun_Game('DQN_PER', 'Breakout', lifes=5, episodes=40001)\n", ...
[ 0, 1, 2, 3 ]
import p01 as p stu = p.Student() stu.say() p.sayHello()
normal
{ "blob_id": "8be3a3d32da208e2f45aad61813bc6f5ea513f01", "index": 9803, "step-1": "<mask token>\n", "step-2": "<mask token>\nstu.say()\np.sayHello()\n", "step-3": "<mask token>\nstu = p.Student()\nstu.say()\np.sayHello()\n", "step-4": "import p01 as p\nstu = p.Student()\nstu.say()\np.sayHello()\n", "step-...
[ 0, 1, 2, 3 ]
def area (a, b): resultado = a * b return (resultado) def main(): #escribe tu código abajo de esta línea num1 = float(input("INTRODUCE LA BASE: ")) num2 = float(input("INTRODUCE LA ALTURA: ")) print ("EL AREA DEL RECTANGULO ES: ", area (num1, num2)) pass if __name__ == '__main__': main()
normal
{ "blob_id": "282dbdb3a8d9ed914e8ca5c7fa74d2873920e18c", "index": 7308, "step-1": "<mask token>\n", "step-2": "def area(a, b):\n resultado = a * b\n return resultado\n\n\n<mask token>\n", "step-3": "def area(a, b):\n resultado = a * b\n return resultado\n\n\ndef main():\n num1 = float(input('IN...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python # -*- coding: UTF-8 -*- # 可写函数说明 def sum(arg1, arg2): # 返回2个参数的和." total = arg1 + arg2 print "函数内 : ", total return total; # 调用sum函数 total = sum(10, 20); def nop(): pass a = nop();
normal
{ "blob_id": "9761070a75b043f6cc9e6134e09810b215ccd0c0", "index": 6430, "step-1": "#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\n# 可写函数说明\ndef sum(arg1, arg2):\n # 返回2个参数的和.\"\n total = arg1 + arg2\n print \"函数内 : \", total\n return total;\n\n\n# 调用sum函数\ntotal = sum(10, 20);\n\ndef nop():\n pass\n...
[ 0 ]
from tqdm import trange import numpy as np class GPTD_fixedGrid: def __init__(self, env, sigma0, gamma, kernel, D, V_mu=[]): self.env = env self.gamma = gamma self.sigma0 = sigma0 self.kernel = kernel.kernel if (not V_mu): V_mu = lambda s: np.zeros((s.sh...
normal
{ "blob_id": "92eaceb46974ba3a5944300139d5929d44673181", "index": 1223, "step-1": "<mask token>\n\n\nclass GPTD_fixedGrid:\n\n def __init__(self, env, sigma0, gamma, kernel, D, V_mu=[]):\n self.env = env\n self.gamma = gamma\n self.sigma0 = sigma0\n self.kernel = kernel.kernel\n ...
[ 3, 5, 6, 7, 8 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- """Script to view and manage OPenn repositories. Use this script to list and update OPenn primary repositories, to view repository details, and to list documents in each repository. """ import os import sys import argparse import logging sys.path.insert(0, os.path.abspa...
normal
{ "blob_id": "e3071643548bb3a4e8d0a5710820ad39b8a6b04b", "index": 5057, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Script to view and manage OPenn repositories. Use this script to list and\nupdate OPenn primary repositories, to view repository details, and to list\ndocuments in each reposi...
[ 0 ]
file = open('../_datasets/moby_dick.txt', mode='r') print(file.read()) print(file.closed) file.close() print(file.closed)
normal
{ "blob_id": "dfe0ee5bbb906e5a23adcf06d2d704700fa1567d", "index": 1179, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(file.read())\nprint(file.closed)\nfile.close()\nprint(file.closed)\n", "step-3": "file = open('../_datasets/moby_dick.txt', mode='r')\nprint(file.read())\nprint(file.closed)\nfile...
[ 0, 1, 2 ]
import cv2 import numpy as np from math import * def appendimages(im1,im2): """ Return a new image that appends the two images side-by-side. """ # select the image with the fewest rows and fill in enough empty rows rows1 = im1.shape[0] rows2 = im2.shape[0] if rows1 < rows2: im1 = np.concat...
normal
{ "blob_id": "c3e313805c6f91f9aac77922edfd09650143f905", "index": 4862, "step-1": "<mask token>\n\n\ndef appendimages(im1, im2):\n \"\"\" Return a new image that appends the two images side-by-side. \"\"\"\n rows1 = im1.shape[0]\n rows2 = im2.shape[0]\n if rows1 < rows2:\n im1 = np.concatenate(...
[ 9, 11, 12, 15, 18 ]
""" This file is part of the tractor library. See LICENSE.txt for licensing, CONTRIBUTORS.txt for contributor information. Created on Jan 06, 2012. """ from StringIO import StringIO from datetime import datetime from tractor.attachment import AttachmentWrapper from tractor.attachment import Base64Converter from tract...
normal
{ "blob_id": "41681a80807800efc06b3912533d739dab2cd085", "index": 1999, "step-1": "<mask token>\n\n\nclass AttachmentTestCase(BaseTestCase):\n\n def set_up(self):\n BaseTestCase.set_up(self)\n self.init_data = dict(content='Important attachment content.',\n file_name='test_file1.txt', ...
[ 5, 10, 11, 12, 14 ]
''' Copyright (c) 2011 Jacob K. Schoen (jacob.schoen@gmail.com) 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, modify,...
normal
{ "blob_id": "e2e3b63deba20cd87fdfca81a9f67fa24891a1e0", "index": 6416, "step-1": "<mask token>\n\n\ndef _getAlbums(conn, smugmug, lock):\n albums = smugmug.albums_get(Extras='LastUpdated')\n for album in albums['Albums']:\n myLogger.debug(album)\n title = album['Title']\n cat = None\n ...
[ 5, 6, 7, 8, 9 ]
from customer_service.model.customer import Customer def get_customer(customer_id, customer_repository): return customer_repository.fetch_by_id(customer_id) def create_customer(first_name, surname, customer_repository): customer = Customer(first_name=first_name, surname=surname) customer_repository.stor...
normal
{ "blob_id": "f5e60f2d384242b9675e756f67391ea09afcc262", "index": 5408, "step-1": "<mask token>\n\n\ndef update_customer(first_name, surname, cid, customer_repository):\n customer = customer_repository.fetch_by_id(cid)\n customer.first_name = first_name\n customer.surname = surname\n customer_reposito...
[ 1, 2, 3, 4 ]
'''Autogenerated by xml_generate script, do not edit!''' from OpenGL import platform as _p, arrays from OpenGL.constant import Constant as _C # End users want this... from OpenGL.raw.GLES2 import _errors # Code generation uses this from OpenGL.raw.GLES2 import _types as _cs _EXTENSION_NAME = 'GLES2_NV_viewport_array' ...
normal
{ "blob_id": "9535973f9714926269490b8550a67c74d04d8f0a", "index": 834, "step-1": "<mask token>\n\n\n@_f\n@_p.types(None, _cs.GLuint, _cs.GLsizei, arrays.GLfloatArray)\ndef glDepthRangeArrayfvNV(first, count, v):\n pass\n\n\n@_f\n@_p.types(None, _cs.GLuint, _cs.GLfloat, _cs.GLfloat)\ndef glDepthRangeIndexedfNV(...
[ 11, 12, 13, 14, 16 ]
from django.urls import path from . import views # 현재 패키지에서 views 모듈을 가져옴 urlpatterns = [ path('', views.home, name='home'), path('ppt1',views.ppt1,name='ppt1'), path('ppt2',views.ppt2,name='ppt2'), ]
normal
{ "blob_id": "9db1887c5379623687d1dea343d72122bab66303", "index": 2143, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.home, name='home'), path('ppt1', views.ppt1,\n name='ppt1'), path('ppt2', views.ppt2, name='ppt2')]\n", "step-3": "from django.urls import path\nfrom . ...
[ 0, 1, 2, 3 ]
def pattern4(n): """ n: length of the base of the triangle ie. the max number of starts it will contain. """ for row in range(1, n+1): for col in range(1, row+1): print("*", end="") print("") if __name__ == '__main__': n = int(input(("Enter height of the triangle: "))) pattern4(n)
normal
{ "blob_id": "d77036ed07231719358658a42dc14d20453bd792", "index": 7563, "step-1": "<mask token>\n", "step-2": "def pattern4(n):\n \"\"\"\n\tn: length of the base of the triangle ie. the max number\n\t\tof starts it will contain.\n\t\"\"\"\n for row in range(1, n + 1):\n for col in range(1, row + 1)...
[ 0, 1, 2, 3 ]
from .__init__ import * def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'): a = random.randint(1, maxHeight) b = random.randint(1, maxRadius) slopingHeight = math.sqrt(a**2 + b**2) problem = f"Surface area of cone with height = {a}{unit} and radius = {b}{unit} is" ans = int(math.pi * b * s...
normal
{ "blob_id": "3e19ede2112a109a776b607e927e2f0a095ba5cc", "index": 7677, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):\n a = random.randint(1, maxHeight)\n b = random.randint(1, maxRadius)\n slopingHeight = math.sqrt(a ** 2 + b ** 2)\...
[ 0, 1, 2, 3, 4 ]
from django.db import models from django.contrib.auth.models import User from django.db.models.deletion import CASCADE class Profile(models.Model): user = models.OneToOneField(User, on_delete=CASCADE) # portfolio = models.ManyToOneRel(User, on_delete=) def __str__(self): return f"{self.user.user...
normal
{ "blob_id": "51ff1181f0ddac3a8f7cbd9f9d2eedae29a6c559", "index": 6654, "step-1": "<mask token>\n\n\nclass Profile(models.Model):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Profile(models.Model):\n <mask token>\n\n def __str__(self):\n return f'{self.user.username} P...
[ 1, 2, 3, 4, 5 ]
from .exenv import *
normal
{ "blob_id": "9fea76b1612bd02f512072692090f8ef60e8a0fe", "index": 1498, "step-1": "<mask token>\n", "step-2": "from .exenv import *\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#!/usr/bin/env python """ This code is fot testing the region growing. """ import os import sys import time import nibabel as nib import region_growing as rg import matplotlib.pyplot as plt import numpy as np img = nib.load("zstat1.nii.gz") data = img.get_data() #test coor [36,60,28] [21,39,30] [23,38,30] coor = [23,...
normal
{ "blob_id": "6bcddd1b2ec8653400f710e5cab552d4bec75b6b", "index": 1162, "step-1": "#!/usr/bin/env python\n\"\"\"\nThis code is fot testing the region growing.\n\"\"\"\nimport os\nimport sys\nimport time\nimport nibabel as nib\nimport region_growing as rg\nimport matplotlib.pyplot as plt \nimport numpy as np\n\nim...
[ 0 ]
// Time Complexity : O(n) // Space Complexity : O(n) // Did this code successfully run on Leetcode : Yes // // Any problem you faced while coding this : No // Your code here along with comments explaining your approach class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: res=[] ...
normal
{ "blob_id": "23bcef07326db084d4e0e6337beb00faba329193", "index": 1834, "step-1": "// Time Complexity : O(n)\n// Space Complexity : O(n)\n// Did this code successfully run on Leetcode : Yes\n// // Any problem you faced while coding this : No\n\n// Your code here along with comments explaining your approach\nclass...
[ 0 ]
from django.apps import AppConfig class CheckoutConfig(AppConfig): name = "checkout" # Override the ready method and import the signals module # so that update_on_save and update_on_delete will be called # after an OrderLineItem model instance is saved or deleted def ready(self): import c...
normal
{ "blob_id": "74e3f4cd7b09d9b96feb3f927a509b113481eaed", "index": 7575, "step-1": "<mask token>\n\n\nclass CheckoutConfig(AppConfig):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass CheckoutConfig(AppConfig):\n <mask token>\n\n def ready(self):\n import checkout.signals\n...
[ 1, 2, 3, 4, 5 ]
from django.test import TestCase from stack_it.models import Image class TextPageContentModelTest(TestCase): def test_instance(self): file = Image.create_empty_image_file(name='hello.jpg') image = Image.objects.create(image=file, alt="World") self.assertEqual(Image.objects.count(), 1) ...
normal
{ "blob_id": "5287bd1847848aa527df8ce57e896bc30c70b43c", "index": 4432, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TextPageContentModelTest(TestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TextPageContentModelTest(TestCase):\n\n def test_instance(self):\n file ...
[ 0, 1, 2, 3, 4 ]
import queue from enum import IntEnum from time import sleep import keyboard # I know, I copy pasted this horrobly written class # again... # and again.. I should really write a proper intcode computer class IntCodeComputer: def __init__(self, code): self.defaultCode = code self.runningCode = self...
normal
{ "blob_id": "6eac04bc10ef712ab4e2cde4730950ddcbe42585", "index": 8983, "step-1": "<mask token>\n\n\nclass IntCodeComputer:\n\n def __init__(self, code):\n self.defaultCode = code\n self.runningCode = self.defaultCode.copy()\n self.instructionPointer = 0\n self.outputQueue = queue.Q...
[ 5, 8, 9, 10, 12 ]
from redis3barScore import StudyThreeBarsScore from redisUtil import RedisTimeFrame def test_score1() -> None: package = {'close': 13.92, 'high': 14.57, 'low': 12.45, 'open': 13.4584, 'symbol': 'FANG', 'timestamp': 1627493640000000000, ...
normal
{ "blob_id": "ec64ddd01034debadb6674e71125f673f5de8367", "index": 567, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_score1() ->None:\n package = {'close': 13.92, 'high': 14.57, 'low': 12.45, 'open': 13.4584,\n 'symbol': 'FANG', 'timestamp': 1627493640000000000, 'trade_count': \n ...
[ 0, 1, 2, 3 ]
from arcgis.geocoding import geocode from arcgis.gis import GIS import pandas as pd import Point_v1 """ This module is used to get the location information of different companies from arcgis API. """ def crawl(file): gis = GIS() map = gis.map("United States") map # read all kinds of job files jo...
normal
{ "blob_id": "902159d9ad3a1e36b69142518007b5d4bcaef0f3", "index": 1320, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef crawl(file):\n gis = GIS()\n map = gis.map('United States')\n map\n job_df = pd.read_csv(Point_v1.CONSULTING_FILE).append(pd.read_csv(\n Point_v1.DS_FILE)).appe...
[ 0, 1, 2, 3 ]
#!/usr/bin/python #Program for functions pay scale from user input hrs = raw_input("Enter Hours:") h = float(hrs) rate = raw_input("Enter Rate:") r = float(rate) def computepay(h,r): if (h>40) : pay = (40*r)+(h-40)*1.5*r else: pay = (h*r) return pay print computepay(h,r)
normal
{ "blob_id": "8f30de819412b03ef12009320978cb1becd85131", "index": 2767, "step-1": "#!/usr/bin/python\n#Program for functions pay scale from user input\n\nhrs = raw_input(\"Enter Hours:\")\n\nh = float(hrs)\n\nrate = raw_input(\"Enter Rate:\")\n\nr = float(rate)\n\n\n\ndef computepay(h,r):\n\n if (h>40) : \n\n ...
[ 0 ]
def test(a): """ This function return square of number """ return (a**2) print(test(2)) help(test) test.__doc__
normal
{ "blob_id": "7b35a7f28c11be15fe2ac8d6eae4067ac5379f3e", "index": 3546, "step-1": "<mask token>\n", "step-2": "def test(a):\n \"\"\"\n This function return square of number\n \"\"\"\n return a ** 2\n\n\n<mask token>\n", "step-3": "def test(a):\n \"\"\"\n This function return square of number...
[ 0, 1, 2, 3 ]
from matplotlib import pyplot as plt import pandas as pd import numpy as np from sklearn.cluster import KMeans cols = ['Clump Thickness', 'Uniformity of Cell Size', 'Uniformity of Cell Shape', 'Marginal Adhesion', 'Single Epithelial Cell Size', 'Bare Nuclei', 'Bland Chromatin', ...
normal
{ "blob_id": "ff331dc0c72378222db9195cce7c794f93799401", "index": 5833, "step-1": "<mask token>\n", "step-2": "<mask token>\ndata.replace(to_replace='?', value=np.nan, inplace=True)\ndata.dropna(inplace=True)\n<mask token>\nkms.fit(data_train)\nprint(kms.predict(data_test))\nplt.figure()\n", "step-3": "<mask ...
[ 0, 1, 2, 3, 4 ]
# Bisection recursion algo for sqrt of 2 def bisectionSqrt(x, epsilon = 0.01, low = None, high = None): """ Performs a recursive bisection search to find the square root of x, within epsilon """ if low == None: low = 0.0 if high == None: high = x midPoint = (high + low)/2.0 # If the difference of the ...
normal
{ "blob_id": "d332ddd6c66bb22d60190ab8f94931eac6fd2394", "index": 8482, "step-1": "# Bisection recursion algo for sqrt of 2\n\ndef bisectionSqrt(x, epsilon = 0.01, low = None, high = None):\n\t\"\"\" \n\t\tPerforms a recursive bisection search to find the\n\t\tsquare root of x, within epsilon\n\t\"\"\"\n\n\tif lo...
[ 0 ]
env = 'DEV' ## this had to be in uppercase platform = 'hive' from datahub.emitter.kafka_emitter import DatahubKafkaEmitter, KafkaEmitterConfig from datahub.emitter.rest_emitter import DatahubRestEmitter from datahub.ingestion.extractor.schema_util import * from datahub.metadata.schema_classes import ( DatasetSn...
normal
{ "blob_id": "7ad5e803afa42790e878bfb923eddcfde2d21928", "index": 1501, "step-1": "<mask token>\n\n\ndef add_owner_mce(m) ->MetadataChangeEventClass:\n entity = m['Table']\n schema = m['Schema']\n dataset_name = f'{schema}.{entity}'\n owners = [OwnerClass(owner=owner, type=OwnershipTypeClass.DATAOWNER...
[ 2, 3, 4, 5, 6 ]
import uuid from website.util import api_v2_url from django.db import models from osf.models import base from website.security import random_string from framework.auth import cas from website import settings from future.moves.urllib.parse import urljoin def generate_client_secret(): return random_string(lengt...
normal
{ "blob_id": "8186b7bddbdcdd730a3f79da1bd075c25c0c3998", "index": 3131, "step-1": "<mask token>\n\n\nclass ApiOAuth2Application(base.ObjectIDMixin, base.BaseModel):\n \"\"\"Registration and key for user-created OAuth API applications\n\n This collection is also used by CAS to create the master list of avail...
[ 17, 18, 21, 25, 26 ]
#Merge Sort #O(nlogn) #Merge Part from __future__ import division #use for python2 def merge(A, B): #Merge A[0:m], B[0,n] (C, m, n) = ([], len(A), len(B)) (i, j) = (0, 0) #Current positions in A, B while (i + j) < (m + n): #i+j is no. of elements merged so far ...
normal
{ "blob_id": "7b4c2689ad1d4601a108dd8aa6e3c4d1e9730dc5", "index": 5257, "step-1": "<mask token>\n\n\ndef merge(A, B):\n C, m, n = [], len(A), len(B)\n i, j = 0, 0\n while i + j < m + n:\n if i == m:\n C.append(B[j])\n j = j + 1\n elif j == n:\n C.append(A[i]...
[ 1, 2, 3, 4, 5 ]
/Users/AbbyPennington/anaconda/lib/python3.5/os.py
normal
{ "blob_id": "8c4006ed8f4b1744f0316a61d95458b227653fee", "index": 5887, "step-1": "/Users/AbbyPennington/anaconda/lib/python3.5/os.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns def distribution(): ##testing_results = pd.read_csv('https://raw.githubusercontent.com/dsfsi/covid19za/master/data/covid19za_timeline_testing.csv') confirmed_results = pd.read_csv('https://raw.githubusercontent.com/dsf...
normal
{ "blob_id": "38be4e75c2311a1e5a443d39a414058dc4d1879b", "index": 2320, "step-1": "<mask token>\n\n\ndef distribution_plot():\n confirmed_results = pd.read_csv(\n 'https://raw.githubusercontent.com/dsfsi/covid19za/master/data/covid19za_timeline_confirmed.csv'\n )\n trial = pd.notnull(confirmed...
[ 2, 3, 4, 5, 6 ]
import random from datetime import datetime from slackbot.bot import respond_to from .term_model import Term, Response from ..botmessage import botsend, botwebapi # すでに存在するコマンドは無視する RESERVED = ( 'drive', 'manual', 'jira', 'wikipedia', 'plusplus', 'translate', '翻訳', 'weather', '天気', 'term', 'shuff...
normal
{ "blob_id": "86e97e7eaf0d23ccf4154b5ffc853c5aee966326", "index": 5769, "step-1": "<mask token>\n\n\n@respond_to('^term\\\\s+([\\\\w-]+)$')\n@respond_to('^term\\\\s+create\\\\s+([\\\\w-]+)$')\n@respond_to('^term\\\\s+add\\\\s+([\\\\w-]+)$')\ndef term_create(message, command):\n \"\"\"\n 指定されたコマンドを生成する\n ...
[ 7, 9, 12, 15, 19 ]
# generated from catkin/cmake/template/order_packages.context.py.in source_root_dir = "/home/songsong/image_transport_ws/src" whitelisted_packages = "".split(';') if "" != "" else [] blacklisted_packages = "".split(';') if "" != "" else [] underlay_workspaces = "/home/songsong/image_transport_ws/devel;/home/songsong/pi...
normal
{ "blob_id": "86ca94820c05b3f63f4a733b6d1fa7eb9dea6a5d", "index": 325, "step-1": "<mask token>\n", "step-2": "source_root_dir = '/home/songsong/image_transport_ws/src'\nwhitelisted_packages = ''.split(';') if '' != '' else []\nblacklisted_packages = ''.split(';') if '' != '' else []\nunderlay_workspaces = (\n ...
[ 0, 1, 2 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- db = { 'host': "localhost", 'user': "root", 'passwd': "m74e71", 'database': "dw_toner" } data_inicial = '1990-01-01' ano_final = 2018 feriados = "feriados.csv" meses_de_ferias = (1, 2, 7, 12) #Janeiro, Fevereiro, Julho, Dezembro dias_final_semana = (1, ...
normal
{ "blob_id": "360881cecbad88ea5d150548fba6a39d8dc30681", "index": 8598, "step-1": "<mask token>\n", "step-2": "db = {'host': 'localhost', 'user': 'root', 'passwd': 'm74e71', 'database':\n 'dw_toner'}\ndata_inicial = '1990-01-01'\nano_final = 2018\nferiados = 'feriados.csv'\nmeses_de_ferias = 1, 2, 7, 12\ndia...
[ 0, 1, 2 ]
Max = 100010 a = [0 for i in range(Max)] p = [] for i in range(2,Max): if a[i ] == 0: p.append(i) j = i * i while j < Max: a[j ] = 1 j = j + i cnt,j = 0,1 n = int(input()) while p[j] <= n : if p[j ] - p[j-1] == 2: cnt = cnt + 1 j = j + 1 print(cnt)
normal
{ "blob_id": "e828c2792d508ba41c5dca3f4a255eee2611c333", "index": 3565, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(2, Max):\n if a[i] == 0:\n p.append(i)\n j = i * i\n while j < Max:\n a[j] = 1\n j = j + i\n<mask token>\nwhile p[j] <= n:\n ...
[ 0, 1, 2, 3 ]
import sys; input = sys.stdin.readline from collections import deque from itertools import combinations from copy import deepcopy n, m = map(int, input().split()) graph = [list(map(int,input().split())) for i in range(n)] virus_lst = [] for i in range(n): for j in range(n): if graph[i][j]==2: g...
normal
{ "blob_id": "0e3bf0ddd654b92b2cd962a2f3935c639eeb0695", "index": 2155, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bfs(start_nodes, g):\n dq = deque()\n dq.extend(start_nodes)\n for i, j in start_nodes:\n g[i][j] = -1\n while dq:\n y, x = dq.popleft()\n for k i...
[ 0, 1, 2, 3, 5 ]
# # LeetCode # ver.Python # # Created by GGlifer # # Open Source """ 21. Merge Two Sorted Lists """ from typing import List import sys # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeTwoList...
normal
{ "blob_id": "2730b2a1016f306936dcac3c3b44a3fd7194bac6", "index": 7216, "step-1": "<mask token>\n\n\nclass ListNode:\n\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\n\nclass Solution:\n\n def mergeTwoLists(self, l1: ListNode, l2: ListNode) ->ListNode:\n r...
[ 4, 6, 7, 8, 9 ]
from random import randrange from django.core.exceptions import ValidationError from django.contrib.auth import get_user_model from rest_framework import serializers from rest_framework_simplejwt.serializers import TokenObtainPairSerializer from .models import EmailValidation from ..emails.models import Ema...
normal
{ "blob_id": "9f34bf3a0bb24db428b7af1a354aec1d3a72df98", "index": 359, "step-1": "<mask token>\n\n\nclass CreatePasswordEmailValidationSerializer(serializers.Serializer):\n <mask token>\n\n def save(self):\n validation_code = randrange(10000000, 100000000)\n email = Email.objects.create(valida...
[ 15, 16, 18, 19, 21 ]
from django.conf.urls import url from django.urls import path from .views import * from flujo.views import * """ URL para el Sprint crear, listar y modificar """ urlpatterns = [ url(r'^$', SprintListView.as_view(), name='sprint_list'), path('create/', view=CreateSprintView.as_view(), name='create_sprint'), ...
normal
{ "blob_id": "2b1ec422a42af59a048c708f86b686eb0564b51f", "index": 2456, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^$', SprintListView.as_view(), name='sprint_list'),\n path('create/', view=CreateSprintView.as_view(), name='create_sprint'),\n path('modificar/<int:sprint_pk>/'...
[ 0, 1, 2, 3 ]
# - *- coding: utf- 8 - *- import RPi.GPIO as io import time import math io.setmode(io.BOARD) hz = 50 dt = 1/hz kr = 48 enc_res = 0.01636246 num_samples = 100 special_words = ['BackSpace', 'Tab', 'Enter', 'Cap', 'Shift2', 'Ctrl1', 'WIN1', 'Alt1', 'Alt2', 'WIN2', 'MClick', 'Ctrl2', 'Shift1', '\\'] L1...
normal
{ "blob_id": "ce1ef1ce538b8753af9e4b3e8e88f4cde9a2d860", "index": 9620, "step-1": "# - *- coding: utf- 8 - *-\r\n\r\nimport RPi.GPIO as io\r\nimport time\r\nimport math\r\n\r\nio.setmode(io.BOARD)\r\n\r\nhz = 50\r\ndt = 1/hz\r\nkr = 48\r\nenc_res = 0.01636246\r\nnum_samples = 100\r\nspecial_words = ['BackSpace', ...
[ 0 ]
from django import forms from .models import BlogPost class BlogPostForm(forms.ModelForm): class Meta: model = BlogPost fields = '__all__'
normal
{ "blob_id": "c4624425f57211e583b5fbaec3943539ce6fea6f", "index": 88, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BlogPostForm(forms.ModelForm):\n\n\n class Meta:\n model = BlogPost\n fields = '__all__'\n", "step-3": "from django import forms\nfrom .models import BlogPost\n...
[ 0, 1, 2 ]
import requests from SPARQLWrapper import SPARQLWrapper, JSON from rdflib import Graph from plenum.server.plugin.graphchain.graph_store import GraphStore from plenum.server.plugin.graphchain.logger import get_debug_logger logger = get_debug_logger() class StardogGraphStore(GraphStore): def __init__(self, ts_db_...
normal
{ "blob_id": "a42a94798d176e20646d41cf0f4b7e4f99e0790b", "index": 105, "step-1": "<mask token>\n\n\nclass StardogGraphStore(GraphStore):\n <mask token>\n\n def check_whether_db_exists(self):\n logger.debug(\"Checking whether a triple store with db '{}' exists...\"\n .format(self._node_ts_u...
[ 4, 5, 6, 7, 8 ]
from setuptools import setup, find_packages def find_version(): with open('pytest_defer.py') as fp: for line in fp: if '__version__' in line: version = line.split('=')[-1].strip() return version[1:-1] # trim '' with open('README.md') as fp: long_desc = fp...
normal
{ "blob_id": "7903484b4a36d4b6ea03b9eaf3bf2b2e056baad8", "index": 8148, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_version():\n with open('pytest_defer.py') as fp:\n for line in fp:\n if '__version__' in line:\n version = line.split('=')[-1].strip()\n ...
[ 0, 1, 2, 3, 4 ]
import pygame from config import * from Map import * from NeuralNetwork import * class Pacman(object): RADIUS = int(TILE_WIDTH/2) def __init__(self, mapa, neural_net): self.mapa = mapa self.pos_x = 11 self.pos_y = 17 self.vel_x = 1 self.vel_y = 0 self.isAlive ...
normal
{ "blob_id": "d3b5d87b56421940449fdef48be6da9fa650dd90", "index": 1756, "step-1": "<mask token>\n\n\nclass Pacman(object):\n <mask token>\n\n def __init__(self, mapa, neural_net):\n self.mapa = mapa\n self.pos_x = 11\n self.pos_y = 17\n self.vel_x = 1\n self.vel_y = 0\n ...
[ 7, 8, 10, 11, 12 ]
start=0 last=100 middle=50 counter=1 print(" Guess a number between 0 and 100") condition = int(input("Is your guess " + str(middle) + "? (0 means it's too low, 1 means it's your guess and 2 means it's too high) ")) while condition != 1: counter += 1 if condition == 0: last = middle elif conditio...
normal
{ "blob_id": "42d03aabef7d75c813f30bb6d8a835d76fd1fc83", "index": 603, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(' Guess a number between 0 and 100')\n<mask token>\nwhile condition != 1:\n counter += 1\n if condition == 0:\n last = middle\n elif condition == 2:\n start = ...
[ 0, 1, 2, 3 ]
def memo(fn): cache = {} missed = object() def query(*args): result = cache.get(args, missed) if result is missed: result = cache[args] = fn(*args) return result return query @memo def cal_edit_distance(ori, tar): def edit_tuple(old, distance, path): r...
normal
{ "blob_id": "88390f411af90d494284617ef8f5fb0e9bb8890e", "index": 8039, "step-1": "def memo(fn):\n cache = {}\n missed = object()\n\n def query(*args):\n result = cache.get(args, missed)\n if result is missed:\n result = cache[args] = fn(*args)\n return result\n return ...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt from sklearn.ensemble import ( StackingClassifier, RandomForestClassifier ) import pandas as pd from sklearn.metrics import f1_score # feel free to import any sklearn model here from sklearn.linear_model import LogisticRegression from ...
normal
{ "blob_id": "cf65966f5daf88bdefc7a8aa2ff80835cff0d0b6", "index": 4627, "step-1": "<mask token>\n\n\ndef load_data():\n \"\"\"\n Helper function for loading in the data\n\n ------\n # of training samples: 419\n # of testing samples: 150\n ------\n \"\"\"\n df = pd.read_csv('../../Data/brea...
[ 1, 2, 3, 4, 5 ]
from django.test import TestCase from .models import Seller, Product from rest_framework.test import APIClient import json class SellerModelTests(TestCase): def test_class_str(self): seller = Seller() seller.name = "Bruna" self.assertEquals(seller.__str__(), "Bruna") def test_to_dic...
normal
{ "blob_id": "71ab4ada4062ecde1463f2a766b5951860d0f2fb", "index": 7250, "step-1": "<mask token>\n\n\nclass ProductModelTests(TestCase):\n <mask token>\n <mask token>\n\n\nclass SellerViewTests(TestCase):\n\n @classmethod\n def setUpTestData(cls):\n Seller.objects.create(name='Bruna', email='bru...
[ 9, 10, 13, 16, 17 ]
# -*- coding: utf-8 -*- from yuancloud import models, fields, api, _ import yuancloud.addons.decimal_precision as dp from yuancloud.exceptions import UserError from yuancloud.osv import fields as old_fields class event_event(models.Model): _inherit = 'event.event' event_ticket_ids = fields.One2many( ...
normal
{ "blob_id": "bddba2fd710829db17c6419878ce535df0aba01c", "index": 2760, "step-1": "<mask token>\n\n\nclass event_ticket(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>...
[ 7, 12, 14, 19, 20 ]
# Python implementation of Bubble Sort def bubbleSort(arr): k = len(arr) # Traverse through all elements for i in range(k): # Last i elements are already in correct place for j in range(0, k - i - 1): # Swap if element is greater than next element if arr[j] > arr[j ...
normal
{ "blob_id": "178f9dcd9cbea140abebd509b56979417b5d7503", "index": 6785, "step-1": "<mask token>\n", "step-2": "def bubbleSort(arr):\n k = len(arr)\n for i in range(k):\n for j in range(0, k - i - 1):\n if arr[j] > arr[j + 1]:\n arr[j], arr[j + 1] = arr[j + 1], arr[j]\n\n\n...
[ 0, 1, 2, 3, 4 ]
import time t0 = time.time() while abs(t0 - time.time() < 60): pass
normal
{ "blob_id": "9a0e37aaa41f3b21ed7ad11096cd6c5dd0bb8564", "index": 5608, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile abs(t0 - time.time() < 60):\n pass\n", "step-3": "<mask token>\nt0 = time.time()\nwhile abs(t0 - time.time() < 60):\n pass\n", "step-4": "import time\nt0 = time.time()\nwh...
[ 0, 1, 2, 3 ]
import sqlite3 conn = sqlite3.connect("19-BD/prove.db") cursor = conn.cursor() dipendenti = [ ("Sofia","commessa"), ("Diego","tecnico"), ("Lucia","cassiera"), ("Luca","Magazziniere"), ("Pablo","Capo reparto") ] cursor.executemany("INSERT INTO persone VALUES (null,?,?)", dipendenti) conn.commit() ...
normal
{ "blob_id": "3e1ca6ed4668e75a62baa65ef44346dd86a16491", "index": 3093, "step-1": "<mask token>\n", "step-2": "<mask token>\ncursor.executemany('INSERT INTO persone VALUES (null,?,?)', dipendenti)\nconn.commit()\nconn.close()\n", "step-3": "<mask token>\nconn = sqlite3.connect('19-BD/prove.db')\ncursor = conn...
[ 0, 1, 2, 3, 4 ]
from django.shortcuts import render from rest_framework.response import Response from .serializers import * from rest_framework import generics, status class HistoryMyList(generics.ListCreateAPIView): serializer_class = HistorySer queryset = History.objects.all() class HistoryListView(generics.GenericAPIVie...
normal
{ "blob_id": "8edca4c50e48734073e80de85088964837247696", "index": 2597, "step-1": "<mask token>\n\n\nclass HistoryListView(generics.GenericAPIView):\n <mask token>\n\n def post(self, request):\n serializer_class = self.serializer_class(data=request.data)\n serializer_class.is_valid(raise_excep...
[ 8, 9, 11, 12 ]
# -*- coding: utf-8 -*- import threading import time def work(): i = 0 while i < 10: print 'I am working..' time.sleep(0.5) i += 1 t = threading.Thread(target=work) # Daemon 설정 #t.setDaemon(True) t.daemon = True # 혹인 이렇게도 가능 t.start() print 'main thread finished'
normal
{ "blob_id": "f77df47fdb72ba50331b8b5d65984efaec474057", "index": 4049, "step-1": "# -*- coding: utf-8 -*-\n\nimport threading\nimport time\n\ndef work():\n i = 0\n while i < 10:\n print 'I am working..'\n time.sleep(0.5)\n i += 1\n\nt = threading.Thread(target=work)\n# Daemon 설정\n#t.se...
[ 0 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render from django.http import JsonResponse from knowdb.models import Knowledge import random # Create your views here. def answer(request): ret = {} data = Knowledge.objects.all() num = random.choice(range(1,int...
normal
{ "blob_id": "eb558644283d992af2c324d457dbe674b714235f", "index": 735, "step-1": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.shortcuts import render\nfrom django.http import JsonResponse\nfrom knowdb.models import Knowledge\n\nimport random\n# Create your views here.\n\ndef an...
[ 0 ]
from flask import Flask, request from flask import render_template import sqlite3 import datetime app = Flask(__name__) @app.route('/') def index(date = ""): date = request.args.get('date') if not date: now = datetime.datetime.now() date = "%02d.%02d.%04d" % (now.day, now.month, now.year) ...
normal
{ "blob_id": "f6fe33e04ccdca1d9714caec412478d0cfc8b363", "index": 5559, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index(date=''):\n date = request.args.get('date')\n if not date:\n now = datetime.datetime.now()\n date = '%02d.%02d.%04d' % (now.day, now.month, now.year)\n conn = sqli...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Created on Tue Mar 16 16:11:46 2021 @author: Suman """ import numpy as np import cv2 rect = (0,0,0,0) startPoint = False endPoint = False def mark_object(event,x,y,flags,params): global rect,startPoint,endPoint # get mouse click if event == cv2.EVENT_LB...
normal
{ "blob_id": "0f3e19b02dbe508bc4e0ef7879af81a9eabfd8c9", "index": 6141, "step-1": "<mask token>\n\n\ndef mark_object(event, x, y, flags, params):\n global rect, startPoint, endPoint\n if event == cv2.EVENT_LBUTTONDOWN:\n if startPoint == True and endPoint == True:\n startPoint = False\n ...
[ 1, 2, 3, 4, 5 ]
from rllab.algos.trpo import TRPO from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline from rllab.envs.gym_env import GymEnv from rllab.envs.normalized_env import normalize from rllab.misc.instrument import run_experiment_lite from rllab.policies.gaussian_mlp_policy import GaussianMLPPolicy from rl...
normal
{ "blob_id": "9f479ad2acf4f6deb0ca4db606c3d804979c10bd", "index": 3804, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run_task(*_):\n env = normalize(GymEnv('DartWalker2d-v1', record_video=False))\n policy_sep = GaussianHLCPolicy(env_spec=env.spec, hidden_sizes=(64, 32),\n sub_out_di...
[ 0, 1, 2, 3, 4 ]
from django.urls import path from .views import * urlpatterns = [path('country', Country_Data, name='country_data'), path( 'tours', Scrape_Data, name='scrape_data'), path('draws', Draw_Data, name='Draw_data')]
normal
{ "blob_id": "b39c783cbaff2915c8864ce0b081b5bf052baee5", "index": 6731, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('country', Country_Data, name='country_data'), path(\n 'tours', Scrape_Data, name='scrape_data'), path('draws', Draw_Data,\n name='Draw_data')]\n", "step-3": "...
[ 0, 1, 2 ]
from matplotlib import pyplot as plt # Function for testing # Maps x => x*x def calculate(x): return x * x inputs = [-0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5] outputs = [calculate(x) for x in inputs] plt.plot(inputs, outputs) plt.savefig("plot.png")
normal
{ "blob_id": "1b3891565f776064cfcca02fb22ea65853f7e66f", "index": 3629, "step-1": "<mask token>\n\n\ndef calculate(x):\n return x * x\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef calculate(x):\n return x * x\n\n\n<mask token>\nplt.plot(inputs, outputs)\nplt.savefig('plot.png')\n", "step-3": "<...
[ 1, 2, 3, 4, 5 ]
import sys import numpy as np #################################################################################################### ### These functions all perform QA checks on input files. ### These should catch many errors, but is not exhaustive. #####################################################################...
normal
{ "blob_id": "7413c06a990894c34ee5174d84f0e3bd20abf51f", "index": 3294, "step-1": "<mask token>\n\n\ndef check_controls(subpuc_names, subpuc_controls):\n if len(subpuc_names) == len(subpuc_controls):\n pass\n else:\n sys.exit(\n 'There is an issue with your subpuc_controls.csv file....
[ 3, 5, 6, 7, 8 ]
# Generated by Django 3.1.1 on 2020-12-02 19:50 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('element', '0011_suggestion_suggestion_type'), ('bot', '0001_initial'), ] operations = [ migrations.AddField( model_name=...
normal
{ "blob_id": "43ae01ffe35c6c4491f3f7e480dd6f5c1be86eb2", "index": 2475, "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 = [('element', '...
[ 0, 1, 2, 3, 4 ]
# from django.test import TestCase ,LiveServerTestCase,Client # from MeetUps.models import* # from django.shortcuts import reverse # from .forms import RegistrationForm # class MeetUpViewTest(TestCase): # @classmethod # def setupTestDat(cls): # #create or get all meetups # d...
normal
{ "blob_id": "9156ee034ceb8a39fc1eb3a18c1597c737814c72", "index": 692, "step-1": "# from django.test import TestCase ,LiveServerTestCase,Client\n\n# from MeetUps.models import*\n# from django.shortcuts import reverse\n# from .forms import RegistrationForm\n\n# class MeetUpViewTest(TestCase):\n\n# @classmetho...
[ 1 ]
{ # Theme information 'name' : 'Clarico CMS Blocks', 'category' : 'Website', 'version' : '1.0', 'summary': '13 CMS Building Blocks', 'description': """""", # Dependencies 'depends': [ 'snippet_style_1', 'snippet_style_2', 'snippet_style_3', 'snippet_style_4'...
normal
{ "blob_id": "34f98d4a6a15c9a7b42f237cab204b736dc97136", "index": 1372, "step-1": "<mask token>\n", "step-2": "{'name': 'Clarico CMS Blocks', 'category': 'Website', 'version': '1.0',\n 'summary': '13 CMS Building Blocks', 'description': '', 'depends': [\n 'snippet_style_1', 'snippet_style_2', 'snippet_sty...
[ 0, 1, 2 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 26 23:42:11 2018 @author: pohsuanh Fully Covolutional Network FCN-32s. FCN-32s network is based on VGG-16 """ import os import tensorflow as tf import numpy as np import matplotlib.pyplot as plt import data_load from datetime import datetime ...
normal
{ "blob_id": "df6fa0409500f97e5afde8f97796d6ed0cc4d746", "index": 1330, "step-1": "<mask token>\n\n\ndef fcn_model_fn(features, labels, mode):\n L2 = tf.contrib.layers.l2_regularizer(scale=0.1)\n trainable = False\n if mode == tf.estimator.ModeKeys.TRAIN:\n trainable = True\n seed = 2019\n w...
[ 1, 2, 3, 4, 5 ]
# V0 class Codec: def encode(self, strs): s = "" for i in strs: s += str(len(i)) + "#" + i return s def decode(self, s): i, str = 0, [] while i < len(s): sharp = s.find("#", i) l = int(s[i:sharp]) str.append(s[sharp + 1:sh...
normal
{ "blob_id": "b94392c9c6547415326d80ff0923cb8ba9251783", "index": 5724, "step-1": "<mask token>\n\n\nclass Codec:\n <mask token>\n\n def decode(self, s):\n \"\"\"Decodes a single string to a list of strings.\n \n :type s: str\n :rtype: List[str]\n \"\"\"\n i, str = ...
[ 5, 6, 7, 8, 10 ]
# question 1d # points: 6 import sys import numpy as np from astropy.stats import kuiper import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt import handin2 as nur def main(): seed = 8912312 np.random.seed(8912312) u = 0 sigma = 1 cdf = nur.gaussian_cdf num_samples = np.lo...
normal
{ "blob_id": "0158141832423b567f252e38640e384cdf340f8b", "index": 7105, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n seed = 8912312\n np.random.seed(8912312)\n u = 0\n sigma = 1\n cdf = nur.gaussian_cdf\n num_samples = np.logspace(1, 5, num=50)\n sample_size = int(...
[ 0, 1, 2, 3, 4 ]
import sys import unittest import random from k_order_statistic import k_order_statistic test_case_find = [([0], 0, 0), ([-1, -1, -1, -1], 3, -1), ([-1, -1, -1, -1], 1, -1), ([-1, 0, 3, -10], 3, 3), ([-1, -2, -3, -4, -5], 0, -5), ([1, 2, 3, 4, 5], 1, 2), ([True, False, True], 2, True), ([sys.maxsize], 0, sys ...
normal
{ "blob_id": "b93cd5ad957da37b1a4cca1d465a67723110e926", "index": 2813, "step-1": "<mask token>\n\n\nclass TestKOrderStatistic(unittest.TestCase):\n\n def test_find(self):\n for a, k, ans in test_case_find:\n self.assertEqual(k_order_statistic(a, k), ans)\n <mask token>\n", "step-2": "<m...
[ 2, 3, 4, 5 ]
#---------------------------- # | # Instagram Bot- Devesh Kr. Verma # instagram- @felon_tpf # | #---------------------------- from selenium import webdriver from time import sleep from selenium.webdriver.common.keys import Keys import random import string from time import sleep from selenium import we...
normal
{ "blob_id": "6d18aa585c656b244d1e4272caa8419c04b20b6c", "index": 2363, "step-1": "<mask token>\n\n\ndef start():\n username = browser.find_element_by_name('username')\n username.send_keys('Username')\n password = browser.find_element_by_name('password')\n password.send_keys('Password')\n nextButto...
[ 1, 3, 4, 5, 6 ]
import numpy as np def calculate_distance_for_tour(tour, node_id_to_location_dict): length = 0 num = 0 for i in tour: j = tour[num - 1] distance = np.linalg.norm(node_id_to_location_dict[i] - node_id_to_location_dict[j]) length += distance num += 1 return length def...
normal
{ "blob_id": "67d79a5c9eceef9f1ed69f79d6a9d1f421f3246c", "index": 2757, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef calculate_distance_for_tour(tour, node_id_to_location_dict):\n length = 0\n num = 0\n for i in tour:\n j = tour[num - 1]\n distance = np.linalg.norm(node_id...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import socket import sys from ctypes import * import re if len(sys.argv) == 3: TCP_IP = sys.argv[1] TCP_PORT = int(sys.argv[2]) else: TCP_IP = "127.0.0.1" TCP_PORT = 5005 BUFFER_SIZE = 1024 MESSAGE = "Hello, World!\n" s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) print "Connecting to " ...
normal
{ "blob_id": "f570d7e723fd0bec8c51022912a7dab4795fad43", "index": 2049, "step-1": "#!/usr/bin/python\n\nimport socket\nimport sys\nfrom ctypes import *\nimport re\n\nif len(sys.argv) == 3:\n\tTCP_IP = sys.argv[1]\n\tTCP_PORT = int(sys.argv[2])\nelse:\n\tTCP_IP = \"127.0.0.1\"\n\tTCP_PORT = 5005\n\nBUFFER_SIZE = 1...
[ 0 ]
import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from WeatherDL.data_maker import dataset_maker from WeatherDL.model_maker import model_3 # Extract data from data_maker X, y = dataset_maker(window=5, forecast_day=1) (X_train, X_test, y_train, y_test) = train_test_split(X, y, test_s...
normal
{ "blob_id": "011dd579bb076ec094e9e3085aa321883c484f1c", "index": 5296, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(model.summary())\n<mask token>\nplt.plot(history.history['loss'])\nplt.plot(history.history['val_loss'])\nplt.title('MSE')\nplt.legend(['Train', 'Test'], loc='upper right')\nplt.sho...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python __author__ = 'greghines' import numpy as np import matplotlib.pyplot as plt import csv import sys import os import pymongo import matplotlib.cbook as cbook import cPickle as pickle sys.path.append("/home/greg/github/pyIBCC/python") import ibcc client = pymongo.MongoClient() db = client['condor...
normal
{ "blob_id": "c025fccad9d37dff4db3a10455cbe7d92917d8f6", "index": 6341, "step-1": "#!/usr/bin/env python\n__author__ = 'greghines'\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport csv\nimport sys\nimport os\nimport pymongo\nimport matplotlib.cbook as cbook\nimport cPickle as pickle\n\nsys.path.append(...
[ 0 ]
# -*- coding: utf-8 -*- __author__ = 'Yun' __project__ = 'DjangoBookTest2' # from django.template import Template, Context # from django.template.loader import get_template # from django.http import HttpResponse from django.shortcuts import render_to_response import datetime def current_datetime(request): # now ...
normal
{ "blob_id": "ef6f55bf27982f53441215da6822cfcdc80706a5", "index": 240, "step-1": "<mask token>\n\n\ndef display_meta(request):\n context_dict = {'meta_dict': request.META}\n return render_to_response('display_meta.html', context_dict)\n", "step-2": "<mask token>\n\n\ndef current_datetime(request):\n cu...
[ 1, 2, 3, 4, 5 ]
__author__ = 'aniket' import freenect import cv2 import numpy as np kernel = nfrp.ones((5,5),np.uint8) freenect.C def grayscale(): maske = np.zeros((480,640,3)) a = freenect.sync_get_depth(format=freenect.DEPTH_MM)[0] mask = a == 0 a[mask] = 8000 mask1 = a > 1000 b = freenect.sync_get_video()...
normal
{ "blob_id": "9540319cf192add1fb24375a35d70ea8e3031a72", "index": 7455, "step-1": "<mask token>\n\n\ndef grayscale():\n maske = np.zeros((480, 640, 3))\n a = freenect.sync_get_depth(format=freenect.DEPTH_MM)[0]\n mask = a == 0\n a[mask] = 8000\n mask1 = a > 1000\n b = freenect.sync_get_video()[0...
[ 1, 2, 3, 4, 5 ]
from django.shortcuts import render,redirect,get_object_or_404 from .models import Blog,UseCase,Comment from courses.models import offerings from django.contrib.auth.models import User from django.contrib import auth from django.contrib.auth.decorators import login_required from django.utils import timezone from django...
normal
{ "blob_id": "70fcf25cd7d70972e8042dc882f6ecb12d36461a", "index": 3353, "step-1": "<mask token>\n\n\ndef blogs(request):\n only_pub_blog = Blog.objects.filter(status=1)\n return render(request, 'dlblog/blogs.html', {'blog': only_pub_blog})\n\n\n<mask token>\n\n\n@login_required\ndef newblog(request):\n r...
[ 5, 6, 7, 8, 9 ]
#!/usr/bin/env python from io import StringIO import sys from contextlib import redirect_stdout import pytest # test input_name(): from mailroom3 import input_name def test_1(monkeypatch): # tests "list" monkeypatch.setattr('builtins.input', lambda x: "list") f = StringIO() with redirect_stdout(f): ...
normal
{ "blob_id": "286a47cece7002a88f34ace3e08d013e2d14801a", "index": 2793, "step-1": "<mask token>\n\n\ndef test_1(monkeypatch):\n monkeypatch.setattr('builtins.input', lambda x: 'list')\n f = StringIO()\n with redirect_stdout(f):\n input_name()\n testdata = f.getvalue()\n assert testdata == '\...
[ 9, 11, 14, 17, 20 ]
""" Modulo collection - Counter Collections -> High-performance Container Datatypes Counter -> Recebe um interável como parametro e cria um objeto do tipo Collections Counter que é parecido com um dicionario, contendo como chave o elemento da lista passada como parametro e como valor a quantidade de ocorrencia...
normal
{ "blob_id": "4989d01f31ca034aacdda28eff56adb2e0bb15da", "index": 1889, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f'resultado: {resultado} || seu tipo: {type(resultado)}')\nprint('--------------\\n')\nprint(f\"\"\"Nasca de bacana: \n {Counter('Nasca de bacana')}\"\"\")\nprint('--------------\\n...
[ 0, 1, 2, 3, 4 ]
from genericentity import GenericEntity as GEntity import random as ran class GenericBreeder(object): """description of class: its a classy class""" def __init__(self,nlifesize,nparentsize,nlowestscore): self.Reset(nlifesize,nparentsize,nlowestscore) def Reset(self,nlifesize,nparentsize,nlowe...
normal
{ "blob_id": "753617c189a88adee8430e994aa597c9db9410fe", "index": 6143, "step-1": "<mask token>\n\n\nclass GenericBreeder(object):\n <mask token>\n\n def __init__(self, nlifesize, nparentsize, nlowestscore):\n self.Reset(nlifesize, nparentsize, nlowestscore)\n\n def Reset(self, nlifesize, nparents...
[ 8, 10, 13, 14, 15 ]