code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
radius = int(input("enter the value for the radius of the cycle: ")) circumference = 2 * 3.14159 * radius diameter = 2 * radius area = 3.14159 * radius ** 2 print('circumference is ', circumference) print('diameter is: ', diameter) print('area is ', area)
normal
{ "blob_id": "ab5412a3d22bd53a592c93bad4870b06fd9f0720", "index": 4080, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('circumference is ', circumference)\nprint('diameter is: ', diameter)\nprint('area is ', area)\n", "step-3": "radius = int(input('enter the value for the radius of the cycle: '))\...
[ 0, 1, 2, 3 ]
import argparse import os import shutil import time, math from collections import OrderedDict import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import torch.utils.data import torchvision.transforms as transforms import torchvision.datasets as datasets im...
normal
{ "blob_id": "c9de51ee5a9955f36ecd9f5d92813821fb68fb3d", "index": 4308, "step-1": "<mask token>\n\n\nclass SpatialAttention(nn.Module):\n\n def __init__(self, kernel_size=7):\n super(SpatialAttention, self).__init__()\n self.conv1 = nn.Conv2d(2, 1, kernel_size, padding=kernel_size // 2,\n ...
[ 8, 10, 11, 13, 14 ]
from flask import Blueprint, render_template from bashtube import cache singlevideos = Blueprint('singlevideos', __name__, template_folder='templates') @singlevideos.route('/') def index(): return render_template('singlevideos/single.html')
normal
{ "blob_id": "ee10bca1126b20378c4e9cea4d2dc7ed6a2044ab", "index": 9187, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@singlevideos.route('/')\ndef index():\n return render_template('singlevideos/single.html')\n", "step-3": "<mask token>\nsinglevideos = Blueprint('singlevideos', __name__, templa...
[ 0, 1, 2, 3 ]
import numpy as np import tensorflow as tf class LocNet: def __init__(self, scope, buttom_layer): self.scope = scope with tf.variable_scope(scope) as scope: self.build_graph(buttom_layer) self.gt_loc = tf.placeholder(dtype=tf.float32, shape=(None,4),name='gt_loc') ...
normal
{ "blob_id": "dd4dc1c4a0dc47711d1d0512ef3f6b7908735766", "index": 3149, "step-1": "<mask token>\n\n\nclass LocNet:\n\n def __init__(self, scope, buttom_layer):\n self.scope = scope\n with tf.variable_scope(scope) as scope:\n self.build_graph(buttom_layer)\n self.gt_loc = tf....
[ 2, 3, 4, 5, 6 ]
from __future__ import unicode_literals import frappe, json def execute(): for ps in frappe.get_all('Property Setter', filters={'property': '_idx'}, fields = ['doc_type', 'value']): custom_fields = frappe.get_all('Custom Field', filters = {'dt': ps.doc_type}, fields=['name', 'fieldname']) if custom_fields: ...
normal
{ "blob_id": "6f951815d0edafb08e7734d0e95e6564ab1be1f7", "index": 2375, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef execute():\n for ps in frappe.get_all('Property Setter', filters={'property': '_idx'\n }, fields=['doc_type', 'value']):\n custom_fields = frappe.get_all('Custom ...
[ 0, 1, 2, 3 ]
class tenDParameters: def __init__(self, b: float, DM: float, pm_l: float, pm_b: float, vrad: float, sb: float, spml: float, spmb: float, sdm: float, vc: float): self.b = b self.DM = DM # this is actually pm_l * cos b, apparently self.pm_l = pm...
normal
{ "blob_id": "82e7e22293551e061dcb295c52714c22df0ed0ce", "index": 5678, "step-1": "<mask token>\n", "step-2": "class tenDParameters:\n <mask token>\n", "step-3": "class tenDParameters:\n\n def __init__(self, b: float, DM: float, pm_l: float, pm_b: float, vrad:\n float, sb: float, spml: float, spm...
[ 0, 1, 2, 3 ]
# 只放置可执行文件 # # from ..src import package # data_dict = package.pack() # from ..src.plugins import * #解释一遍全放入内存 # from ..src import plugins #导入这个文件夹(包,模块,类库),默认加载init文件到内存 # # # plugins.pack() from ..src.script import run if __name__ == '__main__': run()
normal
{ "blob_id": "4f870e0d86d9f9b8c620115a618ea32abc24c52d", "index": 3008, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n run()\n", "step-3": "from ..src.script import run\nif __name__ == '__main__':\n run()\n", "step-4": "# 只放置可执行文件\n#\n# from ..src import package\n# d...
[ 0, 1, 2, 3 ]
from django.shortcuts import render, redirect from django.http import HttpResponse from django.contrib.auth.decorators import login_required from django.contrib.admin.views.decorators import staff_member_required from lessons.models import Lesson, Question, Response from usermanage.models import SchoolClass import json...
normal
{ "blob_id": "ee417c5fff858d26ca60a78dffe4cff503a6f2b5", "index": 6824, "step-1": "<mask token>\n\n\n@login_required\ndef lessons_overview(request):\n if request.method == 'POST':\n if request.user.is_staff:\n school_class = SchoolClass.objects.get(id=request.POST['class_id'])\n sc...
[ 7, 8, 9, 10, 11 ]
from django.urls import path from . import views app_name = 'orders' urlpatterns = [ path('checkout' , views.order_checkout_view , name='orders-checkout') , ]
normal
{ "blob_id": "031f668fbf75b54ec874a59f53c60ceca53779cf", "index": 8942, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'orders'\nurlpatterns = [path('checkout', views.order_checkout_view, name=\n 'orders-checkout')]\n", "step-3": "from django.urls import path\nfrom . import views\napp_name...
[ 0, 1, 2, 3 ]
""" Tests for the Transformer RNNCell. """ import pytest import numpy as np import tensorflow as tf from .transformer import positional_encoding, transformer_layer from .cell import (LimitedTransformerCell, UnlimitedTransformerCell, inject_at_timestep, sequence_masks) def test_inject_at_timestep...
normal
{ "blob_id": "958f6e539f9f68892d77b6becc387581c6adfa16", "index": 3366, "step-1": "<mask token>\n\n\ndef test_inject_at_timestep():\n with tf.Graph().as_default():\n with tf.Session() as sess:\n in_seq = tf.constant(np.array([[[1, 2, 3, 4], [5, 6, 7, 8]], [[\n 9, 10, 11, 12], [...
[ 3, 4, 5, 6, 7 ]
""" WINRM Module to connect to windows host """ from winrm.protocol import Protocol from lib import logger class WINRM(object): """ WINRM Module to connect to windows host """ def __init__(self, host_ip, usr, pwd): """ - **parameters**, **types**, **return** and **return t...
normal
{ "blob_id": "96ac9088650490a7da00c7a20f634b76e673ca2d", "index": 1174, "step-1": "<mask token>\n\n\nclass WINRM(object):\n <mask token>\n <mask token>\n\n def connect(self):\n \"\"\"\n Method to connect to a Windows machine.\n \"\"\"\n try:\n self.host_win_ip =...
[ 3, 4, 5, 6, 7 ]
class Solution(object): def restoreIpAddresses(self, s): """ :type s: str :rtype: List[str] """ def helper(sb, string, level): if len(string) == 0: if level == 4: ans.append(sb[:-1]) return if level ...
normal
{ "blob_id": "ec4348c61cd1c9130543bb20f9ca199399e1caff", "index": 226, "step-1": "class Solution(object):\n def restoreIpAddresses(self, s):\n \"\"\"\n :type s: str\n :rtype: List[str]\n \"\"\"\n\n def helper(sb, string, level):\n if len(string) == 0:\n ...
[ 0 ]
#coding=utf-8 ''' Created on 04/09/2012 @author: Johnny ''' from ckeditor.widgets import CKEditorWidget from django.conf.urls import patterns, url from django.shortcuts import render_to_response from django.template import RequestContext from django.templatetags.static import static import views from portfolio.models ...
normal
{ "blob_id": "caac9dfc7d52607c2af67ddc03a3a7bdae9911bb", "index": 8204, "step-1": "<mask token>\n\n\nclass ServicoForm(forms.ModelForm):\n <mask token>\n\n\n class Meta:\n model = Servico\n\n\nclass ServicosAdmin(CustomModelAdmin):\n list_display = 'imagem_icone', 'titulo', 'intro'\n list_displ...
[ 13, 14, 15, 16, 19 ]
#!/usr/bin/env python import sys,re print('\n'.join(re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',sys.stdin.read())))
normal
{ "blob_id": "4cefaa964251e77a05066af1f61f9fd2a4350d38", "index": 7622, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('\\n'.join(re.findall(\n 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\\\(\\\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'\n , sys.stdin.read())))\n", "step-3": "import sys, re\nprint(...
[ 0, 1, 2, 3 ]
from django.db import models class Building(models.Model): Number = models.CharField(max_length=60) Description = models.CharField(max_length=120) OSMWAYID = models.DecimalField(decimal_places=0, max_digits=15) # the osm way id Lat = models.CharField(max_length=20) #lat/lon of then center Lon = m...
normal
{ "blob_id": "02ddf213cd3f455f8d8fbde8621fc4788124d5a9", "index": 3714, "step-1": "<mask token>\n\n\nclass Logger(models.Model):\n Facinet = models.ForeignKey('Facinet', null=False, blank=False,\n related_name='Loggers')\n loggerindex = models.IntegerField(unique=True, db_column='LoggerIndex')\n n...
[ 4, 6, 7, 11, 12 ]
# The purpose of this module is essentially to subclass the basic SWIG generated # pynewton classes and add a bit of functionality to them (mostly callback related # stuff). This could be done in the SWIG interface file, but it's easier to do it # here since it makes adding python-specific extensions to newton easier. ...
normal
{ "blob_id": "90d792fe18e589a0d74d36797b46c6ac1d7946be", "index": 4303, "step-1": "<mask token>\n\n\nclass ChamferCylinder(pynewton.ChamferCylinder):\n pass\n\n\nclass ConvexHull(pynewton.ConvexHull):\n pass\n\n\nclass ConvexHullModifier(pynewton.ConvexHullModifier):\n pass\n\n\nclass NullCollider(pynewt...
[ 33, 52, 66, 68, 76 ]
data = { 'title': 'Dva leteca (gostimo na 2)', 'song': [ 'x - - - - - x - - - - -', '- x - - - x - - - x - -', '- - x - x - - - x - x -', '- - - x - - - x - - - x' ], 'bpm': 120, 'timeSignature': '4/4' } from prog import BellMusicCreator exportFile = __file__.replac...
normal
{ "blob_id": "957fb1bd34d13b86334da47ac9446e30afd01678", "index": 5477, "step-1": "<mask token>\n", "step-2": "<mask token>\nBellMusicCreator().write(data, fp=exportFile)\n", "step-3": "data = {'title': 'Dva leteca (gostimo na 2)', 'song': [\n 'x - - - - - x - - - - -', '- x - - - x - - - x - -',\n '- -...
[ 0, 1, 2, 3, 4 ]
#!/bin/python3 # Implement a stack with push, pop, inc(e, k) operations # inc (e,k) - Add k to each of bottom e elements import sys class Stack(object): def __init__(self): self.arr = [] def push(self, val): self.arr.append(val) def pop(self): if len(self.arr): return...
normal
{ "blob_id": "5ed439a2a7cfb9c941c40ea0c5eba2851a0f2855", "index": 24, "step-1": "<mask token>\n\n\nclass Stack(object):\n\n def __init__(self):\n self.arr = []\n\n def push(self, val):\n self.arr.append(val)\n\n def pop(self):\n if len(self.arr):\n return self.arr.pop()\n\...
[ 5, 6, 7, 8, 10 ]
from bs4 import BeautifulSoup import os, re, json import pandas as pd from urllib import request from openpyxl import load_workbook from bilibili.append_xlsx import append_df_to_excel # 获取页面的所有的avid, title, url def parse_html(content): arr = [] # 使用beautifulsoup解析html文档 soup = BeautifulSoup(content) ...
normal
{ "blob_id": "a63718ba5f23d6f180bdafcb12b337465d6fa052", "index": 4734, "step-1": "<mask token>\n\n\ndef read_path(path):\n path_set = set()\n dir_path = os.listdir(path)\n for item in dir_path:\n child = os.path.join('%s/%s' % (path, item))\n path_set.add(child)\n return path_set\n\n\nd...
[ 4, 5, 7, 8, 10 ]
""" This class runs the RL Training """ from __future__ import division import logging import numpy as np from data.data_provider import DataProvider from episode.episode import Episode from tracker import TrainingTracker from tqdm import tqdm class RLTrainer(object): """ Creates RL training object """ ...
normal
{ "blob_id": "7c004cb0c9eefa5e88f5085fb3b2878db98d2b20", "index": 3200, "step-1": "<mask token>\n\n\nclass RLTrainer(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass RLTrainer(object):\n <mask token>\n\n def __init__(self, config_, grid_search=False):\n...
[ 1, 3, 4, 5, 6 ]
""" The :mod:`sklearn.experimental` module provides importable modules that enable the use of experimental features or estimators. The features and estimators that are experimental aren't subject to deprecation cycles. Use them at your own risks! """
normal
{ "blob_id": "d3952306679d5a4dc6765a7afa19ce671ff4c0b4", "index": 8501, "step-1": "<mask token>\n", "step-2": "\"\"\"\nThe :mod:`sklearn.experimental` module provides importable modules that enable\nthe use of experimental features or estimators.\n\nThe features and estimators that are experimental aren't subje...
[ 0, 1 ]
import pickle import saveClass as sc import libcell as lb import numpy as np import struct import os # def save_Ldend(Ldends, bfname): # # create a binary file # bfname='Dend_length.bin' # binfile = file(bfname, 'wb') # # and write out two integers with the row and column dimension # header = struc...
normal
{ "blob_id": "6eb8172e7e26ad6ec9cb0d30c5a0613ce79296e6", "index": 8421, "step-1": "<mask token>\n\n\ndef save_ave_replay(aveData, nIter, nStart, bfname):\n vd = np.zeros((nIter, 4, nStart))\n for i_trial in range(nIter):\n vv = aveData[i_trial]\n for i_dendrite in range(4):\n vvv = ...
[ 1, 2, 3, 4, 5 ]
def findFirst(arr, l, h, x): if l > h: return -1 mid = (l + h) // 2 if arr[mid] == x: return mid elif arr[mid] > x: return findFirst(arr, l, mid - 1, x) return findFirst(arr, mid + 1, h, x) def indexes(arr, x): n = len(arr) ind = findFirst(arr, 0, n - 1, x) if i...
normal
{ "blob_id": "b4783540224902b10088edbd038d6d664934a237", "index": 4893, "step-1": "<mask token>\n", "step-2": "def findFirst(arr, l, h, x):\n if l > h:\n return -1\n mid = (l + h) // 2\n if arr[mid] == x:\n return mid\n elif arr[mid] > x:\n return findFirst(arr, l, mid - 1, x)\n...
[ 0, 1, 2, 3 ]
import os _basedir = os.path.abspath(os.path.dirname(__file__)) DEBUG = True SECRET_KEY = '06A52C5B30EC2960310B45E4E0FF21C5D6C86C47D91FE19FA5934EFF445276A0' SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(_basedir, 'app.db') SQLALCHEMY_ECHO = True DATABASE_CONNECT_OPTIONS = {} THREADS_PER_PAGE = 8 CSRF_ENABL...
normal
{ "blob_id": "6ee71cf61ae6a79ec0cd06f1ddc7dc614a76c7b9", "index": 6547, "step-1": "<mask token>\n", "step-2": "<mask token>\n_basedir = os.path.abspath(os.path.dirname(__file__))\nDEBUG = True\nSECRET_KEY = '06A52C5B30EC2960310B45E4E0FF21C5D6C86C47D91FE19FA5934EFF445276A0'\nSQLALCHEMY_DATABASE_URI = 'sqlite:///...
[ 0, 1, 2, 3 ]
_registry = [] def registry(name): _registry.append(name) def registry_names(): return iter(_registry)
normal
{ "blob_id": "51642dbb210600f9ca4e035fb884fbdda030fd04", "index": 1491, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef registry_names():\n return iter(_registry)\n", "step-3": "<mask token>\n\n\ndef registry(name):\n _registry.append(name)\n\n\ndef registry_names():\n return iter(_regis...
[ 0, 1, 2, 3 ]
import uuid from fastapi import APIRouter, Depends, HTTPException, Form, Body from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm from sqlalchemy.orm import Session # dependency from configs.config_sqlalchemy import get_db # schema from schema import store_schema # define the url the clie...
normal
{ "blob_id": "64bbf2e3b961a6e0b5d7e551278bb21990df2ed9", "index": 5526, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@router.post('/account/register', summary='register to create a new store',\n response_model=store_schema.Store, status_code=201)\nasync def account_register(StoreName: str=Body(.....
[ 0, 1, 2, 3, 4 ]
import torch from training import PointNetTrain, PointAugmentTrain, Model #from PointAugment.Augment.config import opts from data_utils.dataloader import DataLoaderClass from mpl_toolkits import mplot3d import matplotlib.pyplot as plt import numpy as np import yaml def visualize_batch(pointclouds, pred_labels, labels,...
normal
{ "blob_id": "0ced42c8bfaad32fc2b397326150e6c7bc5cedab", "index": 4991, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef visualize_batch(pointclouds, pred_labels, labels, categories):\n batch_size = len(pointclouds)\n fig = plt.figure(figsize=(8, batch_size / 2))\n ncols = 5\n nrows = ma...
[ 0, 1, 2, 3, 4 ]
import os import click import csv import sqlite3 from sqlite3.dbapi2 import Connection import requests import mimetypes from urllib.parse import urljoin, urlparse from lxml.html.soupparser import fromstring from lxml import etree from lxml.etree import tostring from analysis import lmdict, tone_count_with_negation_chec...
normal
{ "blob_id": "88e4e6647d4720d1c99f3e3438100790903921b5", "index": 9163, "step-1": "<mask token>\n\n\n@click.command()\n@click.option('-s', '--batch-size', 'batch_size', default=50)\ndef analyze(batch_size):\n db = db_connect()\n db_ensure_init(db)\n cmd = db.execute('SELECT id, url FROM reports WHERE is_...
[ 3, 6, 9, 10, 13 ]
#!/usr/bin/env python # Copyright 2017 Google 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 require...
normal
{ "blob_id": "fb9ae5b3cdeac0c254669e214779ad43a02bff6d", "index": 4596, "step-1": "<mask token>\n\n\ndef read_dataset(mode, args):\n\n def decode_example(protos, vocab_size):\n features = {'key': tf.FixedLenFeature(shape=[1], dtype=tf.int64),\n 'indices': tf.VarLenFeature(dtype=tf.int64), 'va...
[ 3, 4, 5, 6, 7 ]
from __future__ import absolute_import from __future__ import division from __future__ import unicode_literals from rasa_core.actions.action import Action from rasa_core.events import SlotSet from rasa_core.dispatcher import Button, Element, Dispatcher import json import pickle class ActionWeather(Action): def na...
normal
{ "blob_id": "f87d08f3bb6faa237cce8379de3aaaa3270a4a34", "index": 3854, "step-1": "<mask token>\n\n\nclass ActionWeather(Action):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ActionWeather(Action):\n <mask token>\n\n def run(self, dispatcher, tracker, domain):\n loc = ...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-02-24 11:30 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.Create...
normal
{ "blob_id": "56157aaf3f98abc58572b45111becb91cb93f328", "index": 2926, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 import matplotlib from matplotlib.colors import to_hex from matplotlib import cm import matplotlib.pyplot as plt import numpy as np import itertools as it from pathlib import Path import subprocess from tqdm import tqdm from koala import plotting as pl from koala import phase_diagrams as pd fr...
normal
{ "blob_id": "d429f03c0f0c241166d6c0a5a45dc1101bcaec16", "index": 5878, "step-1": "<mask token>\n\n\ndef multi_set_symmetric_difference(sets):\n return list(functools.reduce(lambda a, b: a ^ b, [set(s) for s in sets]))\n\n\ndef flood_iteration_plaquettes(l, plaquettes):\n return set(plaquettes) | set(it.cha...
[ 3, 4, 5, 6, 7 ]
class Restaurant(): """A restaurant model.""" def __init__(self, restaurant_name, cuisine_type): """Initialize name and type.""" self.name = restaurant_name self.type = cuisine_type def describe_restaurant(self): """Prints restaurant information.""" print("The restaurant's name is " + self.name.title())...
normal
{ "blob_id": "4ecf976a7d655efb5af427083ec1943cae6fe56d", "index": 3672, "step-1": "class Restaurant:\n <mask token>\n <mask token>\n <mask token>\n\n def open_restaurant(self):\n \"\"\"Message indicating the restaurant is open.\"\"\"\n print('The restaurant is now open!')\n", "step-2":...
[ 2, 3, 4, 5, 6 ]
from parser import read_expression_line, read_expression_lines, read_assignment_line, read_import_line, Import def test_expression(): lines = ['a % b'] expression, left = read_expression_lines(lines) assert expression is not None and len(left) == 0, left print "test_expression 0: {} {}".format(expressi...
normal
{ "blob_id": "657866affd653a99eb7d9a9a82b2f7d6503ec21a", "index": 2468, "step-1": "from parser import read_expression_line, read_expression_lines, read_assignment_line, read_import_line, Import\n\ndef test_expression():\n lines = ['a % b']\n expression, left = read_expression_lines(lines)\n assert expres...
[ 0 ]
import reddit import tts import sys import praw import os #TODO: CENSOR CURSE WORDS,tag images that have curse words in them. strip punctuation from comment replies mp3 #TODO: pay for ads :thinking: buy views? #TODO: sort by top upvotes #todo: remove the formatting stuff #todo: redo ducking #todo quick scri...
normal
{ "blob_id": "fd57e13269ca00ed5eb05e00bd7999c041141187", "index": 4256, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f'NOW PROCESSING POST ID: {POST_ID}')\n<mask token>\ntts.comment_to_mp3(post_title, './quota.txt', 'titles', 0, randomize=True)\n<mask token>\nfor comment in comments_from_post:\n ...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Tue Jul 11 11:11:32 2017 @author: lindseykitchell """ import pandas as pd import numpy as np from scipy.stats.stats import pearsonr import matplotlib.pylab as plt import glob import os pwd = os.getcwd() df_dict = {} subj_list = [] for file in glob.glob(pwd + "/*spectrum.json")...
normal
{ "blob_id": "f78f8f560b7eb70232658be762e2058535a68122", "index": 9086, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor file in glob.glob(pwd + '/*spectrum.json'):\n subj_name = os.path.basename(file)[0:6]\n subj_list.append(subj_name)\n df_dict[os.path.basename(file)[0:6]] = pd.read_json(file...
[ 0, 1, 2, 3, 4 ]
# PySNMP SMI module. Autogenerated from smidump -f python DOCS-IETF-QOS-MIB # by libsmi2pysnmp-0.1.3 at Thu May 22 11:57:36 2014, # Python version sys.version_info(major=2, minor=7, micro=2, releaselevel='final', serial=0) # Imports ( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integ...
normal
{ "blob_id": "b90678c8f7ad9b97e13e5603bdf1dc8cb3511ca5", "index": 5432, "step-1": "<mask token>\n\n\nclass DocsIetfQosRfMacIfDirection(Integer):\n subtypeSpec = Integer.subtypeSpec + SingleValueConstraint(2, 1)\n namedValues = NamedValues(('downstream', 1), ('upstream', 2))\n\n\nclass DocsIetfQosSchedulingT...
[ 4, 5, 6, 7, 9 ]
# -*- coding: utf-8 -*- #some xml helpers from xml.dom.minidom import Document class XMLReport: def __init__(self, name): self.doc = Document() self.main_node = self.add(name, node=self.doc) def add(self, name, node=None): if node is None: node = self.main_node elem = self.doc.createElement(name) ...
normal
{ "blob_id": "146487738006ce3efb5bd35c425835a1fd8e0145", "index": 9490, "step-1": "# -*- coding: utf-8 -*-\n#some xml helpers\nfrom xml.dom.minidom import Document\n\nclass XMLReport:\n def __init__(self, name):\n\tself.doc = Document()\n\tself.main_node = self.add(name, node=self.doc)\n \n def add(s...
[ 0 ]
from django.shortcuts import render from PIL import Image from django.views.decorators import csrf import numpy as np import re import sys import os from .utils import * from django.http import JsonResponse from django.views.decorators.csrf import csrf_exempt import base64 sys.path.append(os.path.abspath("./models")) O...
normal
{ "blob_id": "b84b3206e87176feee2c39fc0866ada994c9ac7a", "index": 8655, "step-1": "<mask token>\n\n\ndef convertImage(imgData):\n getI420FromBase64(imgData)\n\n\n<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.path.abspath('./models'))\n<mask token>\n\n\ndef getI420FromBase64(codec):\n base64...
[ 1, 5, 6, 7, 8 ]
def calc_fib(n): fib_lis = dict() for i in range(n+1): if (i <= 1): fib_lis[i] = i else: fib_lis[i] = fib_lis[i-2] + fib_lis[i-1] return fib_lis[n] n = int(input()) print(calc_fib(n))
normal
{ "blob_id": "426b711571d3b5c4f8c7b0bad3a613951902e60b", "index": 4129, "step-1": "<mask token>\n", "step-2": "def calc_fib(n):\n fib_lis = dict()\n for i in range(n + 1):\n if i <= 1:\n fib_lis[i] = i\n else:\n fib_lis[i] = fib_lis[i - 2] + fib_lis[i - 1]\n return f...
[ 0, 1, 2, 3, 4 ]
# Core Packages import difflib import tkinter as tk from tkinter import * from tkinter import ttk from tkinter.scrolledtext import * import tkinter.filedialog import PyPDF2 from tkinter import filedialog import torch import json from transformers import T5Tokenizer, T5ForConditionalGeneration, T5Config # ...
normal
{ "blob_id": "e3dece36ba3e5b3df763e7119c485f6ed2155098", "index": 795, "step-1": "<mask token>\n\n\ndef get_summary():\n model = T5ForConditionalGeneration.from_pretrained('t5-small')\n tokenizer = T5Tokenizer.from_pretrained('t5-small')\n device = torch.device('cpu')\n text = str(url_display1.get('1....
[ 8, 9, 13, 14, 15 ]
""" File: ex17_map_reduce.py Author: TonyDeep Date: 2020-07-21 """ from functools import reduce print('#1 map') a_list = [2, 18, 9, 22, 17, 24, 8, 12, 27] map_data = map(lambda x: x * 2 + 1, a_list) new_list = list(map_data) print(new_list) print('\n#2 reduce') b_list = [1, 2, 3, 4, 5] reduce_data = reduce(lambda x,...
normal
{ "blob_id": "8e3b26826752b6b3482e8a29b9b58f5025c7ef58", "index": 4758, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('#1 map')\n<mask token>\nprint(new_list)\nprint('\\n#2 reduce')\n<mask token>\nprint(reduce_data)\n", "step-3": "<mask token>\nprint('#1 map')\na_list = [2, 18, 9, 22, 17, 24, 8, ...
[ 0, 1, 2, 3, 4 ]
import sys from PySide6.QtCore import * from PySide6.QtWidgets import * from PySide6.QtGui import * from simple_drawing_window import * class simple_drawing_window1( simple_drawing_window): def __init__(self): super().__init__() def paintEvent(self, e): p = QPainter() p.begin(self) """ p.setPen(Q...
normal
{ "blob_id": "6fc43919f521234d0dc9e167bb72f014e9c0bf17", "index": 2102, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass simple_drawing_window1(simple_drawing_window):\n <mask token>\n\n def paintEvent(self, e):\n p = QPainter()\n p.begin(self)\n \"\"\"\n\t\tp.setPen(QCo...
[ 0, 2, 3, 4, 5 ]
# © MNELAB developers # # License: BSD (3-clause) from .dependencies import have from .syntax import PythonHighlighter from .utils import count_locations, image_path, interface_style, natural_sort
normal
{ "blob_id": "837534ebc953dae966154921709398ab2b2e0b33", "index": 578, "step-1": "<mask token>\n", "step-2": "from .dependencies import have\nfrom .syntax import PythonHighlighter\nfrom .utils import count_locations, image_path, interface_style, natural_sort\n", "step-3": "# © MNELAB developers\n#\n# License:...
[ 0, 1, 2 ]
import os basedir = os.path.abspath(os.path.dirname(__file__)) class FlaskConfig(object): SECRET_KEY = os.environ.get('FLASK_SECRET_KEY') or 'TuLAsWbcoKr5YhDE' BOOTSTRAP_SERVE_LOCAL = os.environ.get('FLASK_BOOTSTRAP_SERVE_LOCAL') or True APPLICATION_ROOT = os.environ.get('FLASK_APPLICATION_ROOT') or '' ...
normal
{ "blob_id": "a0349abb3a56ff4bc1700dbf0fa5a1fc2e3453ce", "index": 6469, "step-1": "<mask token>\n\n\nclass FlaskConfig(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass FlaskConfig(object):\n SECRET_KEY = os.environ.get('FLASK_SECRET_KEY') or 'TuLAsWbcoKr5Y...
[ 1, 2, 3, 4, 5 ]
import cv2 import pdb import skvideo import numpy as np import pandas as pd from tqdm import tqdm from harp import fdops from word2number import w2n from harp.vid import VidReader class RegPropData: """ Processes region proposal data. """ _df = None props = None """Dictionary containing regio...
normal
{ "blob_id": "b10badc172be119be5b2ab8ccc32cc95a0ed1e7a", "index": 2680, "step-1": "<mask token>\n\n\nclass RegPropData:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, csv_path):\n \"\"\"\n Initialize a region proposal data instance.\n\n Param...
[ 5, 7, 8, 9, 11 ]
""" Interfaces to Juju API ModelManager """ from conjureup import juju @juju.requires_login def list_models(user='user-admin'): """ Lists Juju Models Arguments: user: Name of user to list models for. Returns: Dictionary of known Juju Models (default: user-admin) """ models = juju.CLIENT...
normal
{ "blob_id": "11045cffc6d47902be7236e1d684422317f2c5f9", "index": 1444, "step-1": "<mask token>\n\n\n@juju.requires_login\ndef list_models(user='user-admin'):\n \"\"\" Lists Juju Models\n\n Arguments:\n user: Name of user to list models for.\n\n Returns:\n Dictionary of known Juju Models (default: ...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/2/18 22:27 # @Author : name # @File : 01.requests第一血.py import requests if __name__ == "__main__": # step1:指定url url = r'https://www.sogou.com/' # step2:发起请求 reponse = requests.get(url = url) # setp3:获取响应数据 text返回的是字...
normal
{ "blob_id": "7ae6ed8797d6ee02effd04750e243c5a59840177", "index": 8444, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n url = 'https://www.sogou.com/'\n reponse = requests.get(url=url)\n page_text = reponse.text\n print(page_text)\n with open('./sogou.html', 'w',...
[ 0, 1, 2, 3 ]
from card import Card; from deck import Deck; import people; import chip; import sys; import time; def display_instructions() : print('\nInstructions: The objective of this game is to obtain a hand of cards whose value is as close to 21 '); print('as possible without going over. The numbered cards hav...
normal
{ "blob_id": "a7050ebd545c4169b481672aed140af610aea997", "index": 4879, "step-1": "<mask token>\n\n\ndef create_players(num):\n players_list = []\n for i in range(num):\n name = input(f'Player {i + 1}, what is your name? ')\n while name == '':\n name = input('Please enter your name:...
[ 7, 19, 20, 21, 22 ]
from template.db import Database from template.query import Query import os ''' READ ME!! Before using this demo, be sure that the Tail_Const is set to a value high enough to guaranteed that all updates are contained within the same block. config.py -> TAIL_CONST = 4 This program is mean...
normal
{ "blob_id": "8f5b7711d913c7375d6816dd94731f1ce5ca1a62", "index": 8289, "step-1": "<mask token>\n", "step-2": "<mask token>\ndb.open('ECS165')\nprint(db)\n<mask token>\nprint('Merge Start')\nq.table.merge(0)\nprint('Merge End')\ndb.close()\n", "step-3": "<mask token>\ndb = Database()\ndb.open('ECS165')\nprint...
[ 0, 1, 2, 3, 4 ]
class SmartChineseAnalyzer: def __init__(self): pass def create_components(self, filename): #tokenizer = SentenceTokenize(filename) #result = WordTokenFilter(tokenizer) #result = PorterStemFilter(result) if self.stopwords: result = StopFilter(result,...
normal
{ "blob_id": "e486e0ab91a8f5671435f5bbcf5340a62a970d3a", "index": 8670, "step-1": "<mask token>\n", "step-2": "class SmartChineseAnalyzer:\n <mask token>\n <mask token>\n", "step-3": "class SmartChineseAnalyzer:\n <mask token>\n\n def create_components(self, filename):\n if self.stopwords:\...
[ 0, 1, 2, 3, 4 ]
""" Add requests application (adding and managing add-requests) """ from flask import Blueprint __author__ = 'Xomak' add_requests = Blueprint('addrequests', __name__, template_folder='templates', ) from . import routes
normal
{ "blob_id": "d39965c3070ec25230b4d6977ff949b3db070ab6", "index": 7399, "step-1": "<mask token>\n", "step-2": "<mask token>\n__author__ = 'Xomak'\nadd_requests = Blueprint('addrequests', __name__, template_folder='templates')\n<mask token>\n", "step-3": "<mask token>\nfrom flask import Blueprint\n__author__ =...
[ 0, 1, 2, 3 ]
from django.db import models # Create your models here. class Airlines(models.Model): flight_number=models.CharField(max_length=8,unique=True) airlines_id=models.CharField(max_length=10) source=models.CharField(max_length=20) destination=models.CharField(max_length=20) departure=models.TimeField() arrival=models...
normal
{ "blob_id": "e57b30a7a1cf987918abfb3cb7d612bdead2ddcd", "index": 406, "step-1": "<mask token>\n\n\nclass Bookings(models.Model):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Airlines(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask ...
[ 1, 6, 7, 9, 10 ]
import os.path class State: def __init__(self): self.states=[] self.actions=[] class Candidate: def __init__(self,height,lines,holes,bump,fit): self.heightWeight = height self.linesWeight = lines self.holesWeight = holes self.bumpinessWeight = bump ...
normal
{ "blob_id": "94100d0253ee82513fe024b2826e6182f852db48", "index": 2349, "step-1": "import os.path\nclass State:\n\n\n def __init__(self):\n self.states=[]\n self.actions=[]\n\n\n\nclass Candidate:\n\n def __init__(self,height,lines,holes,bump,fit):\n\n self.heightWeight = height\n ...
[ 0 ]
from tdm.lib.device import DddDevice, DeviceAction, DeviceWHQuery, Validity class CallJohnDevice(DddDevice): class MakeCall(DeviceAction): def perform(self, select_contact, select_number): contact = self.device.CONTACTS.get(select_contact) number_type = self.device.CONTACT...
normal
{ "blob_id": "1dd235ecfe577b508d0777e8c70026114aeb154f", "index": 6648, "step-1": "from tdm.lib.device import DddDevice, DeviceAction, DeviceWHQuery, Validity\r\n\r\n\r\nclass CallJohnDevice(DddDevice):\r\n\r\n class MakeCall(DeviceAction):\r\n def perform(self, select_contact, select_number):\r\n ...
[ 0 ]
#Author: Abeer Rafiq #Modified: 11/23/2019 3:00pm #Importing Packages import socket, sys, time, json, sqlite3 import RPi.GPIO as GPIO from datetime import datetime, date #Creating a global server class class GlobalServer: #The constructor def __init__(self, port, room_ip_addrs, app_ip_addrs):...
normal
{ "blob_id": "7ce679d5b889493f278de6deca6ec6bdb7acd3f5", "index": 910, "step-1": "#Author: Abeer Rafiq\n#Modified: 11/23/2019 3:00pm\n\n#Importing Packages\nimport socket, sys, time, json, sqlite3\nimport RPi.GPIO as GPIO\nfrom datetime import datetime, date\n\n#Creating a global server class\nclass GlobalServer:...
[ 0 ]
import SCons.Util import xml.dom.minidom, re, os.path ################################################################################ # DocBook pseudobuilder # TODO: Only generate the output formats that are known ################################################################################ def generate(env) : ...
normal
{ "blob_id": "cae49da8dd436fc51b472c4a88703d8bc6c79bda", "index": 427, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate(env):\n\n def remove_doctype(target, source, env):\n f = open(str(target[0]))\n output = []\n for line in f.readlines():\n output.append...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python #pylint: skip-file """ HostApi.py Copyright 2016 Cisco Systems 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...
normal
{ "blob_id": "4243c863827f1378c364171ca7d8fdabd42be22f", "index": 3625, "step-1": "<mask token>\n\n\nclass HostApi(object):\n <mask token>\n <mask token>\n <mask token>\n\n def getHostById(self, **kwargs):\n \"\"\"Retrieves host based on id\n\n Args:\n\n id, str: Host Id (requ...
[ 2, 4, 5, 6, 7 ]
x = 5 print(x , " "*3 , "5") print("{:20d}".format(x))
normal
{ "blob_id": "88542a18d98a215f58333f5dd2bf5c4b0d37f32f", "index": 5539, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(x, ' ' * 3, '5')\nprint('{:20d}'.format(x))\n", "step-3": "x = 5\nprint(x, ' ' * 3, '5')\nprint('{:20d}'.format(x))\n", "step-4": "x = 5\nprint(x , \" \"*3 , \"5\")\nprint(\"{:2...
[ 0, 1, 2, 3 ]
import sys import time def initialize(x: object) -> object: # Create initialization data and take a lot of time data = [] starttimeinmillis = int(round(time.time())) c =0 file1 = sys.argv[x] with open(file1) as datafile: for line in datafile: c+=1 if(c%100==0): ...
normal
{ "blob_id": "91f3aae4e74f371cadaf10385510bc1c80063f55", "index": 7765, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef initialize(x: object) ->object:\n data = []\n starttimeinmillis = int(round(time.time()))\n c = 0\n file1 = sys.argv[x]\n with open(file1) as datafile:\n for...
[ 0, 1, 2, 3 ]
import numpy as np import matplotlib.pyplot as plt ########################################## # line plot ######################################### # x축 생략시 x축은 0, 1, 2, 3이 됨 """ plt.plot([1, 4, 9, 16]) plt.show() """ # x축과 y축 지정 """ plt.plot([10, 20, 30, 40], [1, 4, 9, 16]) plt.show() """ # 스타일지정 # 색깔, 마커, 선 순서로 ...
normal
{ "blob_id": "89ffb2da456d2edf15fde8adc01615a277c6caa1", "index": 8522, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith plt.xkcd():\n plt.title('XKCD style plot!!!')\n plt.plot(X, C, label='cosine')\n t = 2 * np.pi / 3\n plt.scatter(t, np.cos(t), 50, color='blue')\n plt.annotate('0.5 He...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python3 __author__ = "yang.dd" """ example 090 """ # list # 新建list testList = [10086, "中国移动", [1, 2, 3, 4]] # 访问列表长度 print("list len: ", len(testList)) # 切片 print("切片(slice):", testList[1:]) # 追加 print("追加一个元素") testList.append("i'm new here!"); print("list len: ", len(testLi...
normal
{ "blob_id": "4f19eed272c12be137df92bfd3c72e978408c974", "index": 3216, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('list len: ', len(testList))\nprint('切片(slice):', testList[1:])\nprint('追加一个元素')\ntestList.append(\"i'm new here!\")\nprint('list len: ', len(testList))\nprint('last item :', testLi...
[ 0, 1, 2, 3 ]
import os from sqlalchemy import Column, ForeignKey, Integer, String, Float, Boolean, DateTime from sqlalchemy import and_, or_ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship from sqlalchemy import create_engine, func from sqlalchemy.orm import sessionmaker, scoped_sess...
normal
{ "blob_id": "6db0adf25a7cc38c8965c07cc80bde0d82c75d56", "index": 3955, "step-1": "<mask token>\n\n\nclass UsageData(Base):\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\n @property\n def dt...
[ 9, 11, 12, 16, 21 ]
# SPDX-FileCopyrightText: 2013 The glucometerutils Authors # # SPDX-License-Identifier: Unlicense
normal
{ "blob_id": "39ffb85fb10882041c2c9a81d796e7ff9df7d930", "index": 8551, "step-1": "# SPDX-FileCopyrightText: 2013 The glucometerutils Authors\n#\n# SPDX-License-Identifier: Unlicense\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 1 ] }
[ 1 ]
import sys def input(_type=str): return _type(sys.stdin.readline().strip()) def main(): N, K, D = map(int, input().split()) rules = [tuple(map(int, input().split())) for _ in range(K)] minv, maxv = min([r[0] for r in rules]), max([r[1] for r in rules]) while minv + 1 < maxv: midv = (minv + maxv)//2 cnt, max_...
normal
{ "blob_id": "f0b98a3d6015d57a49e315ac984cac1cccf0b382", "index": 6084, "step-1": "<mask token>\n\n\ndef main():\n N, K, D = map(int, input().split())\n rules = [tuple(map(int, input().split())) for _ in range(K)]\n minv, maxv = min([r[0] for r in rules]), max([r[1] for r in rules])\n while minv + 1 <...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Created on Wed Mar 24 20:59:36 2021 @author: Abeg """ #factorial using recursion """def factorial(n): if n==0 or n==1: return 1 elif n==2: return n else: return n*factorial(n-1) n=int(input("enter the no")) print(factorial(n))""" #fibonancci using recursi...
normal
{ "blob_id": "d1ee33ce6fb071aae800b0597a09e7039a209ec8", "index": 2574, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef reverse(string):\n if len(string) == 0:\n return\n temp = string[0]\n reverse(string[1:])\n print(temp, end='')\n\n\n<mask token>\n", "step-3": "<mask token>\...
[ 0, 1, 2, 3, 4 ]
# coding: UTF-8 import os import sys if len(sys.argv) == 3: fname = sys.argv[1] out_dir = sys.argv[2] else: print "usage: vcf_spliter <input file> <output dir>" exit() count = 0 if not os.path.exists(out_dir): os.makedirs(out_dir) with open(fname, 'r') as f: for l in f: if l.strip()...
normal
{ "blob_id": "f410a77d4041514383110d9fd16f896178924d59", "index": 8871, "step-1": "# coding: UTF-8\n\nimport os \nimport sys\n\nif len(sys.argv) == 3:\n fname = sys.argv[1]\n out_dir = sys.argv[2]\nelse:\n print \"usage: vcf_spliter <input file> <output dir>\"\n exit()\n\ncount = 0\nif not os.path.exi...
[ 0 ]
count=0 def merge(a, b): global count c = [] h = j = 0 while j < len(a) and h < len(b): if a[j] <= b[h]: c.append(a[j]) j += 1 else: count+=(len(a[j:])) c.append(b[h]) h += 1 if j == len(a): for i in b[h:]: ...
normal
{ "blob_id": "cf3b66a635c6549553af738f263b035217e75a7a", "index": 903, "step-1": "<mask token>\n\n\ndef merge_sort(lists):\n if len(lists) <= 1:\n return lists\n middle = len(lists) // 2\n left = merge_sort(lists[:middle])\n right = merge_sort(lists[middle:])\n return merge(left, right)\n\n\...
[ 1, 2, 3, 4, 5 ]
from math import sqrt from numpy import concatenate from matplotlib import pyplot from pandas import read_csv from pandas import DataFrame from pandas import concat from sklearn.preprocessing import MinMaxScaler from sklearn.preprocessing import LabelEncoder from sklearn.metrics import mean_squared_error from tensorflo...
normal
{ "blob_id": "11984027baf6d4c97b2976e4ac49a0e8ec62f893", "index": 8709, "step-1": "from math import sqrt\nfrom numpy import concatenate\nfrom matplotlib import pyplot\nfrom pandas import read_csv\nfrom pandas import DataFrame\nfrom pandas import concat\nfrom sklearn.preprocessing import MinMaxScaler\nfrom sklearn...
[ 0 ]
from bs4 import BeautifulSoup import urllib.request import re import math url_header = "http://srh.bankofchina.com/search/whpj/search.jsp?erectDate=2016-01-25&nothing=2016-02-25&pjname=1314" Webpage = urllib.request.urlopen(url_header).read() Webpage=Webpage.decode('UTF-8') # soup = BeautifulSoup(Webpage) print (Webp...
normal
{ "blob_id": "62a86bd33755510f0d71f4920e63be1a3ce8c563", "index": 6304, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(Webpage)\n<mask token>\nprint(a)\n<mask token>\nprint(total_page)\n", "step-3": "<mask token>\nurl_header = (\n 'http://srh.bankofchina.com/search/whpj/search.jsp?erectDate=201...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import pprint import requests import string import subprocess #Create three files f_arptable = open( 'arptable', 'w+' ) f_maclist = open( 'maclist', 'w+' ) f_maclookup = open( 'maclookup', 'w+' ) #Give write permissions the three files subprocess.call([ 'chmod','+w','maclist' ]) subprocess.call([ ...
normal
{ "blob_id": "d566104b00ffd5f08c564ed554e0d71279a93047", "index": 6394, "step-1": "<mask token>\n", "step-2": "<mask token>\nsubprocess.call(['chmod', '+w', 'maclist'])\nsubprocess.call(['chmod', '+w', 'arptable'])\nsubprocess.call(['chmod', '+w', 'maclookup'])\nsubprocess.Popen(['arp', '-a'], stdout=f_arptable...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python # # Script written by Legoktm, 2011 # Released into the Public Domain on November, 16, 2011 # This product comes with no warranty of any sort. # Enjoy! # from commands import getoutput def notify(string, program=False): if not program: command = 'growlnotify Python -m "%s"' %string else: command...
normal
{ "blob_id": "4318c99b3de9bb9c44eed57525c9ccbe82a17276", "index": 5946, "step-1": "#!/usr/bin/python\n#\n# Script written by Legoktm, 2011\n# Released into the Public Domain on November, 16, 2011\n# This product comes with no warranty of any sort.\n# Enjoy!\n#\nfrom commands import getoutput\ndef notify(string, p...
[ 0 ]
import io import os from flask import Flask from werkzeug.datastructures import FileStorage import pytest PNG_FILE = os.path.join(os.path.dirname(__file__), 'flask.png') JPG_FILE = os.path.join(os.path.dirname(__file__), 'flask.jpg') class TestConfig: TESTING = True MONGODB_DB = 'flask-fs-test' MONGODB...
normal
{ "blob_id": "dfc412acc9b69f50396680db1b9f6feafe162996", "index": 5571, "step-1": "<mask token>\n\n\nclass TestConfig:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass TestFlask(Flask):\n\n def configure(self, *storages, **configs):\n import flask_file_system as fs\n ...
[ 6, 10, 11, 13, 16 ]
class Figure: area = 0 def __new__(cls, *args): if cls is Figure: return None return object.__new__(cls) def add_area(self, other): if isinstance(other, Figure): return self.area + other.area else: raise ValueError("Should pass Figure as...
normal
{ "blob_id": "ceab21e41adf171e99e6c3c8541c418d82db6168", "index": 3272, "step-1": "class Figure:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Figure:\n <mask token>\n\n def __new__(cls, *args):\n if cls is Figure:\n return None\n return object.__new__...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # caixinjun import argparse from sklearn import metrics import datetime import jieba from sklearn.feature_extraction.text import TfidfVectorizer import pickle from sklearn import svm import os import warnings warnings.filterwarnings('ignore') def get_data(train_file): targ...
normal
{ "blob_id": "199872ea459a9dba9975c6531034bdbc1e77f1db", "index": 5875, "step-1": "<mask token>\n\n\ndef train(cls, data, target, model_path):\n cls = cls.fit(data, target)\n with open(model_path, 'wb') as f:\n pickle.dump(cls, f)\n\n\n<mask token>\n\n\ndef load_models(matrix_path, model_path):\n ...
[ 3, 4, 5, 6, 8 ]
TheBeatles = ['John', 'Paul', 'George', 'Ringo'] Wings = ['Paul'] for Beatle in TheBeatles: if Beatle in Wings: continue print Beatle
normal
{ "blob_id": "9a54ff8e7e8d6d46860cb6173f03c52655b30f43", "index": 6449, "step-1": "TheBeatles = ['John', 'Paul', 'George', 'Ringo']\nWings = ['Paul']\n\nfor Beatle in TheBeatles:\n\t\tif Beatle in Wings:\n\t\t\t\tcontinue\n\t\tprint Beatle\n\n", "step-2": null, "step-3": null, "step-4": null, "step-5": nu...
[ 0 ]
# Import smtplib for the actual sending function import smtplib # Import the email modules we'll need from email.message import EmailMessage # Open the plain text file whose name is in textfile for reading. with open("testfile.txt") as fp: # Create a text/plain message msg = EmailMessage() msg.set_content...
normal
{ "blob_id": "9feb24da78113310509664fa9efcf5f399be5335", "index": 5914, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('testfile.txt') as fp:\n msg = EmailMessage()\n msg.set_content('test')\n<mask token>\ns.send_message(msg)\ns.quit()\n", "step-3": "<mask token>\nwith open('testfile.txt...
[ 0, 1, 2, 3, 4 ]
# The project is based on Tensorflow's Text Generation with RNN tutorial # Copyright Petros Demetrakopoulos 2020 import tensorflow as tf import numpy as np import os import time # The project is based on Tensorflow's Text Generation with RNN tutorial # Copyright Petros Demetrakopoulos 2020 import tensorflow as tf impor...
normal
{ "blob_id": "5ff0c6bde8f3ffcb1f5988b0bbd1dfdd7fa2e818", "index": 8800, "step-1": "<mask token>\n\n\ndef yuh():\n corpus_path = '/tmp/data.txt'\n text = open(corpus_path, 'rb').read().decode(encoding='utf-8')\n text = preprocessText(text)\n corpus_words = corpusToList(text)\n map(str.strip, corpus_...
[ 6, 7, 8, 9, 11 ]
from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.serialization import load_ssh_public_key from ingredients_http.schematics.types import ArrowType, KubeName from schematics import Model from schematics.exceptions import ...
normal
{ "blob_id": "a521220ac287a840b5c69e2d0f33daa588132083", "index": 4983, "step-1": "<mask token>\n\n\nclass RequestCreateKeypair(Model):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass ResponseKeypair(Model):\n name = KubeName(required=True, min_length=3)\n public_key = StringType(required=T...
[ 4, 6, 10, 11, 12 ]
import unittest from domain.Activity import Activity from domain.NABException import NABException from domain.Person import Person from domain.ActivityValidator import ActivityValidator from repository.PersonRepository import PersonRepository from repository.PersonFileRepository import PersonFileRepository from reposit...
normal
{ "blob_id": "130581ddb0394dcceabc316468385d4e21959b63", "index": 8682, "step-1": "<mask token>\n\n\nclass StatsControllerTestCase(unittest.TestCase):\n\n def setUp(self):\n pR = PersonRepository()\n aR = ActivityRepository()\n self.L = StatsController(pR, aR)\n self.p = Person(1, '...
[ 4, 5, 6, 7, 9 ]
# -*- coding: utf-8 -*- from matplotlib import pyplot as plt from matplotlib import colors import numpy as np import sys max_value = int(sys.argv[1]) file1 = open(sys.argv[2]) file2 = open(sys.argv[3]) file3 = open(sys.argv[4]) histogram = np.zeros(max_value, dtype=int).tolist() highest_value = 0.0 sample_size = 0...
normal
{ "blob_id": "8356bc92a3a8b561d55bf5f2d9aeb0da89b730ca", "index": 1387, "step-1": "# -*- coding: utf-8 -*-\nfrom matplotlib import pyplot as plt\nfrom matplotlib import colors\nimport numpy as np\nimport sys\n\nmax_value = int(sys.argv[1])\n\nfile1 = open(sys.argv[2])\nfile2 = open(sys.argv[3])\nfile3 = open(sys....
[ 0 ]
salario = float(input('Qual o valor do seu Salario atual? R$ ')) novo = salario + (salario * 15 / 100) print('Um funcioario que ganhava R$ {:.2f} com o aumento de 15% passa a ganhar R$ {:.2f}'.format(salario, novo))
normal
{ "blob_id": "ffcd3c0086ff73eb722d867b335df23382615d20", "index": 1657, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\n 'Um funcioario que ganhava R$ {:.2f} com o aumento de 15% passa a ganhar R$ {:.2f}'\n .format(salario, novo))\n", "step-3": "salario = float(input('Qual o valor do seu Sa...
[ 0, 1, 2, 3 ]
from allcode.controllers.image_classifiers.image_classifier import ImageClassifier class ImageClassifierMockup(ImageClassifier): def classify_images(self, images): pass def classify_image(self, image): return {'final_class': 'dog', 'final_prob': .8}
normal
{ "blob_id": "71fb9dc9f9ac8b1cdbc6af8a859dbc211512b4d1", "index": 1675, "step-1": "<mask token>\n\n\nclass ImageClassifierMockup(ImageClassifier):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ImageClassifierMockup(ImageClassifier):\n <mask token>\n\n def classify_image(self, ...
[ 1, 2, 3, 4, 5 ]
def filter_lines(in_filename, in_filename2,out_filename): """Read records from in_filename and write records to out_filename if the beginning of the line (taken up to the first comma at or after position 11) is found in keys (which must be a set of byte strings). """ proper_convert = 0 missing_...
normal
{ "blob_id": "502e0f0c6376617dc094fcdd47bea9773d011864", "index": 900, "step-1": "<mask token>\n", "step-2": "def filter_lines(in_filename, in_filename2, out_filename):\n \"\"\"Read records from in_filename and write records to out_filename if\n the beginning of the line (taken up to the first comma at or...
[ 0, 1, 2, 3, 4 ]
import requests import codecs import urllib.request import time from bs4 import BeautifulSoup from html.parser import HTMLParser import re import os #input Result_File="report.txt" #deleting result file if exists if os.path.exists(Result_File): os.remove(Result_File) #reading html file and parsing logic f=codecs.o...
normal
{ "blob_id": "869bbc8da8cdb5de0bcaf5664b5482814daae53a", "index": 6212, "step-1": "<mask token>\n", "step-2": "<mask token>\nif os.path.exists(Result_File):\n os.remove(Result_File)\n<mask token>\nwith open(Result_File, 'w') as r:\n r.write(\n 'OI_CE|Chng_in_OI_CE |Volume_CE|IV_CE|LTP_CE|NetChng_CE...
[ 0, 1, 2, 3, 4 ]
import requests, csv, configuration headers = {'Authorization': f'Bearer {configuration.CARRIERX_API_TOKEN}'} url = f'{configuration.BASE_CARRIERX_API_URL}/core/v2/calls/call_drs' date = configuration.DATE i = 1 params = {'limit': '1', 'order': 'date_stop asc', 'filter': f'date_stop ge {date}'} r = requests.get(url...
normal
{ "blob_id": "8262d8b5bbb156eccae021c1c9333d3cd1a6260f", "index": 9030, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(dr_items):\n with open('calls.csv', 'w', encoding='UTF8') as csv_file:\n csv_writer = csv.writer(csv_file)\n csv_header = ['dr_sid', 'date_start', 'number_src', 'n...
[ 0, 1, 2, 3 ]
class Solution: def countBits(self, num: int) -> List[int]: total = [] for i in range(num + 1): counter = bin(i).count('1') # for j in bin(i): # if j == '1': # counter += 1 total.append(counter) return total...
normal
{ "blob_id": "c6554ff18c23a61d3694e73b808f44c96f9a19c4", "index": 2012, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def countBits(self, num: int) ->List[int]:\n total = []\n for i in range(num + 1):\n counter = bin(i)....
[ 0, 1, 2, 3 ]
from torchvision import datasets, transforms import torch def load_data(data_folder, batch_size, train, num_workers=0, **kwargs): transform = { 'train': transforms.Compose( [transforms.Resize([256, 256]), transforms.RandomCrop(224), transforms.RandomHorizontalFli...
normal
{ "blob_id": "d99fd3dc63f6a40dde5a6230111b9f3598d3c5fd", "index": 7830, "step-1": "<mask token>\n\n\nclass _InfiniteSampler(torch.utils.data.Sampler):\n \"\"\"Wraps another Sampler to yield an infinite stream.\"\"\"\n\n def __init__(self, sampler):\n self.sampler = sampler\n\n def __iter__(self):\...
[ 8, 9, 10, 11, 12 ]
from rest_framework.generics import GenericAPIView from rest_framework.response import Response from rest_framework.status import HTTP_400_BAD_REQUEST, HTTP_404_NOT_FOUND from ...models.brand import Brand from ...models.product import type_currency_choices, type_condition_choices, User, Product from ...models.product_c...
normal
{ "blob_id": "47e9b73fc7f6b3c8295e78d0cdb5aa51ca4c5f8d", "index": 8140, "step-1": "<mask token>\n\n\nclass UpdateProduct(GenericAPIView):\n <mask token>\n <mask token>\n <mask token>\n\n def get(self, request, *args, **kwargs):\n data = self.get_queryset()\n extract_sp = self.extract_fil...
[ 11, 13, 16, 17, 19 ]
"""Functions for parsing various strings to RGB tuples.""" import json import re from pathlib import Path import importlib.resources as resources from pilutils.basic import hex_to_rgb __all__ = [ "parse_hex6", "parse_hex3", "parse_rgbfunc_int", "parse_rgbfunc_float", "parse_rgbfunc_percent", "...
normal
{ "blob_id": "978f3979aee1c4361483fd61b54352e7fff8d3b3", "index": 697, "step-1": "<mask token>\n\n\ndef parse_hex3(hex3):\n \"\"\"Example: #a3d\"\"\"\n if (m := re.match('^#?([0-9A-Fa-f]{3})$', hex3.strip())):\n h3 = m.group(1)\n return tuple(int(c * 2, 16) for c in h3)\n raise ValueError(f...
[ 7, 10, 12, 13, 14 ]
import redis r = redis.StrictRedis() r.set("counter", 40) print(r.get("counter")) print(r.incr("counter")) print(r.incr("counter")) print(r.get("counter"))
normal
{ "blob_id": "b38c9357030b2eac8298743cfb4d6c4d58c99ed4", "index": 7463, "step-1": "<mask token>\n", "step-2": "<mask token>\nr.set('counter', 40)\nprint(r.get('counter'))\nprint(r.incr('counter'))\nprint(r.incr('counter'))\nprint(r.get('counter'))\n", "step-3": "<mask token>\nr = redis.StrictRedis()\nr.set('c...
[ 0, 1, 2, 3, 4 ]
from setuptools import setup setup( name="CoreMLModules", version="0.1.0", url="https://github.com/AfricasVoices/CoreMLModules", packages=["core_ml_modules"], setup_requires=["pytest-runner"], install_requires=["numpy", "scikit-learn", "nltk"], tests_require=["pytest<=3.6.4"] )
normal
{ "blob_id": "24cd3a1a05a1cfa638b8264fd89b36ee63b29f89", "index": 1625, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='CoreMLModules', version='0.1.0', url=\n 'https://github.com/AfricasVoices/CoreMLModules', packages=[\n 'core_ml_modules'], setup_requires=['pytest-runner'], install_requ...
[ 0, 1, 2, 3 ]
CARD_SIZE = (70, 90) SPACING = 3
normal
{ "blob_id": "b8ebbef7403a71d6165a5462bc08e2634b4cebc5", "index": 4287, "step-1": "<mask token>\n", "step-2": "CARD_SIZE = 70, 90\nSPACING = 3\n", "step-3": "CARD_SIZE = (70, 90)\nSPACING = 3", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
# 1.- Crear una grafica que muestre la desviacion tipica de los datos cada dia para todos los pacientes # 2.- Crear una grafica que muestre a la vez la inflamacion maxima, media y minima para cada dia import numpy as np data = np.loadtxt(fname='inflammation-01.csv', delimiter=',') import matplotlib.pyplot as pl...
normal
{ "blob_id": "52064b518ad067c9906e7de8542d9a399076a0b5", "index": 4214, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.plot(data.std(axis=0))\nplt.show()\nplt.plot(data.max(axis=0))\nplt.plot(data.mean(axis=0))\nplt.plot(data.min(axis=0))\n", "step-3": "<mask token>\ndata = np.loadtxt(fname='inflamm...
[ 0, 1, 2, 3, 4 ]
../../2.0.2/mpl_examples/axes_grid/simple_axesgrid2.py
normal
{ "blob_id": "73d1129418711c35046a99c1972a413357079836", "index": 3022, "step-1": "../../2.0.2/mpl_examples/axes_grid/simple_axesgrid2.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
"""API - Files endpoints.""" import os import click import cloudsmith_api import requests from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor from .. import ratelimits from ..rest import create_requests_session from ..utils import calculate_file_md5 from .exceptions import ApiException, catch_rai...
normal
{ "blob_id": "ee03263d92372899ec1feaf3a8ea48677b053676", "index": 6281, "step-1": "<mask token>\n\n\ndef get_files_api():\n \"\"\"Get the files API client.\"\"\"\n return get_api_client(cloudsmith_api.FilesApi)\n\n\ndef validate_request_file_upload(owner, repo, filepath, md5_checksum=None):\n \"\"\"Valid...
[ 2, 3, 4, 5, 6 ]
import torch import torchvision from torch import nn def get_resnet18(pre_imgnet=False, num_classes=64): model = torchvision.models.resnet18(pretrained=pre_imgnet) model.fc = nn.Linear(512, 64) return model
normal
{ "blob_id": "8e05b2723d8c50354e785b4bc7c5de8860aa706d", "index": 5355, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_resnet18(pre_imgnet=False, num_classes=64):\n model = torchvision.models.resnet18(pretrained=pre_imgnet)\n model.fc = nn.Linear(512, 64)\n return model\n", "step-3"...
[ 0, 1, 2 ]
def add(a, b): print "ADDING %d + %d" % (a, b) return a + b def subtract(a, b): print "SUBTRACTING %d - %d" %(a, b) return a - b def multipy(a, b): print "MULTIPLYING %d * %d" % (a, b) return a * b def divide(a, b): print "DIVIDING %d / %d" % (a, b) return a / b print "Let's do some...
normal
{ "blob_id": "b4b80e40d12486881e37dd7ddeeef9c76417ebd9", "index": 5906, "step-1": "def add(a, b):\n print \"ADDING %d + %d\" % (a, b)\n return a + b\n\ndef subtract(a, b):\n print \"SUBTRACTING %d - %d\" %(a, b)\n return a - b\n\ndef multipy(a, b):\n print \"MULTIPLYING %d * %d\" % (a, b)\n retu...
[ 0 ]
'''Mock classes that imitate idlelib modules or classes. Attributes and methods will be added as needed for tests. ''' from idlelib.idle_test.mock_tk import Text class Editor: '''Minimally imitate EditorWindow.EditorWindow class. ''' def __init__(self, flist=None, filename=None, key=None, root=None): ...
normal
{ "blob_id": "3b7c30718838a164eaf3aa12cd7b6a68930346f8", "index": 8604, "step-1": "<mask token>\n\n\nclass UndoDelegator:\n <mask token>\n\n def undo_block_start(*args):\n pass\n\n def undo_block_stop(*args):\n pass\n", "step-2": "<mask token>\n\n\nclass Editor:\n <mask token>\n\n d...
[ 3, 7, 8, 9, 10 ]
import numpy as np import cv2 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml') img = cv2.imread('modi.jpg') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray, 1.3, 5) #Write the for loop code h...
normal
{ "blob_id": "759ff4cc123e85bdc8c1457bb521cd35841956cd", "index": 482, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.imshow('img', img)\ncv2.waitKey(0)\ncv2.destroyAllWindows()\n", "step-3": "<mask token>\nface_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')\neye_cascade = cv...
[ 0, 1, 2, 3, 4 ]