code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
#%%
import numpy
import time
import scipy
import os
os.chdir('/home/bbales2/modal')
import pyximport
import seaborn
pyximport.install(reload_support = True)
import polybasisqu
reload(polybasisqu)
#from rotations import symmetry
#from rotations import quaternion
#from rotations import inv_rotations
# basis polynomial... | normal | {
"blob_id": "87df5481cf2dd5bb990a9b4bd5169d9293d6af79",
"index": 1144,
"step-1": "#%%\nimport numpy\nimport time\nimport scipy\nimport os\nos.chdir('/home/bbales2/modal')\nimport pyximport\nimport seaborn\npyximport.install(reload_support = True)\n\nimport polybasisqu\nreload(polybasisqu)\n\n#from rotations impo... | [
0
] |
import tensorflow as tf
import numpy as np
import OpenAi.Pendulum.ActorCritic.Models as Models
"""
The `Buffer` class implements Experience Replay.
---

---
**Critic loss** - Mean Squared Error of `y - Q(s, a)`
where `y` is the expected return as seen by the Target netw... | normal | {
"blob_id": "8a9ed10bf25f3aa13fde43079303194fc6db26c0",
"index": 4248,
"step-1": "<mask token>\n\n\nclass Agent:\n <mask token>\n\n def record(self, obs_tuple):\n index = self.buffer_counter % self.buffer_capacity\n self.state_buffer[index] = obs_tuple[0]\n self.action_buffer[index] = ... | [
8,
9,
10,
12,
13
] |
import sys
sys.path.append("../circos_report/cnv_anno2conf")
from cnv_anno2conf import main_cnv
tarfile = {"yaml": "data/test_app.yaml"}
def test_main_cnv():
main_cnv(tarfile)
if __name__ == "__main__":
test_main_cnv()
| normal | {
"blob_id": "3c0beb7be29953ca2d7b390627305f4541b56efa",
"index": 69,
"step-1": "<mask token>\n\n\ndef test_main_cnv():\n main_cnv(tarfile)\n\n\n<mask token>\n",
"step-2": "<mask token>\nsys.path.append('../circos_report/cnv_anno2conf')\n<mask token>\n\n\ndef test_main_cnv():\n main_cnv(tarfile)\n\n\nif _... | [
1,
2,
3,
4,
5
] |
# Improting Image class from PIL module
from PIL import Image
# Opens a image in RGB mode
im = Image.open("data/frame1.jpg")
# Setting the points for cropped image
left = 155
top = 65
right = 360
bottom = 270
# Cropped image of above dimension
# (It will not change orginal image)
im1 = im.crop((left, top, right, bot... | normal | {
"blob_id": "9fd73e0a1dacc46c177f11ce4cf2351b3d622c0d",
"index": 7594,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nim1.show()\nim.show()\n",
"step-3": "<mask token>\nim = Image.open('data/frame1.jpg')\nleft = 155\ntop = 65\nright = 360\nbottom = 270\nim1 = im.crop((left, top, right, bottom))\nim1.sh... | [
0,
1,
2,
3,
4
] |
num1 = input("첫 번째 실수 : ")
num2 = input("두 번째 실수 : ")
print(float(num1) + float(num2))
num1 = float(input("첫 번째 실수 : "))
num2 = float(input("두 번째 실수 : "))
print(num1 + num2)
| normal | {
"blob_id": "ee8bf681adcb07c4f79245c8f118131bbcabd2fa",
"index": 7920,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(float(num1) + float(num2))\n<mask token>\nprint(num1 + num2)\n",
"step-3": "num1 = input('첫 번째 실수 : ')\nnum2 = input('두 번째 실수 : ')\nprint(float(num1) + float(num2))\nnum1 = float(... | [
0,
1,
2,
3
] |
import scrapy
import datetime
from tzscrape.items import CitizenItem
class CitizenSpider(scrapy.Spider):
name = 'citizen'
allowed_domains = ['thecitizen.co.tz']
start_urls = ['http://www.thecitizen.co.tz/']
def parse(self, response):
# headlines
for href in response.xpath('//*[@itempro... | normal | {
"blob_id": "d307c3479e34a12971f62a765aca2ba0850d80d1",
"index": 5660,
"step-1": "<mask token>\n\n\nclass CitizenSpider(scrapy.Spider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass CitizenSpider(scrapy.Spider):\n <mask token... | [
1,
3,
4,
5,
6
] |
def printall(s):
for i in s:
print i
n=str(raw_input("Enter Word:- "))
printall(n)
| normal | {
"blob_id": "de77fa677b3b200a41083e609d4da697f9e77f21",
"index": 8726,
"step-1": "def printall(s):\r\n for i in s:\r\n print i\r\n\r\nn=str(raw_input(\"Enter Word:- \"))\r\nprintall(n)\r\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
#!/usr/bin/env python3
# coding: utf-8
# Time complexity: O()
# Space complexity: O()
import math
# 最大公约数 Greatest common divisor
def get_gcd(a, b):
if b == 0:
return a
print(a, b)
return get_gcd(b, a % b)
get_gcd(48, 30)
# 计算约数个数
# 时间复杂度 O(n)
def divisor1(num):
count = 0
for i in ran... | normal | {
"blob_id": "32066db8b43bc70c564cce5a33f50921285b3627",
"index": 6477,
"step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\nclass Solution:\n\n def isPowerOfTwo(self, n: int) ->bool:\n return n > 0 and n & n - 1 == 0\n\n\nclass Solution:\n\n def isPowerOfTwo(self, n: int) ->bool:\n ... | [
11,
17,
19,
21,
22
] |
"""Stencil based grid operations in 2D."""
from .advection_flux_2d import gen_advection_flux_conservative_eno3_pyst_kernel_2d
from .advection_timestep_2d import (
gen_advection_timestep_euler_forward_conservative_eno3_pyst_kernel_2d,
)
from .brinkmann_penalise_2d import (
gen_brinkmann_penalise_pyst_kernel_2d,
... | normal | {
"blob_id": "2dddee735e23e8cdb7df83f47f63926727cf8963",
"index": 2731,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfrom .advection_flux_2d import gen_advection_flux_conservative_eno3_pyst_kernel_2d\nfrom .advection_timestep_2d import gen_advection_timestep_euler_forward_conservative_eno3_pyst_kernel_2... | [
0,
1,
2
] |
# difference between size an shape of an image
import cv2
img = cv2.imread('police.jpg')
print img.size # byte size; slightly larger than the file size
print img.shape # y,x or rows, cols
cv2.imshow("My Picture", img)
cv2.waitKey(0)
cv2.destroyAllWindows() | normal | {
"blob_id": "ba42c6af53329035f7ab72f3f1ac87cd90d9dc7f",
"index": 9408,
"step-1": "# difference between size an shape of an image\r\n\r\nimport cv2\r\n\r\nimg = cv2.imread('police.jpg')\r\nprint img.size # byte size; slightly larger than the file size\r\nprint img.shape # y,x or rows, cols\r\n\r\ncv2.imshow(\... | [
0
] |
#!/usr/bin/python
import sys,os
import argparse
import subprocess
from pprint import pprint
chroot_start_path="/srv/chroot"
chroots_conf="/etc/schroot/chroot.d"
build_pkgs = 'build-essential fakeroot devscripts apt-utils'
include = 'eatmydata,ccache,lintian'
distro_conf={
'debootstrap_mirror':None,
'componen... | normal | {
"blob_id": "600691b87f7776e96bbf439d7195b870ed86090b",
"index": 1145,
"step-1": "<mask token>\n\n\ndef configure_distro(distro='debian', arch='i386', release='unstable'):\n if distro not in ['ubuntu', 'debian']:\n print('Unknown Distro %s' % distro)\n return False\n if distro == 'ubuntu':\n ... | [
2,
3,
4,
5,
6
] |
'''
Copyright (C) 2014 mdm
marco[dot]masciola[at]gmail
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
d... | normal | {
"blob_id": "4daf029c4bc9f0726080bd67f37b1e77c9697d1c",
"index": 3669,
"step-1": "'''\n Copyright (C) 2014 mdm \n marco[dot]masciola[at]gmail \n \nLicensed to the Apache Software Fo... | [
0
] |
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name='VitaminSHE-home'),
path('signup/', views.signup, name='VitaminSHE-signup'),
path('login/', views.login, name='VitaminSHE-login'),
path('healthcheck/', views.healthcheck, name='VitaminSHE-healthcheck'),
path('... | normal | {
"blob_id": "33aa5c5ab75a26705875b55baf61f7f996cb69cd",
"index": 1280,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', views.home, name='VitaminSHE-home'), path('signup/',\n views.signup, name='VitaminSHE-signup'), path('login/', views.login,\n name='VitaminSHE-login'), path(... | [
0,
1,
2,
3
] |
import sys
import urllib
import urlparse
import xbmcgui
import xbmcplugin
import xbmcaddon
import shutil
from shutil import copyfile
base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])
addon = xbmcaddon.Addon()
xbmcplugin.setContent(addon_handle, 'videos')
... | normal | {
"blob_id": "15bcfd8859322034ec76a8c861d2151153ab54af",
"index": 5120,
"step-1": "import sys\r\nimport urllib\r\nimport urlparse\r\nimport xbmcgui\r\nimport xbmcplugin\r\nimport xbmcaddon\r\nimport shutil\r\nfrom shutil import copyfile\r\n\r\nbase_url = sys.argv[0]\r\naddon_handle = int(sys.argv[1])\r\nargs = u... | [
0
] |
'''This class contains a custom made format for printing complex numbers'''
class ComplexCustom(complex):
'''
This class contains function for
a custom made printing format for complex numbers
'''
def __format__(self, fmt):
'''This function creates a custom made format for printing complex n... | normal | {
"blob_id": "c62647b0b226d97926d1f53975a7aac7c39949d8",
"index": 7959,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ComplexCustom(complex):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ComplexCustom(complex):\n <mask token>\n\n def __format__(self, fmt):\... | [
0,
1,
2,
3,
4
] |
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, sof... | normal | {
"blob_id": "86b24ddaae0d3477a3f82295224b7e84805eed91",
"index": 1413,
"step-1": "<mask token>\n\n\nclass AuthenticatorTest(absltest.TestCase):\n <mask token>\n\n def testGetGoogleSheetsServiceByCred_badFilePath_raisesFileNotFoundError(\n self):\n bad_file_path = './credential.json'\n ... | [
2,
3,
4,
5,
6
] |
import numpy as np
import argparse
import torch
from gridworlds.envs import GridWorldEnv, generate_obs_dict
from gridworlds.constants import possible_objects
import nengo_spa as spa
from collections import OrderedDict
from spatial_semantic_pointers.utils import encode_point, ssp_to_loc, get_heatmap_vectors
import mat... | normal | {
"blob_id": "34a456efc72b303aed5f722bb415d30ff62addab",
"index": 7391,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnp.random.seed(seed)\n<mask token>\nnp.random.seed(params['seed'])\n<mask token>\nfor i in range(n_goals):\n sp_name = possible_objects[i]\n if use_dataset_goals:\n object_lo... | [
0,
1,
2,
3,
4
] |
#
# Util for WebDriver
#
import sys
from string import Formatter
from functools import wraps
from numbers import Integral
from .locator import Locator
from .keys import Keys
PY3 = sys.version_info[0] == 3
class MemorizeFormatter(Formatter):
"""Customize the Formatter to record used and unused kwargs."""
... | normal | {
"blob_id": "773fc4660def134410eca92886b2629be6977f74",
"index": 4095,
"step-1": "<mask token>\n\n\nclass MemorizeFormatter(Formatter):\n \"\"\"Customize the Formatter to record used and unused kwargs.\"\"\"\n\n def __init__(self):\n \"\"\"Initialize the MemorizeFormatter.\"\"\"\n Formatter._... | [
10,
11,
12,
13,
15
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
处理与合约名字有关的变量
"""
import re
# 上期所
PRODUCTS_SHFE = {'cu', 'al', 'zn', 'pb', 'ni', 'sn', 'au', 'ag', 'rb', 'wr', 'hc', 'fu', 'bu', 'ru'}
# 中金所
PRODUCTS_CFFEX = {'IF', 'IC', 'IH', 'T', 'TF'}
# 郑商所
PRODUCTS_CZCE = {'SR', 'CF', 'ZC', 'FG', 'TA', 'WH', 'PM', 'RI', 'LR', 'JR',... | normal | {
"blob_id": "8bb39149a5b7f4f4b1d3d62a002ab97421905ea1",
"index": 551,
"step-1": "<mask token>\n\n\ndef get_product(symbol):\n \"\"\"\n 从合约名中提取产品名\n :param symbol:\n :return:\n \"\"\"\n pattern = re.compile('(\\\\D{1,2})(\\\\d{0,1})(\\\\d{3})')\n match = pattern.match(symbol)\n if match:\n... | [
2,
5,
6,
7,
8
] |
# GeoPy can be used to interface to map box https://pypi.org/project/geopy/
from pygeodesy.ellipsoidalVincenty import LatLon
from geojson import Polygon, Feature, FeatureCollection, dump
import sys
import random
BEARING_SOUTH = 180.0
BEARING_EAST = 90.0
class Cell(object):
def __init__(self, cellId, top_left_cel... | normal | {
"blob_id": "01f0ad8746ed9a9941faa699b146625ad3a0b373",
"index": 4289,
"step-1": "<mask token>\n\n\nclass Cell(object):\n\n def __init__(self, cellId, top_left_cell, top_right_cell,\n bottom_right_cell, bottom_left_cell):\n self.cellId = cellId\n self.top_left_cell = top_left_cell\n ... | [
6,
7,
8,
9,
11
] |
import os
from dataclasses import dataclass
from dotenv import load_dotenv
from fastapi.security import OAuth2PasswordBearer
from passlib.context import CryptContext
load_dotenv()
@dataclass
class Settings:
SECRET_KEY = os.getenv("SECRET_KEY", "mysecret")
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES ... | normal | {
"blob_id": "a1c5d86a3f042d9e5ba522726191c8aeb9b738ed",
"index": 8018,
"step-1": "<mask token>\n\n\n@dataclass\nclass Settings:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\nload_dotenv()\n\n\n@dataclass\nclass Settings:... | [
1,
3,
4,
5,
6
] |
from typing import List
def uppercase_first_letter(string: str) ->str:
return string[0:1].upper() + string[1:]
string_list: List[str] = input('Please, input string: ').split(' ')
result: str = ''
for i, value in enumerate(string_list):
result += (lambda index: '' if index == 0 else ' ')(i
) + upperc... | normal | {
"blob_id": "0555c577a8fb746cf2debb929d02b46cd3be4d7b",
"index": 1062,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef uppercase_first_letter(string: str) ->str:\n return string[0:1].upper() + string[1:]\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef uppercase_first_letter(string: str... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
import os
import re
import pycolor
import sys
pyc = pycolor.pyColor()
def decompile(mainapk):
print pyc.Info("Decompiling apks...")
os.system("bash apktool.sh d -f %s"%mainapk)
os.system("bash apktool.sh d -f temp.apk")
def inject(mainapk):
print pyc.Info("Injecting payload...")
mk = "mkd... | normal | {
"blob_id": "fcc73647a5e841bcb5ea4fcd06579cc6912cfe1e",
"index": 435,
"step-1": "#!/usr/bin/env python\n\nimport os\nimport re\nimport pycolor\nimport sys\n\npyc = pycolor.pyColor()\n\ndef decompile(mainapk):\n\tprint pyc.Info(\"Decompiling apks...\")\n\tos.system(\"bash apktool.sh d -f %s\"%mainapk)\n\tos.syste... | [
0
] |
import gitlab
from core import settings
gl = gitlab.Gitlab('https://gitlab.intecracy.com/', private_token='dxQyb5fNbLnBxvvpFjyc')
gl.auth()
project = gl.projects.get(settings.projectID)
print(project)
pipelines = project.pipelines.get(26452)
print pipelines
pipelines_jobs = pipelines.jobs.list()[2]
jobs = project.j... | normal | {
"blob_id": "c7f8731fe58a0e0065827b82bb4ad4af670541db",
"index": 5101,
"step-1": "import gitlab\nfrom core import settings\n\n\ngl = gitlab.Gitlab('https://gitlab.intecracy.com/', private_token='dxQyb5fNbLnBxvvpFjyc')\n\ngl.auth()\n\nproject = gl.projects.get(settings.projectID)\nprint(project)\npipelines = proj... | [
0
] |
""" Script to run pilon iteratively to correct genome assemblies """
import os
import argparse
import logging
import subprocess
def parse_arguments():
""" Parse command line arguments """
# Create parser
parser = argparse.ArgumentParser(description='Run pilon many times')
# Add arguments
pars... | normal | {
"blob_id": "fdfb71595bf86fbe1763535814ec9c3cfd312d87",
"index": 2722,
"step-1": "<mask token>\n\n\ndef run_bwa(reference_genome, forward_read, reverse_read, threads, output, i):\n \"\"\" Run bwa to align reads to reference genome \"\"\"\n print('Align reads with BWA MEM')\n bwa_index_args = ['bwa', 'in... | [
3,
4,
6,
7,
8
] |
correction_list = {}
correction_list["Legend of Zelda, The - Majora's Mask"] = "The Legend of Zelda - Majora's Mask"
correction_list["Legend of Zelda, The - Ocarina of Time"] = "The Legend of Zelda - Ocarina of Time"
correction_list["Doubutsu no Mori"] = "Animal Forest"
correction_list["Bomberman 64 - The Second Attac... | normal | {
"blob_id": "c4dcb94b7d6e45b875dccde752d3621e491f1076",
"index": 6382,
"step-1": "<mask token>\n",
"step-2": "correction_list = {}\ncorrection_list[\"Legend of Zelda, The - Majora's Mask\"\n ] = \"The Legend of Zelda - Majora's Mask\"\ncorrection_list['Legend of Zelda, The - Ocarina of Time'\n ] = 'The L... | [
0,
1,
2
] |
#! /usr/bin/python
# -*- coding: utf8 -*-
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
import unittest
from pyama.filereader import FileReader,Segment
class TestFileReader(unittest.TestCase):
def test_reads_file(self):
reader = FileReader(
"sample_reader_test.txt",
regexe... | normal | {
"blob_id": "92dc0bd3cfcddd98f99d8152d0221f047beb4fb0",
"index": 9492,
"step-1": "<mask token>\n\n\nclass TestFileReader(unittest.TestCase):\n\n def test_reads_file(self):\n reader = FileReader('sample_reader_test.txt', regexes=[(\n 'name=\"(\\\\w+)\"', 'END SEGMENT'), ('\\\\s*\\\\*\\\\s*STA... | [
2,
3,
4,
5,
6
] |
from django.contrib import admin
from .models import Cliente, Pack
# Register your models here.
admin.site.register(Pack)
admin.site.register(Cliente)
| normal | {
"blob_id": "2af590ad11704ecf21489a5d546e61f40dcceee6",
"index": 2121,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(Pack)\nadmin.site.register(Cliente)\n",
"step-3": "from django.contrib import admin\nfrom .models import Cliente, Pack\nadmin.site.register(Pack)\nadmin.site.registe... | [
0,
1,
2,
3
] |
import sys
import pandas as pd
from components.helpers.Logger import Logger
class DataFrameCreatorBase:
"""
DataFrameCreatorBase
"""
START_DATE = "03/16/2020"
def __init__(self, input_file):
self._input_file = input_file
self.df = self._read_raw_csv()
self._clean_df()
... | normal | {
"blob_id": "f4fa7563d2cce5ee28198d4974a4276d9f71f20b",
"index": 4329,
"step-1": "<mask token>\n\n\nclass DataFrameCreatorBase:\n <mask token>\n <mask token>\n\n def __init__(self, input_file):\n self._input_file = input_file\n self.df = self._read_raw_csv()\n self._clean_df()\n ... | [
4,
6,
7,
8,
9
] |
# First, we'll import pandas, a data processing and CSV file I/O library
import pandas as pd
# We'll also import seaborn, a Python graphing library
import warnings # current version of seaborn generates a bunch of warnings that we'll ignore
warnings.filterwarnings("ignore")
import seaborn as sns
import matplotlib.py... | normal | {
"blob_id": "0125abab0312d8f007e76ee710348efc9daae31e",
"index": 4989,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwarnings.filterwarnings('ignore')\n<mask token>\nsns.set(style='white', color_codes=True)\n<mask token>\nsns.boxplot(x='Species', y='PetalLengthCm', data=iris)\nplt.show()\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
class Solution:
def minWindow(self, s: str, t: str) -> str:
char_cnt = {}
for character in t:
if character not in char_cnt:
char_cnt[character] = 1
else:
char_cnt[character] += 1
dq = [] # add index & character
min_substring = ... | normal | {
"blob_id": "22706d7d9c04bb660c9bf0df66de89ed6bd480c2",
"index": 8210,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def minWindow(self, s: str, t: str) ->str:\n char_cnt = {}\n for character in t:\n if character not in... | [
0,
1,
2,
3
] |
from ED63RDScenarioHelper import *
def main():
SetCodePage("ms932")
CreateScenaFile(
FileName = 'C2219 ._SN',
MapName = 'Ruan',
Location = 'C2219.x',
MapIndex = 84,
MapDefaultBGM = "ed60015",
Flags ... | normal | {
"blob_id": "55c2bf914a77c573d1b6835f54c82921d9fa6ad6",
"index": 1010,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n SetCodePage('ms932')\n CreateScenaFile(FileName='C2219 ._SN', MapName='Ruan', Location=\n 'C2219.x', MapIndex=84, MapDefaultBGM='ed60015', Flags=0,\n ... | [
0,
1,
2,
3,
4
] |
import requests
import datetime
import time
from tqdm import tqdm
import json
import logging
logging.basicConfig(filename='logo.log', level=logging.DEBUG, filemode='w')
logging.debug('debug message')
logging.info('info message')
# from pprint import pprint
id_vk = input('введите id пользователя вк: ')
token_vk = input... | normal | {
"blob_id": "a22bc3bdb5e35060eff7f523b90d605ff2dd3878",
"index": 9581,
"step-1": "<mask token>\n\n\ndef ya_headers():\n return {'Content-type': 'application/json', 'Authorization': 'OAuth {}'\n .format(token_ya)}\n\n\ndef put_folder(path):\n url = 'https://cloud-api.yandex.net/v1/disk/resources/'\n ... | [
3,
4,
5,
6,
7
] |
import random
import profile_handler
import re
class RollBot():
"""A class that handles the bulk of functionality"""
def __init__(self):
"""initializes the attributes of the class"""
# this is where the procesed user input gets stored for easy readbacks
self.input_last_roll = ''
... | normal | {
"blob_id": "301a6ec56bd265ff63a924ecd64d6708cb6b139c",
"index": 8419,
"step-1": "<mask token>\n\n\nclass RollBot:\n <mask token>\n\n def __init__(self):\n \"\"\"initializes the attributes of the class\"\"\"\n self.input_last_roll = ''\n self.last_roll = []\n self.result = 0\n ... | [
4,
7,
8,
9,
11
] |
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Category, Base, CategoryItem, User
engine = create_engine('postgresql:///thegoodybasket')
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
... | normal | {
"blob_id": "964499c02548a7e790d96efcd780f471ab1fe1e3",
"index": 9923,
"step-1": "from sqlalchemy import create_engine\nfrom sqlalchemy.orm import sessionmaker\n\nfrom database_setup import Category, Base, CategoryItem, User\n\nengine = create_engine('postgresql:///thegoodybasket')\n# Bind the engine to the meta... | [
0
] |
from . import match
from . import mimetype
from .mimetype import MIMEType
def sniff_unknown(resource: bytes, sniff_scriptable: bool = False): #might need more arguments
raise NotImplementedError
def sniff_mislabeled_binary(resource: bytes) -> MIMEType:
raise NotImplementedError
def sniff_mislabeled_feed(reso... | normal | {
"blob_id": "a2344f405aa681daff12166b7aad1230652373de",
"index": 3499,
"step-1": "<mask token>\n\n\ndef sniff_mislabeled_feed(resource: bytes) ->MIMEType:\n raise NotImplementedError\n\n\ndef sniff(resource: bytes, mime_type_string: str='unknown/unknown',\n no_sniff: bool=False, check_for_apache_bug: bool=... | [
2,
3,
4,
5,
6
] |
N, M = map(int, input().split())
if N >= M // 2:
print(M // 2)
else:
answer = N
M -= 2 * N
N = 0
print(answer + M // 4)
| normal | {
"blob_id": "ba26aa2f33983019b515c5ea287bd5d5d190eeac",
"index": 7685,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif N >= M // 2:\n print(M // 2)\nelse:\n answer = N\n M -= 2 * N\n N = 0\n print(answer + M // 4)\n",
"step-3": "N, M = map(int, input().split())\nif N >= M // 2:\n pr... | [
0,
1,
2
] |
import pysftp
import time
import threading
def sftp_connection():
while True:
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
try:
with pysftp.Connection('sb-emea.avl.com', username='abhishek.hingwasia@avl.com', password='AvlAvl2931!!',
... | normal | {
"blob_id": "676ccbac9385a4b63d599c3f85f16e28d839e9b8",
"index": 3731,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef sftp_connection():\n while True:\n cnopts = pysftp.CnOpts()\n cnopts.hostkeys = None\n try:\n with pysftp.Connection('sb-emea.avl.com', username... | [
0,
1,
2,
3,
4
] |
T = int(input())
for i in range(T):
start, end = map(int, input().split())
between = end - start
flag = 0
num = 1
while between > 0:
if flag % 2 == 1:
between -= num
num += 1
flag += 1
else:
between -= num
flag += 1
prin... | normal | {
"blob_id": "a96761fc483c0883b058c2b045b038522c23d426",
"index": 3441,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(T):\n start, end = map(int, input().split())\n between = end - start\n flag = 0\n num = 1\n while between > 0:\n if flag % 2 == 1:\n betwee... | [
0,
1,
2
] |
#!/usr/bin/env python3
"""Shannon entropy and P affinities"""
import numpy as np
def HP(Di, beta):
"""
Function that calculates shannon entropy
"""
P = np.exp(-Di * beta)
sumP = np.sum(P)
Pi = P / sumP
Hi = -np.sum(Pi * np.log2(Pi))
return (Hi, Pi)
| normal | {
"blob_id": "0b05b027e3c3147aa2b9c35a0bdc33633ba6e658",
"index": 7129,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef HP(Di, beta):\n \"\"\"\n Function that calculates shannon entropy\n \"\"\"\n P = np.exp(-Di * beta)\n sumP = np.sum(P)\n Pi = P / sumP\n Hi = -np.sum(Pi * np.... | [
0,
1,
2,
3
] |
from pyftpdlib.authorizers import DummyAuthorizer # Autorizaciones
from pyftpdlib.handlers import FTPHandler # Comandos del usuario
from pyftpdlib.servers import FTPServer # Creacion del servidor
import logging
import os
def main():
# Instancia un autorizador dummy para controlar usuarios "virtuales"
auth... | normal | {
"blob_id": "a12fe733e607b1ce4cf0f3f4adc3ea85d082e769",
"index": 6615,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n authorizer = DummyAuthorizer()\n authorizer.add_user('user', '12345', '.', perm='elradfmwMT')\n authorizer.add_anonymous(os.getcwd())\n handler = FTPHandler\... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 18 18:21:37 2021
@author: benoitdeschrynmakers
"""
import requests
url = 'http://127.0.0.1:8888/productionplan'
if __name__ == "__main__":
filename = "example_payloads/payload1.json"
data = open(filename, 'rb').read()
headers = {'Acc... | normal | {
"blob_id": "255130082ee5f8428f1700b47dee717465fed72f",
"index": 4067,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n filename = 'example_payloads/payload1.json'\n data = open(filename, 'rb').read()\n headers = {'Accept': 'application/json', 'Content-Type': 'applicat... | [
0,
1,
2,
3,
4
] |
class item():
def __init__(self,iname,itq,iup):
self.iname = iname
self.itq = itq
self.iup = iup
class store():
def __init__(self,dic):
self.dic = dic
def add(self,iname,itq,iup):
i = item(iname,itq,iup)
self.dic[iname]=[itq,iup]
def cal... | normal | {
"blob_id": "b11210e73b403bc7a9ee24a53201ab2366ec1808",
"index": 7106,
"step-1": "<mask token>\n\n\nclass store:\n <mask token>\n\n def add(self, iname, itq, iup):\n i = item(iname, itq, iup)\n self.dic[iname] = [itq, iup]\n\n def callbill(self, rname, rq):\n for i in range(0, len(s... | [
4,
6,
7,
9,
10
] |
# 30_Days_Of_Code
# Day 2
# Boolean
print(True)
print(False)
| normal | {
"blob_id": "f1ca3d7ff7efcf500f1a16e415b13c47fd08688d",
"index": 5044,
"step-1": "<mask token>\n",
"step-2": "print(True)\nprint(False)\n",
"step-3": "# 30_Days_Of_Code\n# Day 2\n# Boolean\nprint(True)\nprint(False)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
#! /usr/bin/env python
def see_great_place_about_large_man(str_arg):
own_day_and_last_person(str_arg)
print('own_case')
def own_day_and_last_person(str_arg):
print(str_arg)
if __name__ == '__main__':
see_great_place_about_large_man('use_work_of_next_way')
| normal | {
"blob_id": "515c14fcf2c3e9da31f6aba4b49296b18f04f262",
"index": 4786,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef own_day_and_last_person(str_arg):\n print(str_arg)\n\n\n<mask token>\n",
"step-3": "def see_great_place_about_large_man(str_arg):\n own_day_and_last_person(str_arg)\n p... | [
0,
1,
2,
3,
4
] |
def func():
print("这是无参数的打印")
func()
def func1(a):
print(f"这是有参数的打印:{a}")
func1("有参数a")
def func2(a, b):
return a + b
print(f"有返回值打印:{func2(3, 2)}")
def func3(a, b):
return
print(f"无返回值打印:{func3(3, 2)}")
| normal | {
"blob_id": "be892250c31198e801836dba24fa8218dd50e811",
"index": 1178,
"step-1": "<mask token>\n\n\ndef func3(a, b):\n return\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef func1(a):\n print(f'这是有参数的打印:{a}')\n\n\n<mask token>\n\n\ndef func2(a, b):\n return a + b\n\n\n<mask token>\n\n\ndef func... | [
1,
3,
4,
5,
6
] |
from channels.generic.websocket import WebsocketConsumer, AsyncWebsocketConsumer
from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
import json
class AsyncConsumer(AsyncWebsocketConsumer):
chats = dict()
async def connect(self): # 连接时触发
self.room_name = self.scope... | normal | {
"blob_id": "7955479c70de679cfb7575c8bd9208d00a4893df",
"index": 4979,
"step-1": "<mask token>\n\n\nclass AsyncConsumer(AsyncWebsocketConsumer):\n <mask token>\n\n async def connect(self):\n self.room_name = self.scope['url_route']['kwargs']['room_name']\n self.room_group_name = 'chat_%s' % s... | [
1,
2,
3,
4,
5
] |
# Accepted
def bubble_sort(a_list, n):
num_reverse = 0
for i in range(n):
for j in range(n - i - 1):
# With a for roop (reversed order),
# index starts -1, -2 ,...,
# NOT -0, -1, ...
if a_list[-j - 2] > a_list[-j - 1]:
tmp_elem = a_list[-... | normal | {
"blob_id": "fef1273552350bfaf075d90279c9f10a965cae25",
"index": 2939,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n n = int(input())\n a_list = list(map(int, input().split()))\n a_list_reversed, num_reverse = bubble_sort(a_list, n)\n print(' '.join(map(str, a_list_reversed... | [
0,
1,
2,
3,
4
] |
import h5py
import sys
f = h5py.File(sys.argv[1], 'r+')
try:
del f['optimizer_weights']
except:
print "done"
f.close() | normal | {
"blob_id": "3458e1efdc492a08d8272469aa9e3f0ca72c7ba3",
"index": 9146,
"step-1": "import h5py\nimport sys\nf = h5py.File(sys.argv[1], 'r+')\ntry:\n\tdel f['optimizer_weights']\nexcept:\n\tprint \"done\"\nf.close()",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]... | [
0
] |
# player input is: Word made, starting tile position of the word made, horizontal or vertical
# example: playerinput = ['STRING', (0, 1), 'v']
import numpy as np
import string
def boundarytester(playerinput): # to check whether the player is placing the tiles within the confines of the board
if playerinput[1][0]... | normal | {
"blob_id": "2cb0f2fbf3ceddb2f1ee65614506dbfb3b5c8089",
"index": 4736,
"step-1": "<mask token>\n\n\ndef boundarytester(playerinput):\n if playerinput[1][0] > 14 or playerinput[1][0] < 0 or playerinput[1][1\n ] > 14 or playerinput[1][1] < 0:\n return False\n if playerinput[2] == 'h':\n ... | [
6,
7,
8,
9,
10
] |
import unittest
from pattern.multiplier import Multiplier, FixedWidth, Range
from pattern.multiplier import WHATEVER, ONE_OR_MORE
class TestMultipler(unittest.TestCase):
def test__create__fixed_width(self):
self.assertIsInstance(Multiplier.create(23), FixedWidth)
def test__create__range(self):
... | normal | {
"blob_id": "5a7e535f2ae585f862cc792dab77f2fe0584fddc",
"index": 9986,
"step-1": "<mask token>\n\n\nclass TestWhatever(unittest.TestCase):\n\n def test_compile(self):\n self.assertEqual(WHATEVER.compile(), '*')\n\n\nclass TestOneOrMore(unittest.TestCase):\n\n def test_compile(self):\n self.as... | [
8,
10,
12,
13,
15
] |
from pygraphblas.matrix import Matrix
from pygraphblas.types import BOOL
from pyformlang.regular_expression import Regex
class Graph:
def __init__(self):
self.n_vertices = 0
self.label_matrices = dict()
self.start_vertices = set()
self.final_vertices = set()
def from_trans(se... | normal | {
"blob_id": "2ccc3bb63445572610f6dbdfe5b1cbeef506c9a9",
"index": 8613,
"step-1": "<mask token>\n\n\nclass Graph:\n <mask token>\n <mask token>\n <mask token>\n\n def transitive_closure_1(self):\n adj_matrix = Matrix.sparse(BOOL, self.n_vertices, self.n_vertices)\n for label_matrix in se... | [
3,
5,
8,
9
] |
import time
from PyQt5.QtCore import (
QThread,
)
from common import attach_common
from database_downloader import DatabaseDownload
from ai_list_memorize import MemorizeList
from ai_list_morpheme import MorphemeList
from ai_list_ngram import NgramList
from ai_list_none import NoneList
from ai_bot_memorize import Me... | normal | {
"blob_id": "77763f501c6776969d2594f987e5d7ab7d4377fb",
"index": 317,
"step-1": "<mask token>\n\n\n@attach_common\nclass TalkBotThread(QThread):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def run(self):\n self.start_database()\n ... | [
6,
7,
9,
11,
12
] |
"""Tests for Node objects."""
import numpy as np
import unittest
import optimus.core as core
import optimus.nodes as nodes
import optimus.util as util
def __relu__(x):
"Numpy Rectified Linear Unit."
return 0.5 * (np.abs(x) + x)
class NodeTests(unittest.TestCase):
def setUp(self):
pass
de... | normal | {
"blob_id": "8e74bd0c051b672bf22c2c8dfb03760805b105c5",
"index": 8799,
"step-1": "<mask token>\n\n\nclass NodeTests(unittest.TestCase):\n <mask token>\n\n def tearDown(self):\n pass\n <mask token>\n <mask token>\n\n def test_Add(self):\n x1 = core.Input(name='x1', shape=(2, 2))\n ... | [
19,
20,
23,
25,
34
] |
''' 简述:这里有四个数字,分别是:1、2、3、4
提问:能组成多少个互不相同且无重复数字的三位数?各是多少? '''
for x in range(1,5):
for y in range(1,5):
for z in range(1,5):
if (x != y) & (x != z) & (y != z):
print(x,y,z)
| normal | {
"blob_id": "caac877bf6c42217ea41f51717f6a704a3a9774b",
"index": 6838,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor x in range(1, 5):\n for y in range(1, 5):\n for z in range(1, 5):\n if (x != y) & (x != z) & (y != z):\n print(x, y, z)\n",
"step-3": "''' 简述:这里有... | [
0,
1,
2
] |
#_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-#
# PROJECT : RegCEl - Registro para el Consumo Eléctrico #
# VERSION : 1.2 ... | normal | {
"blob_id": "7da8a074704b1851ac352477ef72a4c11cea1a0b",
"index": 6737,
"step-1": "<mask token>\n\n\nclass NumericKeyboard(Bubble):\n\n def on_touch_up(self, touch):\n app = App.get_running_app()\n if not self.collide_point(*touch.pos\n ) and not self.parent.collide_point(*touch.pos):\... | [
5,
9,
10,
11,
16
] |
import csv
with open('faculty.csv') as facultycsv:
emails = list() #all email addresses
for line in facultycsv:
line = line.split(',')
if line[0] == 'name' : continue
try:
email = line[3].rstrip()
emails.append(email)
except:
continue
with o... | normal | {
"blob_id": "5af5c10c149c7b0e2a969be7895780d26a4294d0",
"index": 7326,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('faculty.csv') as facultycsv:\n emails = list()\n for line in facultycsv:\n line = line.split(',')\n if line[0] == 'name':\n continue\n try... | [
0,
1,
2,
3
] |
import sys
from pcaspy import SimpleServer, Driver
import time
from datetime import datetime
import thread
import subprocess
import argparse
#import socket
#import json
import pdb
class myDriver(Driver):
def __init__(self):
super(myDriver, self).__init__()
def printDb(prefix):
global pvdb
print... | normal | {
"blob_id": "03943e146c0d64cfe888073e3a7534b6615b023f",
"index": 6410,
"step-1": "import sys\n\nfrom pcaspy import SimpleServer, Driver\nimport time\nfrom datetime import datetime\nimport thread\nimport subprocess\nimport argparse\n#import socket\n#import json\nimport pdb\n\nclass myDriver(Driver):\n def __in... | [
0
] |
import numpy as np
from .basic import scRefData, featureSelection
from .utils import find_variable_genes, dropout_linear_model
from .process import find_de_tt, find_de_anova
"""
after normalization
befor cluster or nn_indexing
"""
class highlyVarSelecter(featureSelection):
"""
select highly varable genes;
... | normal | {
"blob_id": "c972f732553f27261d2a4a03e6e353f2e1b5f5d3",
"index": 8256,
"step-1": "<mask token>\n\n\nclass manualSelecter(featureSelection):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass markerSelecter_tt(featureSelection):\n \"\"\"\n for labeled data only\n select cluster marker as fe... | [
9,
11,
21,
23,
25
] |
# Generated by Django 2.2 on 2020-11-05 16:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('accounts', '0011_auto_20201104_0936'),
]
operations = [
migrations.AddField(
model_name='users',
name='isadmin',
... | normal | {
"blob_id": "37f610457e51599a29168accd95eaa6699c6f777",
"index": 677,
"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 = [('accounts', '... | [
0,
1,
2,
3,
4
] |
#basic API start
from flask import Flask, jsonify, abort, request
from cruiseItem import cruiseItem
from sqlalchemy import create_engine
from json import dumps
db_connect = create_engine('sqlite:///Carnivorecruise.sqlite')
app = Flask(__name__)
app.json_encoder.default = lambda self, o: o.to_joson()
app.app_c... | normal | {
"blob_id": "65bfb59a255b42854eec8b55b28711737cfc46c2",
"index": 9325,
"step-1": "<mask token>\n\n\ndef get_cruiseitemArr():\n conn = db_connect.connect()\n query = conn.execute('select * from CruiseItem')\n InventoryArr = query.cursor.fetchall()\n print(InventoryArr)\n return jsonify(InventoryArr... | [
4,
5,
6,
8,
9
] |
# coding=utf-8
from numpy import *
""" 1
函数loadDataSet()创建了一些实验样本。 该函数返回的第一个变量是进行词条切分后的文档集合, 这些文档来自斑点犬爱好者留言
板。 这些留言文本被切分成一系列的词条集合, 标点符号从文本中去掉,
loadDataSet( )函数返回的第二个
变量是一个类别标签的集合。 这里有两类, 侮辱性和非侮辱性。 这些文本的类别由人工标注, 这些标注信息用于训练程序以便自动检测侮辱性留言
"""
def loadDataSet():
postingList=[['my', 'dog', 'has', 'flea', 'problems', ... | normal | {
"blob_id": "1a166a08c835caa8dd308d59227051751aff7c0f",
"index": 9059,
"step-1": "\n# coding=utf-8\n\nfrom numpy import *\n\n\"\"\" 1\n函数loadDataSet()创建了一些实验样本。 该函数返回的第一个变量是进行词条切分后的文档集合, 这些文档来自斑点犬爱好者留言\n板。 这些留言文本被切分成一系列的词条集合, 标点符号从文本中去掉, \nloadDataSet( )函数返回的第二个\n变量是一个类别标签的集合。 这里有两类, 侮辱性和非侮辱性。 这些文本的类别由人工标注, 这些标注... | [
0
] |
# Python 3.6. Written by Alex Clarke
# Breakup a large fits image into smaller ones, with overlap, and save to disk.
# Sourecfinding is run on each cutout, and catalogues are sifted to remove duplicates from the overlap.
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import multiprocessing... | normal | {
"blob_id": "a22aa66bd65033750f23f47481ee84449fa80dbc",
"index": 8995,
"step-1": "# Python 3.6. Written by Alex Clarke\n# Breakup a large fits image into smaller ones, with overlap, and save to disk.\n# Sourecfinding is run on each cutout, and catalogues are sifted to remove duplicates from the overlap.\n\nimpor... | [
0
] |
import TryItYourSelf_9_8 as userObj
print('\n\n\n\n')
admin1 = userObj.Admin('john', 'deer', 30)
admin1.describe_user()
print('\n')
admin1.set_user_name('Reven10')
print('\n')
admin1.describe_user()
admin1.privileges.show_privileges()
| normal | {
"blob_id": "169ad888e7629faff9509399ac7ead7a149a9602",
"index": 543,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('\\n\\n\\n\\n')\n<mask token>\nadmin1.describe_user()\nprint('\\n')\nadmin1.set_user_name('Reven10')\nprint('\\n')\nadmin1.describe_user()\nadmin1.privileges.show_privileges()\n",
... | [
0,
1,
2,
3
] |
#!/usr/bin/python
#
# Copyright 2018-2020 Polyaxon, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... | normal | {
"blob_id": "fd391d28d76b0c1b3cf6d0b5134390ab3f1267fb",
"index": 5152,
"step-1": "<mask token>\n\n\nclass CliConfigManager(BaseConfigManager):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @classmethod\n def _get_count(cls):\n config = cls.get_config_o... | [
4,
5,
6,
7,
8
] |
import random
choices = ['X', 'O']
try:
# Choice of X-O given to the player
player_sym = input("Choose 'X' or 'O' : ")
# raising an exception if the variable is not X or O
if player_sym!='X' and player_sym!='O':
raise Exception("Symbol not found")
except Exception as e:
print(e.args)
else:
... | normal | {
"blob_id": "d2f6d7c779d3d6e61d9da7af01a2931fdabec828",
"index": 371,
"step-1": "<mask token>\n\n\ndef gameOver(board, symbol):\n if board[0] == board[3] == board[6] == symbol or board[1] == board[7\n ] == board[4] == symbol or board[2] == board[5] == board[8\n ] == symbol or board[0] == board[1... | [
3,
4,
5,
6,
7
] |
M, N = map(int, input().split())
def is_prime(num):
if num <= 1:
return False
i = 2
while i * i <= num:
if num % i == 0:
return False
i += 1
return True
if __name__=="__main__":
for i in range(M, N+1):
if is_prime(i):
print(i)
| normal | {
"blob_id": "07fdf6605d970d2491116ad82a1119499b561d1f",
"index": 4144,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef is_prime(num):\n if num <= 1:\n return False\n i = 2\n while i * i <= num:\n if num % i == 0:\n return False\n i += 1\n return True\n\n... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-03-26 16:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_auto_20170308_1949'),
]
operations = [
migrations.AlterField(
... | normal | {
"blob_id": "bf3b529f8f06619c94d2dfca283df086466af4ea",
"index": 5027,
"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 = [('api', '0002... | [
0,
1,
2,
3,
4
] |
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing... | normal | {
"blob_id": "049950bd4bbf7903218bb8fb3a4c91492d6af17b",
"index": 3252,
"step-1": "<mask token>\n\n\nclass _CallableObject(object):\n\n def __init__(self):\n self._lock = threading.Lock()\n self._passed_values = []\n\n def __call__(self, value):\n with self._lock:\n self._pas... | [
8,
10,
11,
12,
13
] |
from .login import LoginTask
from .tag_search import TagSearchTask
from .timeline import TimelineTask
from .get_follower import GetFollowerTask
from .followback import FollowBackTask
from .unfollow import UnFollowTask
| normal | {
"blob_id": "e899b093152ee0923f1e5ad3b5719bbf9eb4339c",
"index": 7466,
"step-1": "<mask token>\n",
"step-2": "from .login import LoginTask\nfrom .tag_search import TagSearchTask\nfrom .timeline import TimelineTask\nfrom .get_follower import GetFollowerTask\nfrom .followback import FollowBackTask\nfrom .unfollo... | [
0,
1
] |
#!/usr/bin/python3 -S
# -*- coding: utf-8 -*-
import netaddr
from cargo.fields import MacAddress
from unit_tests.fields.Field import TestField
from unit_tests import configure
class TestMacAddress(configure.NetTestCase, TestField):
@property
def base(self):
return self.orm.mac
def test___call__... | normal | {
"blob_id": "b5dba7c1566721f8bb4ec99bc2f13cae4ade4f0a",
"index": 8713,
"step-1": "<mask token>\n\n\nclass TestMacAddress(configure.NetTestCase, TestField):\n <mask token>\n <mask token>\n\n def test_insert(self):\n self.base('08-00-2b-01-02-03')\n val = self.orm.new().insert(self.base)\n ... | [
8,
9,
11,
14,
15
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# http://stackoverflow.com/questions/5276967/python-in-xcode-4
"""tv_write_xyzt2matlab.py: TremVibe Write Accelerometer XYZ and Timestamp to .m file"""
__author__ = "Salvador Aguinaga"
import sys
import MySQLdb
import math
from itertools import groupby
import csv
##########... | normal | {
"blob_id": "4f21fb4168ed29b9540d3ca2b8cf6ef746c30831",
"index": 6732,
"step-1": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n# http://stackoverflow.com/questions/5276967/python-in-xcode-4\n\n\"\"\"tv_write_xyzt2matlab.py: TremVibe Write Accelerometer XYZ and Timestamp to .m file\"\"\"\n__author__ = \"Salvador ... | [
0
] |
# Generated by Django 3.0.3 on 2020-04-24 14:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('HMS', '0009_auto_20200329_0911'),
]
operations = [
migrations.CreateModel(
name='mess_timetable',
fields=[
... | normal | {
"blob_id": "e307bcc28526081141f1f2204c225d8e5f0100a8",
"index": 9015,
"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 = [('HMS', '0009... | [
0,
1,
2,
3,
4
] |
from .auth import Auth
from .banDetection import BanDetectionThread
from .botLogging import BotLoggingThread
from .clientLauncher import ClientLauncher
from .log import LogThread, Log
from .mainThread import MainThread
from .nexonServer import NexonServer
from .tmLogging import TMLoggingThread
from .worldCheckboxStatus... | normal | {
"blob_id": "b7038ad73bf0e284474f0d89d6c34967d39541c0",
"index": 6566,
"step-1": "<mask token>\n",
"step-2": "from .auth import Auth\nfrom .banDetection import BanDetectionThread\nfrom .botLogging import BotLoggingThread\nfrom .clientLauncher import ClientLauncher\nfrom .log import LogThread, Log\nfrom .mainTh... | [
0,
1
] |
class Node():
def __init__(self, value):
self.value = value
self.next = None
def linked_list_from_array(arr):
head = Node(arr[0])
cur = head
for i in range(1, len(arr)):
cur.next = Node(arr[i])
cur = cur.next
return head
def array_from_linked_list(head):
arr = []
cur = head
whil... | normal | {
"blob_id": "e1eb86480fa4eadabf05f10cc54ff9daa790438c",
"index": 3935,
"step-1": "class Node:\n\n def __init__(self, value):\n self.value = value\n self.next = None\n\n\n<mask token>\n\n\ndef array_from_linked_list(head):\n arr = []\n cur = head\n while cur:\n arr.append(cur.valu... | [
3,
5,
7,
8,
9
] |
from rest_framework import serializers
from notes import models
class CategorySerializer(serializers.ModelSerializer):
id = serializers.StringRelatedField()
class Meta:
model = models.Category
fields = (
'id',
'name',
'color',
)
# nested category in... | normal | {
"blob_id": "704047cb7eb05db9fa5f7ae61763ddbc8942ff60",
"index": 9614,
"step-1": "<mask token>\n\n\nclass InsightSerializer(serializers.ModelSerializer):\n id = serializers.StringRelatedField()\n category = CategorySerializer()\n\n\n class Meta:\n model = models.Insight\n fields = 'id', 'c... | [
2,
3,
4,
5,
6
] |
#!/usr/bin/env python
import sys
import json
import time
import random
import pathlib
import argparse
import subprocess
proc = None
def get_wallpaper(FOLDER):
files = [path for path in pathlib.Path(FOLDER).iterdir()
if path.is_file()]
return random.choice(files)
def get_outputs():
cmd = ... | normal | {
"blob_id": "46b1991bba83968466390d306a4415b362b6a868",
"index": 3140,
"step-1": "<mask token>\n\n\ndef get_outputs():\n cmd = ['swaymsg', '-t', 'get_outputs']\n proc_result = subprocess.run(cmd, capture_output=True).stdout.decode()\n proc_json = json.loads(proc_result)\n return [output['name'] for o... | [
1,
2,
3,
5,
6
] |
../../3.1.1/_downloads/b19d86251aea30061514e17fba258dab/nan_test.py | normal | {
"blob_id": "23bd2ed783ab117bee321d97aa1c70698bdeb387",
"index": 4587,
"step-1": "../../3.1.1/_downloads/b19d86251aea30061514e17fba258dab/nan_test.py",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
import logging
loggers = {}
def create_logger(
log_level:str ='INFO',
log_name:str = 'logfile',
export_log: bool = True,
save_dir:str = ''):
if log_name in loggers.keys():
logger = loggers.get(log_name)
else:
# create logger
logger = logging.getLogger(log_name)
... | normal | {
"blob_id": "3146775c466368c25c92bd6074abb97408533500",
"index": 2956,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef create_logger(log_level: str='INFO', log_name: str='logfile',\n export_log: bool=True, save_dir: str=''):\n if log_name in loggers.keys():\n logger = loggers.get(log_... | [
0,
1,
2,
3,
4
] |
import sys, os
sys.path.append(os.path.abspath('../models'))
from GANSynth import flags as lib_flags
from GANSynth import generate_util as gu
from GANSynth import model as lib_model
from GANSynth import util
from GANSynth import train_util
import tensorflow as tf
import numpy as np
import json
from models.G... | normal | {
"blob_id": "f13a2820fe1766354109d1163c7e6fe887cd6f34",
"index": 7051,
"step-1": "<mask token>\n\n\nclass GANSynthWrapper(GenerativeModel):\n\n def __init__(self, ckpt_path, data_size, use_approx=True):\n super(GANSynthWrapper, self).__init__(use_approx=use_approx)\n self.latent_size = 256\n ... | [
7,
8,
9,
10,
11
] |
# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User
TYPE_ENT = (
( 'ROOT' , 'ROOT' ),
( 'TIERS', 'TIERS'),
)
class EntiteClass(models.Mode... | normal | {
"blob_id": "a094207b2cd9a5a4bd409ac8a644268f3808e346",
"index": 7023,
"step-1": "<mask token>\n\n\nclass UserProfile(models.Model):\n <mask token>\n <mask token>\n\n def __unicode__(self):\n return '%s : %s' % (self.user, self.tiers)\n\n @property\n def list_name(self):\n t = Entite... | [
3,
4,
6,
9,
10
] |
# -*- coding: utf-8 -*-
a=float(input('Digite um número:'))
b=(a-(a%1))
c=(a%1)
print('O valor inteiro é %d' %b)
print('O valor decimal é %.6f' %c) | normal | {
"blob_id": "1b09b18926dc95d4c4b3088f45088f12c162ccb3",
"index": 5465,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('O valor inteiro é %d' % b)\nprint('O valor decimal é %.6f' % c)\n",
"step-3": "a = float(input('Digite um número:'))\nb = a - a % 1\nc = a % 1\nprint('O valor inteiro é %d' % b)\... | [
0,
1,
2,
3
] |
from sanic import Sanic
from sanic.blueprints import Blueprint
from sanic.response import html, json, text
from sanic_jwt import Initialize
from sanic_jwt.decorators import inject_user, protected, scoped
def test_forgotten_initialized_on_protected():
blueprint = Blueprint("Test")
@blueprint.get("/protected"... | normal | {
"blob_id": "55fc197eebc4e06466e0fc0458957d0460602eef",
"index": 2032,
"step-1": "<mask token>\n\n\ndef test_forgotten_initialized_on_protected():\n blueprint = Blueprint('Test')\n\n @blueprint.get('/protected')\n @protected()\n def protected_hello_world(request):\n return json({'message': 'he... | [
6,
7,
8,
11,
13
] |
import glob
import logging
import os
import sqlite3
from aiogram import Bot, Dispatcher, executor, types
TOKEN = '1772334389:AAE5wv8gssOFOgxQjQwKk7rUSKQHr6NTjus'
logging.basicConfig(level=logging.INFO)
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)
path1 = 'C:\\Users\\const\\PycharmProjects\\t'
conn = sqlite3.connect('... | normal | {
"blob_id": "4193fa992d06890afb660c072842cf1b85a43774",
"index": 3207,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlogging.basicConfig(level=logging.INFO)\n<mask token>\n\n\n@dp.message_handler(commands=['start', 'help'])\nasync def send_welcome(message: types.Message):\n await message.reply(\n ... | [
0,
1,
2,
3,
4
] |
from django.contrib import admin
from .models import Recipe, Ingredient, ChosenIngredient, timezone
# Register your models here.)
admin.site.register(Ingredient)
admin.site.site_header = "Chef's Apprentice Admin"
admin.site.site_title = "Chef's Apprentice Admin Portal"
admin.site.index_title = "Welcome to Chef's Appre... | normal | {
"blob_id": "65bb3743ca569c295d85016c82c4f6f043778d3f",
"index": 8848,
"step-1": "<mask token>\n\n\nclass RecipeAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n model = Recipe\n\n def make_visible(self, request, queryset):\n ... | [
3,
5,
6,
8,
10
] |
from django.contrib import admin
from apps.cart.models import *
# Register your models here.
class CartAdmin(admin.ModelAdmin):
list_display = ('user_id', 'goods_id', 'goods_num')
search_fields = ('user_id', 'goods_id', 'goods_num')
list_filter = ['user_id', 'goods_id', 'goods_num']
admin.sit... | normal | {
"blob_id": "222948fb0a991bb6d7faa186c7442a303b88290b",
"index": 7184,
"step-1": "<mask token>\n\n\nclass CartAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass CartAdmin(admin.ModelAdmin):\n list_display = 'user_id', 'good... | [
1,
2,
3,
4,
5
] |
# joiner = '+'
# seq = ["Sushil","Bahadur","KC"]
# txt = joiner.join(seq)
# txt
# txt = " Sam "
# ljus = txt.ljust(7,"*")
# ljus
# txtstrip = txt.strip().strip('S')
# txtstrip
# txt = "This is my world."
# txtSplit = txt.split(maxsplit=1)
# txtSplit
# name = input("Enter your full name")
# name = name.strip()
# txt = ... | normal | {
"blob_id": "32b22cccac75c87b8638c76c0c6d27db0de4d750",
"index": 8480,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(type(list1))\nprint(list1[0])\nprint(list1[len(list1) - 1])\n<mask token>\nprint(list1)\n<mask token>\nlist4\n<mask token>\nlist4\n<mask token>\nlist4\n<mask token>\nlist4\n<mask to... | [
0,
1,
2,
3
] |
import pygame
class DrawingBrush():
def __init__(self, size, color, radius):
self.drawSurface = pygame.Surface(size, pygame.SRCALPHA, 32).convert_alpha()
self.drawColor = color
self.size = radius
self.winSize = size
self.winSurface = pygame.display.get_surface()
def Dra... | normal | {
"blob_id": "45658cdfcd1529bbf803294cd7cec32d6d2c2198",
"index": 7638,
"step-1": "<mask token>\n\n\nclass DrawingBrush:\n\n def __init__(self, size, color, radius):\n self.drawSurface = pygame.Surface(size, pygame.SRCALPHA, 32\n ).convert_alpha()\n self.drawColor = color\n self... | [
3,
4,
5,
6,
7
] |
import tkinter as tk
import tkinter.ttk as ttk
import GUIForm
import sys
def main():
global window
global _form
print("You are using Python {}.{}.{}".format(sys.version_info.major, sys.version_info.minor, sys.version_info.micro))
window=tk.Tk()
GUIForm.BuildInterface(window)
window.mainloop()... | normal | {
"blob_id": "ca5057a5fdfef0edf4cf0c3ff3e2a371907ca4ee",
"index": 1270,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n global window\n global _form\n print('You are using Python {}.{}.{}'.format(sys.version_info.major,\n sys.version_info.minor, sys.version_info.micro))\n ... | [
0,
1,
2,
3,
4
] |
from flask import Flask
from flask_ask import Ask, statement, question, session
# import json, requests
import random
app = Flask(__name__)
ask = Ask(app, "/")
def get_cat_fact():
myFacts = [
"Cats should not be fed tuna exclusively, as it lacks taurine, an essential nutrient required for good feline hea... | normal | {
"blob_id": "77971b088a7e076e3bf6d7aa320981a50e7756ce",
"index": 429,
"step-1": "<mask token>\n\n\ndef get_cat_fact():\n myFacts = [\n 'Cats should not be fed tuna exclusively, as it lacks taurine, an essential nutrient required for good feline health. Make sure you have the proper Pet supplies to kee... | [
3,
4,
5,
7,
8
] |
import pandemic as pd
from typing import Sequence
def save_gml(path: str, peers: Sequence[pd.Peer]) -> bool:
try:
with open(path, "w") as file:
file.write(graph(peers))
except Exception:
return True
return False
def print_gml(peers: Sequence[pd.Peer]) -> None:
print(grap... | normal | {
"blob_id": "cb0b963c0e5aadcb67b5ee5f055fb9b6f21892fc",
"index": 5292,
"step-1": "<mask token>\n\n\ndef node(peer: pd.Peer):\n if peer.data_infection is None:\n return ''\n return '\\t' + 'node [' + '\\n' + '\\t' + '\\t' + 'id {}'.format(peer.id\n ) + '\\n' + '\\t' + '\\t' + 'label \"{}\"'.fo... | [
2,
5,
6,
7,
8
] |
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt
import numpy ... | normal | {
"blob_id": "f8d815bcdc74452b66a1b3b33bf0fbe976e728c8",
"index": 231,
"step-1": "<mask token>\n\n\ndef dataX(features, set):\n data_x = np.array([])\n count = 0\n for filepath in glob.iglob(set):\n globpath = filepath + '\\\\*.jpg'\n for filepath in glob.iglob('' + globpath):\n ... | [
3,
4,
5,
6,
7
] |
import requests
import json
import pyttsx
engine = pyttsx.init()
engine.say('Hello from Eliq.')
engine.runAndWait()
power_value = 0
power_value_int = 0
prompt=0
Eliq_just_NOW ={}
accesstoken = "xxxxxxxxxxxxxxxxxxxxxx"
#Say warning for power use over this limmit in Watts
level_warning = 2000
Eliq_request_string = (... | normal | {
"blob_id": "72abba6fa40441ab172bccb9065aaa0af5fefd64",
"index": 7209,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nengine.say('Hello from Eliq.')\nengine.runAndWait()\n<mask token>\nprint(power_str)\nif power_value_int > level_warning:\n engine.say(power_str)\n engine.say('Warning.')\n engine... | [
0,
1,
2,
3,
4
] |
__author__ = 'xcbtrader'
# -*- coding: utf-8 -*-
from bitcoin import *
def crear_addr_word(word):
priv = sha256(word)
pub = privtopub(priv)
addr = pubtoaddr(pub)
wif = encode_privkey(priv, 'wif')
return addr, priv, wif
word = input('Entra la palabra para crear direccion bitcoin:? ')
addr, priv, wif = crear_addr... | normal | {
"blob_id": "cc7a44754dc1371733420fd3a1e51ab6b5e7c4d8",
"index": 6898,
"step-1": "<mask token>\n\n\ndef crear_addr_word(word):\n priv = sha256(word)\n pub = privtopub(priv)\n addr = pubtoaddr(pub)\n wif = encode_privkey(priv, 'wif')\n return addr, priv, wif\n\n\n<mask token>\n",
"step-2": "<mask... | [
1,
2,
3,
4,
5
] |
import traceback
from functools import partial
import json
import logging
from collections import defaultdict
from itertools import cycle as CycleIter
from datetime import datetime, date, timedelta
from decimal import Decimal
import random
from copy import deepcopy
from math import ceil
import boto3
import bottle
from... | normal | {
"blob_id": "1fbe9078748b00efad0211b29ad572df97cda921",
"index": 1958,
"step-1": "<mask token>\n\n\ndef dpd1_process(lst):\n \"\"\"已废弃的方法\"\"\"\n if not lst:\n return\n for key, l in lst.items():\n rule = getattr(BeforeInBomber, key).value\n query = AutoIVRActions.select(fn.DISTINCT... | [
60,
69,
74,
80,
146
] |
n, x = input().split()
n = int(n)
x = int(x)
m = [int(i) for i in input().split()]
m.sort(reverse=True)
i = 0
res = 0
while x > 0:
res += max(0, m[i])
m[i] -= 1
x -= 1
if m[i % n] < m[(i + 1) % n]:
i = (i + 1) % n
print(res)
| normal | {
"blob_id": "9d3439a2be1f22c8ec59923b88ac22877a4f13e8",
"index": 663,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nm.sort(reverse=True)\n<mask token>\nwhile x > 0:\n res += max(0, m[i])\n m[i] -= 1\n x -= 1\n if m[i % n] < m[(i + 1) % n]:\n i = (i + 1) % n\nprint(res)\n",
"step-3":... | [
0,
1,
2
] |
import numpy as np
import itertools as itt
from random import random
from sys import float_info
DIGITS = 3
ACCURACY = 0.001
UP_MAX = 30
class AngleInfo(object):
def __init__(self, information):
# 0 <= spin <= 360
# 0 <= up <= UP_MAX
# -1 <= sin, cos <= 1
if len(information) == 2:
... | normal | {
"blob_id": "97bbbbe6a3a89b9acc22ebdff0b96625d6267178",
"index": 3341,
"step-1": "import numpy as np\nimport itertools as itt\nfrom random import random\nfrom sys import float_info\n\nDIGITS = 3\nACCURACY = 0.001\nUP_MAX = 30\n\nclass AngleInfo(object):\n\n def __init__(self, information):\n # 0 <= spi... | [
0
] |
from time import sleep
import RPi.GPIO as gpio
buzzer_pin = 18
gpio.setmode(gpio.BCM)
gpio.setup(buzzer_pin, gpio.OUT)
def buzz(pitch, duration):
peroid = 1.0 / pitch
delay = peroid / 2.0
cycles = int(duration * pitch)
for i in range(cycles):
gpio.output(buzzer_pin, True)
sleep(delay)
... | normal | {
"blob_id": "149ac778a552fac4499d7146db8600c91c68c60e",
"index": 4479,
"step-1": "<mask token>\n\n\ndef buzz(pitch, duration):\n peroid = 1.0 / pitch\n delay = peroid / 2.0\n cycles = int(duration * pitch)\n for i in range(cycles):\n gpio.output(buzzer_pin, True)\n sleep(delay)\n ... | [
1,
2,
3,
4
] |
#listas
lista=[]
print(lista)
#lista semana
listasemana=["Lunes","Martes","Miercoles","Jueves","Viernes"]
print(listasemana[0])
#lista semana
listasemana=["Lunes","Martes","Miercoles","Jueves","Viernes"]
print(listasemana[-1])
#lista semana
listasemana=["Lunes","Martes","Miercoles","Jueves","Viernes"]
print(listase... | normal | {
"blob_id": "37b23dc520abc7cbb6798f41063696916065626f",
"index": 2203,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(lista)\n<mask token>\nprint(listasemana[0])\n<mask token>\nprint(listasemana[-1])\n<mask token>\nprint(listasemana[0, 3])\n<mask token>\nprint(conjunto)\n<mask token>\nprint(lista1p... | [
0,
1,
2,
3
] |
# zip(),可以压缩 N 个列表成为一个zip对象(可迭代对象)。
a =['a', 'b', 'c']
b =[1, 2, 3]
[x for x in zip(a, b)] # [('a', 1), ('b', 2), ('c', 3)]
# 列表长度不等时,以短的为准
c =['x','y']
[x for x in zip(a, c)] # [('a', 'x'), ('b', 'y')]
# 例子
books =['简爱','小王子','瓦尔登湖']
prices =[56, 78, 66]
for book, price in zip(books, prices):
print("%s的价格是:%3.... | normal | {
"blob_id": "0eab23f4271f724da587707599eb0cbf2144efa1",
"index": 8178,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n[x for x in zip(a, b)]\n<mask token>\n[x for x in zip(a, c)]\n<mask token>\nfor book, price in zip(books, prices):\n print('%s的价格是:%3.1f' % (book, price))\n[y for y in reversed(b)]\nfo... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.