code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
import requests from bs4 import BeautifulSoup import codecs url = "https://en.wikipedia.org/wiki/Pennsylvania_State_University" response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') infoBox = soup.find("table", class_="infobox vcard") webScrape = {"Univeristy": "The Pennsylvania State U...
normal
{ "blob_id": "f45ca4e75de7df542fbc65253bb9cc44a868522a", "index": 6398, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor tr in infoBox.find_all('tr'):\n if len(tr.findChildren('th', recursive=False)) > 0 and len(tr.\n findChildren('td', recursive=False)) > 0:\n header = tr.findChildren(...
[ 0, 1, 2, 3, 4 ]
j= float(input("juros")) Q0= 1500 t= 36 Qf=Q0*(1+j)**t print(round(Qf,2))
normal
{ "blob_id": "700d6e0c7dab58ed0157265ff78021923c17e397", "index": 5619, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(round(Qf, 2))\n", "step-3": "j = float(input('juros'))\nQ0 = 1500\nt = 36\nQf = Q0 * (1 + j) ** t\nprint(round(Qf, 2))\n", "step-4": "j= float(input(\"juros\"))\nQ0= 1500\nt= 36...
[ 0, 1, 2, 3 ]
from zipline.api import ( # add_history, history, order_target_percent, order, record, symbol, get_datetime, schedule_function, ) from zipline.algorithm import TradingAlgorithm from zipline.utils.factory import load_from_yahoo import numpy as np import pandas as pd from datetime import datetime ...
normal
{ "blob_id": "2e8737a48bd04ef5c158afb23dc94476ea790e18", "index": 2074, "step-1": "from zipline.api import (\r\n\t# add_history,\r\n\thistory,\r\n\torder_target_percent,\r\n\torder,\r\n\trecord,\r\n\tsymbol,\r\n\tget_datetime,\r\n\tschedule_function,\r\n)\r\nfrom zipline.algorithm import TradingAlgorithm\r\nfrom ...
[ 0 ]
# -*- coding: utf-8 -*- # @Author : William # @Project : TextGAN-william # @FileName : gan_loss.py # @Time : Created at 2019-07-11 # @Blog : http://zhiweil.ml/ # @Description : # Copyrights (C) 2018. All Rights Reserved. import torch import torch.nn as nn import config as cfg class ...
normal
{ "blob_id": "9cea998d7d5cad3ddc00f667ca06151a938d48a1", "index": 9424, "step-1": "<mask token>\n\n\nclass GANLoss(nn.Module):\n <mask token>\n\n def __init__(self, loss_mode, which_net, which_D, target_real_label=1.0,\n target_fake_label=0.0, CUDA=False):\n \"\"\" Initialize the GAN's Discrim...
[ 5, 6, 7, 8, 9 ]
import sys import time from abc import ABC, abstractmethod from PySide6.QtGui import QPixmap from PySide6.QtWidgets import QApplication import inupdater.resource from inupdater.splash import SplashScreen class UserInterface(ABC): """Interface for GUI element""" def __init__(self) -> None: self.stat...
normal
{ "blob_id": "efeb069a7e2aab7262a557236c693752d2973523", "index": 4169, "step-1": "<mask token>\n\n\nclass UserInterface(ABC):\n <mask token>\n <mask token>\n\n @abstractmethod\n def show_message(self, msg: str):\n \"\"\"Show a message\"\"\"\n <mask token>\n\n @abstractmethod\n def clo...
[ 14, 15, 16, 17, 19 ]
from mx.handlers import MainHandler # handler for changing app language class Locale(MainHandler): """ handles requests to change LOCALE or language for internationalization. """ def get(self): locale = self.request.get('locale') if not locale : locale = LOCALE locale...
normal
{ "blob_id": "bdcbb946dadf168149342c651ad03eaf4b748401", "index": 6803, "step-1": "<mask token>\n\n\nclass Locale(MainHandler):\n <mask token>\n <mask token>\n\n\nclass MainPage(MainHandler):\n\n def get(self):\n self.render('home.html')\n\n def post(self):\n pw = self.request.get('pw')\...
[ 4, 5, 6, 7, 8 ]
import yet import pickle sources = pickle.load(open("./db/source_list")) addr_list = sources.keys() ''' for i in range(len(addr_list)): print addr_list[i], try: a = yet.tree(None, sources[addr_list[i]]) print ' Owner :', for i in a.owner.keys(): print i+ '() ' + a.owner[...
normal
{ "blob_id": "1c55cfa03cd9210b7cf9e728732afe19930e9a41", "index": 9786, "step-1": "import yet\nimport pickle\n\nsources = pickle.load(open(\"./db/source_list\"))\naddr_list = sources.keys()\n\n'''\nfor i in range(len(addr_list)):\n print addr_list[i], \n try:\n a = yet.tree(None, sources[addr_list[i]...
[ 0 ]
#!/usr/bin/env python import os from distutils.core import setup, Extension import distutils.util setup (name = 'pybanery', version= '1.0', description='Python interface for Kanbanery', author = 'Pablo Lluch', author_email = 'pablo.lluch@gmail.com', py_modules = ['pybanery'], ...
normal
{ "blob_id": "60c862accbb9cda40ed4c45491f643f065e2868a", "index": 6467, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='pybanery', version='1.0', description=\n 'Python interface for Kanbanery', author='Pablo Lluch', author_email=\n 'pablo.lluch@gmail.com', py_modules=['pybanery'], script...
[ 0, 1, 2, 3 ]
import platform import keyboard import threading import atexit from threading import Timer triggerCount = 0 triggerTimer = -1 result = None def cleanup (): print 'cleanup before exit' clearTimer() keyboard triggerCount = 0 def clearTimer (): global triggerTimer global triggerCount try: ...
normal
{ "blob_id": "9e8ed462e429d6c6c0fe232431ee1e98721863e9", "index": 6148, "step-1": "import platform\nimport keyboard\nimport threading\nimport atexit\nfrom threading import Timer\n\ntriggerCount = 0\ntriggerTimer = -1\n\nresult = None\n\ndef cleanup ():\n print 'cleanup before exit'\n clearTimer()\n keybo...
[ 0 ]
"""inactivate fb posts Revision ID: f37637c1bcf8 Revises: 43c7ecf8ed02 Create Date: 2017-06-22 12:01:59.623040 """ from alembic import op from pd.facebook.models import MediaType # revision identifiers, used by Alembic. revision = 'f37637c1bcf8' down_revision = '43c7ecf8ed02' branch_labels = None depends_on = None ...
normal
{ "blob_id": "89ed30411c624e3d930db0bc0b5b716a10908727", "index": 8259, "step-1": "<mask token>\n\n\ndef upgrade():\n op.execute(' '.join([update.format('false'), where]))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef upgrade():\n op.execute(' '.join([update.format('false'), where]))\n\n\ndef dow...
[ 1, 2, 3, 4, 5 ]
from django.apps import AppConfig class WebApiAppConfig(AppConfig): name = 'WebApiApp'
normal
{ "blob_id": "cc97f70b9d41357f020ea9c59d8b149392a336cc", "index": 9656, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass WebApiAppConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass WebApiAppConfig(AppConfig):\n name = 'WebApiApp'\n", "step-4": "from django.apps impo...
[ 0, 1, 2, 3 ]
import streamlit as st import tensorflow.keras from PIL import Image, ImageOps import numpy as np st.set_option('deprecation.showfileUploaderEncoding', False) np.set_printoptions(suppress=True) model = tensorflow.keras.models.load_model('keras_model.h5') data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32) st.ti...
normal
{ "blob_id": "746e0895f0fb971156e778cbff20317cc88441f1", "index": 2059, "step-1": "<mask token>\n", "step-2": "<mask token>\nst.set_option('deprecation.showfileUploaderEncoding', False)\nnp.set_printoptions(suppress=True)\n<mask token>\nst.title('Leaf Disease Detection Using Machine Learning')\n<mask token>\nif...
[ 0, 1, 2, 3, 4 ]
import requests import csv from bs4 import BeautifulSoup reservoirs = [["LVQ"], ["HTH"], ["APN"], ["KNT"], ["SHA"]] for reservoir in reservoirs: storageURL = "https://cdec.water.ca.gov/dynamicapp/QueryMonthly?s=" + reservoir[0] storagePage = requests.get(storageURL) storageSoup = BeautifulSoup(storagePage...
normal
{ "blob_id": "ebe7c245e3e14116a37020971e67ada054e0b434", "index": 1171, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor reservoir in reservoirs:\n storageURL = ('https://cdec.water.ca.gov/dynamicapp/QueryMonthly?s=' +\n reservoir[0])\n storagePage = requests.get(storageURL)\n storageSou...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Fri Nov 14 22:09:56 2014 @author: duhan """ #arrayMapPath = r'/usr/local/lib/python2.7/dist-packages/ticketpitcher/data/3' arrayMapPath = r'C:\Python27\Lib\site-packages\ticketpitcher\data' #tempPath = r'/tmp/' tempPath = 'd:\\temp\\'
normal
{ "blob_id": "9627e8a468d3a75787c5a9e01856913fc8beb3c4", "index": 1868, "step-1": "<mask token>\n", "step-2": "<mask token>\narrayMapPath = 'C:\\\\Python27\\\\Lib\\\\site-packages\\\\ticketpitcher\\\\data'\ntempPath = 'd:\\\\temp\\\\'\n", "step-3": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Nov 14 22:09...
[ 0, 1, 2 ]
import numpy as np, argparse, sys, itertools, os, errno, warnings from mpi4py import MPI from enlib import enmap as en, powspec, utils from enlib.degrees_of_freedom import DOF, Arg from enlib.cg import CG warnings.filterwarnings("ignore") #from matplotlib.pylab import * parser = argparse.ArgumentParser() parser.add_ar...
normal
{ "blob_id": "6a601d1c7c3c162c0902d03e6c39f8d75d4bcaf0", "index": 798, "step-1": "import numpy as np, argparse, sys, itertools, os, errno, warnings\nfrom mpi4py import MPI\nfrom enlib import enmap as en, powspec, utils\nfrom enlib.degrees_of_freedom import DOF, Arg\nfrom enlib.cg import CG\nwarnings.filterwarning...
[ 0 ]
import sqlalchemy from sqlalchemy.ext.automap import automap_base from sqlalchemy.orm import Session from sqlalchemy import create_engine, func, inspect from flask import Flask, jsonify, render_template, redirect from flask_pymongo import PyMongo from config import mongo_password, mongo_username, sql_username, sql_pass...
normal
{ "blob_id": "15e1ce95398ff155fe594c3b39936d82d71ab9e2", "index": 5015, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n pokemon_data = mongo.db.pokemon.find_one()\n return render_template('index.html', pokemon_data=pokemon_data)\n\n\n@app.route('/stats')\ndef stats():\n session = Session(eng...
[ 3, 4, 5, 6, 7 ]
################################################################################ # Controller of the Darwin Squat-Stand task using numpy # # Note: all joint data used in this file uses the dof indexing with # # from the simulation environment, not the hardware. ...
normal
{ "blob_id": "97c5b75323bb143c87972b389e2f27e443c1e00c", "index": 9945, "step-1": "<mask token>\n\n\nclass NP_Net_MirrorSym:\n <mask token>\n\n def load_from_file(self, fname):\n params = joblib.load(fname)\n pol_scope = list(params.keys())[0][0:list(params.keys())[0].find('/')]\n obrms...
[ 8, 12, 14, 16, 17 ]
import random import matplotlib.pyplot as plt import numpy as np def dado(n): i = 1 dos =0 tres =0 cuatro =0 cinco=0 seis =0 siete=0 ocho=0 nueve=0 diez=0 once=0 doce=0 cont = [0,0,0,0,0,0,0,0,0,0,0] while i <= n: r1 = random.randint(1,6)...
normal
{ "blob_id": "2d0d73c0ea20d6736c10d5201abcfa9d561ef216", "index": 7474, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef dado(n):\n i = 1\n dos = 0\n tres = 0\n cuatro = 0\n cinco = 0\n seis = 0\n siete = 0\n ocho = 0\n nueve = 0\n diez = 0\n once = 0\n doce = 0\n...
[ 0, 1, 2, 3, 4 ]
""" Suffix Arrays - Optimized O(n log n) - prefix doubling A suffix is a non-empty substring at the end of the string. A suffix array contains all the sorted suffixes of a string A suffix array provides a space efficient alternative to a suffix tree which itself is a compressed version of a trie. Suffix array can do ...
normal
{ "blob_id": "5a2106f5255493d2f6c8cb9e06a2666c8c55ed38", "index": 3852, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef prefix_doubling_suffix_array(n):\n n_len = len(n)\n if n_len == 0:\n return []\n if n_len == 1:\n return [0]\n suffixes = []\n for i in range(n_len):\...
[ 0, 1, 2, 3, 4 ]
import os, json, locale, requests, dash, dash_table, copy, time, flask, base64 import dash_core_components as dcc import dash_html_components as html import plotly.graph_objects as go import pandas as pd from os import listdir import plotly.figure_factory as ff from concurrent.futures import ThreadPoolExecutor, Process...
normal
{ "blob_id": "c5f41b69ac215bd661ee39bdc8c3119db9606ca8", "index": 6020, "step-1": "<mask token>\n\n\n@app.callback(Output('ganttpersoon', 'figure'), [Input(\n 'dropdownganttpersoon', 'value'), Input('dropdownganttpersoonstatus',\n 'value')])\ndef update_ganttpersoon(v1, v2):\n ganttdata = []\n for i, ...
[ 2, 8, 10, 11, 12 ]
string1 = "Vegetable" #string2 = "Fruit" string2 = "vegetable" print(string1 == string2) print(string1 != string2) if string1.lower() == string2.lower(): print("The strings are equal") else: print("The strings are not equal") number1 = 25 number2 = 30 # == # != # > # < # >= # <= if number1 <...
normal
{ "blob_id": "fecaf41152e8c98784585abfdb3777fc0a4824f3", "index": 1052, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(string1 == string2)\nprint(string1 != string2)\nif string1.lower() == string2.lower():\n print('The strings are equal')\nelse:\n print('The strings are not equal')\n<mask toke...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # encoding: utf-8 import multiprocessing import time import sys def daemon(): p = multiprocessing.current_process() print('Starting:', p.name, p.pid) sys.stdout.flush() time.sleep(2) print('Exiting :', p.name, p.pid) sys.stdout.flush() def non_daemon(): p = multipr...
normal
{ "blob_id": "9bb6fd6fbe212bdc29e2d1ec37fa6ec6ca9a9469", "index": 1060, "step-1": "<mask token>\n\n\ndef daemon():\n p = multiprocessing.current_process()\n print('Starting:', p.name, p.pid)\n sys.stdout.flush()\n time.sleep(2)\n print('Exiting :', p.name, p.pid)\n sys.stdout.flush()\n\n\n<mask ...
[ 2, 5, 6, 7, 8 ]
# Standard Library imports: import argparse import os from pathlib import Path from typing import Dict, List # 3rd Party imports: import keras.backend as K from keras.layers import * from keras.models import Model import tensorflow as tf from tensorflow.python.framework import graph_io, graph_util from tensorflow.pyth...
normal
{ "blob_id": "a5f3af6fc890f61eecb35bd157fc51bb65b4c586", "index": 3958, "step-1": "<mask token>\n\n\ndef squeezenet_fire_module(input, input_channel_small=16,\n input_channel_large=64):\n channel_axis = 3\n input = Conv2D(input_channel_small, (1, 1), padding='valid')(input)\n input = Activation('relu'...
[ 2, 4, 5, 6, 8 ]
import os import os.path import numpy as np import pickle import codecs from konlpy.tag import Okt from hyperparams import params from gensim.models import FastText #tokenizer tokenizer = Okt() def make_word_dictionary(word_dict_pkl_path=params['default_word_dict_pkl_path'], training_data_path = params['d...
normal
{ "blob_id": "430e971d2ae41bfd60e7416ecb2c26bb08e4df45", "index": 6520, "step-1": "<mask token>\n\n\ndef make_word_dictionary(word_dict_pkl_path=params[\n 'default_word_dict_pkl_path'], training_data_path=params[\n 'default_training_data_path']):\n word_dict = dict()\n if os.path.isfile(word_dict_pkl_...
[ 1, 3, 5, 6, 7 ]
#!/usr/bin/env python import matplotlib.pyplot as plt import numpy as np n_points = 100 n_sims = 1000 def simulate_one_realisation(): return np.random.normal(1, 2, size=n_points) def infer(sample): return {'mean': np.mean(sample), 'std': np.std(sample)} inference = [infer(simulate_one_realisation()) for _ ...
normal
{ "blob_id": "6e8ef901fc614ecbba25df01f84a43c429f25cf6", "index": 4919, "step-1": "<mask token>\n\n\ndef infer(sample):\n return {'mean': np.mean(sample), 'std': np.std(sample)}\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef simulate_one_realisation():\n return np.random.normal(1, 2, size=n_points...
[ 1, 3, 4, 5, 6 ]
""" help find Holly find dups in the PC's Given a particular dir - report the dupset of each of the files so we can see where the dups are """ import os, sys, re from comms.dup_manager import DupManager class DupFinder (DupManager): base_archives_path = '/Volumes/archives/CommunicationsImageCollection/' ba...
normal
{ "blob_id": "037a02ff2c0699acdd1fefbe60098c93cd99e777", "index": 1987, "step-1": "\"\"\"\nhelp find Holly find dups in the PC's\n\nGiven a particular dir - report the dupset of each of the files so we can see\nwhere the dups are\n\n\"\"\"\nimport os, sys, re\n\nfrom comms.dup_manager import DupManager\n\nclass D...
[ 0 ]
#!/usr/bin/env python ''' Created on 2011-08-27 @author: xion Setup script for the seejoo project. ''' import ast import os from setuptools import find_packages, setup def read_tags(filename): """Reads values of "magic tags" defined in the given Python file. :param filename: Python filename to read the tag...
normal
{ "blob_id": "9d1b795b561a26ae28e82833485ca6034438e78b", "index": 8491, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef read_tags(filename):\n \"\"\"Reads values of \"magic tags\" defined in the given Python file.\n\n :param filename: Python filename to read the tags from\n :return: Dictio...
[ 0, 2, 3, 4, 5 ]
"""Scans all files in this project for FIXME and TODO comments and writes them to todos.txt has to be invoked while being in myLambda/ and not in e.g. myLambda/src""" import sys import os import re files = [] searchFiles = [] # get all subdirs and its files for root, dirs, f in os.walk('./'): files.append((root, f)) ...
normal
{ "blob_id": "3bc6091d822fa197dcce3cd75fa9755dc9f93592", "index": 7520, "step-1": "\"\"\"Scans all files in this project for FIXME and TODO comments and writes them to todos.txt\nhas to be invoked while being in myLambda/ and not in e.g. myLambda/src\"\"\"\nimport sys\nimport os\nimport re\nfiles = []\nsearchFile...
[ 0 ]
def f(p_arg, *s_args, **kw_args): return (s_args[0] + kw_args['py'])+p_arg r = f(3, 2, py = 1) ## value r => 6
normal
{ "blob_id": "4a913cfdbddb2f6b5098395814f5fc1203192b9a", "index": 4847, "step-1": "<mask token>\n", "step-2": "def f(p_arg, *s_args, **kw_args):\n return s_args[0] + kw_args['py'] + p_arg\n\n\n<mask token>\n", "step-3": "def f(p_arg, *s_args, **kw_args):\n return s_args[0] + kw_args['py'] + p_arg\n\n\nr...
[ 0, 1, 2, 3 ]
import re def find_all_links(text): result = [] iterator = re.finditer(r"https?\:\/\/(www)?\.?\w+\.\w+", text) for match in iterator: result.append(match.group()) return result
normal
{ "blob_id": "b8c7aa5ff7387eacb45d996fa47186d193b44782", "index": 4823, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_all_links(text):\n result = []\n iterator = re.finditer('https?\\\\:\\\\/\\\\/(www)?\\\\.?\\\\w+\\\\.\\\\w+', text)\n for match in iterator:\n result.append(m...
[ 0, 1, 2, 3 ]
from sense_hat import SenseHat import time sense = SenseHat() b = (0, 0, 204) #Blue w = (255, 255, 255) #White e = (0, 0, 0) #Empty y = (255, 255, 0) #Yellow r = (255, 0, 0) #red prenume = [ e, e, e, e, e, e, e, e, e, e, e, e, e, e, e, e, e, b, e, y, y, e, r, e, b, e, b, y, e, y, r, e, b, b, b, y,...
normal
{ "blob_id": "b9eeccbed63aa42afa09fe7ef782066f300255a1", "index": 2173, "step-1": "<mask token>\n", "step-2": "<mask token>\nsense.set_pixels(prenume)\n", "step-3": "<mask token>\nsense = SenseHat()\nb = 0, 0, 204\nw = 255, 255, 255\ne = 0, 0, 0\ny = 255, 255, 0\nr = 255, 0, 0\nprenume = [e, e, e, e, e, e, e,...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # ================================================== # @Author : Copyright@Ryuchen # ================================================== from .version import VERSION __all__ = [ "VERSION" ]
normal
{ "blob_id": "d815c6e233d81dfb144442a83e6006aa4e29bfce", "index": 100, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['VERSION']\n", "step-3": "from .version import VERSION\n__all__ = ['VERSION']\n", "step-4": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# ==============================...
[ 0, 1, 2, 3 ]
# coding=utf-8 # oscm_app/cart/models # django imports from django.core.urlresolvers import reverse from django.db import models from django.utils.translation import ugettext_lazy as _ # OSCM imports from ...constants import CARTS, CART_STATUSES, DEFAULT_CART_STATUS from ...utils import get_attr from ..cart_manager i...
normal
{ "blob_id": "ae0ccbb9b0a2c61d9ee9615ba8d0c1a186a81c34", "index": 3177, "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 <mask token>\n <mask token>\n <mask token>\n\n\n ...
[ 6, 8, 9, 11, 12 ]
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'Admin.ui' # # Created by: PyQt5 UI code generator 5.12 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets from qtpandas.views.DataTableView import DataTableWidget from qtpandas.models.DataFra...
normal
{ "blob_id": "5e2a8e95af88a582b6e760a53dfd41f880d66963", "index": 2670, "step-1": "<mask token>\n\n\nclass Ui_Admin(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Ui_Admin(object):\n\n def setupUi(self, Admin):\n Admin.setObjectName('Admin')\n Admin.resize(6...
[ 1, 2, 3, 4, 5 ]
# dealing with the packet fragments and their reconsttruction import logging # shut up scapy logging.getLogger("scapy.runtime").setLevel(logging.ERROR) from scapy.all import * conf.verb=0 from collections import OrderedDict pkt_frag_loads = OrderedDict() def get_load(pkt): ack = str(pkt[TCP].ack) seq = str...
normal
{ "blob_id": "3e0bc91b81d0f503b78c9ac685b05b7ecb754e28", "index": 3460, "step-1": "<mask token>\n\n\ndef get_load(pkt):\n ack = str(pkt[TCP].ack)\n seq = str(pkt[TCP].seq)\n src_ip_port = str(pkt[IP].src) + ':' + str(pkt[TCP].sport)\n dst_ip_port = str(pkt[IP].dst) + ':' + str(pkt[TCP].dport)\n loa...
[ 3, 4, 5, 6, 7 ]
import random import Manhattan_segmental_dist # Greedy # s: dictionary of points # k: number of medoids # returns # k medoids from sample set s def greedy(s, k): # print("Hello Word!") m_1 = random.choice(list(s.keys())) medoids = {m_1: s[m_1]} dimensions = list(range(len(s[m_1]))) s.pop(m_1...
normal
{ "blob_id": "9a02bd0bc14494db033c032003aa5baea111ea8c", "index": 7185, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef greedy(s, k):\n m_1 = random.choice(list(s.keys()))\n medoids = {m_1: s[m_1]}\n dimensions = list(range(len(s[m_1])))\n s.pop(m_1)\n dist = {}\n for x in s:\n ...
[ 0, 1, 2, 3 ]
from test.framework import TestCase from test.mock import Mock from package.util.svnutil import ReleaseXmlParser, Release import time class SvnUtilTests(TestCase): def setUp(self): r1 = Release() r1.name = 'BETA1.1.0' r1.type = 'BETA' r1.version = '1.1.0' r1.date = time.strp...
normal
{ "blob_id": "9c320db85ca1a9df6b91f6bb062e4d5c3d94ee91", "index": 9516, "step-1": "<mask token>\n\n\nclass SvnUtilTests(TestCase):\n\n def setUp(self):\n r1 = Release()\n r1.name = 'BETA1.1.0'\n r1.type = 'BETA'\n r1.version = '1.1.0'\n r1.date = time.strptime('2009-04-21 23:...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- class CacheDecorator: def __init__(self): self.cache = {} self.func = None def cachedFunc(self, *args): if args not in self.cache: print("Ergebnis berechnet") self.cache[args] = self.func(*args) else:...
normal
{ "blob_id": "b7f6207fe6c013a964258255445004c3f4e0adbb", "index": 7217, "step-1": "class CacheDecorator:\n <mask token>\n\n def cachedFunc(self, *args):\n if args not in self.cache:\n print('Ergebnis berechnet')\n self.cache[args] = self.func(*args)\n else:\n p...
[ 3, 4, 5, 6, 7 ]
import pandas as pd import os import re main_dir = r'C:\Users\Username\Desktop\Python\End-to-End-Data-Analysis\1. Get the Data\table' file = 'CMBS Table.csv' os.chdir(main_dir) cmbs = pd.read_csv(file, encoding='ISO-8859-1') # Delete extra Loan & Seller columns loan_seller_cols = [val for val in cmbs.co...
normal
{ "blob_id": "eb890c68885cbab032ce9d6f3be3fd7013a2788b", "index": 2140, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.chdir(main_dir)\n<mask token>\nfor col in loan_seller_cols:\n cmbs.drop(columns=col, axis=1, inplace=True)\n<mask token>\nfor key, value in regex_dict.items():\n cmbs.columns = [...
[ 0, 1, 2, 3, 4 ]
from django.conf.urls import patterns, include, url from django.contrib.auth.decorators import login_required from django.views.generic import TemplateView from analyze import views #from lecture import views urlpatterns = patterns('', url(r'^$', 'analyze.views.analyze', name='analyze'), )
normal
{ "blob_id": "035de226c2d2ee85cb7e319de35fb09b21bc523d", "index": 9061, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', url('^$', 'analyze.views.analyze', name='analyze'))\n", "step-3": "from django.conf.urls import patterns, include, url\nfrom django.contrib.auth.decorators im...
[ 0, 1, 2, 3 ]
from can.interfaces.ics_neovi.neovi_bus import NeoViBus
normal
{ "blob_id": "6025b8d4015572ea1a760c1b4bc7200a1019c802", "index": 5031, "step-1": "<mask token>\n", "step-2": "from can.interfaces.ics_neovi.neovi_bus import NeoViBus\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
import pygame naytto = pygame.display.set_mode((740, 500)) pygame.display.set_caption("Piirtäminen") x = 100 y = 300 def main(): while True: tapahtuma = pygame.event.poll() if tapahtuma.type == pygame.QUIT: break naytto.fill((0, 0, 0)) pygame.draw.line(naytto, (0, 0, ...
normal
{ "blob_id": "3fdb29797894737edae37ad7890e14cb9ce705e8", "index": 5901, "step-1": "<mask token>\n", "step-2": "<mask token>\npygame.display.set_caption('Piirtäminen')\n<mask token>\n\n\ndef main():\n while True:\n tapahtuma = pygame.event.poll()\n if tapahtuma.type == pygame.QUIT:\n ...
[ 0, 2, 3, 4, 5 ]
__author__ = "Sarah Hazell Pickering (sarah.pickering@anu.edu.au)" __date__ = "2018-11-15" """ QC and Trimming with fastp Trimming and QC with fastp. Then subsampling of reads via seqtk. Now starts with a sample/sample.file structure. Number of reads to sample is can be supplied via pairs_to_sample ...
normal
{ "blob_id": "655e6531dc21dcdf8fa827184444cee483492b81", "index": 7715, "step-1": "__author__ = \"Sarah Hazell Pickering (sarah.pickering@anu.edu.au)\"\n__date__ = \"2018-11-15\"\n\n\"\"\" QC and Trimming with fastp\n\n Trimming and QC with fastp.\n Then subsampling of reads via seqtk.\n\n Now starts wit...
[ 0 ]
quilogramas = float ( input ( "Insira o peso em Kg:" )) libras = quilogramas / 0 , 45 print ( libras )
normal
{ "blob_id": "9c35e64fd773c79dc20e6b388478e892bda85788", "index": 1599, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(libras)\n", "step-3": "quilogramas = float(input('Insira o peso em Kg:'))\nlibras = quilogramas / 0, 45\nprint(libras)\n", "step-4": "quilogramas = float ( input ( \"Insira o ...
[ 0, 1, 2, 3 ]
from neodroidagent.entry_points.agent_tests import sac_gym_test if __name__ == "__main__": sac_gym_test()
normal
{ "blob_id": "e9890fcf9ad2a78b3400f6e4eeb75deac8edcd6a", "index": 1609, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n sac_gym_test()\n", "step-3": "from neodroidagent.entry_points.agent_tests import sac_gym_test\nif __name__ == '__main__':\n sac_gym_test()\n", "step...
[ 0, 1, 2, 3 ]
from count_freqs import * from eval_gene_tagger import * ''' Using gene.train gene.counts prediction file to evaluate the performance Usage: python viterbi.py gene.counts gene.dev gene_dev.p1.out ''' if __name__ == "__main__": #if len(sys.argv)!=2: # Expect exactly one argument: the training data file # ...
normal
{ "blob_id": "6dda23cc5d0083e72520b0664b6550ccb48e4b4f", "index": 7288, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n counter1 = Hmm(3)\n input_counts = open('gene_NoClass.counts', 'r')\n dev_file = open('gene.dev', 'r+')\n output_file2 = open('gene_dev.NoClass.ou...
[ 0, 1, 2, 3 ]
# Generated by Django 3.0.6 on 2020-07-06 17:10 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('s1app', '0004_auto_20200706_0753'), ] operations = [ migrations.AlterField( model_name='gall', name='date', ...
normal
{ "blob_id": "a7d7408808f28343a51ff6522c5e14747c8c6e43", "index": 9819, "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 = [('s1app', '00...
[ 0, 1, 2, 3, 4 ]
import requests import sqlite3 url = 'http://dummy.restapiexample.com/api/v1/employees' r = requests.get(url) packages_json = r.json() # Create the employee database if it does not exist db = sqlite3.connect('employee.sqlite') #create the table db.execute("CREATE TABLE IF NOT EXISTS employee (id INTEGER P...
normal
{ "blob_id": "497203be99643e2bb0087977f292f4ed890f9ead", "index": 7111, "step-1": "<mask token>\n", "step-2": "<mask token>\ndb.execute(\n 'CREATE TABLE IF NOT EXISTS employee (id INTEGER PRIMAR KEY, employee_name TEXT, employee_salary INTEGER, employee_age INTEGER, profile_image BLOB)'\n )\nfor employee ...
[ 0, 1, 2, 3, 4 ]
import contextlib import logging import os import pwd import sys from typing import Iterable from sqlalchemy import Table, exists, null, select from sqlalchemy.engine import Engine from sqlalchemy.exc import DBAPIError from sqlalchemy.pool import NullPool from hades import constants from hades.common import db from h...
normal
{ "blob_id": "c9df53ac06b8bb106d73825d60fa885c06385e95", "index": 8557, "step-1": "<mask token>\n\n\ndef check_database(engine: Engine, user_name: pwd.struct_passwd, tables:\n Iterable[Table]):\n logger.info('Checking database access as user %s', user_name)\n try:\n conn = engine.connect()\n ex...
[ 3, 4, 5, 6, 7 ]
import curses from zeep import Client from zeep import xsd from zeep.plugins import HistoryPlugin import time from datetime import datetime import os LDB_TOKEN = 'NULLTOKEN' WSDL = 'http://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx?ver=2017-10-01' if LDB_TOKEN == '': raise Exception("Please configure y...
normal
{ "blob_id": "302634b93725ceb9333e236021cbb64e023ff798", "index": 2135, "step-1": "<mask token>\n", "step-2": "<mask token>\nif LDB_TOKEN == '':\n raise Exception(\n 'Please configure your OpenLDBWS token in getDepartureBoardExample!')\n<mask token>\n\n\ndef main(stdscr):\n res = client.service.Get...
[ 0, 2, 3, 4, 5 ]
#求11+12+13+。。。+m m = int(input('请输入一个数:')) S = m for x in range(11,m): S = S+x print('sum =',S)
normal
{ "blob_id": "49ffa225d433ef2263159ba2145da5ba2a95d1f2", "index": 4664, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor x in range(11, m):\n S = S + x\nprint('sum =', S)\n", "step-3": "m = int(input('请输入一个数:'))\nS = m\nfor x in range(11, m):\n S = S + x\nprint('sum =', S)\n", "step-4": "#求11+...
[ 0, 1, 2, 3 ]
# Copyright (c) 2016, Xilinx, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of ...
normal
{ "blob_id": "15514d5636471b1a311641a40b6a00b81703cd2b", "index": 6488, "step-1": "<mask token>\n\n\nclass Grove_PIR(Pmod_IO):\n <mask token>\n\n def __init__(self, mb_info, gr_pin):\n \"\"\"Return a new instance of a PIR object. \n \n Parameters\n ----------\n mb_info : d...
[ 3, 4, 5, 6, 7 ]
n = 5 a = '1' if n == 1: print(a) else: for i in range(2, n + 1): if i == 2: a = '11' else: count = 1 for j in range(len(a) - 1): if j == len(a) - 2 : if a[j] == a[j + 1]: count += 1 ...
normal
{ "blob_id": "26a778f16cc50d1a8791fb672fb8907464865f3f", "index": 1349, "step-1": "n = 5\na = '1'\nif n == 1:\n print(a)\nelse:\n for i in range(2, n + 1):\n if i == 2:\n a = '11'\n else:\n count = 1\n for j in range(len(a) - 1):\n if j == len(a)...
[ 0 ]
import os import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import cv2 import color_to_gray_operations VIZ_PATH = '../output_data/visualizations/gray_intensities/' def visualize_grayscale_intensities(img, out_path): img_x, img_y = np.mgrid[0: img.shape[0], 0: img.shape...
normal
{ "blob_id": "21fec6d307b928a295f2ffbf267456f9cd9ea722", "index": 9105, "step-1": "<mask token>\n\n\ndef visualize_grayscale_intensities(img, out_path):\n img_x, img_y = np.mgrid[0:img.shape[0], 0:img.shape[1]]\n fig = plt.figure()\n ax = fig.gca(projection='3d')\n ax.plot_surface(img_x, img_y, img, r...
[ 4, 6, 7, 8, 9 ]
# coding: UTF-8 from PIL import ImageFont,Image,ImageDraw def min_element(table_d,ignoring_index = None): min_i,min_j,min_e = 0,0,max(table_d.values()) for key in table_d.keys(): # ignore if i in key or j in key if ignoring_index is not None: i,j = key if i in ignoring_index or j in ignoring_i...
normal
{ "blob_id": "aee009b37b99bf44e27c608470c43834a58e0cc7", "index": 8490, "step-1": "<mask token>\n\n\ndef to_dict(table):\n table_d = dict()\n for i in range(len(table)):\n for j in range(i):\n table_d[i, j] = table[i][j]\n table_d[j, i] = table[i][j]\n return table_d\n\n\ndef...
[ 3, 4, 5, 6, 7 ]
from abc import abstractmethod class BaseButton: @abstractmethod def render(self): pass @abstractmethod def on_click(self): pass class WindowsButton(BaseButton): def render(self): print("Render window button") def on_click(self): print("On click") class Ht...
normal
{ "blob_id": "003976d850e371e01e6d0a307d3cf366f962c53d", "index": 4358, "step-1": "<mask token>\n\n\nclass HtmlButton(BaseButton):\n\n def render(self):\n print('Render html button')\n <mask token>\n\n\nclass BaseDialog:\n\n @abstractmethod\n def create_button(self) ->BaseButton:\n pass\...
[ 14, 15, 19, 23, 24 ]
#!/usr/bin/python import sys, os, glob, numpy wd = os.path.dirname(os.path.realpath(__file__)) sys.path.append(wd + '/python_speech_features') from features import mfcc, logfbank import scipy.io.wavfile as wav DIR = '/home/quiggles/Desktop/513music/single-genre/classify-me/subset' OUTDIR = wd + '/songdata/subset' #...
normal
{ "blob_id": "cca1a491e2a48b4b0c7099a6c54e528158ef30bb", "index": 5189, "step-1": "<mask token>\n\n\ndef getMFCC(rate, sig):\n mfcc_feat = mfcc(sig, rate)\n return numpy.concatenate(getQuartileMeans(mfcc_feat))\n\n\ndef getLogFBank(rate, sig):\n logfbank_feat = logfbank(sig, rate)\n return numpy.conca...
[ 3, 7, 8, 9, 10 ]
import numpy as np import pandas as pd import nltk from collections import defaultdict import os.path stop_words = ['i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', 'her', 'hers', 'herself',...
normal
{ "blob_id": "0356b408624988100c10b20facecef14f1552203", "index": 4537, "step-1": "<mask token>\n\n\ndef build_statements_features(df, vectorizer, train=True, tokenizer=\n tokenizer_nltk):\n filtered_statements_dic = {}\n for index, row in df.iterrows():\n filtered_statement = []\n tokenize...
[ 3, 5, 7, 9, 10 ]
# 다이얼 dial = ['ABC', 'DEF', 'GHI','JKL','MNO','PQRS','TUV','WXYZ'] cha = input() num = 0 for i in range(len(cha)): for j in dial: if cha[i] in j: num = num + dial.index(j) + 3 print(num)
normal
{ "blob_id": "774e607c693fa2d5199582302e466674f65b6449", "index": 6213, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(cha)):\n for j in dial:\n if cha[i] in j:\n num = num + dial.index(j) + 3\nprint(num)\n", "step-3": "dial = ['ABC', 'DEF', 'GHI', 'JKL', 'MNO', '...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python """ Main training workflow """ from __future__ import division import os import time import glob import torch import random import signal import argparse from models.trainer import build_trainer from models import data_loader, model_builder from models.pytorch_pretrained_bert.modeling import...
normal
{ "blob_id": "3adb50a6375a73f786369dd22712a657b66f758e", "index": 8432, "step-1": "<mask token>\n\n\nclass Running(object):\n <mask token>\n\n def __init__(self, args, device_id):\n \"\"\"\n :param args: parser.parse_args()\n :param device_id: 0 or -1\n \"\"\"\n self.args ...
[ 7, 16, 17, 18, 24 ]
class Solution(object): def shortestPalindrome(self, s): """ :type s: str :rtype: str """ left= 0 #for right in range(len(s)-1, -1, -1): for right in reversed(range(len(s))): if s[right] == s[left]: left += 1 ...
normal
{ "blob_id": "4d18c056845403adc9c4b5848fafa06d0fe4ff4c", "index": 3165, "step-1": "class Solution(object):\n <mask token>\n\n\n<mask token>\n", "step-2": "class Solution(object):\n\n def shortestPalindrome(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n left =...
[ 1, 2, 3, 4, 5 ]
class Process: def __init__(self, id, at, bt): self.id = id self.at = at self.bt = bt self.wt = 0 self.ct = 0 self.st = 0 self.tat = 0 def fill(self, st): print('Current process:', self.id) self.st = st self.ct = self.st + self.bt ...
normal
{ "blob_id": "be58a2e0dcdbcb3a3df0da87be29ce7ebcee7fe9", "index": 6185, "step-1": "class Process:\n\n def __init__(self, id, at, bt):\n self.id = id\n self.at = at\n self.bt = bt\n self.wt = 0\n self.ct = 0\n self.st = 0\n self.tat = 0\n <mask token>\n <ma...
[ 2, 4, 5, 6, 7 ]
from ROOT import * import math import os,sys,time,glob,fnmatch import argparse import ROOT import sys sys.path.append("utils") from moments import * from dirhandle import * from plothandle import * from AnalysisGeneratorMT import * def doAnalysis( blabla): return blabla.DoThreatdAnalysis() if __name__ =...
normal
{ "blob_id": "7db31940aea27c10057e2ce1e02410994bd2039b", "index": 3328, "step-1": "from ROOT import *\nimport math\nimport os,sys,time,glob,fnmatch\nimport argparse\nimport ROOT\nimport sys\nsys.path.append(\"utils\")\nfrom moments import *\nfrom dirhandle import *\nfrom plothandle import *\nfrom AnalysisGene...
[ 0 ]
import sys from random import randint if len(sys.argv) != 2: print "Usage: generate.py <number of orders>" sys.exit(1) n = int(sys.argv[1]) for i in range(0, n): action = 'A' orderid = i + 1 side = 'S' if (randint(0,1) == 0) else 'B' quantity = randint(1,100) price = randint(100,200) ...
normal
{ "blob_id": "6267c999d3cec051c33cbcde225ff7acaa6bff74", "index": 5383, "step-1": "import sys\nfrom random import randint\n\nif len(sys.argv) != 2:\n print \"Usage: generate.py <number of orders>\"\n sys.exit(1)\n\nn = int(sys.argv[1])\n\nfor i in range(0, n):\n action = 'A'\n orderid = i + 1\n sid...
[ 0 ]
# #!/usr/bin/python # last edit abigailc@Actaeon on jan 27 2017 #pulling the taxonomy functions out of makespeciestree because I need to make them faster... #insects is running for literally >20 hours. names_file = "/Users/abigailc/Documents/Taxonomy_Stuff/taxdump/names.dmp" nodes_file = "/Users/abigailc/Documents/...
normal
{ "blob_id": "5c1324207e24f2d723be33175101102bd97fe7a2", "index": 4860, "step-1": "<mask token>\n\n\ndef Ret_Sister_Same_Rank(string, nodes_file, names_file):\n print(string)\n interest_taxid = Str_To_Taxid(string, names_file)\n print(interest_taxid)\n up_taxid = Return_Parent(interest_taxid, nodes_fi...
[ 2, 15, 18, 21, 27 ]
# -*- coding: utf-8 -*- """ Created on Wed May 16 10:17:32 2018 @author: pearseb """ #%% imporst import os import numpy as np import netCDF4 as nc import matplotlib.pyplot as plt import matplotlib.cm as cm import cmocean.cm as cmo import seaborn as sb sb.set(style='ticks') import mpl_toolkits.basemap as bm import p...
normal
{ "blob_id": "635b02e03578d44f13530bd57ab1a99987d4909d", "index": 5987, "step-1": "<mask token>\n", "step-2": "<mask token>\nsb.set(style='ticks')\n<mask token>\nos.chdir(\n 'C://Users/pearseb/Dropbox/PhD/My articles/nitrogen-carbon cycles/data_for_publication'\n )\n<mask token>\nlon_bnds[:, 0] += 360.0\n...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # coding: utf-8 # # PyCity School Analysis # 1. Charter school types show better performace than District School types in all the scores. # 2. Overall students are performing better in english between (80 to 84%), than math (76 to 84%) # ### Note # * Instructions have been included for each seg...
normal
{ "blob_id": "8488fdd216c30c3cb4b0060305af6708d890bc86", "index": 8203, "step-1": "<mask token>\n", "step-2": "<mask token>\nDistrict_Summary_df\n<mask token>\nschool_summary_df\n<mask token>\ntop_performing.head()\n<mask token>\ntop_performing.head()\n<mask token>\ngrade_math_score\n<mask token>\ngrade_reading...
[ 0, 1, 2, 3, 4 ]
from Player import Player class GameSequence: ''' GameSequence summary: Keeps track of player turn sequence and Game end Functionalities -start game -must start turns -change turns -end turns -end game ''' def __init__(self, ArrayofPlaye...
normal
{ "blob_id": "bdfd941be29a31d6c1bbedd270dadac844f49fc4", "index": 1198, "step-1": "<mask token>\n\n\nclass GameSequence:\n <mask token>\n <mask token>\n\n def changeMode(self, number):\n self.currentMode = self.modes[number]\n\n def startGame(self):\n self.currentTurn = 0\n \"\"\"...
[ 6, 7, 8, 9, 11 ]
#!/usr/bin/env python3 ''' towerdev - Ansible Tower Testing Framework MIT License Copyright © 2021 falcon78921 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 wit...
normal
{ "blob_id": "63e28e6a1ea5db1d1c41bbc755b9c33905e066bb", "index": 9832, "step-1": "<mask token>\n\n\ndef runTowerContainer(towerVersion, externalPort, osVersion, containerName,\n debug=False, **kwargs):\n \"\"\"Runs Tower container from pre-existing image\"\"\"\n allowedMemory = None\n if debug == Tru...
[ 1, 3, 4, 5, 6 ]
import tkinter import csv import datetime import time root = tkinter.Tk() root.title("Attendance") root.geometry("+450+250") ts = time.time() date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') fileName = "Attendance/Attendance_"+date+".csv" # open file with open(fileName, newline="") as file: reader ...
normal
{ "blob_id": "2343a9d3e253b5a0347b5890a5d7b9c3be777669", "index": 5958, "step-1": "<mask token>\n", "step-2": "<mask token>\nroot.title('Attendance')\nroot.geometry('+450+250')\n<mask token>\nwith open(fileName, newline='') as file:\n reader = csv.reader(file)\n r = 0\n for col in reader:\n c = ...
[ 0, 1, 2, 3, 4 ]
group = {'A': 20, 'B': 15, 'C': 10} def split_the_bill(x): owed_dict = {} sum = 0 people = 0 for key in x: sum = sum + x[key] people = people + 1 price_pp = sum / people for key in x: owed_value = x[key] - price_pp owed_dict[key] = round(owed_value, 2) retur...
normal
{ "blob_id": "69d7e7eb644a67ee921086005f0a55f39507f361", "index": 2864, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef split_the_bill(x):\n owed_dict = {}\n sum = 0\n people = 0\n for key in x:\n sum = sum + x[key]\n people = people + 1\n price_pp = sum / people\n f...
[ 0, 1, 2, 3 ]
import asyncio import json from functools import lru_cache from pyrogram import Client SETTINGS_FILE = "/src/settings.json" CONN_FILE = "/src/conn.json" def load_setting(setting: str): with open(SETTINGS_FILE) as f: return json.load(f)[setting] @lru_cache() def get_bot_name(): return load_setting(...
normal
{ "blob_id": "14e1af3d60efef842c72bf9b55143d0e14f3a7b8", "index": 5897, "step-1": "<mask token>\n\n\ndef load_setting(setting: str):\n with open(SETTINGS_FILE) as f:\n return json.load(f)[setting]\n\n\n@lru_cache()\ndef get_bot_name():\n return load_setting('bot_name')\n\n\n@lru_cache()\ndef get_app_...
[ 4, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- # !/usr/bin/python import re import sys import xlwt import os ''' python logcat_time.py config_file logcat_file ''' config_file = sys.argv[1] logcat_file = sys.argv[2] turns_time = 0 turn_compelete_flag = 0 def get_filePath_fileName_fileExt(filename): (filepath, tempfilename) = os.path.s...
normal
{ "blob_id": "585c0f89605f1d791b449f42412174f06d0c5db5", "index": 5163, "step-1": "# -*- coding: utf-8 -*-\n# !/usr/bin/python\nimport re\nimport sys\nimport xlwt\nimport os\n\n'''\npython logcat_time.py config_file logcat_file\n'''\n\nconfig_file = sys.argv[1]\nlogcat_file = sys.argv[2]\n\nturns_time = 0\nturn_c...
[ 0 ]
#!../virtual_env/bin/python from migrate.versioning import api from config import SQLALCHEMY_DATABASE_URI from config import SQLALCHEMY_MIGRATE_REPO from models.base import metadata from sqlalchemy import create_engine import os.path engine = create_engine(SQLALCHEMY_DATABASE_URI) metadata.create_all(engine) if not...
normal
{ "blob_id": "9bbf0953d228c970764b8ba94675346820bc5d90", "index": 3006, "step-1": "<mask token>\n", "step-2": "<mask token>\nmetadata.create_all(engine)\nif not os.path.exists(SQLALCHEMY_MIGRATE_REPO):\n api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')\n api.version_control(SQLALCHEMY_DATABASE_U...
[ 0, 1, 2, 3, 4 ]
import random def patternToNumber(pattern): if len(pattern) == 0: return 0 return 4 * patternToNumber(pattern[0:-1]) + symbolToNumber(pattern[-1:]) def symbolToNumber(symbol): if symbol == "A": return 0 if symbol == "C": return 1 if symbol == "G": return 2 if sy...
normal
{ "blob_id": "51848a64102f7fe8272fcf56a9792ed50c430538", "index": 9115, "step-1": "<mask token>\n\n\ndef patternToNumber(pattern):\n if len(pattern) == 0:\n return 0\n return 4 * patternToNumber(pattern[0:-1]) + symbolToNumber(pattern[-1:])\n\n\ndef symbolToNumber(symbol):\n if symbol == 'A':\n ...
[ 8, 9, 11, 13, 15 ]
from flask.ext.wtf import Form from wtforms import TextField from wtforms.validators import Required class VerifyHandphoneForm(Form): handphone_hash = TextField('Enter verification code here', validators=[ Required()])
normal
{ "blob_id": "cb0df06ee474576b3024678fa0f63ce400d773ea", "index": 4096, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass VerifyHandphoneForm(Form):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass VerifyHandphoneForm(Form):\n handphone_hash = TextField('Enter verification code here', ...
[ 0, 1, 2, 3 ]
def solve(): valid_passes = 0 with open('.\day4.txt') as fp: for line in fp.read().strip().splitlines(): list_of_words = set() add = 1 for word in line.split(): modified_word = ''.join(sorted(word)) if modified_word in list_of_words: ...
normal
{ "blob_id": "870d260b58c10e0379d66c3b44bc45594ff7d666", "index": 4396, "step-1": "<mask token>\n", "step-2": "def solve():\n valid_passes = 0\n with open('.\\\\day4.txt') as fp:\n for line in fp.read().strip().splitlines():\n list_of_words = set()\n add = 1\n for w...
[ 0, 1, 2, 3 ]
from SMP.motion_planner.node import PriorityNode import numpy as np from heapq import nsmallest import sys from SMP.motion_planner.plot_config import DefaultPlotConfig from SMP.motion_planner.search_algorithms.best_first_search import GreedyBestFirstSearch # imports for route planner: class StudentMotionPlanner(Greedy...
normal
{ "blob_id": "6ecbe119c8a14776373d165dc05e81f91084893c", "index": 4229, "step-1": "<mask token>\n\n\nclass StudentMotionPlanner(GreedyBestFirstSearch):\n <mask token>\n\n def __init__(self, scenario, planningProblem, automata, plot_config=\n DefaultPlotConfig):\n super().__init__(scenario=scen...
[ 9, 11, 12, 13, 17 ]
# This is a generated file, do not edit from typing import List import pydantic from ..rmf_fleet_msgs.DockParameter import DockParameter class Dock(pydantic.BaseModel): fleet_name: str = "" # string params: List[DockParameter] = [] # rmf_fleet_msgs/DockParameter class Config: orm_mode = True...
normal
{ "blob_id": "62d0818395a6093ebf2c410aaadeb8a0250707ab", "index": 3865, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Dock(pydantic.BaseModel):\n fleet_name: str = ''\n params: List[DockParameter] = []\n\n\n class Config:\n orm_mode = True\n", "step-3": "from typing import Lis...
[ 0, 1, 2, 3 ]
import org.cogroo.gc.cmdline import typing class __module_protocol__(typing.Protocol): # A module protocol which reflects the result of ``jp.JPackage("org.cogroo.gc")``. cmdline: org.cogroo.gc.cmdline.__module_protocol__
normal
{ "blob_id": "f615e7bbfa9179d0bfb321242cd8df4ae7b48993", "index": 3181, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass __module_protocol__(typing.Protocol):\n cmdline: org.cogroo.gc.cmdline.__module_protocol__\n", "step-3": "import org.cogroo.gc.cmdline\nimport typing\n\n\nclass __module_pr...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 19 09:31:20 2021 @author: dclabby """ import os import cv2 import pickle from utils import locateLetterRegions # # Constants # sourceFolder = '/home/dclabby/Documents/Springboard/HDAIML_SEP/Semester03/MachineLearning/Project/solving_captchas_code_e...
normal
{ "blob_id": "6109efeb3462ac2c5a94a68fbfa4f2f0617dd927", "index": 1221, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef extractLetters(sourceFolder, trainRatio=0.8, destFolder=\n './data/separateLetters'):\n \"\"\" \n\n Parameters\n ----------\n sourceFolder : string\n DESC...
[ 0, 1, 2, 3 ]
import json import os from flask import Flask, request, url_for from flask_cors import CORS from werkzeug.utils import secure_filename from service.Binarizacion import Binarizacion UPLOAD_FOLDER = './public/files' app = Flask(__name__) app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER CORS(app) @app.route('/') def hell...
normal
{ "blob_id": "b9c8689dbdf451e6a981f1abdae55771266fe231", "index": 9129, "step-1": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return 'Hello word'\n\n\n@app.route('/analyze', methods=['POST'])\ndef analyze():\n if request.method == 'POST':\n image_file = request.files['image']\n file_nam...
[ 2, 3, 4, 5, 6 ]
# coding: utf-8 def init_list(): print("=== init_list ===") l = list() print(l) l2 = [] print(l2) l3 = list((1, 2)) print(l3) l4 = [1, 2] print(l4) def insert_append_and_extend_list(): print("=== insert_append_and_extend_list ===") l = ['e', 'h'] l.insert(-1, 'g') ...
normal
{ "blob_id": "1a710916461644a0676a3bd84926aeabb2aa3f71", "index": 7127, "step-1": "<mask token>\n\n\ndef get_len_count_index_list():\n print('=== get_len_count_index_list ===')\n l = ['a', 'b', 'c', 'd', 'e', 'e']\n print(l[0])\n print('len: {}'.format(len(l)))\n print('count d: {}'.format(l.count(...
[ 10, 11, 12, 14, 15 ]
class FixtureBittrex: PING = {"serverTime": 1582535502000} MARKETS = [ { "symbol": "ETH-BTC", "baseCurrencySymbol": "ETH", "quoteCurrencySymbol": "BTC", "minTradeSize": "0.01314872", "precision": 8, "status": "ONLINE", "createdAt": "2015-08-14T09:02:24.817Z"}, ...
normal
{ "blob_id": "eba8e2bda786760898c10d3e75620144973d6236", "index": 9555, "step-1": "<mask token>\n", "step-2": "class FixtureBittrex:\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>...
[ 0, 1, 2, 3 ]
if input is not None: element = S(input) if newChild is not None: newChild = S(newChild) element.replaceChild(existingChild, newChild)
normal
{ "blob_id": "fdbb64159b72bf902efc3aa2eaa534e199dccf84", "index": 8442, "step-1": "<mask token>\n", "step-2": "if input is not None:\n element = S(input)\nif newChild is not None:\n newChild = S(newChild)\nelement.replaceChild(existingChild, newChild)\n", "step-3": null, "step-4": null, "step-5": nu...
[ 0, 1 ]
import numpy as np import pandas as pd import plotly.graph_objects as go from matplotlib import pyplot as plt def plot_feature_VS_Observed(feature, df, linecolor): """ This function plots the 1880-2004 time series plots for the selected feature and observed earth :param Input: df -- > The dataframe...
normal
{ "blob_id": "8348d353e6fdea77c9c994d541db1420ef57a797", "index": 4399, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef plot_feature_VS_Observed(feature, df, linecolor):\n \"\"\"\n This function plots the 1880-2004 time series plots for the selected feature and observed earth\n :param\n ...
[ 0, 1, 2, 3 ]
# Generated by Django 2.0.7 on 2018-08-14 21:31 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('orion_integration', '000...
normal
{ "blob_id": "5791c1efa82a1e02ca067e1db776e9d466a111e2", "index": 1765, "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 = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
from tkinter import * from tkinter import messagebox from tkinter import ttk from PIL import Image, ImageTk import time import socket import threading root = Tk() root.title("Tic-Tac-Toe") root.geometry('600x600') winner = False def start_thread(target): thread = threading.Thread(target=target) ...
normal
{ "blob_id": "cc924892afe179e55166ea9b237b2bfe8ea900df", "index": 2120, "step-1": "<mask token>\n\n\ndef start_thread(target):\n thread = threading.Thread(target=target)\n thread.daemon = True\n thread.start()\n\n\n<mask token>\n\n\ndef receive_data():\n while True:\n data = sock.recv(1024).dec...
[ 5, 6, 7, 8, 9 ]
import os import time import argparse import cPickle as pickle from definitions import OieFeatures from definitions.OieExample import OieExample class FeatureLexicon: """ A wrapper around various dictionaries storing the mined data. It holds 5 dictionaries in total. Two of them store mappings\n - str ...
normal
{ "blob_id": "8102bdf4d29d2d3a1bdddbcfb6045b0660693996", "index": 402, "step-1": "import os\nimport time\nimport argparse\nimport cPickle as pickle\nfrom definitions import OieFeatures\nfrom definitions.OieExample import OieExample\n\n\nclass FeatureLexicon:\n \"\"\"\n A wrapper around various dictionaries ...
[ 0 ]
# -*- coding: utf-8 -*- # ------------------------------------------------------------------------------- # Name: sfp_googlesearch # Purpose: Searches Google for content related to the domain in question. # # Author: Steve Micallef <steve@binarypool.com> # # Created: 07/05/2012 # Copyright...
normal
{ "blob_id": "3a6eaa238e78e7a818bcf6e18cc7881eadf94b07", "index": 7863, "step-1": "<mask token>\n\n\nclass sfp_googlesearch(SpiderFootPlugin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def watchedEvents(self):\n return ['INTERNET_NAME']\n\n def prod...
[ 4, 5, 7, 8, 9 ]
# Written by Jagannath Bilgi <jsbilgi@yahoo.com> import sys import json import re """ Program accepts *.md document and converts to csv in required format Program parse line by line and uses recursive method to traverse from leaf to root. Single turn object (string, int etc) is used as point of return from recursio...
normal
{ "blob_id": "739921a6a09edbb81b442f4127215746c601a69a", "index": 4990, "step-1": "<mask token>\n\n\ndef obj_rec(obj, t, flag=0, acc=''):\n v_obj = type(obj)\n r = ''\n if type(obj) not in [dict, list, map]:\n ref_url = re.findall('\\\\((http.*?)\\\\)', obj)\n ref_title = re.findall('\\\\[[...
[ 1, 2, 3, 4, 5 ]
from tkinter import* me=Tk() me.geometry("354x460") me.title("CALCULATOR") melabel = Label(me,text="CALCULATE HERE",bg='PINK',font=("ARIAL",25)) melabel.pack(side=TOP) me.config(background='BROWN') displayStr=StringVar() op="" def but(a): global op op=op+str(a) displayStr.set(op) def eq(): ...
normal
{ "blob_id": "106cca8af164fa4ae946f77b40c76e03accf171c", "index": 9645, "step-1": "<mask token>\n\n\ndef but(a):\n global op\n op = op + str(a)\n displayStr.set(op)\n\n\ndef eq():\n global op\n result = str(eval(op))\n displayStr.set(result)\n op = ''\n\n\ndef clrbut():\n displayStr.set(''...
[ 3, 4, 5, 6, 7 ]
import zipfile zzz = zipfile.ZipFile('channel.zip','r') filestr = '90052' comment = [] for i in range(1000): fname = filestr + ".txt" for j in zzz.infolist(): if j.filename == fname : print j.comment comment.append(j.comment) break inzzz = zzz.open(fname).read() print 'fname = ' + fname ...
normal
{ "blob_id": "34ad2e6fc7167766dac1ca962cab40511c89ad68", "index": 7551, "step-1": "import zipfile\n\nzzz = zipfile.ZipFile('channel.zip','r')\nfilestr = '90052'\ncomment = []\nfor i in range(1000):\n fname = filestr + \".txt\"\n for j in zzz.infolist():\n if j.filename == fname :\n print j.comment\n ...
[ 0 ]
import numpy as np from base_test import ArkoudaTest from context import arkouda as ak """ Encapsulates unit tests for the pdarrayclass module that provide summarized values via reduction methods """ class SummarizationTest(ArkoudaTest): def setUp(self): ArkoudaTest.setUp(self) self.na = np.linsp...
normal
{ "blob_id": "88109909d0c80f25373f917426c3c3634bfc8114", "index": 6267, "step-1": "<mask token>\n\n\nclass SummarizationTest(ArkoudaTest):\n\n def setUp(self):\n ArkoudaTest.setUp(self)\n self.na = np.linspace(1, 10, 10)\n self.pda = ak.array(self.na)\n <mask token>\n\n def testMin(s...
[ 6, 7, 8, 9, 11 ]
# helper functions to handle intcode from collections import defaultdict def read_code(string): """ string should be a comma-separated string. """ code = defaultdict(int) for i, x in enumerate(string.split(',')): code[i] = int(x) return code def to_ascii(line): """ Writes a ...
normal
{ "blob_id": "68c2fd1d8ca9e1dd9373ca9f641c2920c87b2392", "index": 1346, "step-1": "<mask token>\n\n\nclass IntCode:\n\n def __init__(self, code):\n self.code = code\n self.base = 0\n self.idx = 0\n self.terminated = False\n\n @staticmethod\n def load_code(code_string):\n ...
[ 10, 11, 12, 13, 14 ]
class Account: '''은행계좌를 표현하는 클래스''' def __init__(self,name,account): self.name = name self._balance = amount def __str__(self): return '예금주 {}, 잔고 {}'.format(slef.name, self._balance) def _info(self): print('\t')
normal
{ "blob_id": "2dc4a4ae8e02e823073b1a9711dbd864a54bab43", "index": 5072, "step-1": "class Account:\n '''은행계좌를 표현하는 클래스'''\n \n\n def __init__(self,name,account):\n self.name = name\n self._balance = amount\n\n def __str__(self):\n return '예금주 {}, 잔고 {}'.format(slef.name, self._...
[ 0 ]
from torch import Tensor from torch.autograd import Variable from torch.optim import Adam from maac.utils.misc import hard_update, onehot_from_logits from maac.utils.policies import DiscretePolicy class AttentionAgent(object): """ General class for Attention agents (policy, target policy) """ def __i...
normal
{ "blob_id": "845d04312abc0e64a7810b52bbee333d2bdf3dfb", "index": 7164, "step-1": "<mask token>\n\n\nclass AttentionAgent(object):\n <mask token>\n\n def __init__(self, num_in_pol, num_out_pol, hidden_dim=64, lr=0.01,\n onehot_dim=0):\n \"\"\"\n Inputs:\n num_in_pol (int): nu...
[ 4, 5, 6, 7 ]
#Coded by J. Prabhath #14th April, 2020 #Released under GNU GPL import numpy as np import matplotlib.pyplot as plt from scipy import signal K = 96 Kp = 1 Td = 1.884 s1 = signal.lti([-1/Td],[0,-2,-4,-6], K) s2 = signal.lti([],[0,-2,-4,-6], K) w,mag1,phase1 = signal.bode(s1) _,mag2,phase2 = signal.bode(s2) plt.xlabel...
normal
{ "blob_id": "84e84d9f35702c2572ad5e7daa92a271674986dc", "index": 3882, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.xlabel('Freq (in rad/s)')\nplt.ylabel('Phase (in deg)')\nplt.title('Phase plot')\nplt.semilogx(w, phase1, label='With Controller')\nplt.semilogx(w, phase2, label='Without Controller')...
[ 0, 1, 2, 3, 4 ]
""" Created on Wed Nov 6 13:03:42 2019 @author: antonio.blago """ #%% Connect to database import sqlite3 conn = sqlite3.connect('Portfolio_dividens.db') c = conn.cursor() from sqlalchemy import create_engine #suport pd.dataframe to sql table #import mysqlclient engine = create_engine("sqlite:///Portf...
normal
{ "blob_id": "cee77a97503cca517d03ce7cce189974da282a03", "index": 2500, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(inspect_tables) == 0:\n for k, t in enumerate(tickers):\n ticker_data = pd.DataFrame()\n try:\n ticker_data = wb.DataReader(t, data_source='yahoo', star...
[ 0, 1, 2, 3, 4 ]
from guet.commands.strategies.strategy import CommandStrategy class TooManyArgsStrategy(CommandStrategy): def apply(self): print('Too many arguments.')
normal
{ "blob_id": "afd72ce2d9598f92937f3038eb0ef49b740b9977", "index": 6846, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TooManyArgsStrategy(CommandStrategy):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TooManyArgsStrategy(CommandStrategy):\n\n def apply(self):\n print('To...
[ 0, 1, 2, 3 ]