code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
""" Visualize the predictions of a GQCNN on a dataset Visualizes TP, TN, FP, FN.. Author: Vishal Satish """ import copy import logging import numpy as np import os import sys from random import shuffle import autolab_core.utils as utils from autolab_core import YamlConfig, Point from perception import BinaryImage, Co...
normal
{ "blob_id": "806bdb75eed91d1429d8473a50c136b58a736147", "index": 8852, "step-1": "\"\"\"\nVisualize the predictions of a GQCNN on a dataset Visualizes TP, TN, FP, FN..\nAuthor: Vishal Satish \n\"\"\"\nimport copy\nimport logging\nimport numpy as np\nimport os\nimport sys\nfrom random import shuffle\n\nimport aut...
[ 0 ]
import numpy as np from scipy import stats from statarray import statdat #a2a1 = np.loadtxt('a2a1_130707_2300.dat') #a2a1 = np.concatenate( (a2a1, np.loadtxt('a2a1_130708_1223.dat')), axis=0 ) #a2a1 = np.loadtxt('a2a1_130708_1654.dat') #a2a1 = np.loadtxt('a2a1_130709_0030.dat') import matplotlib.pyplot as plt impo...
normal
{ "blob_id": "feac1092d1aaf70eb4d4df919e434cdc1aa9c826", "index": 9171, "step-1": "<mask token>\n", "step-2": "<mask token>\nrc('font', **{'family': 'serif'})\n<mask token>\nfor i, nafm in enumerate(nafms):\n detuning = 6.44\n a1, a2 = fetchdata.fetch_data_A1A2({'afmsize': nafm, 'ai': 0.0}, 'det',\n ...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import sys import xlrd import numpy as np import matplotlib.pyplot as plt if __name__ == "__main__": param = sys.argv print "Hello:" + param[0] # ファイルのオープン book = xlrd.open_workbook('sample.xls') # シートの選択 sheet = book.sheet_by_name(u"Sheet1") # sheet = book.sheet_by_index(0) plot_x =...
normal
{ "blob_id": "dacd4334433eb323ce732c96f680fb7b9333721a", "index": 2268, "step-1": "# -*- coding: utf-8 -*-\n\nimport sys\nimport xlrd\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nif __name__ == \"__main__\":\n\tparam = sys.argv\n\tprint \"Hello:\" + param[0]\n\n\t# ファイルのオープン\n\tbook = xlrd.open_workboo...
[ 0 ]
#!/usr/bin/env python #coding=UTF8 ''' @author: devin @time: 2013-11-23 @desc: timer ''' import threading import time class Timer(threading.Thread): ''' 每隔一段时间执行一遍任务 ''' def __init__(self, seconds, fun, **kwargs): ''' seconds为间隔时间,单位为秒 fun为定时执行的任务...
normal
{ "blob_id": "4a546222082e2a25296e31f715baf594c974b7ad", "index": 5844, "step-1": "#!/usr/bin/env python\n#coding=UTF8\n'''\n @author: devin\n @time: 2013-11-23\n @desc:\n timer\n'''\nimport threading\nimport time\n\nclass Timer(threading.Thread):\n '''\n 每隔一段时间执行一遍任务\n '''\n def _...
[ 0 ]
import numpy as np import matplotlib.pyplot as plt import csv category = ["Ecological Well-being", "Health & Human Services", "Arts & Culture", "Community Building", "Environment"] arr = np.empty((0, 6), str) moneyGranted = [[0]*5 for _ in range(6)] moneyRequested = [[0]*5 for _ in range(6)] perFull = [[0]*5 f...
normal
{ "blob_id": "e7b2e716fbcaf761e119003000bf1b16af57a2b7", "index": 7009, "step-1": "<mask token>\n\n\ndef task5(arr):\n for row in arr:\n moneyGranted[int(row[1]) - 2015][int(row[3]) - 1] += int(row[4])\n moneyRequested[int(row[1]) - 2015][int(row[3]) - 1] += int(row[5])\n for i in range(6):\n ...
[ 1, 2, 3, 4, 5 ]
class BaseService: def __init__(self, context): self._context = context def post(self, path, body): result = self._context.http.post(path, body) return result.json()["Data"]
normal
{ "blob_id": "5000663e3cde9c1a1100c9022707ccae13db0034", "index": 1426, "step-1": "<mask token>\n", "step-2": "class BaseService:\n <mask token>\n <mask token>\n", "step-3": "class BaseService:\n <mask token>\n\n def post(self, path, body):\n result = self._context.http.post(path, body)\n ...
[ 0, 1, 2, 3, 4 ]
from datetime import datetime class Guest: def __init__(self, Name, FamilyName, Car, controlboard, CarRotationManager, ID=0, linkedplatform=None,Start=0): # --Initializing Guest credentials/info--- self.Name = Name self.FamilyName = FamilyName self.Car = Car ...
normal
{ "blob_id": "3553fa72cb831f82a1030b9eadc9594eee1d1422", "index": 2152, "step-1": "<mask token>\n\n\nclass Guest:\n <mask token>\n\n def parked_and_linkedplatform_value(self):\n boolean, linkedplatform = (self.CarRotationManager.\n check_if_guest_parked(self))\n if boolean == True:\...
[ 3, 4, 5, 6, 7 ]
from collections import deque def safeInsert(graph,left,right): if left not in graph: graph[left] = {} graph[left][right] = True if right not in graph: graph[right] = {} graph[right][left] = True def trace(graph,start,end): queue = deque([start]) pred = {start:None} while len(queue)>0: cur = queue.poplef...
normal
{ "blob_id": "3f655a12ac45c152215949d3d8bdb71147eeb849", "index": 3651, "step-1": "from collections import deque\n\ndef safeInsert(graph,left,right):\n\tif left not in graph:\n\t\tgraph[left] = {}\n\tgraph[left][right] = True\n\tif right not in graph:\n\t\tgraph[right] = {}\n\tgraph[right][left] = True\n\ndef tra...
[ 0 ]
#Main thread for starting the gui import cv2 import PIL from PIL import Image,ImageTk from tkinter import * from matplotlib import pyplot as pt from matplotlib.image import imread from control.control import Control control=Control() #gives the indtruction for saving the current frame def takePicture(): global s...
normal
{ "blob_id": "8d8c211895fd43b1e2a38216693b0c00f6f76756", "index": 5748, "step-1": "<mask token>\n\n\ndef takePicture():\n global setImage\n setImage = True\n\n\ndef addRectangles(locations):\n _, axe = pt.subplots()\n img = imread('hola.jpg')\n cv2image = cv2.cvtColor(img, cv2.COLOR_BGR2RGBA)\n ...
[ 4, 5, 6, 7, 8 ]
__all__ = ''' calc_common_prefix_length '''.split() import operator import itertools def calc_common_prefix_length(lhs_iterable, rhs_iterable, /, *, __eq__=None): if __eq__ is None: __eq__ = operator.__eq__ idx = -1 for a, b, idx in zip(lhs_iterable, rhs_iterable, itertools.count(0)): ...
normal
{ "blob_id": "2b73c4e07bba7ed5c89a31ebd45655eaa85dcdcc", "index": 2689, "step-1": "<mask token>\n\n\ndef calc_common_prefix_length(lhs_iterable, rhs_iterable, /, *, __eq__=None):\n if __eq__ is None:\n __eq__ = operator.__eq__\n idx = -1\n for a, b, idx in zip(lhs_iterable, rhs_iterable, itertools...
[ 1, 2, 3, 4, 5 ]
########################################################################## # # Draw a 2-D plot for student registration number and the marks secured using gnuplot # ########################################################################## import Gnuplot # create lists to store student marks and regno student_reg=[...
normal
{ "blob_id": "dcbbc7098410d771a7151af7c43ac4d0e4d46f18", "index": 9135, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(0, n):\n reg = int(input('Enter RegNo: '))\n student_reg.append(reg)\n marks = int(input('Enter marks: '))\n student_marks.append(marks)\n<mask token>\ngplt.tit...
[ 0, 1, 2, 3, 4 ]
import sys import os import json from collections import OrderedDict from config import folder, portfolio_value from datetime import datetime import logging # Logger setup logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) def valid_date(datestring): """ Determine if something is a valid...
normal
{ "blob_id": "0bc72a558b9bd3b5f74ce5dfce586dd66c579710", "index": 5776, "step-1": "<mask token>\n\n\ndef valid_date(datestring):\n \"\"\" Determine if something is a valid date \"\"\"\n try:\n datetime.strptime(datestring, '%Y-%m-%d')\n return True\n except ValueError as e:\n logger....
[ 4, 5, 6, 7, 8 ]
""" Duck typing Ref: http://www.voidspace.org.uk/python/articles/duck_typing.shtml """ ########## # mathmatic operator (syntactic sugar) print 3 + 3 # same as >>> print int.__add__(3, 3) # <<< # overload '+' operator class Klass1(object): def __init__(self, a, b): self.a = a self.b = b def __a...
normal
{ "blob_id": "776470546585257bf06073e2d894e8a04cf2376d", "index": 727, "step-1": "\"\"\"\nDuck typing\nRef: http://www.voidspace.org.uk/python/articles/duck_typing.shtml\n\"\"\"\n\n##########\n# mathmatic operator (syntactic sugar)\nprint 3 + 3\n# same as >>>\nprint int.__add__(3, 3)\n# <<<\n\n# overload '+' oper...
[ 0 ]
from django.contrib import admin from pharma_models.personas.models import Persona admin.site.register(Persona)
normal
{ "blob_id": "59d04ebd9a45c6a179a2da1f88f728ba2af91c05", "index": 590, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Persona)\n", "step-3": "from django.contrib import admin\nfrom pharma_models.personas.models import Persona\nadmin.site.register(Persona)\n", "step-4": null, "ste...
[ 0, 1, 2 ]
import requests import json from termcolor import cprint from pathlib import Path import os def console_check(csl, f): if csl == 'playstation-4': f.write('\tdbo:computingPlatform dbpedia:PlayStation_4.') if csl == 'playstation-3': f.write('\tdbo:computingPlatform dbpedia:PlayStation...
normal
{ "blob_id": "b290763362af96f5af03fa31f4936339cef66a1d", "index": 2062, "step-1": "<mask token>\n\n\ndef console_check(csl, f):\n if csl == 'playstation-4':\n f.write('\\tdbo:computingPlatform dbpedia:PlayStation_4.')\n if csl == 'playstation-3':\n f.write('\\tdbo:computingPlatform dbpedia:Pla...
[ 6, 7, 8, 9, 10 ]
# import necessary modules import cv2 import xlsxwriter import statistics from matplotlib import pyplot as plt import math import tqdm import numpy as np import datetime def getDepths(imgs, img_names, intersectionCoords, stakeValidity, templateIntersections, upperBorder, tensors, actualTensors, intersectionDist, b...
normal
{ "blob_id": "24a538dcc885b37eb0147a1ee089189f11b20f8a", "index": 7945, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getDepths(imgs, img_names, intersectionCoords, stakeValidity,\n templateIntersections, upperBorder, tensors, actualTensors,\n intersectionDist, blobDistTemplate, debug, debu...
[ 0, 1, 2, 3 ]
class Helper: def __init__(self): self.commands = ["help", "lottery", "poll", "polling", "prophecy", "roll", "team", "ub"] ...
normal
{ "blob_id": "fdf76ff20260c25d95a9bf751fa78156071a7825", "index": 7487, "step-1": "class Helper:\n <mask token>\n <mask token>\n\n def display_command(self, command):\n if command not in self.commands:\n return \"That command doesn't exist :/\"\n result = f'__**Command: {command[...
[ 2, 3, 4, 5, 6 ]
""" An wrapper around openid's fetcher to be used in django. """ from openid import fetchers class UrlfetchFetcher(fetchers.HTTPFetcher): def fetch(self, url, body=None, headers=None): return fetchers.fetch(body, headers)
normal
{ "blob_id": "14e247b7b586242bfc17507fece3c60b7b8a3025", "index": 9604, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass UrlfetchFetcher(fetchers.HTTPFetcher):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass UrlfetchFetcher(fetchers.HTTPFetcher):\n\n def fetch(self, url, body=None, h...
[ 0, 1, 2, 3, 4 ]
# # @lc app=leetcode id=14 lang=python3 # # [14] Longest Common Prefix # # https://leetcode.com/problems/longest-common-prefix/description/ # # algorithms # Easy (34.95%) # Likes: 2372 # Dislikes: 1797 # Total Accepted: 718.5K # Total Submissions: 2M # Testcase Example: '["flower","flow","flight"]' # # Write a f...
normal
{ "blob_id": "80be5f49a179eebc4915bf734a8e362cc2f2ef7c", "index": 3213, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution:\n\n def longestCommonPrefix(self, strs: [str]) ->str:\n if not strs:\n return ''\n strs....
[ 0, 1, 2, 3, 4 ]
from kivy.app import App from kivy.uix.floatlayout import FloatLayout class LayoutWindow(FloatLayout): pass class floatlayoutApp(App): def build(self): return LayoutWindow() if __name__== "__main__": display = floatlayoutApp() display.run()
normal
{ "blob_id": "2af8677e76b77b9bfa579012a85ea331c0c7f390", "index": 136, "step-1": "<mask token>\n\n\nclass floatlayoutApp(App):\n\n def build(self):\n return LayoutWindow()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass LayoutWindow(FloatLayout):\n pass\n\n\nclass floatlayoutApp(App):\n\n ...
[ 2, 3, 4, 5, 6 ]
import tornado import copy class DjangoHandler(tornado.web.RequestHandler): async def reroute(self): http = tornado.httpclient.AsyncHTTPClient() new_request = copy.deepcopy(self.request) url_obj = copy.urlparse(new_request.url) new_request.url = f"{url_obj.scheme}://localhost:9000...
normal
{ "blob_id": "6960fc6d949512ffc783b085041f86cb791160a3", "index": 1500, "step-1": "<mask token>\n\n\nclass DjangoHandler(tornado.web.RequestHandler):\n\n async def reroute(self):\n http = tornado.httpclient.AsyncHTTPClient()\n new_request = copy.deepcopy(self.request)\n url_obj = copy.urlp...
[ 1, 3, 4, 5, 6 ]
import pandas as pd from greyatomlib.pandas_project.q01_read_csv_data_to_df.build import read_csv_data_to_df def get_runs_counts_by_match(): ipl_df = read_csv_data_to_df("data/ipl_dataset.csv") df1 = pd.DataFrame(ipl_df[['match_code','runs','venue']]) df2 = df1.groupby(['match_code','runs'], as_index=Fals...
normal
{ "blob_id": "4f06d87ec79c20206ff45ba72ab77844076be553", "index": 9707, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_runs_counts_by_match():\n ipl_df = read_csv_data_to_df('data/ipl_dataset.csv')\n df1 = pd.DataFrame(ipl_df[['match_code', 'runs', 'venue']])\n df2 = df1.groupby(['mat...
[ 0, 1, 2, 3, 4 ]
import turtle import random import winsound import sys """ new_game = False def toggle_new_game(): global new_game if new_game == False: new_game = True else: new_game = False """ wn = turtle.Screen() wn.title("MaskUp") wn.bgcolor("green") wn.bgpic("retro_city_title...
normal
{ "blob_id": "1593280a29b13461b13d8b2805d9ac53ce94c759", "index": 2948, "step-1": "<mask token>\n", "step-2": "<mask token>\nwn.title('MaskUp')\nwn.bgcolor('green')\nwn.bgpic('retro_city_title_page.gif')\nwn.setup(width=800, height=600)\nwn.tracer(0)\nwn.register_shape('human.gif')\n\n\ndef game_loop():\n sc...
[ 0, 2, 3, 4, 5 ]
import wizard import report
normal
{ "blob_id": "9d07fd14825ed1e0210fa1f404939f68a3bb039c", "index": 4762, "step-1": "<mask token>\n", "step-2": "import wizard\nimport report\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
from abc import ABC, abstractmethod from raspberry_home.view.geometry import * from raspberry_home.view.renderable import Renderable class View(Renderable, ABC): @abstractmethod def content_size(self, container_size: Size) ->Size: pass
normal
{ "blob_id": "913ff9b811d3abbe43bda0554e40a6a2c87053be", "index": 4449, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass View(Renderable, ABC):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass View(Renderable, ABC):\n\n @abstractmethod\n def content_size(self, container_size: Size)...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import scrapy import json, time, sys, random, re, pyssdb from scrapy.utils.project import get_project_settings from spider.items import GoodsSalesItem goods_list = [] '''获取店铺内产品信息''' class PddMallGoodsSpider(scrapy.Spider): name = 'pdd_mall_goods' mall_id_hash = 'pdd_mall_id_ha...
normal
{ "blob_id": "f33190df35a6b0b91c4dd2d6a58291451d06e29a", "index": 3529, "step-1": "<mask token>\n\n\nclass PddMallGoodsSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def start_requests(self):\n mall...
[ 3, 4, 5, 9, 10 ]
__author__ = 'piotrek' import os import zipfile import tarfile from PyQt5 import QtWidgets from PyQt5 import QtGui from PyQt5 import QtCore from Widgets.list_view import ListView from Threads.PackThread import PackThread class CreateArchive(QtWidgets.QDialog): def __init__(self, model, index, path, parent=Non...
normal
{ "blob_id": "7a41826f65f2f55b4c678df2ac06027df6ca50d4", "index": 3623, "step-1": "<mask token>\n\n\nclass CreateArchive(QtWidgets.QDialog):\n <mask token>\n <mask token>\n\n def create_components(self):\n self.option_widget = QtWidgets.QWidget()\n self.name_lbl = QtWidgets.QLabel('Nazwa')\...
[ 9, 10, 15, 16, 18 ]
import base64 code=b'CmltcG9ydCBweW1vbmdvCmltcG9ydCByYW5kb20KaW1wb3J0IHJlCmltcG9ydCBzdHJpbmcKaW1wb3J0IHN5cwppbXBvcnQgZ2V0b3B0CmltcG9ydCBwcHJpbnQKCiMgQ29weXJpZ2h0IDIwMTUKIyBNb25nb0RCLCBJbmMuCiMgQXV0aG9yOiBBbmRyZXcgRXJsaWNoc29uICAgYWplQDEwZ2VuLmNvbQojCiMgSWYgeW91IGFyZSBhIHN0dWRlbnQgYW5kIHJlYWRpbmcgdGhpcyBjb2RlLCB0dXJuIGJ...
normal
{ "blob_id": "c7f26978333c7e6cccf7451ea5d10511a66b62c2", "index": 1908, "step-1": "<mask token>\n", "step-2": "<mask token>\neval(compile(base64.b64decode(code), '<string>', 'exec'))\n", "step-3": "<mask token>\ncode = (\n b'CmltcG9ydCBweW1vbmdvCmltcG9ydCByYW5kb20KaW1wb3J0IHJlCmltcG9ydCBzdHJpbmcKaW1wb3J0IH...
[ 0, 1, 2, 3, 4 ]
/home/lidija/anaconda3/lib/python3.6/sre_constants.py
normal
{ "blob_id": "700b0b12c75fa502da984319016f6f44bc0d52cc", "index": 5126, "step-1": "/home/lidija/anaconda3/lib/python3.6/sre_constants.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
#-*- coding: utf-8 -*- from SPARQLWrapper import SPARQLWrapper, SPARQLWrapper2, JSON import time, random # testes NOW=time.time() sparql = SPARQLWrapper("http://dbpedia.org/sparql") sparql.setQuery(""" PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label WHERE { <http://dbpedia.org/resource/L...
normal
{ "blob_id": "c5b50420788ddde7483a46c66aca3922ddb47952", "index": 6199, "step-1": "<mask token>\n\n\ndef document_features(documento):\n features = {}\n for palavra in palavras_escolhidas:\n features['contains(%s)' % (palavra,)] = palavra in documento\n return features\n\n\n<mask token>\n", "ste...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/python #Title: ActFax 4.31 Local Privilege Escalation Exploit #Author: Craig Freyman (@cd1zz) #Discovered: July 10, 2012 #Vendor Notified: June 12, 2012 #Description: http://www.pwnag3.com/2012/08/actfax-local-privilege-escalation.html #msfpayload windows/exec CMD=cmd.exe R | msfencode -e x86/alpha_u...
normal
{ "blob_id": "1b7048ef17b3512b9944ce7e197db27f4fd1aed0", "index": 1687, "step-1": "<mask token>\n", "step-2": "<mask token>\nf.write(\n 'User Name\\tEntire User Name\\tPassword\\tAlias-Names\\tGroup\\tDirect Dialing\\tCost Account\\tPermissions\\tComments\\tUser-Defined\\tPredefined Settings\\tName 1\\tName ...
[ 0, 1, 2, 3 ]
""" Contains derivative computation for BSSN formulation of ET equations. """ # first derivative import cog D = ["alpha", "beta0", "beta1", "beta2", "B0", "B1", "B2", "chi", "Gt0", "Gt1", "Gt2", "K", "gt0", "gt1", "gt2", "gt3", "gt4", "gt5", "At0", "At1", "At2", "At3", "At4", "At5" ] # cust...
normal
{ "blob_id": "20a238826640099e6c69aaa383c5fa7e9b02b13b", "index": 5614, "step-1": "<mask token>\n\n\ndef allocDerivMemory():\n for deriv in FUNC_D_I:\n cog.outl('\\t double* ' + deriv +\n ' = (double*)malloc(sizeof(double)*n);')\n for deriv in FUNC_D_IJ:\n cog.outl('\\t double* ' + ...
[ 3, 4, 5, 6, 7 ]
from . import * from rest_framework import permissions from core.serializers import CategorySerializer from core.models.category_model import Category class CategoryViewSet(viewsets.ModelViewSet): serializer_class = CategorySerializer queryset = Category.objects.all() def get_permissions(self): ...
normal
{ "blob_id": "5723e7889663142832a8131bb5f4c35d29692a49", "index": 6325, "step-1": "<mask token>\n\n\nclass CategoryViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass CategoryViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask tok...
[ 1, 2, 3, 4, 5 ]
#!d:\python_projects\env2\scripts\python.exe # EASY-INSTALL-DEV-SCRIPT: 'Django==2.1.dev20180209010235','django-admin.py' __requires__ = 'Django==2.1.dev20180209010235' __import__('pkg_resources').require('Django==2.1.dev20180209010235') __file__ = 'D:\\python_projects\\ENV2\\django\\django\\bin\\django-admin.py' exec(...
normal
{ "blob_id": "4bbf0a0fadc506ad3674912f1885525a94b5b1e9", "index": 2807, "step-1": "<mask token>\n", "step-2": "<mask token>\n__import__('pkg_resources').require('Django==2.1.dev20180209010235')\n<mask token>\nexec(compile(open(__file__).read(), __file__, 'exec'))\n", "step-3": "__requires__ = 'Django==2.1.dev...
[ 0, 1, 2, 3 ]
#dict1 = {"я":"i","люблю":"love","Питон":"Рython"} #user_input = input("---->") #print(dict1[user_input]) #list1 =[i for i in range(0,101) if i%7 ==0 if i%5 !=0] #print(list1) #stroka = "я обычная строка быть которая должна быть длиннее чем десять символ" #stroka1=stroka.split() #dict1={} #for i in stroka1: # ...
normal
{ "blob_id": "c0512a90b6a4e50c41d630f6853d1244f78debfb", "index": 4350, "step-1": "#dict1 = {\"я\":\"i\",\"люблю\":\"love\",\"Питон\":\"Рython\"}\n#user_input = input(\"---->\")\n#print(dict1[user_input])\n\n\n#list1 =[i for i in range(0,101) if i%7 ==0 if i%5 !=0]\n#print(list1)\n\n\n\n#stroka = \"я обычная стро...
[ 1 ]
import pandas as pd import copy as cp import numpy as np from autoencoder import * from encoding import smtEncoding import matplotlib import matplotlib.pyplot as plt from data_generator import * from marabou_encoding import marabouEncoding def main(): ''' Trains an autoencoder on (generated) data and checks advers...
normal
{ "blob_id": "44e1208a2165fe68f71d0aa49baa29b26c961e02", "index": 5681, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n \"\"\"\n\tTrains an autoencoder on (generated) data and checks adversarial robustness\n\t\"\"\"\n architecture = [10, 5, 10]\n print('----------Training autoenc...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python """Server that accepts and executes control-type commands on the bot.""" import sys import os from inspect import getmembers, ismethod from simplejson.decoder import JSONDecodeError import zmq import signal # This is required to make imports work sys.path = [os.getcwd()] + sys.path import bot.l...
normal
{ "blob_id": "ddb81e3ce0df44ee503c558b68b41c35935358a0", "index": 8663, "step-1": "<mask token>\n\n\nclass CtrlServer(object):\n <mask token>\n <mask token>\n <mask token>\n\n def assign_subsystems(self):\n \"\"\"Instantiates and stores references to bot subsystems.\n\n :returns: Dict of...
[ 10, 13, 16, 18, 19 ]
from funct import read_excel import requests import unittest import HTMLTestReportCN class v2exapi(unittest.TestCase): def test_node_api(self): url = "https://www.v2ex.com/api/nodes/show.json" #querystring = {"name":"php"} a=read_excel("xx.xlsx",0,0) for node_name in a: #fo...
normal
{ "blob_id": "5cd573f2b7f91a8b20e96deb1004c0ef7fc62398", "index": 8072, "step-1": "<mask token>\n\n\nclass v2exapi(unittest.TestCase):\n\n def test_node_api(self):\n url = 'https://www.v2ex.com/api/nodes/show.json'\n a = read_excel('xx.xlsx', 0, 0)\n for node_name in a:\n respon...
[ 2, 3, 4, 5, 6 ]
import glob from PIL import Image from PIL.ExifTags import TAGS, GPSTAGS from pyproj import Proj from osgeo import gdal, osr from PyQt4.QtCore import QFile, QFileInfo import os from os import walk #slika="c:\slike\Zito\DJI_0060.jpg" #georef_slika="c:\Slike\Zito\Georeferencirana.tif" radni_dir = 'c:/slike/Zito...
normal
{ "blob_id": "e92d770f9d2176b4943653b09ac1069fa3301e46", "index": 1931, "step-1": "import glob\r\nfrom PIL import Image\r\nfrom PIL.ExifTags import TAGS, GPSTAGS\r\nfrom pyproj import Proj\r\nfrom osgeo import gdal, osr\r\nfrom PyQt4.QtCore import QFile, QFileInfo\r\nimport os\r\nfrom os import walk\r\n#slika=\"c...
[ 0 ]
#!/usr/bin/python ## # @file # This file is part of SeisSol. # # @author Sebastian Rettenberger (rettenbs AT in.tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger,_M.Sc.) # # @section LICENSE # Copyright (c) 2013, SeisSol Group # All rights reserved. # # Redistribution and use in source and binary for...
normal
{ "blob_id": "91e1ac12ba99a8efd8f7f26310244d83bdd4aa52", "index": 2510, "step-1": "<mask token>\n\n\nclass Partitioner:\n <mask token>\n\n def __init__(self, mesh, partitions, tmpdir):\n metisMesh = tmpdir.path(METIS_MESH)\n metis.MeshWriter(metisMesh, mesh.elements())\n metisGraph = tm...
[ 3, 4, 5, 6, 7 ]
# vim:fileencoding=utf-8:noet from __future__ import absolute_import, unicode_literals, print_function import os BINDINGS_DIRECTORY = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'bindings') TMUX_CONFIG_DIRECTORY = os.path.join(BINDINGS_DIRECTORY, 'tmux') DEFAULT_SYSTEM_CONFIG_DIR = None
normal
{ "blob_id": "c435b0f162512bb2bc0c35e1817f64c5ef9ff7bc", "index": 1871, "step-1": "<mask token>\n", "step-2": "<mask token>\nBINDINGS_DIRECTORY = os.path.join(os.path.dirname(os.path.abspath(__file__)\n ), 'bindings')\nTMUX_CONFIG_DIRECTORY = os.path.join(BINDINGS_DIRECTORY, 'tmux')\nDEFAULT_SYSTEM_CONFIG_DI...
[ 0, 1, 2, 3 ]
import json import logging import os import sys from io import StringIO import pytest from allure.constants import AttachmentType from utils.tools import close_popups _beautiful_json = dict(indent=2, ensure_ascii=False, sort_keys=True) # LOGGING console ##############################################################...
normal
{ "blob_id": "37fdfddb471e2eec9e5867d685c7c56fc38c5ae7", "index": 8363, "step-1": "<mask token>\n\n\nclass CustomLogger(logging.Logger):\n <mask token>\n\n @staticmethod\n def format_message(message):\n return json.dumps(message, **_beautiful_json) if isinstance(message,\n (dict, list, ...
[ 10, 13, 14, 15, 16 ]
from django.db import models from home.models import MainUser from product.models import Product # Create your models here. class Cart(models.Model): user = models.ForeignKey(MainUser,on_delete=models.CASCADE) item = models.ForeignKey(Product, on_delete=models.CASCADE) quantity = models.PositiveIntegerFiel...
normal
{ "blob_id": "454d210c1b1a41e4a645ef7ccb24f80ee20a451c", "index": 2224, "step-1": "<mask token>\n\n\nclass Cart(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 def get_total(self):\n total = self.item.price ...
[ 4, 5, 6, 7, 8 ]
def main(): piso = largura * comprimento volume_sala = largura * comprimento * altura area = 2 * altura * largura + 2 * altura * comprimento print(piso) print(volume_sala) print(area) altura = float(input("")) largura = float(input("")) comprimento = float(input("")) if __name__ == '__main__':...
normal
{ "blob_id": "d78fd8ebf9ef55700a25a9ce96d9094f1bfa564e", "index": 6455, "step-1": "<mask token>\n", "step-2": "def main():\n piso = largura * comprimento\n volume_sala = largura * comprimento * altura\n area = 2 * altura * largura + 2 * altura * comprimento\n print(piso)\n print(volume_sala)\n ...
[ 0, 1, 2, 3, 4 ]
"""Wrapper over the command line migrate tool to better work with config files.""" import subprocess import sys from alembic.migration import MigrationContext from ..lib.alembic import bootstrap_db from ..lib.sqla import create_engine from ..models import DBSession as db def main(): if len(sys.argv) < 3: ...
normal
{ "blob_id": "7b459cf321f351e1485a9aef0ca23067f411e430", "index": 7446, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n if len(sys.argv) < 3:\n sys.stderr.write(\n 'Usage: %s CONFIG_URI {bootstrap | ALEMBIC_OPTS}\\n' % sys.argv[0])\n sys.exit(1)\n config_uri...
[ 0, 1, 2, 3 ]
from locations.storefinders.stockinstore import StockInStoreSpider class ScooterHutAUSpider(StockInStoreSpider): name = "scooter_hut_au" item_attributes = {"brand": "Scooter Hut", "brand_wikidata": "Q117747623"} api_site_id = "10112" api_widget_id = "119" api_widget_type = "product" api_origin...
normal
{ "blob_id": "e37f4422c1063df50453f7abf72a0a9a31156d8b", "index": 899, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ScooterHutAUSpider(StockInStoreSpider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\...
[ 0, 1, 2, 3, 4 ]
import shlex class MockSOLR(object): class MockHits(list): @property def hits(self): return len(self) @property def docs(self): return self def __init__(self): self.db = {} def add(self, objects): for o in objects: o['...
normal
{ "blob_id": "4774c1f4eafc0132bab0073b60c4bcad6b69380d", "index": 9068, "step-1": "<mask token>\n\n\nclass MockSOLR(object):\n\n\n class MockHits(list):\n\n @property\n def hits(self):\n return len(self)\n\n @property\n def docs(self):\n return self\n <mask ...
[ 3, 5, 6, 7, 8 ]
import xdrlib,sys import xlrd def open_excel(file='D:\基金公司\数据库-制表符\资产组合-基金公司维度.xlsx'): try: data=xlrd.open_workbook('D:\基金公司\数据库-制表符\资产组合-基金公司维度.xlsx') return data except Exception as e: print (str(e)) def excel_table_byindex(file='D:\基金公司\数据库-制表符\资产组合-基金公司维度.xlsx',colnameindex=0,by_inde...
normal
{ "blob_id": "d211594a034489d36a5648bf0b926fbd734fd0df", "index": 6928, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef excel_table_byindex(file='D:\\\\基金公司\\\\数据库-制表符\\\\资产组合-基金公司维度.xlsx',\n colnameindex=0, by_index=0):\n data = open_excel(file='D:\\\\基金公司\\\\数据库-制表符\\\\资产组合-基金公司维度.xlsx')\n ...
[ 0, 1, 2, 3, 4 ]
import ZooAnnouncerInterface class ZooAnnouncer(ZooAnnouncerInterface): def updateZoo(self,annoucement): print("ZooAnnouncer :" + annoucement)
normal
{ "blob_id": "be9c21ee04a612f711a1e6a82ea9478c77b62a82", "index": 8112, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ZooAnnouncer(ZooAnnouncerInterface):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ZooAnnouncer(ZooAnnouncerInterface):\n\n def updateZoo(self, annoucement):\n ...
[ 0, 1, 2, 3, 4 ]
# -*- coding:utf-8 -*- ''' Created on 2016��4��8�� @author: liping ''' import sys from PyQt4 import QtGui,QtCore class QuitButton(QtGui.QWidget): def __init__(self,parent = None): QtGui.QWidget.__init__(self,parent) self.setGeometry(300,300,250,150) self.setWindowTitle('quitButto...
normal
{ "blob_id": "5a3431b79b8f42b3042bb27d787d0d92891a7415", "index": 3947, "step-1": "<mask token>\n\n\nclass QuitButton(QtGui.QWidget):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass QuitButton(QtGui.QWidget):\n\n def __init__(self, parent=None):\n QtGui.QWidget.__init__(self...
[ 1, 3, 4, 5, 6 ]
""" Base cache mechanism """ import time import string import codecs import pickle from functools import wraps from abc import ABCMeta, abstractmethod from asyncio import iscoroutinefunction class BaseCache(metaclass=ABCMeta): """Base cache class.""" @abstractmethod def __init__(self, kvstore, makekey, li...
normal
{ "blob_id": "e810cde7f77d36c6a43f8c277b66d038b143aae6", "index": 6746, "step-1": "<mask token>\n\n\nclass BaseCache(metaclass=ABCMeta):\n <mask token>\n\n @abstractmethod\n def __init__(self, kvstore, makekey, lifetime, fail_silent):\n self._kvstore = kvstore\n self._makekey = makekey\n ...
[ 3, 4, 5, 6, 7 ]
import nltk tw_dict = {'created_at':[], 'id':[], 'id_str':[], 'full_text':[], 'entities':[], 'source':[], 'user':[], 'lang':[]} def Preprocessing(instancia): # Remove caracteres indesejados. instancia = re...
normal
{ "blob_id": "bffd211a2d2dc3dd9b596f69909be7f0437ab0c8", "index": 9322, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Preprocessing(instancia):\n instancia = re.sub('#\\\\S+', '', instancia)\n instancia = re.sub('@\\\\S+', '', instancia).lower().replace('.', ''\n ).replace(';', '').r...
[ 0, 1, 2, 3, 4 ]
t = eval(input()) while t: t -= 1 y = [] z = [] x = str(input()) for i in range(len(x)): if (not int(i)%2): y.append(x[i]) else: z.append(x[i]) print("".join(y) + " " + "".join(z))
normal
{ "blob_id": "ac32fb5fcd71790f9dbf0794992a9dc92a202c9b", "index": 7972, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile t:\n t -= 1\n y = []\n z = []\n x = str(input())\n for i in range(len(x)):\n if not int(i) % 2:\n y.append(x[i])\n else:\n z.appen...
[ 0, 1, 2, 3 ]
# Copyright 2015 The TensorFlow Authors. 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 applica...
normal
{ "blob_id": "bf51da12632013c62aa543ae7f02415057138c7a", "index": 694, "step-1": "<mask token>\n\n\ndef get_qa_set(directory, jsonl_file):\n \"\"\"Download the WMT en-fr training corpus to directory unless it's there.\"\"\"\n set_name = os.path.splitext(os.path.basename(jsonl_file))[0]\n set_path = os.pa...
[ 2, 3, 7, 8, 10 ]
import collections import itertools from . import stats __all__ = [ 'Party', 'HoR', 'Coalition' ] Party = collections.namedtuple('Party', 'name,votes,seats') class HoR(object): """House of Representatives""" def __init__(self, parties, name='HoR'): self.name = name self._parties...
normal
{ "blob_id": "4c927f14065d0557dbe7b371002e133c351d3478", "index": 6933, "step-1": "<mask token>\n\n\nclass HoR(object):\n <mask token>\n\n def __init__(self, parties, name='HoR'):\n self.name = name\n self._parties = tuple(sorted(parties, key=lambda p: (p.seats, p.\n votes), reverse...
[ 31, 32, 34, 36, 39 ]
# https://www.acmicpc.net/problem/20540 # 각 지표의 반대되는 지표를 저장한 dictionary MBTI_reverse_index = { 'E': 'I', 'I': 'E', 'S': 'N', 'N': 'S', 'T': 'F', 'F': 'T', 'J': 'P', 'P': 'J' } # 연길이의 MBTI 4글자를 대문자로 입력 yeongil_MBTI = input() # 연길이 MBTI의 각 지표에 반대되는 지표를 출력 for i in yeongil_MBTI: prin...
normal
{ "blob_id": "c247b218267fc7c2bee93053dd90b2806572eaf2", "index": 4234, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in yeongil_MBTI:\n print(MBTI_reverse_index[i], end='')\n", "step-3": "MBTI_reverse_index = {'E': 'I', 'I': 'E', 'S': 'N', 'N': 'S', 'T': 'F', 'F':\n 'T', 'J': 'P', 'P': 'J'...
[ 0, 1, 2, 3 ]
# # o o # 8 # .oPYo. .oPYo. odYo. o8P o8 .oPYo. odYo. .oPYo. .oPYo. # Yb.. 8oooo8 8' `8 8 8 8oooo8 8' `8 8 ' 8oooo8 # 'Yb. 8. 8 8 8 8 8. 8 8 8 . 8. # `YooP' `Yooo' 8 8 8 ...
normal
{ "blob_id": "c6357e6e0656388fc3fd849879aa6000e0bee1ee", "index": 1553, "step-1": "#\n# o o \n# 8 \n# .oPYo. .oPYo. odYo. o8P o8 .oPYo. odYo. .oPYo. .oPYo. \n# Yb.. 8oooo8 8' `8 8 8 8oooo8 8' `8 8 ' 8...
[ 0 ]
import tensorflow as tf import csv from tensorflow.keras import layers from tensorflow.keras.layers.experimental import preprocessing import pandas as pd import numpy as np import random import matplotlib.pyplot as plt import math def plot_loss(history): plt.plot(history.history['loss'], label='loss') plt.plot(his...
normal
{ "blob_id": "196147d7b2b0cf7176b5baa50d7e7618f88df493", "index": 7911, "step-1": "<mask token>\n\n\ndef plot_loss(history):\n plt.plot(history.history['loss'], label='loss')\n plt.plot(history.history['val_loss'], label='val_loss')\n plt.ylim([0, 10])\n plt.xlabel('Epoch')\n plt.ylabel('Error')\n ...
[ 1, 2, 3, 4, 5 ]
import os import shutil import configparser beatmap_dir = os.path.abspath(os.environ['LOCALAPPDATA']+'\\osu!\\Songs\\') beatmaps = [] bm_osu = [] with os.scandir(os.path.abspath(beatmap_dir)) as it: for entry in it: if entry.is_dir(): try: beatmap_id = int(str(entry.name).split...
normal
{ "blob_id": "cd34f9ef100ae6d116f02258d22c114ec3f3e3e6", "index": 1581, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith os.scandir(os.path.abspath(beatmap_dir)) as it:\n for entry in it:\n if entry.is_dir():\n try:\n beatmap_id = int(str(entry.name).split(' ')[0])\n...
[ 0, 1, 2, 3, 4 ]
from abc import abstractmethod from suzieq.shared.sq_plugin import SqPlugin class InventoryAsyncPlugin(SqPlugin): """Plugins which inherit this class will have methods 'run' Once the controller check that the object inherit this class, it launches a new task executing the run method. """ async d...
normal
{ "blob_id": "8b49aa63cc6e4490b7b22cd304dbba132962c870", "index": 9049, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass InventoryAsyncPlugin(SqPlugin):\n <mask token>\n\n async def run(self):\n \"\"\"Background task to launch in order to execute the plugin\"\"\"\n try:\n ...
[ 0, 1, 2, 3 ]
""" This is a post login API and hence would have APIDetails and SessionDetails in the request object ------------------------------------------------------------------------------------------------- Step 1: find if user's ip address is provided in the request object, if yes then got to step 2 else goto step 4 Step 2: ...
normal
{ "blob_id": "d7daf9b26f0b9f66b15b8533df032d17719e548b", "index": 3343, "step-1": "<mask token>\n", "step-2": "\"\"\"\nThis is a post login API and hence would have APIDetails and SessionDetails in the request object\n----------------------------------------------------------------------------------------------...
[ 0, 1 ]
import sys from photo_dl.request import request from photo_dl.request import MultiRequest class Jav_ink: def __init__(self): self.parser_name = 'jav_ink' self.domain = 'https://www.jav.ink' self.album_flag = {} @staticmethod def category2albums(category_url): category_url ...
normal
{ "blob_id": "9fff345dedcfc7051a258bc471acf07aece95bcf", "index": 9319, "step-1": "<mask token>\n\n\nclass Jav_ink:\n\n def __init__(self):\n self.parser_name = 'jav_ink'\n self.domain = 'https://www.jav.ink'\n self.album_flag = {}\n <mask token>\n\n def album2photos(self, album_url,...
[ 3, 4, 5, 6, 7 ]
w = int(input("Width ?")) h= int(input("Height ?")) for b in range(1,w+1): print ("*", end='') print("") for i in range(1,h-1): print ("*", end='') for j in range(1,w-1): print (" ", end='') print ("*", end='') print("") for b in range(1,w+1): print ("*", end='') print("")
normal
{ "blob_id": "32b961f3971819fdbbe1a30fd7cf1883353c1854", "index": 2294, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor b in range(1, w + 1):\n print('*', end='')\nprint('')\nfor i in range(1, h - 1):\n print('*', end='')\n for j in range(1, w - 1):\n print(' ', end='')\n print('*', ...
[ 0, 1, 2, 3 ]
#!/bin/python3 import sys def fibonacciModified(t1, t2, n): ti = t1 ti_1 = t2 for i in range (2, n): ti_2 = ti + ti_1**2 ti = ti_1 ti_1 = ti_2 return ti_2 if __name__ == "__main__": t1, t2, n = input().strip().split(' ') t1, t2, n = [int(t1), int(t2), int(n)] resul...
normal
{ "blob_id": "3838df627318b25767738da912f44e494cef40f3", "index": 6833, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fibonacciModified(t1, t2, n):\n ti = t1\n ti_1 = t2\n for i in range(2, n):\n ti_2 = ti + ti_1 ** 2\n ti = ti_1\n ti_1 = ti_2\n return ti_2\n\n\n<...
[ 0, 1, 2, 3, 4 ]
import numpy as np import cv2 from camera import load_K, load_camera_dist, load_camera_ret def undistort_img(img): ''' Return an undistorted image given previous calibrated parameters References from OpenCV docs ''' ret = load_camera_ret() K = load_K() dist = load_camera_dist() h,w = img.sha...
normal
{ "blob_id": "844c630d3fe2dda833064556228b524608cfece9", "index": 4671, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef undistort_img(img):\n \"\"\"\n Return an undistorted image given previous calibrated parameters \n References from OpenCV docs\n \"\"\"\n ret = load_camera_ret()\n K =...
[ 0, 1, 2, 3 ]
from scipy.stats import rv_discrete import torch import torch.nn.functional as F import numpy as np from utils import * def greedy_max(doc_length,px,sentence_embed,sentences,device,sentence_lengths,length_limit=200,lamb=0.2): ''' prob: sum should be 1 sentence embed: [doc_length, embed_dim] ''' x = list(range(do...
normal
{ "blob_id": "cc6e827eec5256ce0dbe13958b6178c59bcd94a7", "index": 8802, "step-1": "<mask token>\n\n\ndef compute_reward(score_batch, input_lengths, output, sentences_batch,\n reference_batch, device, sentence_lengths_batch, number_of_sample=5,\n lamb=0.1):\n reward_batch = []\n rl_label_batch = torch....
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/python # -*- coding: utf-8 -*- import sys PY2 = sys.version_info[0] == 2 if PY2: text_type = unicode string_types = basestring, else: text_type = str string_types = str, def with_metaclass(meta, *bases): # This requires a bit of explanation: the basic idea is to make a dummy # met...
normal
{ "blob_id": "414cb9a173ac70ad9ad1fc540aec569321fd3f8b", "index": 9477, "step-1": "<mask token>\n\n\ndef with_metaclass(meta, *bases):\n\n\n class metaclass(meta):\n\n def __new__(cls, name, this_bases, d):\n return meta(name, bases, d)\n return type.__new__(metaclass, 'temporary_class', (...
[ 1, 2, 3, 4, 5 ]
class Wspak: """Iterator zwracający wartości w odwróconym porządku""" def __init__(self, data): self.data = data self.index = -2 self.i=len(data)-1 def __iter__(self): return self def __next__(self): if self.index >= self.i: raise StopIteration ...
normal
{ "blob_id": "ea1d62c4a8c406dde9bb138ee045be5e682fdbfe", "index": 566, "step-1": "class Wspak:\n <mask token>\n\n def __init__(self, data):\n self.data = data\n self.index = -2\n self.i = len(data) - 1\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "class Wspak:\n...
[ 2, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- # Copyright 2015 Donne Martin. 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. A copy of # the License is located at # # http://www.apache.org/licenses/LICENSE-2.0 # # or in the "lice...
normal
{ "blob_id": "a649139a600cb506056a20e00089a07ec9244394", "index": 858, "step-1": "<mask token>\n\n\nclass Config(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask t...
[ 13, 15, 16, 18, 22 ]
count = 0 maximum = -1 m = -1 while m != 0: m = int(input()) if m > maximum: maximum = m count = 1 elif m == maximum: count += 1 print(count)
normal
{ "blob_id": "0e1ea8c7fba90c1b5d18eaa399b91f237d4defee", "index": 2568, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile m != 0:\n m = int(input())\n if m > maximum:\n maximum = m\n count = 1\n elif m == maximum:\n count += 1\nprint(count)\n", "step-3": "count = 0\nmaxi...
[ 0, 1, 2 ]
5 1 6 1x 1112#Desember@@@@@
normal
{ "blob_id": "b324c520400f04719b17121b0b4c2d23915e8841", "index": 2666, "step-1": "5 1\r\n6 1x\r\n1112#Desember@@@@@", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
from math import ceil, log2, sqrt def constructST(s, start, end, st, i): if start == end: st[i] = 0 openst[i] = 1 if s[start] == '(' else 0 closedst[i] = 1 if s[start] == ')' else 0 return st[i], openst[i], closedst[i] else: mid = (start+end)//2 st[i], openst[i], closedst[i] = constructST(s, ...
normal
{ "blob_id": "ccc74f58eff3bb00f0be8c2c963de4208b7f0933", "index": 9125, "step-1": "<mask token>\n\n\ndef constructST(s, start, end, st, i):\n if start == end:\n st[i] = 0\n openst[i] = 1 if s[start] == '(' else 0\n closedst[i] = 1 if s[start] == ')' else 0\n return st[i], openst[i],...
[ 2, 3, 4, 5, 6 ]
import docker import logging import sys if __name__ == '__main__': # setting up logger logging.basicConfig(stream=sys.stdout, format='[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s', level=logging.DEBUG) # get the docker client clie...
normal
{ "blob_id": "a5c9ff1fe250310216e2eaa7a6ff5cc76fc10f94", "index": 4324, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n logging.basicConfig(stream=sys.stdout, format=\n '[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s',\n level=logging.DEBUG...
[ 0, 1, 2, 3 ]
import numpy as np mydict = {} mylist0 = np.array([1, 2, 3, 4, 5]) mylist1 = np.array([2, 3, 4, 5, 6]) print(mydict) print(mylist0) print(mylist1) for c in ('0', '1'): if c in mydict: mydict[c] += mylist0 else: mydict[c] = mylist0 print(mydict) for c in ('0', '1'): if c in mydict: my...
normal
{ "blob_id": "6e5b8be6182f39f185f4547f0abd84a4e404bf34", "index": 1861, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(mydict)\nprint(mylist0)\nprint(mylist1)\nfor c in ('0', '1'):\n if c in mydict:\n mydict[c] += mylist0\n else:\n mydict[c] = mylist0\nprint(mydict)\nfor c in ('0...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals, absolute_import from datetime import datetime try: from unittest.mock import patch except ImportError: from mock import patch import pytest from django.test import TestCase try: from django.test import override_settings except ImportError: ...
normal
{ "blob_id": "71f9d9d7973809654db3ea613073f2d431f2d65f", "index": 1510, "step-1": "<mask token>\n\n\n@override_settings(USE_TZ=False)\nclass TestEmailUserManager(TestCase):\n\n def setUp(self):\n self.email = 'user@example.com'\n self.password = 'default'\n\n def test_private_create_user_witho...
[ 7, 9, 10, 11, 12 ]
def regexp_engine(pattern, letter): return pattern in ('', '.', letter) def match_regexp(pattern, substring): if not pattern: # pattern is empty always True return True if substring: # if string is not empty try the regexp engine if regexp_engine(pattern[0], substring[0]): # if reg and ...
normal
{ "blob_id": "fbfc1749252cf8cbd9f8f72df268284d3e05d6dc", "index": 8024, "step-1": "<mask token>\n\n\ndef match_regexp(pattern, substring):\n if not pattern:\n return True\n if substring:\n if regexp_engine(pattern[0], substring[0]):\n return match_regexp(pattern[1:], substring[1:])\...
[ 1, 2, 3, 4, 5 ]
''' You're playing casino dice game. You roll a die once. If you reroll, you earn the amount equal to the number on your second roll otherwise, you earn the amount equal to the number on your first roll. Assuming you adopt a profit-maximizing strategy, what would be the expected amount of money you would win? This qu...
normal
{ "blob_id": "e5d704541acd0f68a7885d7323118e1552e064c9", "index": 6170, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor threshold in range(1, 6):\n rolls = np.random.randint(1, 7, size=10 ** 7)\n rerolls = np.random.randint(1, 7, size=10 ** 7)\n avg_roll = np.mean(np.where(rolls <= threshold, ...
[ 0, 1, 2, 3 ]
import pandas as pd from sklearn.tree import DecisionTreeClassifier # Import Decision Tree Classifier from sklearn.model_selection import train_test_split # Import train_test_split function from sklearn import metrics #Import scikit-learn metrics module for accuracy calculation from sklearn.tree import DecisionTreeRegr...
normal
{ "blob_id": "1e34087719f6fd0456d2722edbd0a7af68d37e4c", "index": 1577, "step-1": "<mask token>\n\n\ndef read_atomic_data(path):\n if not path or not os.path.exists(path) or not os.path.isfile(path):\n print('To begin with, your path to data should be proper!')\n sys.exit(1)\n df = pd.read_csv...
[ 2, 3, 4, 5, 6 ]
import tensorflow as tf from typing import Optional, Tuple, Union, Callable _data_augmentation = tf.keras.Sequential( [ tf.keras.layers.experimental.preprocessing.RandomFlip("horizontal"), tf.keras.layers.experimental.preprocessing.RandomRotation(0.2), ] ) def _freeze_model( model: tf.ker...
normal
{ "blob_id": "86d42716e05155f9e659b22c42635a8f5b8c4a60", "index": 753, "step-1": "<mask token>\n\n\ndef generate_model(base_model: tf.keras.Model, img_shape: Tuple[Optional[\n int], Optional[int], Optional[int]], freeze: Union[bool, int, float]=\n False, preprocess_input: Optional[Callable]=None, use_data_a...
[ 1, 2, 3, 4, 5 ]
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # # 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 us...
normal
{ "blob_id": "b77c40c89c88b49c851e9a14c67cf0799d6de847", "index": 9235, "step-1": "<mask token>\n\n\ndef register(locator: str, entry_point, **kwargs):\n \"\"\"Register an AgentSpec with the zoo.\n\n In order to load a registered AgentSpec it needs to be reachable from a\n directory contained in the PYTH...
[ 2, 3, 4, 5, 6 ]
"""Command 'run' module.""" import click from loguru import logger from megalus.main import Megalus @click.command() @click.argument("command", nargs=1, required=True) @click.pass_obj def run(meg: Megalus, command: str) -> None: """Run selected script. :param meg: Megalus instance :param command: comma...
normal
{ "blob_id": "23a4ca8eec50e6ab72be3f1b1077c61f676b3cce", "index": 5777, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@click.command()\n@click.argument('command', nargs=1, required=True)\n@click.pass_obj\ndef run(meg: Megalus, command: str) ->None:\n \"\"\"Run selected script.\n\n :param meg: M...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 import pandas from matplotlib import pyplot as plt from sklearn.tree import DecisionTreeRegressor from sklearn.ensemble import AdaBoostRegressor import numpy as np from sklearn.metrics import mean_absolute_error, mean_squared_error from math import sqrt def main(): df = pandas.read_csv("201...
normal
{ "blob_id": "e35dbcdef8779ffabc34b5e5c543e35b29523971", "index": 7989, "step-1": "<mask token>\n\n\ndef make_scatter(df):\n plt.figure(figsize=(8, 6))\n plt.plot(df['Start station number'], df['Counts'], 'o')\n plt.xlabel('Station')\n plt.ylabel('Counts')\n plt.show()\n return\n\n\ndef train_pr...
[ 3, 4, 5, 6, 7 ]
import requests from bs4 import BeautifulSoup class Book: def __init__(self, url): self.url = url self.title = "" self.category = "" self.upc="" self.price_including_tax="" self.price_excluding_tax="" self.number_available="" self.description="" ...
normal
{ "blob_id": "3dc83168264fbb4f9b0ab2980b845dffdc4417bb", "index": 7588, "step-1": "<mask token>\n\n\nclass Book:\n\n def __init__(self, url):\n self.url = url\n self.title = ''\n self.category = ''\n self.upc = ''\n self.price_including_tax = ''\n self.price_excluding_...
[ 11, 12, 13, 15, 16 ]
import pygame from pygame.sprite import Sprite import spritesheet class Bunker(Sprite): def __init__(self, ai_settings, bunker_x, bunker_y, screen, images): """Initialize the ship and set its starting position""" super(Bunker, self).__init__() self.screen = screen self.images = ima...
normal
{ "blob_id": "d088aadc4d88267b908c4f6de2928c812ef36739", "index": 1603, "step-1": "<mask token>\n\n\nclass Bunker(Sprite):\n <mask token>\n <mask token>\n\n def blitme(self):\n \"\"\"Draw the ship at its current location\"\"\"\n self.screen.blit(self.image, self.rect)\n", "step-2": "<mask...
[ 2, 3, 4, 5, 6 ]
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from app import app layout = html.Div([ html.H3('Node 6'), dcc.Dropdown( id='node-6-dropdown', options=[ {'label': 'Node 6 - {}'.format(i), 'value': i} for ...
normal
{ "blob_id": "632b90ea5a2ac35539e589af297c04b31bbf02d0", "index": 3443, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.callback(Output('node-6-display-value', 'children'), [Input(\n 'node-6-dropdown', 'value')])\ndef display_value(value):\n return 'You have selected \"{}\"'.format(value)\n"...
[ 0, 1, 2, 3, 4 ]
valor1=input("Ingrese Primera Cantidad ") valor2=input("Ingrese Segunda Cantidad ") Total = valor1 + valor2 print "El total es: " + str(Total)
normal
{ "blob_id": "5c179752f4c4e1d693346c6edddd79211a895735", "index": 8685, "step-1": "valor1=input(\"Ingrese Primera Cantidad \")\nvalor2=input(\"Ingrese Segunda Cantidad \")\nTotal = valor1 + valor2\nprint \"El total es: \" + str(Total)\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "...
[ 0 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function, with_statement """ cosi299a- Cinderella alexluu@brandeis.edu """ def truecase_is(string): """ -> lower/title/upper/other """ if string.islower(): return 'l' if string.istitle(): return 't' if string...
normal
{ "blob_id": "75ddcdd4e80b962198ff9de1d996837927c3ac1a", "index": 824, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef truecase_is(string):\n \"\"\" -> lower/title/upper/other \"\"\"\n if string.islower():\n return 'l'\n if string.istitle():\n return 't'\n if string.isuppe...
[ 0, 3, 4, 5, 6 ]
from .personal_questions import * from .survey_questions import *
normal
{ "blob_id": "a8f2d527e9824d3986f4bb49c3cc75fd0d999bf7", "index": 3290, "step-1": "<mask token>\n", "step-2": "from .personal_questions import *\nfrom .survey_questions import *\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/6/26 16:11 # @Author : Micky # @Site : # @File : 01_压缩相关知识.py # @Software: PyCharm import numpy as np from PIL import Image from scipy import misc if __name__ == '__main__': # 图像加载 image = Image.open('../datas/xiaoren.png') # 图像转换为num...
normal
{ "blob_id": "176120d4f40bc02b69d7283b7853b74adf369141", "index": 4726, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n image = Image.open('../datas/xiaoren.png')\n img = np.asarray(image)\n print(img.shape)\n imageNew = np.zeros((600, 100, 3))\n imageNew = image...
[ 0, 1, 2, 3 ]
# Copyright (C) 2011 Ruckus Wireless, Inc. All rights reserved. # Please make sure the following module docstring is accurate since it will be used in report generation. """ Description: @author: Chris Wang @contact: cwang@ruckuswireless.com @since: Aug-09, 2010 Prerequisite (Assumptions about the sta...
normal
{ "blob_id": "25288a6dd0552d59f8c305bb8edbbbed5d464d5b", "index": 9997, "step-1": "# Copyright (C) 2011 Ruckus Wireless, Inc. All rights reserved.\n# Please make sure the following module docstring is accurate since it will be used in report generation.\n\n\"\"\"\n Description: \n @author: Chris Wang\n @con...
[ 0 ]
from functools import reduce import confuse config = confuse.Configuration('SleepCycleWebhooks') config.set_file('config.yaml') def get(path): return reduce(lambda view, part: view[part], path.split('.'), config).get()
normal
{ "blob_id": "16879598a8b1a0b23c5ea6de18f8fb0b0b77201c", "index": 1360, "step-1": "<mask token>\n\n\ndef get(path):\n return reduce(lambda view, part: view[part], path.split('.'), config).get()\n", "step-2": "<mask token>\nconfig.set_file('config.yaml')\n\n\ndef get(path):\n return reduce(lambda view, par...
[ 1, 2, 3, 4 ]
import time import torch from torch.utils.data import DataLoader from nn_model import NNModel def train(dataset: 'Dataset', epochs: int=10): loader = DataLoader(dataset, batch_size=2, shuffle=True) model = NNModel(n_input=2, n_output=3) # model.to(device='cpu') optimizer = torch.optim.Adam(model.p...
normal
{ "blob_id": "68bcb76a9c736e21cc1f54c6343c72b11e575b5d", "index": 5093, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef train(dataset: 'Dataset', epochs: int=10):\n loader = DataLoader(dataset, batch_size=2, shuffle=True)\n model = NNModel(n_input=2, n_output=3)\n optimizer = torch.optim.A...
[ 0, 1, 2, 3 ]
# Copyright (C) 2019 Catalyst Cloud Ltd # # 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 la...
normal
{ "blob_id": "cc23eeed44ff66d68c700163cca8b9f4986d497d", "index": 7681, "step-1": "<mask token>\n\n\nclass BaseTask(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mas...
[ 14, 17, 18, 20, 26 ]
run=[] #Creating a empty list no_players=int(input("enter the number of the players in the team :")) for i in range (no_players): run_score=int(input("Enter the runs scored by the player "+str(i+1)+":")) run.append(run_score) #code for the average score of the team def average(run): print("________...
normal
{ "blob_id": "3d7ca468a1f7aa1602bff22167e9550ad515fa79", "index": 4777, "step-1": "<mask token>\n\n\ndef average(run):\n print('____________________________________')\n sum = 0\n for i in range(0, len(run)):\n sum += run[i]\n avg = sum / len(run)\n print('Average score of the team is :',...
[ 4, 5, 6, 7, 8 ]
# Copyright 2023 Sony Group Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to ...
normal
{ "blob_id": "32f10c3e73a3d792416f6b2841a80f8b3c390e8c", "index": 9194, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef ref_mod2(x0, x1, fmod):\n if x0.dtype == np.float32 or fmod == True:\n return np.fmod(x0, x1)\n else:\n return np.mod(x0, x1)\n\n\n@pytest.mark.parametrize('ct...
[ 0, 2, 3, 4, 5 ]
from django.apps import AppConfig class ActivityConfig(AppConfig): name = 'apps.activity'
normal
{ "blob_id": "2a69aa0cd9d0e39ad82d6a354e956bdad0648797", "index": 2252, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ActivityConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ActivityConfig(AppConfig):\n name = 'apps.activity'\n", "step-4": "from django.apps im...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.3 on 2018-12-20 13:06 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('login', '0006_usermovies_img'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "e67cbddf10440e8a31373e05a82840677d3045f5", "index": 4388, "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 = [('login', '00...
[ 0, 1, 2, 3, 4 ]
def sort_descending(numbers): numbers.sort(reverse=True)
normal
{ "blob_id": "46dc9917d9b3a7caf8d7ba5024b17d3b755fc5db", "index": 7278, "step-1": "<mask token>\n", "step-2": "def sort_descending(numbers):\n numbers.sort(reverse=True)\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
# Lists are sequence of objects # Mutable # Lists are represented within square brackets and items are seperated by commas #-----------------------------------Lists-----------------------------------# # Lists of Numbers print("\n1. Lists of Numbers") print("\t" + str([1,2,3])) # Lists of Strings print("\n2. Lists of ...
normal
{ "blob_id": "4d35bb83378805daf4392a1752386ab1403404e0", "index": 1530, "step-1": "<mask token>\n", "step-2": "print(\"\"\"\n1. Lists of Numbers\"\"\")\nprint('\\t' + str([1, 2, 3]))\nprint(\"\"\"\n2. Lists of Strings\"\"\")\nprint('\\t' + str(['Lemon', 'Mango', 'Papaya']))\n<mask token>\nprint('\\tMy favorite ...
[ 0, 1, 2, 3 ]
import boto3 import time import datetime from datetime import date import sqlite3 import logging import logging.handlers from decimal import * ### LOGS CONFIGURATION ### LOG_FILENAME = '/home/pi/Thermostat/alexaThermostat/logs/alexaThermostat.out' # Set up a specific logger with our desired output level my_logger = l...
normal
{ "blob_id": "fcc75550e1317a15c36bc8100c28af59b68e1381", "index": 1571, "step-1": "<mask token>\n", "step-2": "<mask token>\nmy_logger.setLevel(logging.DEBUG)\n<mask token>\nhandler.setFormatter(formatter)\nmy_logger.addHandler(handler)\n<mask token>\nwhile 1:\n c.execute(\n 'SELECT * FROM TEMP_HIST W...
[ 0, 1, 2, 3, 4 ]