code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import json
from iamport import Iamport
from django.views import View
from django.http import JsonResponse
from share.decorators import check_auth_decorator
class PaymentView(View):
@check_auth_decorator
def post(self, request):
data = json.loads(request.body)
try:
user = request... | normal | {
"blob_id": "c1c6db4dbd1e6719d30905babd6ccf5b1e76e75d",
"index": 2824,
"step-1": "import json\nfrom iamport import Iamport\n\nfrom django.views import View\nfrom django.http import JsonResponse\n\nfrom share.decorators import check_auth_decorator\n\nclass PaymentView(View):\n @check_auth_decorator\n def p... | [
0
] |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | normal | {
"blob_id": "8e26a6b50539fa5f498aa2079a2625214e5b4d03",
"index": 5919,
"step-1": "<mask token>\n\n\nclass DagRunnableReportingThread(StoppableThread, LoggingMixin):\n\n def __init__(self, async_mode: bool, dag_file_processor_agent, mailbox:\n Mailbox, *args, **kwargs):\n super(DagRunnableReporti... | [
13,
19,
20,
22,
24
] |
import tensorflow as tf
import gensim
import string
import numpy as np
import random
##### prepare data
path = 'stanfordSentimentTreebank/output_50d.txt'
# model_path = 'stanfordSentimentTreebank/output'
# model = gensim.models.Word2Vec.load(model_path)
model = gensim.models.KeyedVectors.load_word2vec_format('/Users/i... | normal | {
"blob_id": "7e461e212d9944c229d1473ea16283d3d036bf55",
"index": 9933,
"step-1": "import tensorflow as tf\nimport gensim\nimport string\nimport numpy as np\nimport random\n\n##### prepare data\npath = 'stanfordSentimentTreebank/output_50d.txt'\n# model_path = 'stanfordSentimentTreebank/output'\n# model = gensim.... | [
0
] |
import collect_from_webapi.api_public_data as pdapi
from collect_from_webapi import pd_fetch_tourspot_visitor
# url = pdapi.pd_gen_url("http://openapi.tour.go.kr/openapi/serviceTourismResourceStatsService/getPchrgTrrsrtVisitorList",
# YM='{0:04d}{1:02d}'.format(2017, 1),
# ... | normal | {
"blob_id": "c6a6b8f2485528af479fadbdf286e82f10a11de8",
"index": 9101,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor items in pd_fetch_tourspot_visitor(district='서울특별시', year=2017, month=7):\n print(items)\n<mask token>\nprint(item)\n",
"step-3": "<mask token>\nfor items in pd_fetch_tourspot_vi... | [
0,
1,
2,
3,
4
] |
def SimpleSymbols(str):
if str[0].isalpha() and str[-1].isalpha():
return "false"
for i in range(0, len(str)):
if str[i].isalpha():
if str[i-1] == '+' and str[i+1] == '+':
return "true"
return "false"
# keep this function call here
# to see how to enter arguments in Python scrol... | normal | {
"blob_id": "d3a22cad850e895950ce322aac393b31758a2237",
"index": 7157,
"step-1": "def SimpleSymbols(str): \n if str[0].isalpha() and str[-1].isalpha():\n return \"false\"\n for i in range(0, len(str)):\n if str[i].isalpha():\n if str[i-1] == '+' and str[i+1] == '+':\n return \"true\"\n retur... | [
0
] |
import sys
import smtplib
from email.mime.text import MIMEText
from email.utils import formatdate
from ... import config
def create_message(from_addr, to_addr, subject, message, encoding):
body = MIMEText(message, 'plain', encoding)
body['Subject'] = subject
body['From'] = from_addr
body['To'] = to_add... | normal | {
"blob_id": "237724db5130926123a3a31be7070947ec7b01f3",
"index": 3492,
"step-1": "<mask token>\n\n\ndef create_message(from_addr, to_addr, subject, message, encoding):\n body = MIMEText(message, 'plain', encoding)\n body['Subject'] = subject\n body['From'] = from_addr\n body['To'] = to_addr\n body... | [
2,
3,
4,
5,
6
] |
import json
import os
from lib.create import create_server, create_user
os.chdir(r'/home/niko/data/Marvin')
def edit_user_stats(server_id: str, user_id: str, stat: str, datas):
create_user(server_id, user_id)
if os.path.isfile("Server/{}/user.json".format(server_id)):
with open("Server/{}... | normal | {
"blob_id": "e6d506dd45e72ee7f0162a884981ee1156153d3d",
"index": 8661,
"step-1": "<mask token>\n\n\ndef edit_user_stats(server_id: str, user_id: str, stat: str, datas):\n create_user(server_id, user_id)\n if os.path.isfile('Server/{}/user.json'.format(server_id)):\n with open('Server/{}/user.json'.f... | [
5,
6,
7,
8,
9
] |
#Get roll numbers, name & marks of the students of a class(get from user) and store these details in a file- marks.txt
count = int(input("How many students are there in class? "))
fileObj = open('marks.txt',"w")
for i in range(count):
print("Enter details for student",(i+1),"below:")
rollNo = int(input("Rolln... | normal | {
"blob_id": "74cb06ffa41748af431b46c9ff98eb91771a5015",
"index": 537,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(count):\n print('Enter details for student', i + 1, 'below:')\n rollNo = int(input('Rollno: '))\n name = input('Name: ')\n marks = float(input('Marks: '))\n r... | [
0,
1,
2,
3
] |
# coding: utf-8
"""
Created on Mon Oct 29 12:57:40 2018
@authors Jzhu, Lrasmy , Xin128 @ DeguiZhi Lab - UTHealth SBMI
Last updated Feb 20 2020
"""
#general utilities
from __future__ import print_function, division
from tabulate import tabulate
import numpy as np
import random
import matplotlib.pyplot as plt
try:
... | normal | {
"blob_id": "0cef70b8d661fe01ef4a1eda83a21e1186419a0d",
"index": 5038,
"step-1": "<mask token>\n\n\nclass EHRdataFromPickles(Dataset):\n\n def __init__(self, root_dir, file=None, transform=None, sort=True,\n model='RNN', test_ratio=0, valid_ratio=0):\n \"\"\"\n Args:\n 1) root_... | [
15,
16,
17,
18,
19
] |
#!/bin/env python
import sys
import os
import collections
import re
import json
import urllib
import urllib.request
import uuid
import time
PROCESSOR_VERSION = "0.1"
def process(trace_dir, out_dir):
#order files
trace_files = os.listdir(trace_dir)
trace_files = sorted(trace_files)
if trace_files[0] ==... | normal | {
"blob_id": "4b83887e8d8e5c5dc7065354d24044d3c3a48714",
"index": 3387,
"step-1": "<mask token>\n\n\ndef process(trace_dir, out_dir):\n trace_files = os.listdir(trace_dir)\n trace_files = sorted(trace_files)\n if trace_files[0] == 'error.log':\n print('Rotating to properly order logs.')\n t... | [
2,
3,
4,
5,
6
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import phpserialize
import urllib2
from cache import cache
from config import config
def block(request, limit=None):
try:
links = cache.get_cache("sape", expire=3600).get(key="links", createfunc=load_links)
except:
links = cache.get_cache("sape", expi... | normal | {
"blob_id": "6d5acaa4a60b646432feb59f4d8eb9c9d0dceb0f",
"index": 1151,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef block(request, limit=None):\n try:\n links = cache.get_cache('sape', expire=3600).get(key='links',\n createfunc=load_links)\n except:\n links = cach... | [
0,
1,
2,
3,
4
] |
def get_ecgs_by_query(json_data, query):
ecgs_ids = []
for case_id in json_data.keys():
print(case_id)
if query.is_query_ok(json_data[case_id]):
ecgs_ids.append(case_id)
return ecgs_ids
def save_new_dataset_by_ids(old_json, ecg_ids_to_save, name_new_dataset):
"""
Saves... | normal | {
"blob_id": "445ae195edfe9fe9ee58c6c5a14ec787719d698c",
"index": 7454,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef save_new_dataset_by_ids(old_json, ecg_ids_to_save, name_new_dataset):\n \"\"\"\n Saves json only with selected (by id) patients.\n :param old_json: initail dataset dict\n... | [
0,
1,
2,
3
] |
import tensorflow as tf
from sklearn.cluster import KMeans
import tensorflow.keras as keras
from copy import deepcopy
import numpy as np
import h5py
from collections import defaultdict, namedtuple
from heapq import heappush, heappop, heapify
import struct
tf.enable_eager_execution()
mnist = tf.keras.datasets.mnist
(x... | normal | {
"blob_id": "086aefaad7a4b743e5a05b3a44db971dbdbf16b6",
"index": 8299,
"step-1": "<mask token>\n\n\ndef prune_weights(weight):\n for i in range(weight.shape[-1]):\n tmp = deepcopy(weight[..., i])\n tmp = np.abs(tmp)\n tmp = np.sort(np.array(tmp))\n threshold = tmp[int(tmp.shape[0] ... | [
2,
4,
5,
6,
10
] |
from django import template
from django.conf import settings
from django.utils.html import escape
from django.utils.translation import get_language
from cms.models import Page
from cms.conf.global_settings import LANGUAGE_NAME_OVERRIDE
register = template.Library()
# TODO: There's some redundancy here
# TODO: {% cms... | normal | {
"blob_id": "d2acc789224d66de36b319ae457165c1438454a3",
"index": 3392,
"step-1": "from django import template\nfrom django.conf import settings\nfrom django.utils.html import escape\nfrom django.utils.translation import get_language\n\nfrom cms.models import Page\nfrom cms.conf.global_settings import LANGUAGE_NA... | [
0
] |
def chessKnight(cell):
pivot = "abcdefgh"
count = 8
for i in range(len(pivot)):
if cell[0] == pivot[i]:
vertical_4 , vertical_2 = False , False
if int(cell[1]) == 8 or int(cell[1]) == 1:
vertical_4 = True
count -= 4
elif int(cell[1]... | normal | {
"blob_id": "c1335a8128ad4ba6ce6942e80f3c8b68a4210902",
"index": 6355,
"step-1": "<mask token>\n",
"step-2": "def chessKnight(cell):\n pivot = 'abcdefgh'\n count = 8\n for i in range(len(pivot)):\n if cell[0] == pivot[i]:\n vertical_4, vertical_2 = False, False\n if int(ce... | [
0,
1,
2
] |
import types
from robot.libraries.BuiltIn import BuiltIn
def GetAllVariableBySuffix (endswith):
all_vars = BuiltIn().get_variables()
result = {}
for var_name, var in all_vars.items():
#print var_name
if var_name.endswith(endswith+"}"):
print var_name
#print var
def ... | normal | {
"blob_id": "e9de42bb8ed24b95e5196f305fe658d67279c078",
"index": 3915,
"step-1": "import types\nfrom robot.libraries.BuiltIn import BuiltIn\n\ndef GetAllVariableBySuffix (endswith):\n all_vars = BuiltIn().get_variables()\n result = {}\n for var_name, var in all_vars.items():\n #print var_name\n ... | [
0
] |
from soppa.contrib import *
class ModD(Soppa):
needs = ['test_project.modf']
something = 1
| normal | {
"blob_id": "13da16ba89e4743b12d9b8e24929864747f8bbf2",
"index": 1308,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ModD(Soppa):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ModD(Soppa):\n needs = ['test_project.modf']\n something = 1\n",
"step-4": "fro... | [
0,
1,
2,
3
] |
from azureml.core import Workspace
from azureml.pipeline.core import Pipeline
from azureml.core import Experiment
from azureml.pipeline.steps import PythonScriptStep
import requests
ws = Workspace.from_config()
# Step to run a Python script
step1 = PythonScriptStep(
name = "prepare data",
source_di... | normal | {
"blob_id": "4a7f8221208e8252c7f5c0adff2949f0e552def1",
"index": 775,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(rest_endpoint)\n<mask token>\nprint(run_id)\n",
"step-3": "<mask token>\nws = Workspace.from_config()\nstep1 = PythonScriptStep(name='prepare data', source_directory='scripts',\n ... | [
0,
1,
2,
3,
4
] |
'''
Author: Dustin Spicuzza
Date: 3/22/2012
Description:
This mode only feeds another robot, does not move or anything
'''
class FeedOnlyAutonomousMode(object):
# this name should be descriptive and unique. This will be shown to the user
# on the SmartDashboard
MODE_NAME = ... | normal | {
"blob_id": "3596ef12ce407a8d84319daa38a27a99ed0de763",
"index": 5208,
"step-1": "<mask token>\n\n\nclass FeedOnlyAutonomousMode(object):\n <mask token>\n <mask token>\n <mask token>\n\n def OnEnable(self):\n \"\"\"\n This function is called when Autonomous mode is enabled. You shou... | [
3,
4,
5,
6,
7
] |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from abc import ABCMeta, abstractmethod
import numpy as np
from deeprl.trainers import BaseTrainer
from deeprl.callbacks import EGreedyDecay
from deeprl.policy import EGreedyPolicy
class BaseDQNTrainer(BaseTra... | normal | {
"blob_id": "8bf0141cee2832134d61e49652330c7d21583dcd",
"index": 5201,
"step-1": "<mask token>\n\n\nclass BaseDQNTrainer(BaseTrainer):\n <mask token>\n <mask token>\n <mask token>\n\n def update_model(self, batch):\n batch_s = np.array([i[0] for i in batch])\n batch_a = np.array([i[1] f... | [
3,
4,
6,
7
] |
#!/usr/bin/env python3
"""
02-allelefreq.py <vcf file>
"""
import sys
import matplotlib.pyplot as plt
import pandas as pd
vcf = open(sys.argv[1])
maf = []
for line in vcf:
if "CHR" in line:
continue
cols = line.rstrip("\n").split()
values = float(cols[4])
maf.append(values)
fig, ax = pl... | normal | {
"blob_id": "dd79ffe3922494bcc345aec3cf76ed9efeb5185c",
"index": 3916,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in vcf:\n if 'CHR' in line:\n continue\n cols = line.rstrip('\\n').split()\n values = float(cols[4])\n maf.append(values)\n<mask token>\nax.hist(maf, bins=100,... | [
0,
1,
2,
3,
4
] |
# Generated by Django 3.0.8 on 2020-08-28 17:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0003_auto_20200828_1836'),
]
operations = [
migrations.AddField(
model_name='order',
name='total',
... | normal | {
"blob_id": "1f7d770106ea8e7d1c0bb90e1fc576b7ee2f0220",
"index": 381,
"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 = [('shop', '0003... | [
0,
1,
2,
3,
4
] |
import cv2
import numpy as np
"""
# Create a black image
image = np.zeros((512,512,3), np.uint8)
# Can we make this in black and white?
image_bw = np.zeros((512,512), np.uint8)
cv2.imshow("Black Rectangle (Color)", image)
cv2.imshow("Black Rectangle (B&W)", image_bw)
cv2.waitKey(0)
cv2.destroyAllWindows()
image = ... | normal | {
"blob_id": "693f2a56578dfb1e4f9c73a0d33c5585070e9f9e",
"index": 5371,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncv2.putText(image, 'Hello World!', (75, 290), cv2.FONT_HERSHEY_COMPLEX, 2,\n (100, 170, 0), 3)\ncv2.imshow('Hello World!', image)\ncv2.imwrite('Text.jpg', image)\ncv2.waitKey(0)\ncv2.d... | [
0,
1,
2,
3,
4
] |
from functools import reduce
from math import (log, sqrt)
import matplotlib.pyplot as plt
import matplotlib.pylab as mlab
import numpy
import random
import scipy.stats
class Node:
def __init__(
self,
name,
val=None,
observed=False,
candidate_standard_devi... | normal | {
"blob_id": "4c5db1af9fd1c9b09f6e64a44d72351807c0f7a5",
"index": 8136,
"step-1": "<mask token>\n\n\nclass Node:\n <mask token>\n <mask token>\n <mask token>\n\n def save_sample(self, val):\n if self.file:\n self.file.write('{}\\n'.format(self.val))\n\n def sample(self, isBurn=Fal... | [
18,
19,
23,
24,
26
] |
from django.core import management
from django.conf import settings
def backup_cron():
if settings.DBBACKUP_STORAGE is not '':
management.call_command('dbbackup')
| normal | {
"blob_id": "ae9f1c4f70801dace0455c051ba4d4bfb7f3fe67",
"index": 4813,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef backup_cron():\n if settings.DBBACKUP_STORAGE is not '':\n management.call_command('dbbackup')\n",
"step-3": "from django.core import management\nfrom django.conf impo... | [
0,
1,
2
] |
#/usr/bin/python
# File: UdpClient.py
# Author: David Zemon
# Project: Project1
#
# Created with: PyCharm Community Edition
"""
@description:
"""
__author__ = 'david'
import logging
from src.UDP import UDPClient
logging.basicConfig(level="DEBUG")
serverName = '127.0.0.1'
serverPort = 12000
client = UDPClient()... | normal | {
"blob_id": "4d388c912915c3f1f9e433f1342289f0864b3a11",
"index": 409,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlogging.basicConfig(level='DEBUG')\n<mask token>\nclient.sendto(message.encode('utf-8'), (serverName, serverPort))\n<mask token>\nprint(modifiedMessage.decode('utf-8'))\nclient.close()\n",... | [
0,
1,
2,
3,
4
] |
from flask import Blueprint
application_vue_demo = Blueprint('application_vue_demo', __name__)
from . import views
| normal | {
"blob_id": "a33abd253288140f8051aced1d0ed1e41b2fc786",
"index": 8067,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napplication_vue_demo = Blueprint('application_vue_demo', __name__)\n<mask token>\n",
"step-3": "from flask import Blueprint\napplication_vue_demo = Blueprint('application_vue_demo', __n... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 9 18:52:17 2021
@author: lewis
"""
import csv
import pandas as pd
import re
import statistics
import matplotlib.pyplot as plt
import numpy as np
from bs4 import BeautifulSoup
from urllib.request import urlopen
#Creating a function that groups by, co... | normal | {
"blob_id": "30b07e57737ac29643769c4773591199b2ba8656",
"index": 2184,
"step-1": "<mask token>\n\n\ndef groupby_count(df, groupby_column, count_column):\n new_df = pd.DataFrame(df.groupby(groupby_column)[count_column].count())\n new_df.columns = ['count']\n new_df[groupby_column] = new_df.index.get_leve... | [
2,
3,
4,
5,
6
] |
a = [1, 1, 2, 3, 4, 4, 5, 7, 12, 30, 49]
for i in range(0, len(a)):
if a[i] < 5:
print(str(a[i]) + " ")
i += 1
else:
i += 1
| normal | {
"blob_id": "24635989ccdb0f35f1e618dd8dc07f2cf84faddb",
"index": 6621,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(0, len(a)):\n if a[i] < 5:\n print(str(a[i]) + ' ')\n i += 1\n else:\n i += 1\n",
"step-3": "a = [1, 1, 2, 3, 4, 4, 5, 7, 12, 30, 49]\nfor i in... | [
0,
1,
2,
3
] |
from ..IReg import IReg
class RC165(IReg):
def __init__(self):
self._header = ['REG',
'COD_PART',
'VEIC_ID',
'COD_AUT',
'NR_PASSE',
'HORA',
'TEMPER',
... | normal | {
"blob_id": "bf73e2109f11b2214fae060bc343b01091765c2a",
"index": 2325,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass RC165(IReg):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass RC165(IReg):\n\n def __init__(self):\n self._header = ['REG', 'COD_PART', 'VEIC_ID', 'COD_AUT',... | [
0,
1,
2,
3,
4
] |
from core.models import Atom
from core.models.vector3d import cVector3D
from fractions import Fraction
class SpaceGroup(object):
def __init__(self,
index=None,
name=None,
lattice_system=None,
lattice_centering=None,
inversion=Non... | normal | {
"blob_id": "88731049227629ed84ff56922d7ac11d4a137984",
"index": 5376,
"step-1": "<mask token>\n\n\nclass Centering(object):\n\n def __init__(self, letter, additional_lattice_points):\n self.letter = letter\n self.additional_lattice_points = additional_lattice_points\n\n def transform(self, o... | [
15,
28,
33,
34,
44
] |
#!/usr/bin/env python3
import sys
import cksm
from pathlib import Path
VIRTUAL_TO_ROM = 0x800ff000
def patch_rom(rom_path, payload_path, c_code_path, entry_code_path, out_path):
rom = list(Path(rom_path).read_bytes())
payload = list(Path(payload_path).read_bytes())
c_code = list(Path(c_code_path).read_b... | normal | {
"blob_id": "f566c42674728f1874d89b15102627c3b404c9a0",
"index": 3534,
"step-1": "<mask token>\n\n\ndef patch_rom(rom_path, payload_path, c_code_path, entry_code_path, out_path):\n rom = list(Path(rom_path).read_bytes())\n payload = list(Path(payload_path).read_bytes())\n c_code = list(Path(c_code_path)... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/python
import sys
import os
class ParseError(Exception):
pass
def remove_inline_comments(text):
ret = []
in_comment_block = False
p = 0
while True:
if (op := text.find('/*', p)) > 0:
in_comment_block = True
if op != p:
ret.append(text[p... | normal | {
"blob_id": "11e9e4dd5c9c6158fed40080d4cc221f28a0eba0",
"index": 8097,
"step-1": "<mask token>\n\n\nclass AIns:\n <mask token>\n <mask token>\n\n\nclass CIns:\n comp = {'0': '101010', '1': '111111', '-1': '111010', 'D': '001100',\n 'A': '110000', 'M': '110000', '!D': '001101', '!A': '110001', '!M... | [
9,
14,
15,
16,
19
] |
# Generated by Django 3.2 on 2021-04-20 13:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('excursions', '0003_auto_20210420_1608'),
]
operations = [
migrations.AlterField(
model_name='exscursion',
name='type',... | normal | {
"blob_id": "a048396019aa7603a20535a3ce4bc9770509097d",
"index": 2291,
"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 = [('excursions'... | [
0,
1,
2,
3,
4
] |
print((9*int(input())/5)+32) | normal | {
"blob_id": "4e9a968842c2b3eca79690f0b56c8e176b203138",
"index": 362,
"step-1": "<mask token>\n",
"step-2": "print(9 * int(input()) / 5 + 32)\n",
"step-3": "print((9*int(input())/5)+32)",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
#!/usr/bin/env python
"""
This is a Cog used to display processes/ programs running on the client to a discord text channel
Commented using reStructuredText (reST)
ToDo
create and use a database for multiple servers
"""
# Futures
# Built-in/Generic Imports
import os
import sys
import configparser
import shutil
... | normal | {
"blob_id": "8dfef0a4525328be8dfb4723f0a168dc22eb5eb2",
"index": 520,
"step-1": "<mask token>\n\n\nclass ProcessDisplay(commands.Cog):\n <mask token>\n <mask token>\n\n @commands.Cog.listener()\n async def on_ready(self):\n \"\"\"\n Ran when bot is starting up and ready\n Deletes... | [
2,
4,
6,
9,
11
] |
""" mupub module.
"""
__all__ = (
'__title__', '__summary__', '__version__',
'__author__', '__license__', '__copyright__',
)
__title__ = 'mupub'
__summary__ = 'Musical score publishing utility for the Mutopia Project'
"""Versioning:
This utility follows a MAJOR . MINOR . EDIT format. Upon a major
release, t... | normal | {
"blob_id": "eabf06481509962652812af67ad59da5cfe30fae",
"index": 1,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ('__title__', '__summary__', '__version__', '__author__',\n '__license__', '__copyright__')\n__title__ = 'mupub'\n__summary__ = 'Musical score publishing utility for the Mutopia... | [
0,
1,
2,
3
] |
import os
os.mkdir("作业")
f=open("D:/six3/s/作业/tet.txt",'w+')
for i in range(10):
f.write("hello world\n")
f.seek(0)
s=f.read(100)
print(s)
f=open("D:/six3/s/作业/tet2.txt",'w+')
for i in s:
f.write(i)
f.close() | normal | {
"blob_id": "5f5e314d2d18deb12a8ae757a117ef8fbb2ddad5",
"index": 2391,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nos.mkdir('作业')\n<mask token>\nfor i in range(10):\n f.write('hello world\\n')\nf.seek(0)\n<mask token>\nprint(s)\n<mask token>\nfor i in s:\n f.write(i)\nf.close()\n",
"step-3": "... | [
0,
1,
2,
3,
4
] |
#######################
# PYMERGE V.1.1 #
#######################
# Samuel Farrens 2014 #
#######################
"""@file pycatcut.v.1.1
@brief Code that merges cluster catalogues into a single catalogue.
@author Samuel Farrens
"""
import math, optparse, numpy as np
import errors
from classes.cluster import Cl... | normal | {
"blob_id": "e81294c984497dbba9fa345b61abb8d781f136bf",
"index": 9506,
"step-1": "#######################\n# PYMERGE V.1.1 #\n#######################\n# Samuel Farrens 2014 #\n#######################\n\n\"\"\"@file pycatcut.v.1.1\n@brief Code that merges cluster catalogues into a single catalogue.\n@author... | [
0
] |
# -*- coding: utf-8 -*-
# Scrapy settings for reddit_scraper project
#
# For simplicity, this file contains only the most important settings by
# default. All the other settings are documented here:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
#
BOT_NAME = 'reddit_scraper'
SPIDER_MODULES = ['reddit_s... | normal | {
"blob_id": "a352768c2928cb7a33b9f1a31a0b3d8e56a8376a",
"index": 5588,
"step-1": "<mask token>\n",
"step-2": "BOT_NAME = 'reddit_scraper'\nSPIDER_MODULES = ['reddit_scraper.spiders']\nNEWSPIDER_MODULE = 'reddit_scraper.spiders'\n",
"step-3": "# -*- coding: utf-8 -*-\n\n# Scrapy settings for reddit_scraper pr... | [
0,
1,
2
] |
# ------------------------------------#
# Title: Mailroom Part 1
# Dev: SChang
# Date: Feb 2nd, 2019
# ChangeLog: (Who, When, What)
# SChang,02/02/2019, Created Script
# ------------------------------------#
import os
import sys
import math
donor_list = {"William Gates": [1010, 2020, 3030],
... | normal | {
"blob_id": "f2292d1816699392663bdbf7a06c334de3b2022c",
"index": 7118,
"step-1": "<mask token>\n\n\ndef send_ty():\n DonorName = 'list'\n while DonorName == 'list':\n DonorName = input(\n '\"Provide Donor Full Name, or type: \"List\" to display a list of all donors => '\n )\n ... | [
7,
9,
10,
12,
13
] |
# Generated by Django 2.1.2 on 2018-11-05 12:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('PDPAPI', '0011_auto_20181105_1021'),
]
operations = [
migrations.RemoveField(
model_name='optionvoting',
name='total... | normal | {
"blob_id": "53519c704ca9aff62140f187d4246208350fa9ba",
"index": 4610,
"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 = [('PDPAPI', '0... | [
0,
1,
2,
3,
4
] |
from appConfig.App import app, db
import os
dbDir = os.path.dirname(__file__)
# staticFolder = '%sstatic' % os.sep
dbDir = '%s%sappConfig%smine.db' % (dbDir, os.sep, os.sep)
if not os.path.exists(dbDir):
# 创建数据库并创建表
db.create_all()
# app._static_folder = staticFolder
@app.route('/')
def hello_world():
... | normal | {
"blob_id": "71cee06ce697030fd0cea363ddecaa411b39544d",
"index": 4330,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef hello_world():\n return 'Hello Waeweorld!'\n\n\n<mask token>\n",
"step-2": "<mask token>\nif not os.path.exists(dbDir):\n db.create_all()\n\n\n@app.route('/')\ndef hello_world():\n ... | [
1,
2,
3,
4,
5
] |
import dash
import dash_html_components as html
app = dash.Dash(__name__)
app.layout = html.H1("Hello dashboard")
if __name__ == "__main__":
app.run_server(debug=False, port=8080, host="127.0.0.1")
| normal | {
"blob_id": "b66f588149d160c119f9cc24af3acb9f64432d6e",
"index": 6014,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n app.run_server(debug=False, port=8080, host='127.0.0.1')\n",
"step-3": "<mask token>\napp = dash.Dash(__name__)\napp.layout = html.H1('Hello dashboard')\... | [
0,
1,
2,
3,
4
] |
from django.test import TestCase
from ..models import FearConditioningData, FearConditioningModule
from ..registry import DataViewsetRegistry, ModuleRegistry
class ModuleRegistryTest(TestCase):
def test_register_module_create_view(self) -> None:
registry = ModuleRegistry()
registry.register(Fear... | normal | {
"blob_id": "14cc048f517efd3dad9960f35fff66a78f68fb45",
"index": 8975,
"step-1": "<mask token>\n\n\nclass DataViewsetRegistryTest(TestCase):\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass DataViewsetRegistryTest(TestCase):\n\n def test_register_data_model(self) ->None:\n registry = DataView... | [
1,
2,
4,
5,
6
] |
import os
import numpy as np
import pycuda
import pycuda.driver as driver
import cudasim.solvers.cuda.Simulator_mg as sim
import cudasim
class Lsoda(sim.SimulatorMG):
_param_tex = None
_step_code = None
_runtimeCompile = True
_lsoda_source_ = """
extern "C"{
#include <stdio.h>
... | normal | {
"blob_id": "e9754530bef7614c16cdba0e818c1fa188e2d9a2",
"index": 9940,
"step-1": "<mask token>\n\n\nclass Lsoda(sim.SimulatorMG):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def _compile(self, step_code):\n self._beta = 1\n fc = open(os.path.join(os.path.split(os.... | [
2,
3,
4,
5,
6
] |
#SEE /etc/rc.local FOR BOOTUP COMMANDS
from Measure_and_File import *
from WebServer import *
from multiprocessing import *
web = WebServer()
board_boy = Measurer_and_Filer()
#try:
proc1 = Process( target=board_boy.measure_and_file, args=() )
proc1.start()
proc2 = Process( target=web.serve, args=() )
proc2.start()
#... | normal | {
"blob_id": "26744d51dbce835d31d572a053294c9d280e1a8b",
"index": 3956,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nproc1.start()\n<mask token>\nproc2.start()\n",
"step-3": "<mask token>\nweb = WebServer()\nboard_boy = Measurer_and_Filer()\nproc1 = Process(target=board_boy.measure_and_file, args=())\... | [
0,
1,
2,
3,
4
] |
##outcome: Hello, my name is B-max
print("Hello", end="")
print(", my name ", end="")
print("is B-max", end="")
print()
##outcome: ****************************************
for i in range(40):
print('*', end="")
print()
##outcome: x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*
for i in range(20):
print("x*", en... | normal | {
"blob_id": "41aebc4ee9cb058c3351029773be05cdc4f84ffa",
"index": 7282,
"step-1": "<mask token>\n",
"step-2": "print('Hello', end='')\nprint(', my name ', end='')\nprint('is B-max', end='')\nprint()\nfor i in range(40):\n print('*', end='')\nprint()\nfor i in range(20):\n print('x*', end='')\nprint()\nfor... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Customer',
fields=[
('id', models.AutoField(ver... | normal | {
"blob_id": "6bc400896c004f0fdddbbd3dd73ef9aaa19eb4db",
"index": 1053,
"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 = []\n operat... | [
0,
1,
2,
3,
4
] |
def solution(S):
# write your code in Python 3.6
# Definitions
log_sep = ','
num_sep = '-'
time_sep = ':'
# Initialization
from collections import defaultdict
# defaultdict initialize missing key to default value -> 0
bill = defaultdict(int)
total = defaultdict(int)
calls = S... | normal | {
"blob_id": "bf8bbeb408cb75af314ef9f3907456036e731c0b",
"index": 294,
"step-1": "<mask token>\n",
"step-2": "def solution(S):\n log_sep = ','\n num_sep = '-'\n time_sep = ':'\n from collections import defaultdict\n bill = defaultdict(int)\n total = defaultdict(int)\n calls = S.splitlines()... | [
0,
1,
2
] |
from abc import ABCMeta, abstractmethod, ABC
from domain.models.network_information import NetworkInformation
class AbstractTensorboardExportService(ABC):
__metaclass__ = ABCMeta
@abstractmethod
def save_tensorboard(self, network_info: NetworkInformation) ->None:
raise NotImplementedError
| normal | {
"blob_id": "08c3155a5fbf6c94f5885c12cfc7c917313ae9c7",
"index": 5929,
"step-1": "<mask token>\n\n\nclass AbstractTensorboardExportService(ABC):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass AbstractTensorboardExportService(ABC):\n <mask token>\n\n @abstractmethod\n def sa... | [
1,
2,
3,
4
] |
# coding: utf-8
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import time
import random
csvfilename = 'data/0901/exp1/xiaoxiong.csv'
df = pd.read_csv(csvfilename, header=None,
names=['abstime','posx','posy','posz','roty','rotx','anim'... | normal | {
"blob_id": "d0adbcd60727c2c68e06dc5e796f2676f927c45a",
"index": 4593,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndf.head()\n<mask token>\nprint(m)\n<mask token>\nprint(mean)\nfor i in mean:\n random.seed(1)\n randomFactor = [(random.random() * 0.01 + (i - 0.005)) for _ in range(m)]\n for id... | [
0,
1,
2,
3,
4
] |
import math3d
import math
import pygame
import random
class PBody(object):
""" A physics-enabled object. """
def __init__(self, pos, mass=1, rad=10, vel=(0,0), color=(255,255,255)):
self.pos = math3d.VectorN(pos)
self.vel = math3d.VectorN(vel)
self.rad = 10 # in pixe... | normal | {
"blob_id": "2238345a69c2d7a1958a23a470dcb2be6469caeb",
"index": 6643,
"step-1": "<mask token>\n\n\nclass PBody(object):\n <mask token>\n <mask token>\n <mask token>\n\n def update(self, dT):\n \"\"\" Updates our object:\n 1. Changes position due to current velocity.\n 2.... | [
8,
11,
12,
13,
16
] |
"""
Stores custom FASTA sequences under a uuid in the database.
Part of the tables used for custom jobs.
"""
import uuid
from pred.webserver.errors import ClientException, ErrorType, raise_on_too_big_uploaded_data
from pred.queries.dbutil import update_database, read_database
from Bio import SeqIO
from io import String... | normal | {
"blob_id": "2e744c0cbddf64a9c538c9f33fa19ff78c515012",
"index": 6797,
"step-1": "<mask token>\n\n\nclass SequenceList(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def delete_old_and_unattached(cur... | [
8,
14,
15,
16,
17
] |
# aitoff projection
# see:
# https://en.wikipedia.org/wiki/Aitoff_projection
def aitoff_projection(theta, phi):
import numpy as np
# theta, phi in radian
theta = theta - np.pi
cos_phi = np.cos(phi)
denom = np.sqrt(1 + cos_phi * np.cos(theta/2))
x = 180 * cos_phi * np.sin(theta/2) / denom
x =... | normal | {
"blob_id": "0dcf90514543a1ca801e82cd402b3e1002b1f5d0",
"index": 9262,
"step-1": "<mask token>\n",
"step-2": "def aitoff_projection(theta, phi):\n import numpy as np\n theta = theta - np.pi\n cos_phi = np.cos(phi)\n denom = np.sqrt(1 + cos_phi * np.cos(theta / 2))\n x = 180 * cos_phi * np.sin(th... | [
0,
1,
2
] |
#!/usr/bin/env python
from pathlib import Path
import os
from setuptools import setup, find_packages
install_requires = [
"numpy",
"tensorflow-hub==0.4.0",
"bert-tensorflow==1.0.1",
"click"
]
# Hacky check for whether CUDA is installed
has_cuda = any("CUDA" in name.split("_") for name in os.environ.... | normal | {
"blob_id": "a1141e6aae6992a5037d53093378f0d346f2ca29",
"index": 7666,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ninstall_requires.append('tensorflow-gpu==1.13.1' if has_cuda else\n 'tensorflow==1.13.1')\n<mask token>\nsetup(name='easybert', version=version, url=\n 'https://github.com/robrua/ea... | [
0,
1,
2,
3,
4
] |
class Solution:
def maximumTime(self, time: str) ->str:
ans = ''
for i in range(5):
if time[i] != '?':
ans += time[i]
continue
if i == 0:
if time[1] in ['0', '1', '2', '3', '?']:
ans += '2'
e... | normal | {
"blob_id": "e7494104ab98df2b640f710fa69584802b3e1259",
"index": 3032,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def maximumTime(self, time: str) ->str:\n ans = ''\n for i in range(5):\n if time[i] != '?':\n ... | [
0,
1,
2
] |
# Licensed under a 3-clause BSD style license - see LICENSE.rst
import pytest
from sbpy.data import Phys
from sbpy import bib
@pytest.mark.remote_data
def test_from_sbdb():
""" test from_horizons method"""
# query one object
data = Phys.from_sbdb('Ceres')
assert len(data.table) == 1
# query se... | normal | {
"blob_id": "0bfb089556bfa253bf139f03cd3079ced962d858",
"index": 1021,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.mark.remote_data\ndef test_from_sbdb():\n \"\"\" test from_horizons method\"\"\"\n data = Phys.from_sbdb('Ceres')\n assert len(data.table) == 1\n data = Phys.from_... | [
0,
1,
2,
3
] |
users = {
'Students': [
{'first_name': 'Michael', 'last_name' : 'Jordan'},
{'first_name' : 'John', 'last_name' : 'Rosales'},
{'first_name' : 'Mark', 'last_name' : 'Guillen'},
{'first_name' : 'KB', 'last_name' : 'Tonel'}
],
'Instructors': [
{'first_name' : 'Michael', 'last_name' : 'Choi'},
... | normal | {
"blob_id": "c0f4f9eef12d99d286f5ad56f6554c5910b7cc71",
"index": 8356,
"step-1": "users = {\n 'Students': [\n {'first_name': 'Michael', 'last_name' : 'Jordan'},\n {'first_name' : 'John', 'last_name' : 'Rosales'},\n {'first_name' : 'Mark', 'last_name' : 'Guillen'},\n {'first_name' : 'KB', 'last_n... | [
0
] |
import datetime
a = datetime.datetime.now()
while True:
print("""\
Welcome to HMS
1. Are you want enter data
2. Are you want see record
3. exit
""")
option = int(input("enter your option"))
print(option)
if option == 1:
print("""\
Select client na... | normal | {
"blob_id": "5c5a0fd67a6d6e805b77ddfddfe959335daa3bad",
"index": 6383,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n print(\n \"\"\" Welcome to HMS\n 1. Are you want enter data\n 2. Are you want see record\n 3. exit\n \"\"\"\n )\n opti... | [
0,
1,
2,
3,
4
] |
import Utility
import copy
class Ratio_Execution_Time:
utility = None
def __init__(self):
self.utility = Utility.Utility()
print("Successfully Found Ration Corrssponding to Execution Time")
def calculatePercentage(self,B,total,strr):
E = {}
for i in B:
... | normal | {
"blob_id": "150603004a4b194a7c08f1f23e37c613aa3b883a",
"index": 6431,
"step-1": "<mask token>\n\n\nclass Ratio_Execution_Time:\n <mask token>\n <mask token>\n\n def calculatePercentage(self, B, total, strr):\n E = {}\n for i in B:\n s = ''\n for j in range(i[0], i[1]... | [
3,
5,
7,
8,
10
] |
import random
a = input('Nome do primeiro aluno: ')
b = input('Nome do segundo aluno: ')
c = input('Nome do terceiro aluno: ')
d = input('Nome do quarto aluno: ')
names = [a, b, c, d]
print('O aluno escolhido é {}.'.format(random.choice(names)))
| normal | {
"blob_id": "bac3cee5e6d129fcf345d92000cb2a257c303dd5",
"index": 9805,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('O aluno escolhido é {}.'.format(random.choice(names)))\n",
"step-3": "<mask token>\na = input('Nome do primeiro aluno: ')\nb = input('Nome do segundo aluno: ')\nc = input('Nome d... | [
0,
1,
2,
3
] |
import logging
import subprocess
from pathlib import Path
from typing import Union
from git import Repo
def init_repo(metadata: str, path: str, deep_clone: bool) -> Repo:
clone_path = Path(path)
if not clone_path.exists():
logging.info('Cloning %s', metadata)
repo = (Repo.clone_from(metadata, ... | normal | {
"blob_id": "cb2dd08a09d2e39bd83f82940c3d9a79a5a27918",
"index": 6523,
"step-1": "<mask token>\n\n\ndef init_ssh(key: str, key_path: Path) ->None:\n if not key:\n logging.warning('Private Key required for SSH Git')\n return\n logging.info('Private Key found, writing to disk')\n key_path.mk... | [
1,
2,
3,
4,
5
] |
#coding=utf-8
from numpy import *
#代码5-1,Logistic回归梯度上升优化算法。
def loadDataSet():
"""解析文件
Return: dataMat 文档列表 [[1,x1,x2]...]; labelMat 类别标签列表[1,0,1...]
@author:VPrincekin
"""
dataMat = []; labelMat= []
fr = open('testSet.txt')
#每行前两个分别是X1和X2,第三个只是数据对应的类别
for line in fr.readlines():
... | normal | {
"blob_id": "d47ea763ac1a4981fc5dee67cd396ad49570f923",
"index": 7821,
"step-1": "<mask token>\n\n\ndef loadDataSet():\n \"\"\"解析文件\n Return: dataMat 文档列表 [[1,x1,x2]...]; labelMat 类别标签列表[1,0,1...]\n @author:VPrincekin\n \"\"\"\n dataMat = []\n labelMat = []\n fr = open('testSet.txt')\n f... | [
4,
6,
8,
9,
11
] |
/opt/python3.7/lib/python3.7/_weakrefset.py | normal | {
"blob_id": "22f7f725d89db354b2e66ff145550192826af5ea",
"index": 9109,
"step-1": "/opt/python3.7/lib/python3.7/_weakrefset.py",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 17 13:07:47 2020
@author: mmm
"""
n = 2
n1 = 10
for i in range(n,n1):
if n > 1:
for j in range(2,i):
if (i % j!= 0):
else:
print(i)
| normal | {
"blob_id": "1855351b20c7965a29864502e4489ab4324c7859",
"index": 4808,
"step-1": "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Thu Dec 17 13:07:47 2020\r\n\r\n@author: mmm\r\n\"\"\"\r\n\r\n\r\nn = 2\r\nn1 = 10\r\nfor i in range(n,n1):\r\n if n > 1:\r\n for j in range(2,i):\r\n if (i % j!=... | [
0
] |
#Copyright ReportLab Europe Ltd. 2000-2017
#see license.txt for license details
__version__='3.3.0'
__doc__="""
The Canvas object is the primary interface for creating PDF files. See
doc/reportlab-userguide.pdf for copious examples.
"""
__all__ = ['Canvas']
ENABLE_TRACKING = 1 # turn this off to do profile testing w/... | normal | {
"blob_id": "7d6e8e6142184a1540daa29dac802fe75bd93d8e",
"index": 4428,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nc.translate(inch, inch)\nc.setFont('Helvetica', 80)\nc.setStrokeColorRGB(0.2, 0.5, 0.3)\nc.setFillColorRGB(1, 0, 1)\nc.rect(inch, inch, 6 * inch, 9 * inch, fill=1)\nc.rotate(90)\nc.setFil... | [
0,
1,
2,
3,
4
] |
import numpy as np
import matplotlib as plt
import math
from DoublePendulum import DP #imports useful modules and double pendulum class from DoublePendulum.py
import json
import pandas as pd
import copy
from pathlib import Path
#accessing config file
with open('config.json') as config_file:
initdata = ... | normal | {
"blob_id": "c2b6e51622681ac916e860ed4ff5715808dff102",
"index": 9725,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('config.json') as config_file:\n initdata = json.load(config_file)\n<mask token>\npend.updCartesian()\npend.updEnergies()\n<mask token>\nif method == 1:\n for n in range(n... | [
0,
1,
2,
3,
4
] |
import unittest
from traceback import print_tb
from ml_base.utilities.model_manager import ModelManager
from tests.mocks import MLModelMock
class ModelManagerTests(unittest.TestCase):
def test_model_manager_will_return_same_instance_when_instantiated_many_times(self):
"""Testing that the ModelManager wi... | normal | {
"blob_id": "8355faf7c0d3742be34a56ddc982cb389c80d0a9",
"index": 1063,
"step-1": "<mask token>\n\n\nclass ModelManagerTests(unittest.TestCase):\n\n def test_model_manager_will_return_same_instance_when_instantiated_many_times(\n self):\n \"\"\"Testing that the ModelManager will return the same i... | [
9,
13,
14,
15,
16
] |
from FluidStream import *
# List of chemicals and their constant properties
CHEMICALS_KEY_GUIDE = ['MW' , 'Density']
CHEMICALS = {
'Bacteria' : ['NA' , 1.05 ],
'Calcium Carbonate' : [100.087 , 2.71 ],
'Calcium Lactate' : [218.22 , 1.494 ],
'Corn Steep Liquor' : ['NA' , 1.2326],
'Glucose' : [180.156 ,... | normal | {
"blob_id": "3471f02f507104202c1e49440172f120ba17730f",
"index": 9263,
"step-1": "<mask token>\n\n\ndef convert_mass_to_concentration(fluidStream, component):\n total_mass = fluidStream.TotalMass\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef convert_mass_to_concentration(fluidStream, component):\n ... | [
1,
2,
3,
4,
5
] |
# TODO: Add correct copyright header
import io
from unittest.mock import mock_open, patch
from django.test import TestCase
from importer.models import *
from importer.tasks import *
from importer.tests import mock_data
class MockResponse:
"""
This class will be used by the mock to replace requests.get
... | normal | {
"blob_id": "b131107d2161634e2c09e0b3ab80dd322d13fbc2",
"index": 2881,
"step-1": "<mask token>\n\n\nclass GetCollectionItemidsTest(TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass GetCollectionItemAssetURLsTest(TestCase):\n\n def setUp(self):\n \"\"\"\n Setting up the ... | [
16,
25,
31,
33,
38
] |
"""
Problem Statement
You and Fredrick are good friends. Yesterday, Fredrick received N credit
cards from ABCD Bank. He wants to verify whether his credit card numbers are
valid or not. You happen to be great at regex so he is asking for your help!
A valid credit card from ABCD Bank has the following characteristics:... | normal | {
"blob_id": "09f2fabaf3c19aa0d4cb522c6dbf5fd8d720b4df",
"index": 1567,
"step-1": "\"\"\"\nProblem Statement\n\nYou and Fredrick are good friends. Yesterday, Fredrick received N credit\ncards from ABCD Bank. He wants to verify whether his credit card numbers are\nvalid or not. You happen to be great at regex so h... | [
0
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.12 on 2018-07-26 19:11
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('articles', '0014_auto_20180726_0926'),
]
operations = [
migrations.AlterFi... | normal | {
"blob_id": "671a7ee3fabee6ed8dfafe1bddefb1f94322b0e5",
"index": 2477,
"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 = [('articles', ... | [
0,
1,
2,
3,
4
] |
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import re
import sys
import time
import os
# directory 현재 경로에 download폴더 생성
dirPath = "download"
try:
if not (os.path.isdi... | normal | {
"blob_id": "5f022b7f20b8aef1e3538a6b1e69dc302752cdc7",
"index": 7640,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n if not os.path.isdir(dirPath):\n os.makedirs(os.path.join(dirPath))\nexcept OSError as e:\n print('{0} Failed to create directory!!!!!'.format(dirPath))\n<mask token>\... | [
0,
1,
2,
3,
4
] |
################################################################################
#
# titleStrip.py
#
# Generates an output file with the titles of the input stripped
# Usage:
# python titleStrip.py [input filename] [output filename]
#
################################################################################
im... | normal | {
"blob_id": "9c09309d23510aee4409a6d9021c2991afd2d349",
"index": 521,
"step-1": "<mask token>\n\n\ndef clearConsole():\n os.system('cls' if os.name == 'nt' else 'clear')\n\n\ndef main():\n checkArgs()\n rfile = open(sys.argv[1], 'r')\n wfile = open(output_name, 'w')\n parseAndStrip(rfile, wfile)\n... | [
4,
5,
6,
7,
8
] |
# coding=utf8
from __future__ import print_function
from application.controllers import *
from application.models import board
def __return__():
return render_template('board/board.html',
lecturers = board.Lecturer.query.all(), disciplines = board.Discipline.query.all())
def __return_modal__(id):
le... | normal | {
"blob_id": "f87c036c1eb5026e088bed62fbc330cfd2ea1952",
"index": 7500,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef __return_modal__(id):\n lecturer = board.Lecturer.query.get(id)\n print('esdasd' + lecturer.description)\n return render_template('board/modal.html', lecturer=lecturer)\n... | [
0,
1,
2,
3,
4
] |
"""
测试用例
"""
import unittest
import jsonpath
import requests
from apiunittest.lib.loadIni import LoadIni
from apiunittest.keyword.keyword import Keyword
from apiunittest.lib.log import logger
from ddt import ddt, file_data
@ddt
class ApiTest(unittest.TestCase):
@classmethod
def setUpClass... | normal | {
"blob_id": "b28bada020ac593783ac62994bb45311ebb78813",
"index": 9055,
"step-1": "<mask token>\n\n\n@ddt\nclass ApiTest(unittest.TestCase):\n\n @classmethod\n def setUpClass(cls) ->None:\n cls.keyword = Keyword()\n cls.cookie = None\n cls.confData = LoadIni('config.ini')\n logge... | [
2,
3,
4,
5,
6
] |
import Net
import mnist_parser
import numpy as np
#To use this model it is required to download the MNIST database
#The donwloaded base is then needet parse to numpy using mnist_parser.parse_to_npy method
#The files genetared using mnist_parser.parse_to_npy are then loaded using np.load
in_values = np.load("MNIST/mnist... | normal | {
"blob_id": "49005500b299ca276f663fe8431bb955e5585bbd",
"index": 335,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n net = Net.FeedForwardNet(input_count=784, layers=[100, 10],\n activation_function=Net.FeedForwardNet.leaky_relu)\n try:\n epoch_num = int(input('Epoch_num... | [
0,
1,
2,
3,
4
] |
from utilidades import moeda
p = float(input('Digite o preço: R$'))
print(f'Metade de {moeda.moeda(p)} é {moeda.metade(p, show=True)}')
print(f'O dobro de {moeda.moeda(p)} é {moeda.dobro(p, show=True)}')
print(f'Aumentando 10%, temos {moeda.aumentar(p, 10, show=True)}')
print(f'Reduzindo 13%, temos {moeda.diminuir(p, 1... | normal | {
"blob_id": "5a50ca64810c391231a00c6bfe5ae925ffe5ca7d",
"index": 6332,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(f'Metade de {moeda.moeda(p)} é {moeda.metade(p, show=True)}')\nprint(f'O dobro de {moeda.moeda(p)} é {moeda.dobro(p, show=True)}')\nprint(f'Aumentando 10%, temos {moeda.aumentar(p, ... | [
0,
1,
2,
3
] |
traditional_investor_stage1 = \
"SELECT investor, investor_id, invest_amount, invest_change, security_id, isin, issue_date, maturity_date "\
"FROM "\
"(SELECT "\
"report_date, "\
"investor_holdings.investor_name AS investor,"\
"investor_id,"\
... | normal | {
"blob_id": "1e168cf6ba785a08244f47eb490b54605a09e4b0",
"index": 9433,
"step-1": "<mask token>\n",
"step-2": "traditional_investor_stage1 = (\n \"SELECT investor, investor_id, invest_amount, invest_change, security_id, isin, issue_date, maturity_date FROM (SELECT report_date, investor_holdings.investor_name... | [
0,
1,
2
] |
import os
import sys
import platform
import numpy as np
import sklearn.preprocessing as sp
def deal_with_ohe(raw_sample):
# --------------------#
# 10 100 0001 #
# 01 010 1000 #
# 10 001 0100 #
# 01 100 0010 #
# --------------------#
ohe_sample... | normal | {
"blob_id": "0b0282ade565eb4031cef3a2fa8605249f104d9d",
"index": 2438,
"step-1": "<mask token>\n\n\ndef main(argc, argv, envir):\n raw_samples = np.array([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]])\n deal_with_ohe(raw_samples)\n ohe = sp.OneHotEncoder(sparse=False, dtype=int)\n ohe_samples = ohe.fi... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/python3
#start up curses
import curses
HEIGHT = 24
WIDTH = 80
TESTING = True
curses.initscr()
stdscr = curses.newwin(HEIGHT, WIDTH, 0, 0)
curses.noecho() #don't echo keys
stdscr.keypad(1)
#function for displaying other players decision
#statement is the number of the other player's death funciton returne... | normal | {
"blob_id": "a6f03340c2f60c061977fed6807703cdaeb1b7fd",
"index": 7976,
"step-1": "<mask token>\n\n\ndef decision(statement, player):\n stdscr.clear()\n stdscr.border(0)\n stdscr.timeout(-1)\n decision = 'play again' if statement == 1 else 'return to main menu'\n stdscr.addstr(3, 5, 'Your Partner h... | [
4,
5,
8,
9,
10
] |
# Author: Kenneth Lui <hkkenneth@gmail.com>
# Last Updated on: 01-11-2012
## Usage: python ~/code/python/001_Fastq_Trimming.py <FIRST BASE> <LAST BASE> <FASTQ FILES....>
## Bases are inclusive and 1-based
#from Bio.SeqIO.QualityIO import FastqGeneralIterator
#handle = open(sys.argv[2], 'w')
#for title, seq, qual in Fa... | normal | {
"blob_id": "4a8663531f303da29371078e34dc7224fc4580e3",
"index": 6283,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor s in sys.argv[3:]:\n file = open(s + '.' + sys.argv[1] + '-' + sys.argv[2] + '.trimmed', 'w')\n r_list = []\n size = 0\n for r in SeqIO.parse(s, 'fastq'):\n r_list.... | [
0,
1,
2,
3,
4
] |
from oil_prices import *
with_without = 'without training'
show_plot = 'yes'
print('START')
# Defining the past and future sequences for the LSTM training
n_past = 8
n_future = 1
target_date = '2018-11-16'
past = ['t']+['t-'+str(i) for i in range(1,n_past)]
future = ['t+'+str(i) for i in range(1,n_future+1)]
# Imp... | normal | {
"blob_id": "ec6067cc86b6ac702123d13911cc4ab97be6a857",
"index": 4077,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('START')\n<mask token>\nprint(' - Imports data and formats the data')\n<mask token>\ntimeseries_to_supervised(df_train, n_past, n_future)\n<mask token>\nif with_without == 'with tra... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
__author__ = 'wxy'
class ListProcess(object):
def __init__(self, rsp, nickname):
self.rsp = rsp
self.nickname = nickname
def get_friend_uin(self):
try:
for list in self.rsp['result']['info']:
if list['nick'] == self.nickname:
... | normal | {
"blob_id": "1154fd3883dc8856e24127d56ce6a983308dc1aa",
"index": 3683,
"step-1": "# -*- coding: utf-8 -*-\n__author__ = 'wxy'\n\nclass ListProcess(object):\n def __init__(self, rsp, nickname):\n self.rsp = rsp\n self.nickname = nickname\n\n def get_friend_uin(self):\n try:\n ... | [
0
] |
from __future__ import unicode_literals
import requests
try:
import json
except ImportError:
import simplejson as json
def main(app, data):
MEDIUM_API_ENDPOINT = 'https://medium.com/{0}/latest?format=json'
r = requests.get(MEDIUM_API_ENDPOINT.format(data.get('username')))
response_content = r.cont... | normal | {
"blob_id": "96936b7f6553bee06177eb66a2e63064c1bf51a6",
"index": 8373,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(app, data):\n MEDIUM_API_ENDPOINT = 'https://medium.com/{0}/latest?format=json'\n r = requests.get(MEDIUM_API_ENDPOINT.format(data.get('username')))\n response_conte... | [
0,
1,
2,
3
] |
#Exercício Python 055: Faça um programa que leia o peso de cinco pessoas. No final, mostre qual foi o maior e o menor peso lidos.
pessoas = int(input('Informe a quantidade de pessoas que deseja analisar: '))
peso = 0
maior = 0
menor = 0
for c in range(0, pessoas):
peso = float(input('Informe o peso: '))
if c ==... | normal | {
"blob_id": "78c71a4f3c4e8f24f0ae90555a3caf15f35332f6",
"index": 1774,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor c in range(0, pessoas):\n peso = float(input('Informe o peso: '))\n if c == 1:\n maior = peso\n menor = peso\n else:\n if peso > maior:\n maio... | [
0,
1,
2,
3
] |
a = 'Hello, World!'
print
| normal | {
"blob_id": "b779cfc6d6456a370092bf1cfa5904c869b7466a",
"index": 9219,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint\n",
"step-3": "a = 'Hello, World!'\nprint\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
__author__ = 'Chitrang'
from google.appengine.api import memcache
from google.appengine.ext import db
import logging
import os
import jinja2
class User(db.Model):
id = db.StringProperty(required=True)
created = db.DateTimeProperty(auto_now_add=True)
updated = db.DateTimeProperty(auto_now=True)
name =... | normal | {
"blob_id": "0b2bc19aea9393562f79df026bc17513e25c6604",
"index": 8535,
"step-1": "<mask token>\n\n\nclass User(db.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 <mask ... | [
14,
15,
16,
17,
19
] |
import random
import csv
# 提取随机问,同类组成正例,异类组成负例,正:负=1:3
with open('final_regroup.csv', 'w', newline='') as train:
writer = csv.writer(train)
with open('final_syn_train.csv', 'r') as zhidao:
reader = csv.reader(zhidao)
cluster = []
cur = []
stand = ''
# 将同一标准问... | normal | {
"blob_id": "3a09cbd71d23b1320af9b8ddcfc65b223e487b21",
"index": 1811,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('final_regroup.csv', 'w', newline='') as train:\n writer = csv.writer(train)\n with open('final_syn_train.csv', 'r') as zhidao:\n reader = csv.reader(zhidao)\n ... | [
0,
1,
2,
3
] |
# python imports
import re
# django imports
from django.core.management.base import BaseCommand
# module level imports
from utils.spells import SPELLS
from spells.models import Spell
SPELL_SCHOOL = {
'Abjuration': 'Abjuration',
'Conjuration': 'Conjuration',
'Divination': 'Divination',
... | normal | {
"blob_id": "010f78d952657b3d7c11fbf8e46912d0294f6cc1",
"index": 9103,
"step-1": "<mask token>\n\n\nclass Command(BaseCommand):\n <mask token>\n help = (\n 'Will auto populate the database with all the Spells from 5th Edition Dungeons and Dragons.'\n )\n\n def handle(self, *args, **kwargs)... | [
3,
4,
5,
6,
7
] |
#!/usr/bin/env python
# On CI, you can pass the logging and the password of dockerhub through
# the environment variables DOCKER_USERNAME and DOCKER_PASSWORD
import getpass
import os
import subprocess
import sys
from builtins import input
SCRIPT_DIR = os.path.realpath(os.path.join(__file__, '..'))
ROOT_DIR = os.path... | normal | {
"blob_id": "1ad40ef3aa7c81b6eee4fe0b98bcdd2f1110ef8d",
"index": 5990,
"step-1": "<mask token>\n\n\ndef main(arguments):\n docker = [('Dockerfile.ubuntu1804', 'ubuntu1804_ansible_testinfra'), (\n 'Dockerfile.ubuntu1604', 'ubuntu1604_ansible_testinfra')]\n docker_username = os.environ.get('DOCKER_USE... | [
2,
3,
4,
5,
6
] |
version https://git-lfs.github.com/spec/v1
oid sha256:839b1a9cc0c676f388ebfe8d8f2e89ad7c39a6f0aa50fa76b2236703bf1a8264
size 62
| normal | {
"blob_id": "23150f359db97e1e0ce3f12a173cd7015ad22cd4",
"index": 2220,
"step-1": "version https://git-lfs.github.com/spec/v1\noid sha256:839b1a9cc0c676f388ebfe8d8f2e89ad7c39a6f0aa50fa76b2236703bf1a8264\nsize 62\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
... | [
0
] |
from scipy.cluster.hierarchy import dendrogram, linkage
from get_train import get, pre
import matplotlib.pyplot as plt
#%%
index = [
'BAC',
'JPM',
'GS',
'C',
'AAPL',
'IBM',
'MSFT',
'ORCL'
]
years = [
2010,
2013,
... | normal | {
"blob_id": "8279f8a80d96a7231e35100d2c39fa5e1f34f5f5",
"index": 9777,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfig.tight_layout()\nfig.subplots_adjust(wspace=0.05)\n<mask token>\nfor year in years:\n train = get(year, features, index)\n train = pre(train)\n for method in methods:\n ... | [
0,
1,
2,
3,
4
] |
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential, Model
from keras.applications import InceptionV3
from keras.callbacks import ModelCheckpoint
from keras.optimizers import SGD
from keras.layers import Flatten,Dense,Dropout
from keras.preprocessing.image import img_to_a... | normal | {
"blob_id": "17a442a85b910ff47c2f3f01242b7f64a6237146",
"index": 9380,
"step-1": "from keras.preprocessing.image import ImageDataGenerator\r\nfrom keras.models import Sequential, Model\r\nfrom keras.applications import InceptionV3\r\nfrom keras.callbacks import ModelCheckpoint\r\nfrom keras.optimizers import SG... | [
0
] |
# -*- coding: utf-8 -*-
"""
.. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de>
"""
import argparse
from glob import glob
import os
import cv2
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn.functional as F
from src.args import ArgumentParserRGBDSegmentation
from src.build_... | normal | {
"blob_id": "559e46aa4e9b55f8c01acf30fa01e106ab914116",
"index": 5687,
"step-1": "<mask token>\n\n\ndef _load_img(fp):\n img = cv2.imread(fp, cv2.IMREAD_UNCHANGED)\n if img.ndim == 3:\n img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n return img\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nde... | [
1,
2,
3,
4,
5
] |
from .checklist_mixin import ChecklistMixin
from .citation_mixin import CitationMixin
from .license_mixin import LicenseMixin
from .registry_mixin import RegistryMixin
from .repository_mixin import RepositoryMixin
__all__ = [
"RepositoryMixin",
"LicenseMixin",
"RegistryMixin",
"CitationMixin",
"Ch... | normal | {
"blob_id": "bf8a524e54aa866c8293a93b2321335f2c7b0850",
"index": 7419,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['RepositoryMixin', 'LicenseMixin', 'RegistryMixin',\n 'CitationMixin', 'ChecklistMixin']\n",
"step-3": "from .checklist_mixin import ChecklistMixin\nfrom .citation_mixin i... | [
0,
1,
2,
3
] |
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
from sqlalchemy import select, update
from sqlalchemy import Table, Column, String, Integer, Float, Boolean, Date, BigInteger
from sqlalchemy import create_engine, MetaData
import API_and_Database_function as func
import pandas as pd
import re
connection, Twitter_Senti... | normal | {
"blob_id": "a558b42106b036719fe38ee6efd1c5b933290f52",
"index": 47,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nconnection.execute(stmt)\nfunc.update_annotations_db(Twitter_Sentiment_Analysis, connection,\n 'Export_csv5.csv')\n",
"step-3": "<mask token>\nconnection, Twitter_Sentiment_Analysis = ... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'find_result_window.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_FindResultWindow(object):
def setupUi(self, FindResultW... | normal | {
"blob_id": "2fdbf418b5cec50ee6568897e0e749681efeef6b",
"index": 6584,
"step-1": "<mask token>\n\n\nclass Ui_FindResultWindow(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Ui_FindResultWindow(object):\n <mask token>\n\n def retranslateUi(self, FindResultWindow):\n ... | [
1,
2,
3,
4,
5
] |
from django.shortcuts import render
from django.views.generic.list import ListView
from .models import Student
# Create your views here.
class StudentListView(ListView):
model = Student
# Custom has a HIGH priority than default in any field
template_name = 'staff/student_list.html'
# template_name_su... | normal | {
"blob_id": "bcad9869e6bc9b17eee490897b4b706171381366",
"index": 2093,
"step-1": "<mask token>\n\n\nclass StudentListView(ListView):\n <mask token>\n <mask token>\n <mask token>\n\n def get_queryset(self):\n return Student.objects.filter(course='Python')\n <mask token>\n <mask token>\n",... | [
2,
4,
5,
6,
7
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.