code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
# link https://deeplizard.com/learn/video/QK_PP_2KgGE import gym import numpy as np import random import time from IPython.display import clear_output # setup the env env = gym.make("FrozenLake8x8-v0", is_slippery=False) observation = env.reset() # setup the q-table action_space_size = env.action_space.n state_space_...
normal
{ "blob_id": "b791afec1c9fb214d1f3b4ec0ec67f905d96aabf", "index": 3249, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor episode in range(num_episodes):\n state = env.reset()\n done = False\n rewards_current_episode = 0\n for step in range(steps_per_episodes):\n exploration_rate_thres...
[ 0, 1, 2, 3, 4 ]
from wtforms import StringField, PasswordField from wtforms.validators import DataRequired from flask_wtf import FlaskForm # ... class LoginForm(FlaskForm): """登录表单类""" username = StringField('用户名', validators=[DataRequired()]) password = PasswordField('密码', validators=[DataRequired()])
normal
{ "blob_id": "6ad2014191215dac97ad6fc6a026512c3d1866dc", "index": 8244, "step-1": "<mask token>\n\n\nclass LoginForm(FlaskForm):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass LoginForm(FlaskForm):\n <mask token>\n username = StringField('用户名', validators=[Dat...
[ 1, 2, 3, 4, 5 ]
class Solution(object): def gcdOfStrings(self, str1, str2): if str1 == str2: return str1 elif not str1 or not str2: return '' elif str1.startswith(str2): return self.gcdOfStrings(str1[len(str2):], str2) elif str2.startswith(str1): retu...
normal
{ "blob_id": "ab632c3c8a7f295a890de19af82fde87c6d600bc", "index": 1674, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def gcdOfStrings(self, str1, str2):\n if str1 == str2:\n return str1\n elif not str1 o...
[ 0, 1, 2 ]
import splunk.admin as admin import splunk.entity as en class ConfigApp(admin.MConfigHandler): def setup(self): if self.requestedAction == admin.ACTION_EDIT: for myarg in ['api_key']: self.supportedArgs.addOptArg(myarg) def handleList(self, confInfo): confDict = self.readConf("appsetup") if None != c...
normal
{ "blob_id": "8d6c58e9ef4e14a089a7eb33a92214d081ed7692", "index": 8462, "step-1": "<mask token>\n\n\nclass ConfigApp(admin.MConfigHandler):\n <mask token>\n\n def handleList(self, confInfo):\n confDict = self.readConf('appsetup')\n if None != confDict:\n for stanza, settings in conf...
[ 3, 4, 5, 6, 7 ]
import psycopg2 host = "datavis.cauuh8vzeelb.us-east-1.rds.amazonaws.com" database = "top5" user = "teamwonder" password = "visproject" Gentrifying = [10002,10003,10009,10026,10027,10029,10030,10031,10032,10033,10034,10035,10037,10039,10040,10454,10455,10456,10457,10458,10459,10460,10474,11102,11103,11105,11106,11206...
normal
{ "blob_id": "0ebf5646ee9693b7d0c1de61436e05b3725b2c9f", "index": 2560, "step-1": "<mask token>\n", "step-2": "<mask token>\nhost = 'datavis.cauuh8vzeelb.us-east-1.rds.amazonaws.com'\ndatabase = 'top5'\nuser = 'teamwonder'\npassword = 'visproject'\nGentrifying = [10002, 10003, 10009, 10026, 10027, 10029, 10030,...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: ascii -*- """ A script removing animations from SVG graphics. """ import sys, os, re # etree fails utterly at producing nice-looking XML from xml.dom import minidom def process(inpt, outp): def traverse(node): for child in node.childNodes: if child.nodeTy...
normal
{ "blob_id": "f819d1b1f2f6f3052247cda592007eac40aca37a", "index": 7927, "step-1": "<mask token>\n\n\ndef main():\n if len(sys.argv) != 3:\n sys.stderr.write('USAGE: %s input output\\n' % sys.argv[0])\n sys.stderr.flush()\n sys.exit(0)\n with open(sys.argv[1]) as inpt, open(sys.argv[2], ...
[ 1, 2, 3, 4, 5 ]
from sqlitedict import SqliteDict import sys import socket import urllib import argparse import zlib, pickle, sqlite3 import random from datetime import datetime import time from urllib.parse import urlparse import hashlib import subprocess import requests from multiprocessing import Pool def gz_encode(obj): retur...
normal
{ "blob_id": "295d6a66335491b406f47212064da9fd5fca6eb6", "index": 6812, "step-1": "<mask token>\n\n\ndef gz_decode(obj):\n return pickle.loads(zlib.decompress(bytes(obj)))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef gz_encode(obj):\n return sqlite3.Binary(zlib.compress(pickle.dumps(obj, pickle....
[ 1, 2, 3, 4, 5 ]
a=10 b=20 c=400 d=100 e=500 f=30 z=a+b+c+d+e+f print "The total sum is",z print "variable d added" print "Variable e added" print "Variable f is equal to 30" print "You are coming from test branch" print "Your are very new in this branch"
normal
{ "blob_id": "700d876dd45548b74b563ed86f8124fa666e1739", "index": 2588, "step-1": "a=10\nb=20\nc=400\nd=100\ne=500\nf=30\nz=a+b+c+d+e+f\nprint \"The total sum is\",z\nprint \"variable d added\"\nprint \"Variable e added\"\nprint \"Variable f is equal to 30\"\nprint \"You are coming from test branch\"\nprint \"You...
[ 0 ]
# Generated by Django 2.0.1 on 2018-05-01 11:46 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('rover', '0002_auto_20180501_1431'), ] operations = [ migrations.CreateModel( name='RoverPage', fields=[ ...
normal
{ "blob_id": "fed94e0affa1fe6c705577a63fabee839aa9f05c", "index": 5096, "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 = [('rover', '00...
[ 0, 1, 2, 3, 4 ]
print(1/2 * 2) # division ret
normal
{ "blob_id": "2c1e51f2c392e77299463d95a2277b3d2ca7c299", "index": 4336, "step-1": "<mask token>\n", "step-2": "print(1 / 2 * 2)\n", "step-3": "print(1/2 * 2) # division ret\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
def test(x): print x
normal
{ "blob_id": "78e008b4a51cdbbb81dead7bc5945ee98ccad862", "index": 8266, "step-1": "def test(x):\n print x\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
""" @version: author:yunnaidan @time: 2019/07/22 @file: download_mseed.py @function: """ from obspy.clients.fdsn import Client from obspy.core import UTCDateTime import numpy as np import obspy import os import re import time import glob import shutil import platform import subprocess import multiprocessing def load_...
normal
{ "blob_id": "34db3c9998e1d7647dd954e82e18147504cc74fc", "index": 6736, "step-1": "<mask token>\n\n\ndef load_stations(filename):\n with open(filename, 'r') as f:\n sta_data = f.readlines()\n sta_list = []\n for l in range(1, len(sta_data)):\n sta_info = sta_data[l]\n net_name = re.s...
[ 3, 5, 6, 7, 9 ]
from connection import Machine from credentials import get_credentials targets = ['45.32.13.245'] #targets = ['localhost'] input_file = 'cmd' def main(): global targets username, password = get_credentials('laozi') remote_host = Machine(username, password) for target in targets: remote_host.co...
normal
{ "blob_id": "18bc8a8b1cbb544cfbe581e32ee5e509d67beafd", "index": 1410, "step-1": "<mask token>\n\n\ndef main():\n global targets\n username, password = get_credentials('laozi')\n remote_host = Machine(username, password)\n for target in targets:\n remote_host.connect(target)\n stdin, st...
[ 1, 2, 3, 4, 5 ]
from __future__ import print_function import ot import torch import numpy as np from sklearn.neighbors import KernelDensity from torch.utils.data import Dataset import jacinle.io as io import optimal_transport_modules.pytorch_utils as PTU import optimal_transport_modules.generate_data as g_data from optimal_transport_m...
normal
{ "blob_id": "0ee902d59d3d01b6ec8bb4cc8d5e8aa583644397", "index": 1298, "step-1": "<mask token>\n\n\ndef kde_Gaussian_fitting(miu, bandwidth):\n kde_analyzer = KernelDensity(kernel='gaussian', bandwidth=bandwidth).fit(\n miu)\n return kde_analyzer\n\n\n<mask token>\n\n\ndef second_moment_all_dist(bat...
[ 12, 13, 17, 21, 22 ]
# -*- coding:utf-8 -* import tushare as ts import numpy as np import pandas as pd import datetime import chardet import urllib import urllib2 import re from bs4 import BeautifulSoup import time from pandas import Series,DataFrame def get_relation(stock1,stock2): hist_data = ts.get_hist_data(stock1,start='2018...
normal
{ "blob_id": "00f2aafe1a0c66d0414d189b9fa3bbc2da9fd727", "index": 2066, "step-1": "# -*- coding:utf-8 -*\nimport tushare as ts\nimport numpy as np\nimport pandas as pd\nimport datetime\nimport chardet\nimport urllib\nimport urllib2\nimport re\nfrom bs4 import BeautifulSoup\nimport time\nfrom pandas import Series...
[ 0 ]
from django.urls import path from . import views urlpatterns = [ path('', views.home, name ='park-home'), path('login/', views.login, name ='park-login'), ]
normal
{ "blob_id": "2fd490ca54f5d038997cec59a3e07c3f2c2d2538", "index": 6757, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.home, name='park-home'), path('login/', views\n .login, name='park-login')]\n", "step-3": "from django.urls import path\nfrom . import views\nurlpattern...
[ 0, 1, 2, 3 ]
''' Implement GreedyMotifSearch http://rosalind.info/problems/ba2d/ Given: Integers k and t, followed by a collection of strings Dna. Return: A collection of strings BestMotifs resulting from running GreedyMotifSearch(Dna, k, t). If at any step you find more than one Profile-most probable k-mer in a given string, use...
normal
{ "blob_id": "ed7fa6e6f30eb06400cb38128617967a597f6c04", "index": 2450, "step-1": "<mask token>\n\n\ndef greedy_motif_search(dnas, k, t):\n best_motifs = [dna[:k] for dna in dnas]\n best_score = score_motifs(best_motifs)\n for i in range(len(dnas[0]) - k + 1):\n print(i)\n motifs = [dnas[0]...
[ 3, 5, 6, 7, 8 ]
from typing import List h = 5 w = 4 horizontalCuts = [3] verticalCuts = [3] class Solution: def maxArea(self, h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int: horizontalCuts.sort() verticalCuts.sort() horizontalCuts.append(h) verticalCuts.append(w) ...
normal
{ "blob_id": "8fb559810fbf79f0849ed98e51d3f2ad1ccc4b8b", "index": 8296, "step-1": "<mask token>\n\n\nclass Solution:\n\n def maxArea(self, h: int, w: int, horizontalCuts: List[int],\n verticalCuts: List[int]) ->int:\n horizontalCuts.sort()\n verticalCuts.sort()\n horizontalCuts.appe...
[ 2, 3, 4, 5, 6 ]
#coding: utf-8 import mmh3 from bitarray import bitarray BIT_SIZE = 1 << 30 class BloomFilter: def __init__(self): # Initialize bloom filter, set size and all bits to 0 bit_array = bitarray(BIT_SIZE) bit_array.setall(0) self.bit_array = bit_array def add(self, val): ...
normal
{ "blob_id": "5a103a4f72b9cd3ea3911aeefeeb2194c8ad7df0", "index": 589, "step-1": "<mask token>\n\n\nclass BloomFilter:\n\n def __init__(self):\n bit_array = bitarray(BIT_SIZE)\n bit_array.setall(0)\n self.bit_array = bit_array\n\n def add(self, val):\n point_list = self.get_posti...
[ 4, 5, 6, 7, 9 ]
from Products.CMFPlone.utils import getFSVersionTuple from bda.plone.ticketshop.interfaces import ITicketShopExtensionLayer from plone.app.robotframework.testing import MOCK_MAILHOST_FIXTURE from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PL...
normal
{ "blob_id": "5d7080f2778133d1938853512ca038edcf7c0dc4", "index": 1002, "step-1": "<mask token>\n\n\nclass TicketshopATLayer(PloneSandboxLayer):\n defaultBases = PLONE_FIXTURE,\n\n def setUpZope(self, app, configurationContext):\n import Products.ATContentTypes\n self.loadZCML(package=Products...
[ 4, 7, 10, 11, 14 ]
import numpy as np def get_mask(mask): r = mask[:, :, 0] g = mask[:, :, 1] return r // (r.max() or 1) * -1 + g // (g.max() or 1) def calculate_brightness(image): weights = np.array([0.299, 0.587, 0.114]) brightness_matrix = (image*weights).sum(axis=2) return brightness_matrix def calculate...
normal
{ "blob_id": "7130a382784955780a3f258c81ce05c61915af56", "index": 5000, "step-1": "<mask token>\n\n\ndef get_mask(mask):\n r = mask[:, :, 0]\n g = mask[:, :, 1]\n return r // (r.max() or 1) * -1 + g // (g.max() or 1)\n\n\n<mask token>\n\n\ndef extend(image, mask):\n brightness = calculate_brightness(i...
[ 3, 6, 7, 9, 10 ]
# -*- coding: utf-8 -*- {{{ # vim: set fenc=utf-8 ft=python sw=4 ts=4 sts=4 et: # Copyright (c) 2017, Battelle Memorial Institute # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistri...
normal
{ "blob_id": "6fdfcbcfdf2b680a1fbdb74f77fd5d1a9f7eac0b", "index": 6105, "step-1": "<mask token>\n\n\nclass VolttronWebRPC(object):\n\n def __init__(self, url, username='admin', password='admin'):\n \"\"\"\n :param url: Jsonrpc endpoint for posting data.\n :param username:\n :param p...
[ 11, 12, 14, 15, 18 ]
#Sorting for a number list #ascending and descending ls=[1,34,23,56,34,67,87,54,62,31,66] ls.sort(reverse=True) print(ls) ls.sort() print(ls) #Sorting a letter's list with different scenarios ls_l=["aaa","ertdf","ieurtff","fnjr","resdjx","jfh","r","fd"] #1-sort according to string length from small length to bigger ls...
normal
{ "blob_id": "0e0e51904f05b41b4769b730c836568b8bb63869", "index": 9564, "step-1": "<mask token>\n\n\ndef secondItem(ls):\n return ls[2]\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef FirstLetter(string):\n return string[0]\n\n\n<mask token>\n\n\ndef secondItem(ls):\n return ls[2]\n\n\n<mask tok...
[ 1, 2, 3, 4, 5 ]
from collections import defaultdict from typing import Union, Iterable, Sized import numpy as np from cached_property import cached_property from keras.utils import to_categorical from keras.preprocessing.sequence import pad_sequences from keras.preprocessing.text import Tokenizer, text_to_word_sequence class Source...
normal
{ "blob_id": "e5d7cc65041d65f915d4882b4fdad5bebf79a067", "index": 204, "step-1": "<mask token>\n\n\nclass TextDataset(BaseDataset):\n\n def __init__(self, source_sentences: Union[Iterable, Sized],\n target_sentences: Union[Iterable, Sized], shuffle: bool=True,\n word_frequency_threshold: int=2):\...
[ 12, 19, 20, 22, 27 ]
""" Implements BCFW for DIFFRAC objectives. """ import numpy as np import os from tqdm import tqdm from numpy.linalg import norm as matrix_norm import time def get_feat_block(feats, block_idx, memory_mode, bias_value=-1.0): """Get feature for a given block.""" if memory_mode == 'RAM': feat = feats[bl...
normal
{ "blob_id": "af02cd0778e19df7b11145c4863776a1afd1cca6", "index": 1484, "step-1": "\"\"\" Implements BCFW for DIFFRAC objectives. \"\"\"\n\nimport numpy as np\nimport os\nfrom tqdm import tqdm\nfrom numpy.linalg import norm as matrix_norm\nimport time\n\n\ndef get_feat_block(feats, block_idx, memory_mode, bias_va...
[ 0 ]
"Base class for tests." import argparse import http.client import json import os import re import sys import unittest import jsonschema import requests SCHEMA_LINK_RX = re.compile(r'<([^>])+>; rel="([^"]+)') JSON_MIMETYPE = 'application/json' DEFAULT_SETTINGS = { 'ROOT_URL': 'http://127.0.0.1:5002/api', 'U...
normal
{ "blob_id": "c455de70a79f70f5f0e21391511f5035f1b4feb9", "index": 646, "step-1": "<mask token>\n\n\nclass Base(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n self.schemas = {}\n self.session = requests.Session()\n self.session.headers.update({'x-apikey': SETTINGS['APIKEY']})\...
[ 8, 12, 13, 14, 16 ]
#!/usr/bin/python import time from daemon import runner import graphitesend from pywatts import get_data class App(): def __init__(self): self.stdin_path = '/dev/null' self.stdout_path = '/dev/tty' self.stderr_path = '/dev/tty' self.pidfile_path = '/tmp/currentcost_daemon.pid' self.pidfile_timeout = 5 ...
normal
{ "blob_id": "1aa49bc9a3ea12dffff907d17bd40b4425f28e13", "index": 9829, "step-1": "#!/usr/bin/python\nimport time\nfrom daemon import runner\nimport graphitesend\nfrom pywatts import get_data\n\nclass App():\n\tdef __init__(self):\n\t\tself.stdin_path = '/dev/null'\n\t\tself.stdout_path = '/dev/tty'\n\t\tself.std...
[ 0 ]
import sys import json with open(__file__.replace('.py', '.txt')) as f: problem = f.read() data = { 'problem': problem, 'example': """COM)B B)C C)D D)E E)F B)G G)H D)I E)J J)K K)L""" # should give 42 } def solve_problem(input): parents = {} for i, line in enumerate(input.split('\n')): ...
normal
{ "blob_id": "e57680c9bd09866e68ade0cfea7ce83cd6d50f58", "index": 1596, "step-1": "<mask token>\n\n\ndef solve_problem(input):\n parents = {}\n for i, line in enumerate(input.split('\\n')):\n about, object = line.split(')')\n parents[object] = about\n orbit_counts = {'COM': 0}\n for obje...
[ 3, 4, 5, 6, 7 ]
def Hello_worlder(x): a = [] for i in range(x): a.append('Hello world') for i in a: print(i) Hello_worlder(10)
normal
{ "blob_id": "4f116f3eec9198a56a047ab42ed8e018ebb794bb", "index": 3528, "step-1": "<mask token>\n", "step-2": "def Hello_worlder(x):\n a = []\n for i in range(x):\n a.append('Hello world')\n for i in a:\n print(i)\n\n\n<mask token>\n", "step-3": "def Hello_worlder(x):\n a = []\n f...
[ 0, 1, 2 ]
import numpy as np import matplotlib.pyplot as plt from matplotlib.image import imread X = np.array([[51, 55], [14, 19], [0, 4]]) print(X) A = np.array([[1, 2], [3, 4]]) B = np.array([10, 20]) print(A * B) print(X[0]) print(X[0][1]) for row in X: print(row) newX = X.flatten() print(newX) print(X > 15) # 데이터 ...
normal
{ "blob_id": "ba702a9c5d9d31e48b047c106d77cf1707031d70", "index": 1795, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(X)\n<mask token>\nprint(A * B)\nprint(X[0])\nprint(X[0][1])\nfor row in X:\n print(row)\n<mask token>\nprint(newX)\nprint(X > 15)\n<mask token>\nplt.plot(x, y)\nplt.show()\n<mask...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.1.4 on 2019-04-17 03:56 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('historiasClinicas', '0001_initial'), ] operations = [ migrations.AlterField( model_name='actualizacion', name='valor...
normal
{ "blob_id": "4aefabf064cdef963f9c62bd5c93892207c301d3", "index": 3076, "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 = [('historiasCl...
[ 0, 1, 2, 3, 4 ]
from pycat.base.color import Color from pycat.sprite import Sprite from pycat.window import Window from pyglet.gl.glext_arb import GL_FONT_HEIGHT_NV from random import randint window=Window() class Chick(Sprite): def on_create(self): self.image = 'chick-a.png' self.goto_random_position() ...
normal
{ "blob_id": "cc7942c406e9bcb5af43f131fdf0a6441f81c16a", "index": 4260, "step-1": "<mask token>\n\n\nclass Chick(Sprite):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Chick(Sprite):\n\n def on_create(self):\n self.image = 'chick-a.png'\n self.goto_random_position()...
[ 1, 3, 4, 5, 6 ]
# uncompyle6 version 3.2.4 # Python bytecode 2.7 (62211) # Decompiled from: Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] # Embedded file name: filecmp import os, stat from itertools import ifilter, ifilterfalse, imap, izip __all__ = [ 'cmp', 'dircmp', 'cmpfiles'] _cache = {} BU...
normal
{ "blob_id": "38f6700b283bdc68a0271cb3ec397ce72aa2de3c", "index": 6589, "step-1": "# uncompyle6 version 3.2.4\n# Python bytecode 2.7 (62211)\n# Decompiled from: Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]\n# Embedded file name: filecmp\nimport os, stat\nfrom itertools imp...
[ 0 ]
import datetime import logging import os import requests from bs4 import BeautifulSoup import telebot from azure.storage.blob import BlobClient import hashlib import azure.functions as func def hash_string(input_string: str) -> str: return hashlib.sha256(input_string.encode("utf-8")).hexdigest() ...
normal
{ "blob_id": "670a23aa910a6709735281b7e64e5254a19277c6", "index": 7924, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef hash_string(input_string: str) ->str:\n return hashlib.sha256(input_string.encode('utf-8')).hexdigest()\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef hash_string(inp...
[ 0, 1, 2, 3, 4 ]
""" All requests will be sent to backend as: { name: <class name>, data: { <all instance variables> } } """ class NewDriver: def __init__(self, uri, authToken): self.uri = uri self.authorizationToken = authToken class DriverClose: def __init__(self...
normal
{ "blob_id": "dfcb095b26a21ba0c8ccc2a2c664bcfab29b8351", "index": 8214, "step-1": "<mask token>\n\n\nclass SessionRun:\n\n def __init__(self, sessionId, cypher, params):\n self.sessionId = sessionId\n self.cypher = cypher\n self.params = params\n\n\nclass SessionReadTransaction:\n\n def...
[ 14, 16, 17, 19, 23 ]
from adb_local_installer.connection import ADBConnection with ADBConnection("a95x01", domain="dohmens.local") as conn: print(conn.conn)
normal
{ "blob_id": "6f583fde0eeab84984629b795e428300503a49c9", "index": 9852, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith ADBConnection('a95x01', domain='dohmens.local') as conn:\n print(conn.conn)\n", "step-3": "from adb_local_installer.connection import ADBConnection\nwith ADBConnection('a95x01',...
[ 0, 1, 2, 3 ]
# Generated by Django 2.1.5 on 2019-01-21 22:51 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] ope...
normal
{ "blob_id": "a6cb7a134fb8480d344743bcb7bc8766146d256f", "index": 8238, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
import torch from torch import nn import torch.nn.functional as F class JointModel(nn.Module): def __init__(self, d_v, d_e, d_t, encoder_layers, generator_layers,encoder_shortcut, generator_shortcut, generator_transform, num_word, emb_size, word_rnn_size, word_rnn_num_layer, word_rnn_dropout, word...
normal
{ "blob_id": "4f3e297b6925f8d65aacaa59bb837e746747c33f", "index": 2608, "step-1": "<mask token>\n\n\nclass JointModel(nn.Module):\n\n def __init__(self, d_v, d_e, d_t, encoder_layers, generator_layers,\n encoder_shortcut, generator_shortcut, generator_transform, num_word,\n emb_size, word_rnn_siz...
[ 5, 6, 8, 11, 12 ]
#!/usr/bin/env python3 import sys import re from collections import namedtuple def isnum(name): return name.startswith('-') or name.isdigit() class WireValues: def __init__(self): self.wires = {} def __getitem__(self, name): return int(name) if isnum(name) else self.wires[name] def _...
normal
{ "blob_id": "a5eb1f559972519dbe0f3702e03af77e61fbfb4e", "index": 7985, "step-1": "<mask token>\n\n\nclass WireValues:\n\n def __init__(self):\n self.wires = {}\n\n def __getitem__(self, name):\n return int(name) if isnum(name) else self.wires[name]\n\n def __setitem__(self, name, value):\n...
[ 7, 14, 16, 18, 20 ]
# -*- coding: utf-8 -*- import time import datetime def get_second_long(time_str=None): if time_str is None: return long(time.time()) time_array = time.strptime(time_str, "%Y-%m-%d %H:%M:%S") return long(time.mktime(time_array)) def get_curtime_str(): return datetime.datetime.now() def ge...
normal
{ "blob_id": "e735529eddd3a46ea335e593e5937558b50b142d", "index": 2276, "step-1": "<mask token>\n\n\ndef get_second_long(time_str=None):\n if time_str is None:\n return long(time.time())\n time_array = time.strptime(time_str, '%Y-%m-%d %H:%M:%S')\n return long(time.mktime(time_array))\n\n\n<mask t...
[ 7, 9, 10, 11, 14 ]
from room import Room from player import Player from item import Item # Declare all the rooms items = { 'scimitar': Item('Scimitar', '+7 Attack'), 'mace': Item('Mace', '+13 Attack'), 'tower_shield': Item('Tower Shield', '+8 Block'), 'heraldic_shield': Item('Heraldic Shield', '+12 Block'), 'chainmail...
normal
{ "blob_id": "07a172c28057dc803efdbdc10a9e2e11df4e527b", "index": 3134, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n if suppressRoomPrint:\n suppressRoomPrint = False\n else:\n print(player.location)\n print(\n f\"\"\"\n{player.location.name}\n {player.locatio...
[ 0, 1, 2, 3, 4 ]
import pyttsx3 from pydub import AudioSegment engine = pyttsx3.init() # object creation """ RATE""" #printing current voice rate engine.setProperty('rate', 150) # setting up new voice rate rate = engine.getProperty('rate') # getting details of current speaking rate print (rate) ...
normal
{ "blob_id": "32f4f7ad61b99848c907e092c5ed7a839f0b352b", "index": 6399, "step-1": "<mask token>\n", "step-2": "<mask token>\nengine.setProperty('rate', 150)\n<mask token>\nprint(rate)\n<mask token>\nwhile i < l:\n engine.save_to_file(a[i], 'TTS/trump/{}.mp3'.format(str(i)))\n engine.runAndWait()\n if i...
[ 0, 1, 2, 3, 4 ]
import torch import torch.nn as nn class ReconstructionLoss(nn.Module): def __init__(self, config): super(ReconstructionLoss, self).__init__() self.velocity_dim = config.velocity_dim def forward(self, pre_seq, gt_seq): MSE_loss = nn.MSELoss() rec_loss = MSE_loss(pre_seq[:, 1:-...
normal
{ "blob_id": "edc66bdc365f9c40ee33249bd2d02c0c5f28256a", "index": 8386, "step-1": "<mask token>\n\n\nclass VelocityLoss(nn.Module):\n\n def __init__(self, _mean, _std, config):\n super(VelocityLoss, self).__init__()\n self._mean = _mean\n self._std = _std\n self.device = config.devi...
[ 14, 18, 19, 23, 24 ]
#!/usr/bin/env python """ Update the expected test outputs and inputs for rsmsummarize and rsmcompare tests. This script assumes that you have already run `nose2 -s tests` and ran the entire test suite. By doing so, the output has been generated under the given outputs directory. And that is what will be used to gener...
normal
{ "blob_id": "7e20c61fa30ea93e69a2479e70449638eb52b7bb", "index": 2964, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n parser = argparse.ArgumentParser(prog='update_test_files.py')\n parser.add_argument('--tests', dest='tests_dir', required=True, help=\n 'The path to the exi...
[ 0, 1, 2, 3, 4 ]
import os import shutil import numpy as np import unittest from lsst.ts.wep.Utility import FilterType, runProgram from lsst.ts.wep.WepController import WepController from lsst.ts.wep.ctrlIntf.RawExpData import RawExpData from lsst.ts.aoclcSim.Utility import getModulePath from lsst.ts.aoclcSim.WepCmpt import WepCmpt ...
normal
{ "blob_id": "6e434ff213166768a6adadf99dc5d6d8611fa2ba", "index": 2762, "step-1": "<mask token>\n\n\nclass TestWepCmpt(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def testGetWepController(self):\n wepCntlr = self.wepCmpt.getWepController()\n sel...
[ 9, 14, 16, 22, 23 ]
# coding=utf-8 """ Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example Given a binary tree as follow: 1 / \ 2 3 / \ 4 5 The maximum depth is 3. """ """ Definition of TreeNode: """ class ...
normal
{ "blob_id": "262d6722f4c158d0a41b22433792cdc35651d156", "index": 9459, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n \"\"\"\n @param root: The root of binary tree.\n @return: An integer\n \"\"\"\n\n def maxDept...
[ 1, 3, 4, 5, 6 ]
# ================================================== # # MAIN WINDOW # # ================================================== # # Author: Brady Hammond # # Created: 11/21/2017 # # Last Edited: N/A ...
normal
{ "blob_id": "a555226b14223dca688d10b811eb36fb229360ce", "index": 2457, "step-1": "<mask token>\n\n\nclass UIMainWindow(object):\n <mask token>\n\n def retranslateUI(self):\n _translate = QtCore.QCoreApplication.translate\n self.main_window.setWindowTitle(_translate('main_window',\n ...
[ 4, 6, 7, 8, 9 ]
class Solution(object): def minimumTotal(self, triangle): """ :type triangle: List[List[int]] :rtype: int """ t = triangle if len(t) == 1: return t[0][0] ret = [0] * len(t) ret[0] = t[0][0] for i in range(1, len(t)): fo...
normal
{ "blob_id": "84515ef6879b54b333f9afd48c6c4b7c43ff6957", "index": 1068, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def minimumTotal(self, triangle):\n \"\"\"\n :type triangle: List[List[int]]\n :rtype: int...
[ 0, 1, 2 ]
"""This file parses vbulletin forums""" import re import logging from BeautifulSoup import BeautifulSoup as bs import imaget import pdb logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) date_marker = ["<!-- status icon and date -->", "<!-- / status icon and date -->"] message_marker = ["<!-- messa...
normal
{ "blob_id": "0846f73482ad86158c3f4e37713d6d965e21d796", "index": 2671, "step-1": "\"\"\"This file parses vbulletin forums\"\"\"\n\nimport re\nimport logging\nfrom BeautifulSoup import BeautifulSoup as bs\nimport imaget\nimport pdb\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.DEBUG)\n\n\ndate_...
[ 0 ]
from datetime import date atual = date.today().year totmaior = 0 totmenor = 0 for pessoas in range(1, 8): nasc = int(input(f'Qual sua data de nascimento? {pessoas}º: ')) idade = atual - nasc if idade >= 21: totmaior += 1 else: totmenor += 1 print(f'Ao todo tivemos {totmaior} pessoas maio...
normal
{ "blob_id": "f6d7ce2d020d11086640a34aac656098ab0b0f33", "index": 9495, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor pessoas in range(1, 8):\n nasc = int(input(f'Qual sua data de nascimento? {pessoas}º: '))\n idade = atual - nasc\n if idade >= 21:\n totmaior += 1\n else:\n ...
[ 0, 1, 2, 3 ]
# -*- coding:utf-8 -*- # Author: washing # DateTime: 2022/5/18 10:28 # File: 0668.py # Desc: CV class Solution: def findKthNumber(self, m: int, n: int, k: int) -> int: return bisect_left(range(m * n), k, key=lambda x: x // n * n + sum(x // i for i in range(x // n + 1, m + 1)))
normal
{ "blob_id": "ec9efeca7eef7b8ee25c1e089e675bdb1e53413b", "index": 417, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def findKthNumber(self, m: int, n: int, k: int) ->int:\n return bisect_left(range(m * n), k, key=lambda x: x // n * n + s...
[ 0, 1, 2, 3 ]
"""lendbooks URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-...
normal
{ "blob_id": "9e950f6fe895cfd497e94139397e8a0f19725dc0", "index": 1902, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns += [url('^api-auth/', include('rest_framework.urls', namespace=\n 'rest_framework'))]\n", "step-3": "<mask token>\nurlpatterns = [url('^admin/', admin.site.urls), url('^'...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import sys import setuptools from distutils.core import setup with open("README.md", "r") as fh: long_description = fh.read() def get_info(): init_file = 'PIKACHU/__init__.py' with open(init_file, 'r') as f: for line in f.readlines(): if "=" in line: ...
normal
{ "blob_id": "f14ff29a1a76c2916cb211c476a56aaa5061bf71", "index": 8837, "step-1": "<mask token>\n\n\ndef get_info():\n init_file = 'PIKACHU/__init__.py'\n with open(init_file, 'r') as f:\n for line in f.readlines():\n if '=' in line:\n exec(compile(line, '', 'exec'))\n re...
[ 1, 2, 3, 4, 5 ]
import copy import six from eclcli.common import command from eclcli.common import utils from eclcli.storage.storageclient import exceptions class ListVolumeType(command.Lister): def get_parser(self, prog_name): parser = super(ListVolumeType, self).get_parser(prog_name) parser.add_argument( ...
normal
{ "blob_id": "c73bea686786a30f298500968cfd01e2d5125d75", "index": 4013, "step-1": "<mask token>\n\n\nclass ListVolumeType(command.Lister):\n <mask token>\n <mask token>\n\n\nclass ShowVolumeType(command.ShowOne):\n\n def get_parser(self, prog_name):\n parser = super(ShowVolumeType, self).get_parse...
[ 4, 5, 6, 7, 8 ]
from flask import Flask, render_template from config import Config from flask_bootstrap import Bootstrap from config import config_options from flask_login import LoginManager from flask_wtf.csrf import CSRFProtect from flask_sqlalchemy import SQLAlchemy login_manager = LoginManager() login_manager.session_protection ...
normal
{ "blob_id": "2eecc852a6438db19e0ed55ba6cc6610d76c6ed0", "index": 2207, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef create_app(config_name):\n app = Flask(__name__)\n app.config.from_object(Config)\n app.config.from_object(config_options[config_name])\n app.config['SECRET_KEY'] = 'd...
[ 0, 1, 2, 3, 4 ]
import sys,argparse import os,glob import numpy as np import pandas as pd import re,bisect from scipy import stats import matplotlib # matplotlib.use('Agg') import matplotlib.pyplot as plt matplotlib.rcParams['font.size']=11 import seaborn as sns sns.set(font_scale=1.1) sns.set_style("whitegrid", {'axes.grid' : False})...
normal
{ "blob_id": "4ee47435bff1b0b4a7877c06fb13d13cf53b7fce", "index": 3910, "step-1": "<mask token>\n\n\ndef return_dci_df(DCI_dir, subdir, hm_mark, compr_type, suffix):\n dci_file = '{}/{}/{}_{}{}.csv'.format(DCI_dir, subdir, hm_mark,\n compr_type, suffix)\n if os.path.isfile(dci_file):\n dci_df ...
[ 3, 4, 5, 6, 7 ]
import os import sys import logging.config import sqlalchemy as sql from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Float, String, Text, Integer import pandas as pd import numpy as np sys.path.append('./config') import config logging.basicC...
normal
{ "blob_id": "76f2312a01bf8475220a9fcc16209faddfccd2ae", "index": 9754, "step-1": "<mask token>\n\n\nclass BeanAttributes(Base):\n \"\"\" Defines the data model for the table `bean_attributes`. \"\"\"\n __tablename__ = 'bean_attributes'\n id = Column(Integer, primary_key=True)\n species = Column(Strin...
[ 5, 6, 7, 8, 9 ]
from django.views.generic import TemplateView, FormView, CreateView, ListView from .models import Order from .form import OrderForm class OrdersListView(ListView): template_name = 'orders/index.html' queryset = Order.objects.all() context_object_name = 'order_list' class OrderCreateView(CreateView): ...
normal
{ "blob_id": "afd184962e8e69843ca518e140d5fdde3d7c9ed2", "index": 7456, "step-1": "<mask token>\n\n\nclass OrderCreateView(CreateView):\n template_name = 'orders/form.html'\n form_class = OrderForm\n success_url = '/'\n", "step-2": "<mask token>\n\n\nclass OrdersListView(ListView):\n <mask token>\n ...
[ 2, 3, 4, 5 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import tornado.web from sqlalchemy import desc from sqlalchemy.orm import contains_eager from main_app.models.post import Post from main_app.models.thread import PostThread, User2Thread from main_app.handlers.base_handler import BaseHandler class API_Comments(BaseHan...
normal
{ "blob_id": "5186400c9b3463d6be19e73de665f8792d8d68c7", "index": 6982, "step-1": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport tornado.web\n\nfrom sqlalchemy import desc\nfrom sqlalchemy.orm import contains_eager\n\nfrom main_app.models.post import Post\nfrom main_app.models.thread import PostThread...
[ 0 ]
## Author: Aleem Juma import os from app import app import pandas as pd # read in the quotes database q = pd.read_csv(os.path.join('app','data','quotes_all.csv'), sep=';', skiprows=1, header=0) # there are a few quote genres that don't occur in the model vocab # replace them with appropriate words so the similarity ...
normal
{ "blob_id": "8f854f4f2c807f988945af4dc53dba93cfb31168", "index": 9441, "step-1": "<mask token>\n\n\ndef get_similarity(word1, word2):\n \"\"\"\n Returns a similarity score between two words\n \"\"\"\n tok1 = cache.get(word1, nlp(word1))\n tok2 = cache.get(word2, nlp(word2))\n return tok1.simila...
[ 3, 5, 6, 7, 8 ]
def alt(h, dt): t=0 while True: t=t+1 a=(-6)*(t**4)+ h*(t**3)+2*(t**2)+t if a<=0: print('The balloon first touches ground at hour:') print(t) break elif t==dt: print('The balloon does not touch ground in the given tim...
normal
{ "blob_id": "592f29f08637e511bd7d49a3b58f69b700721d89", "index": 8083, "step-1": "<mask token>\n", "step-2": "def alt(h, dt):\n t = 0\n while True:\n t = t + 1\n a = -6 * t ** 4 + h * t ** 3 + 2 * t ** 2 + t\n if a <= 0:\n print('The balloon first touches ground at hour:')...
[ 0, 1, 2, 3 ]
import os import sys import json from subprocess import Popen, PIPE, STDOUT from twisted.internet.task import deferLater from twisted.internet import reactor from autobahn.twisted.websocket import WebSocketServerFactory, WebSocketServerProtocol, listenWS from utils import rsync # TODO: Add Twisted logger # TODO: Cre...
normal
{ "blob_id": "30251b7c2ce30b7fa899a5885707c078788d0106", "index": 1956, "step-1": "import os\nimport sys\nimport json\nfrom subprocess import Popen, PIPE, STDOUT\n\nfrom twisted.internet.task import deferLater\nfrom twisted.internet import reactor\nfrom autobahn.twisted.websocket import WebSocketServerFactory, We...
[ 0 ]
''' runSPP.py - wrap spp peak caller ======================================== :Tags: Python Purpose ------- Runs the spp peak caller. The workflow follows the tutorial at: http://compbio.med.harvard.edu/Supplements/ChIP-seq/tutorial.html Usage ----- Documentation ------------- Requirements: * spp >= ? * snow >...
normal
{ "blob_id": "e886b88a0b7e8c06772fe8a9554cab1bfe9e94a7", "index": 7208, "step-1": "<mask token>\n\n\ndef bamToBed(infile, outfile):\n \"\"\"convert bam to bed with bedtools.\"\"\"\n statement = 'bamToBed -i %(infile)s > %(outfile)s' % locals()\n E.debug(\"executing statement '%s'\" % statement)\n retc...
[ 3, 4, 5, 6, 7 ]
import argparse import requests from ba_bypass_bruteforce import bruteforce, stop_brute, success_queue, dict_queue, success_username from random import choice from time import sleep MAX_ROUND = 3 # 爆破的轮数 curr_round = 0 # 当前的轮数 sleep_time = 2 # 每一轮休眠的秒数 def login_limit_user(): """ 登录函数 """ try: ...
normal
{ "blob_id": "94286fc36e06598b9faa65d9e5759f9518e436c6", "index": 7979, "step-1": "<mask token>\n\n\ndef login_limit_user():\n \"\"\"\n 登录函数\n \"\"\"\n try:\n login_info = dict_queue.get(block=False)\n except Exception as e:\n print('[Error] {0}'.format(repr(e)))\n return\n ...
[ 4, 5, 6, 7, 8 ]
import os import csv import re totWords = 0 wordLen = 0 totSentWithPunctuation = 0 sourceFile = os.path.join('Resources', 'paragraph_2.txt') with open(sourceFile, 'r') as paragraph: paragraph = paragraph.read().split("\n\n") for sentence in paragraph: # Remove punctuation from sentences sentWithPunctua...
normal
{ "blob_id": "3cd7abf9659fe1db0ef3aa58df8dd7fd959e10a6", "index": 386, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(sourceFile, 'r') as paragraph:\n paragraph = paragraph.read().split('\\n\\n')\nfor sentence in paragraph:\n sentWithPunctuation = sentence\n sentNoPunctuation = re.sub('...
[ 0, 1, 2, 3, 4 ]
import pandas as pd import numpy as np import matplotlib.pylab as plt from matplotlib.pylab import rcParams #from pandas import datetime #from pandas.tseries.t from sklearn.preprocessing import MinMaxScaler #from statsmodels.tsa.seasonal import seasonal_decompose from pandas import Series data = pd.read_csv( r'E:\...
normal
{ "blob_id": "19c0c3156488ce99316ce40f32e84e476b7afdac", "index": 2754, "step-1": "<mask token>\n", "step-2": "<mask token>\nafter_process.head(5)\nafter_process.to_csv(path_or_buf=\n 'E:\\\\Thesis Content\\\\ukdale CSV\\\\Without Noise\\\\Tvday.csv', sep=',',\n index_label='date')\n", "step-3": "<mask ...
[ 0, 1, 2, 3, 4 ]
import xml.etree.ElementTree as ET from collections import OrderedDict import json import threading class MyThread(threading.Thread): def __init__(self, filenum): threading.Thread.__init__(self) self.filenum = filenum print('Inicio del thread:', str(self.filenum)) def run(self): ...
normal
{ "blob_id": "9150eb53d309e75299775cd9524a688e8dc2ff76", "index": 4210, "step-1": "<mask token>\n\n\nclass MyThread(threading.Thread):\n\n def __init__(self, filenum):\n threading.Thread.__init__(self)\n self.filenum = filenum\n print('Inicio del thread:', str(self.filenum))\n <mask tok...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- """ Created on Mon Mar 5 14:23:28 2018 @author: emily """ import pipeline import numpy as np import matplotlib.pyplot as plt import pstats import cProfile pr = cProfile.Profile() pr.enable() #def try_running(): max_it=200000 rnd_sd = 1 deps = np.concatenate((np.arange(0,10,0.2), np.aran...
normal
{ "blob_id": "cfe5d013c968afdbf1fc80e3c8c3233a3678450b", "index": 9848, "step-1": "<mask token>\n", "step-2": "<mask token>\npr.enable()\n<mask token>\nfor k in range(all_models[1,].size - 1):\n colstr = str(0.75 - k / 2 / all_models[1,].size)\n plt.plot(all_models[:, k], all_models[:, 0], '-', linewidth=...
[ 0, 1, 2, 3, 4 ]
import json import requests from pyyoutube import Api def get_data(YOUTUBE_API_KEY, videoId, maxResults, nextPageToken): """ Получение информации со страницы с видео по video id """ YOUTUBE_URI = 'https://www.googleapis.com/youtube/v3/commentThreads?key={KEY}&textFormat=plainText&' + \ ...
normal
{ "blob_id": "4ed5ceb784fb1e3046ab9f10c4b556f2e94274db", "index": 7054, "step-1": "<mask token>\n\n\ndef get_data(YOUTUBE_API_KEY, videoId, maxResults, nextPageToken):\n \"\"\"\n Получение информации со страницы с видео по video id\n \"\"\"\n YOUTUBE_URI = (\n 'https://www.googleapis.com/youtub...
[ 1, 2, 3, 4, 5 ]
from codecool_class import CodecoolClass from mentor import Mentor from student import Student codecool_bp = CodecoolClass.create_local
normal
{ "blob_id": "7e985f55271c8b588abe54a07d20b89b2a29ff0d", "index": 8380, "step-1": "<mask token>\n", "step-2": "<mask token>\ncodecool_bp = CodecoolClass.create_local\n", "step-3": "from codecool_class import CodecoolClass\nfrom mentor import Mentor\nfrom student import Student\ncodecool_bp = CodecoolClass.cre...
[ 0, 1, 2 ]
import os from CTFd.utils.encoding import hexencode def generate_nonce(): return hexencode(os.urandom(32))
normal
{ "blob_id": "4f91c57ad42759654a87328d5c92de8da14ca5ea", "index": 2966, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_nonce():\n return hexencode(os.urandom(32))\n", "step-3": "import os\nfrom CTFd.utils.encoding import hexencode\n\n\ndef generate_nonce():\n return hexencode(os.u...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import os #os.environ['CUDA_VISIBLE_DEVICES'] = '-1' import keras from keras.layers import Dense, Dropout, Input, Embedding, LSTM, Reshape, CuDNNLSTM from keras.models import Model,Sequential from keras.da...
normal
{ "blob_id": "bb335187dc61fae049ca4a9a55a93f856b3c7822", "index": 2534, "step-1": "# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport os\n#os.environ['CUDA_VISIBLE_DEVICES'] = '-1'\nimport keras\nfrom keras.layers import Dense, Dropout, ...
[ 0 ]
def twoSensorAvg(input_data, duration=1): times = {} for i in input_data: data = i.split(',') time = int(int(data[1]) / (duration * 1000)) if time not in times: times[time] = [0, 0] times[time][0] += int(data[2]) times[time][1] += 1 ans = [] for i, v i...
normal
{ "blob_id": "836d712c811079f190eae9c2780131a844c9dddf", "index": 3044, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test(input, output, duration):\n results = twoSensorAvg(input, duration)\n print(results)\n if len(results) != len(output):\n return False\n for i in range(len(...
[ 0, 1, 2, 3 ]
''' Created on Sep 23, 2016 @author: Andrew ''' from pymongo import MongoClient import re client = MongoClient() atMentions = re.compile(ur"@\w+", flags=re.I|re.U) atMidnight = re.compile(u"@midnight", flags=re.I|re.U) hashtag = re.compile(ur"#\w+", flags=re.I|re.U) features = [("usf fwa forward most", ...
normal
{ "blob_id": "eb2bb06afb9aeb46ad02cbac145ccd817131074d", "index": 1753, "step-1": "'''\r\nCreated on Sep 23, 2016\r\n\r\n@author: Andrew\r\n'''\r\nfrom pymongo import MongoClient\r\nimport re\r\n\r\nclient = MongoClient()\r\n\r\natMentions = re.compile(ur\"@\\w+\", flags=re.I|re.U)\r\natMidnight = re.compile(u\"@...
[ 0 ]
cardlist = [] card = [] for j in range(1,5): for k in range(1,14): if j == 1: cardlist.append(["S", "{}".format(k)]) elif j == 2: cardlist.append(["H", "{}".format(k)]) elif j == 3: cardlist.append(["C", "{}".format(k)]) elif j == 4: c...
normal
{ "blob_id": "937a101cf5c7e943fc62d18b77357eea151fdfaf", "index": 7789, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor j in range(1, 5):\n for k in range(1, 14):\n if j == 1:\n cardlist.append(['S', '{}'.format(k)])\n elif j == 2:\n cardlist.append(['H', '{}'.for...
[ 0, 1, 2, 3 ]
import argparse def parse_args(): """ Parse command-line arguments to train and evaluate a multimodal network for activity recognition on MM-Fit. :return: Populated namespace. """ parser = argparse.ArgumentParser(description='baseline Mask R-CNN') parser.add_argument('--dataset', required=True...
normal
{ "blob_id": "b6527a09f346ee1b7dd446a0ff21995a995481a8", "index": 6640, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_args():\n \"\"\"\n Parse command-line arguments to train and evaluate a multimodal network for activity recognition on MM-Fit.\n :return: Populated namespace.\n ...
[ 0, 1, 2, 3 ]
#Checks if all declared prefixes are used in the RDF File import glob import logging import sys import Utility as utility import re # set log level logging.basicConfig(level=logging.INFO) root_path = "../" rdf_file_extension = {".ttl":"turtle", ".nt":"nt", ".rdf":"application/rdf+xml"} regex_prefix = {".ttl": r'@pr...
normal
{ "blob_id": "fe406f40b48bf4982e7a48737b6b30514ae1fa71", "index": 7915, "step-1": "<mask token>\n", "step-2": "<mask token>\nlogging.basicConfig(level=logging.INFO)\n<mask token>\nfor extension in rdf_file_extension.keys():\n files_to_check = '**/*' + extension\n for filename in glob.iglob(root_path + fil...
[ 0, 1, 2, 3, 4 ]
from django.db import models from orders.constants import OrderStatus from subscriptions.models import Subscription class Order(models.Model): subscription = models.OneToOneField( Subscription, on_delete=models.CASCADE, related_name='order', ) order_status = models.CharField( ...
normal
{ "blob_id": "78ddae64cc576ebaf7f2cfaa4553bddbabe474b7", "index": 6918, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Order(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Order(m...
[ 0, 1, 2, 3, 4 ]
"""Produce a multi-panel figure of each output lead time in a forecast """ import matplotlib.pyplot as plt import iris.plot as iplt from irise import convert from irise.plot.util import add_map from myscripts import plotdir from myscripts.models.um import case_studies columns = 3 def main(forecast, name, levels, *a...
normal
{ "blob_id": "310e6e693cdce6ff71d06eac86214a21bef236d4", "index": 7425, "step-1": "<mask token>\n\n\ndef main(forecast, name, levels, *args, **kwargs):\n nt = len(forecast)\n rows = nt / columns + 1\n fig = plt.figure(figsize=(18, 10 * float(rows) / columns))\n for n, cubes in enumerate(forecast):\n ...
[ 1, 2, 3, 4, 5 ]
# -*- coding:utf-8 -*- from spider.driver.spider.base.spider import * class LvmamaHotelSpider(Spider): def get_comment_info2(self,shop_data): params_list_comment1 = self.params_dict.get(ParamType.COMMENT_INFO_1) comment_len = shop_data.get(FieldName.SHOP_COMMENT_NUM) while(True): ...
normal
{ "blob_id": "931e73ffce6d24dbfb92501670245e20fc403a7a", "index": 7969, "step-1": "<mask token>\n\n\nclass LvmamaHotelSpider(Spider):\n\n def get_comment_info2(self, shop_data):\n params_list_comment1 = self.params_dict.get(ParamType.COMMENT_INFO_1)\n comment_len = shop_data.get(FieldName.SHOP_CO...
[ 3, 4, 5, 6, 7 ]
/usr/local/python-3.6/lib/python3.6/abc.py
normal
{ "blob_id": "32d830f00a9d33b8f7f438c14b522ef186001bf3", "index": 9392, "step-1": "/usr/local/python-3.6/lib/python3.6/abc.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
import time from selenium import webdriver import os from selenium.webdriver.common.by import By with open("file.txt", "w") as file: content = file.write("Tanyuhich") try: browser = webdriver.Chrome() browser.get("http://suninjuly.github.io/file_input.html") input1 = browser.find_element_by_name('...
normal
{ "blob_id": "03270285c6dc99d8dcb9804270421f36b573048c", "index": 2863, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('file.txt', 'w') as file:\n content = file.write('Tanyuhich')\ntry:\n browser = webdriver.Chrome()\n browser.get('http://suninjuly.github.io/file_input.html')\n inpu...
[ 0, 1, 2, 3 ]
import DB as db import os from Chart import Chart import matplotlib.pyplot as plt import numpy as np table = db.get_researcher_copy() chart_path = '../charts/discipline ' def get_discipline_with_more_female(): docs = table.aggregate([ {'$match':{'gender':{'$exists':1}}}, {'$unwind':'$labels'}, {'$group':{'_id'...
normal
{ "blob_id": "c585b1439217fff42945eeb9e02512d73f8ba19f", "index": 5805, "step-1": "<mask token>\n\n\ndef get_discipline_with_more_female():\n docs = table.aggregate([{'$match': {'gender': {'$exists': 1}}}, {\n '$unwind': '$labels'}, {'$group': {'_id': {'label': '$labels',\n 'gender': '$gender'}, ...
[ 5, 6, 7, 8, 9 ]
import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import cv2 import imageio import pandas as pd import glob, os import numpy as np fileDir = os.getcwd() # os.chdir("./train-jpg") # there are 40480 training examples # we will allocate 39000 for training # and the remaining ...
normal
{ "blob_id": "a4deb67d277538e61c32381da0fe4886016dae33", "index": 85, "step-1": "<mask token>\n\n\nclass Net(nn.Module):\n\n def __init__(self, input_size, hidden_size, num_classes):\n super(Net, self).__init__()\n self.h1 = nn.Linear(input_size, hidden_size)\n self.h2 = nn.Linear(hidden_s...
[ 3, 4, 5, 6, 7 ]
def solution(skill, skill_trees): answer = 0 for tree in skill_trees: able = True for i in range(len(skill) - 1, 0, -1): index = tree.find(skill[i]) if index != -1 and i > 0: if tree[:index].find(skill[i - 1]) == -1: able = False ...
normal
{ "blob_id": "a72d878d246a459038640bf9c1deff562994b345", "index": 7338, "step-1": "<mask token>\n", "step-2": "def solution(skill, skill_trees):\n answer = 0\n for tree in skill_trees:\n able = True\n for i in range(len(skill) - 1, 0, -1):\n index = tree.find(skill[i])\n ...
[ 0, 1, 2, 3 ]
from .. import db class Account(db.Model): id = db.Column(db.Integer, primary_key=True) acc = db.Column(db.String(50), unique=True)#TODO 调整长度 pwd = db.Column(db.String(50))#TODO 调整长度 name = db.Column(db.String(20)) sex = db.Column(db.SmallInteger) idno = db.Column(db.String(20)) phone = db...
normal
{ "blob_id": "b6824251b1165ca6c66049d40c79fccee6bc7d3a", "index": 159, "step-1": "<mask token>\n\n\nclass Consignor(db.Model):\n id = db.Column(db.Integer, db.ForeignKey('account.id'), primary_key=True)\n account = db.relationship('Account', uselist=False)\n indents = db.relationship('Indent', lazy='dyna...
[ 8, 14, 15, 16, 18 ]
# coding=utf-8 while True: a,b=input().split() a=float(a) b=float(b) if b==0: print("error") else: c=a/b+0.5 c=int(c) print(c)
normal
{ "blob_id": "dab5e7ee1d14cba485cbaece1354ec8d686ca4ab", "index": 9080, "step-1": "<mask token>\n", "step-2": "while True:\n a, b = input().split()\n a = float(a)\n b = float(b)\n if b == 0:\n print('error')\n else:\n c = a / b + 0.5\n c = int(c)\n print(c)\n", "step...
[ 0, 1, 2 ]
#!/usr/bin/env python """ Plot EEG data. Usage: plotting.py [options] [<file>] Options: -h --help Show this screen. --version Show version. --center Center the data before plotting --sample-index=N Row index (indexed from one). --transpose Transpose data. --x...
normal
{ "blob_id": "5bd7160b6b2e283e221aeb0a6913e6d13511c1db", "index": 7073, "step-1": "<mask token>\n\n\nclass TopoPlot(object):\n <mask token>\n\n def __init__(self, data=None, axes=None):\n \"\"\"Setup defaults.\n\n Parameters\n ----------\n data : Pandas.Series or dict\n ...
[ 19, 22, 23, 25, 30 ]
"""Tools for working with Scores.""" from typing import List, Optional from citrine._serialization import properties from citrine._serialization.polymorphic_serializable import PolymorphicSerializable from citrine._serialization.serializable import Serializable from citrine._session import Session from citrine.informa...
normal
{ "blob_id": "a0086a9d27a091776378cd8bde31c59899fc07ac", "index": 3122, "step-1": "<mask token>\n\n\nclass LIScore(Serializable['LIScore'], Score):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(sel...
[ 12, 14, 16, 20, 21 ]
import tensorflow as tf class PolicyFullyConnected: def __init__(self, observation_space, action_space, batch_size, reuse): height = observation_space[0] width = observation_space[1] self.observations = tf.placeholder(shape=(batch_size, height, width), dtype=tf.float32) with tf.va...
normal
{ "blob_id": "ecf09f2c503452fefc427e8dbe151e7bc7ef677e", "index": 6139, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PolicyFullyConnected:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass PolicyFullyConnected:\n\n def __init__(self, observation_space, action_space, batch_size, reu...
[ 0, 1, 2, 3, 4 ]
""" URL Configuration to test mounting created urls from registries """ from django.contrib import admin from django.urls import include, path from staticpages.loader import StaticpagesLoader staticpages_loader = StaticpagesLoader() urlpatterns = [ path("admin/", admin.site.urls), # Add base pages urls usi...
normal
{ "blob_id": "333914f99face050376e4713ca118f2347e50018", "index": 989, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns.append(path('sub/', include(\n 'sandbox.staticpages_testapp.sub_urls')))\n", "step-3": "<mask token>\nstaticpages_loader = StaticpagesLoader()\nurlpatterns = [path('admin/...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python3 """minimum time time to write operations of copy and paste""" def minOperations(n): """ a method that calculates the fewest number of operations needed to result in exactly n H characters in the file """ if n <= 1: return 0 """loop for n number of times""" for i...
normal
{ "blob_id": "f14b9373e9bf1ad7fe2216dfefc1571f5380fb27", "index": 6528, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef minOperations(n):\n \"\"\"\n a method that calculates the fewest number of operations needed\n to result in exactly n H characters in the file\n \"\"\"\n if n <= 1:...
[ 0, 1, 2 ]
from django.shortcuts import render, get_object_or_404, redirect from django.utils import timezone from django.core.paginator import Paginator from .models import post from django.contrib.auth.decorators import login_required from .forms import post_fo from django.db.models import Q def index(request): posts_l...
normal
{ "blob_id": "2b88bec388f3872b63d6bfe200e973635bb75054", "index": 5418, "step-1": "<mask token>\n\n\ndef detail(request, post_id):\n po = get_object_or_404(post, pk=post_id)\n ratelist = [1, 2, 3, 4, 5]\n return render(request, 'detail.html', {'post': po, 'ratelist': ratelist})\n\n\n@login_required(login...
[ 2, 4, 5, 6, 7 ]
import json def get_json_data(page): with open('geekshop/json_data.json', encoding='utf-8-sig') as file: json_data = json.load(file) return json_data[page] def get_json_products_data(file_path): with open(file_path, encoding='utf-8-sig') as file: json_data = json.load(file) return js...
normal
{ "blob_id": "08b53ba116b0c5875d39af4ce18296d547d5891d", "index": 5692, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_json_products_data(file_path):\n with open(file_path, encoding='utf-8-sig') as file:\n json_data = json.load(file)\n return json_data\n", "step-3": "<mask token...
[ 0, 1, 2, 3, 4 ]
from __future__ import absolute_import, division, print_function import numbers import torch from torch.distributions import constraints from pyro.distributions.distribution import Distribution from pyro.distributions.score_parts import ScoreParts from pyro.distributions.util import broadcast_shape, sum_rightmost ...
normal
{ "blob_id": "0f0ea6f07f9a082042ed9aff7a95d372c32b5a13", "index": 1897, "step-1": "<mask token>\n\n\nclass ReshapedDistribution(TorchDistribution):\n <mask token>\n <mask token>\n\n def __init__(self, base_dist, sample_shape=torch.Size(),\n reinterpreted_batch_ndims=0):\n sample_shape = tor...
[ 27, 35, 36, 39, 44 ]
# -*- coding: utf-8 -*- """ Noting is perfect, errors and timeouts may happen, and when such failures happen, the consumer has to decide what to do with that. By default, the consumer would reject the envelope (RabbitMQ message) when a failure happens. However, errors and timeouts issues, unless there is a software bug...
normal
{ "blob_id": "848934680253ff2950db7723b1fe82b2ae799900", "index": 801, "step-1": "<mask token>\n\n\nclass LimitedRetriesPolicy(BaseRetryPolicy):\n <mask token>\n\n def __init__(self, consumer, retry_delays, retry_queue_suffix='retry',\n **kwargs):\n \"\"\"\n :param Consumer consumer: me...
[ 9, 13, 15, 23, 27 ]
class Anagram(object): def __init__(self, word): self.word = word self.canonical = self._canonicalize(word) def _canonicalize(self, word): return sorted(word.lower()) def _is_anagram(self, word): return word != self.word and self._canonicalize(word) == self.canonical ...
normal
{ "blob_id": "44224985dbfa6234eff406149ce25e1d00b512e9", "index": 620, "step-1": "class Anagram(object):\n <mask token>\n <mask token>\n <mask token>\n\n def match(self, words):\n return filter(self._is_anagram, words)\n", "step-2": "class Anagram(object):\n\n def __init__(self, word):\n ...
[ 2, 3, 4, 5 ]
# 赛场统分 # 【问题】在编程竞赛中,有10个评委为参赛的选手打分,分数为0 ~ 100分。 # 选手最后得分为:去掉一个最高分和一个最低分后其余8个分数的平均值。请编写一个程序实现。 sc_lst = [] i = 1 while len(sc_lst) < 10: try: sc = int(input('请第%d位评委打分:' % i)) if sc > 0 and sc < 101: sc_lst.append(sc) i += 1 else: print('超出范围,输入无效') ex...
normal
{ "blob_id": "a17abd3947a946daf2c453c120f2e79d2ba60778", "index": 901, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile len(sc_lst) < 10:\n try:\n sc = int(input('请第%d位评委打分:' % i))\n if sc > 0 and sc < 101:\n sc_lst.append(sc)\n i += 1\n else:\n ...
[ 0, 1, 2, 3 ]
""" 7-4. Pizza Toppings: Write a loop that prompts the user to enter a series of pizza toppings until they enter a 'quit' value. As they enter each topping, print a message saying you’ll add that topping to their pizza. """ if __name__ == '__main__': topping = None while topping != "quit": if topping: ...
normal
{ "blob_id": "4d07795543989fe481e1141756f988d276f82c02", "index": 5348, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n topping = None\n while topping != 'quit':\n if topping:\n print(\"I'll add %s to your pizza!\" % topping)\n topping = input(\n ...
[ 0, 1, 2 ]
# Generated by Django 2.2 on 2019-05-13 06:57 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('base_data_app', '0008_key_keyslider'), ] operations = [ migrations.AddField( model_name='key', name='image', ...
normal
{ "blob_id": "ad53b100a1774f5429278379302b85f3a675adea", "index": 8986, "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 = [('base_data_a...
[ 0, 1, 2, 3, 4 ]