code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
# ********************************************************************************** #
# #
# Project: Data Frame Explorer #
# Author: Pawel Rosikiewicz ... | normal | {
"blob_id": "5f50b20bd044471ebb8e1350d1a75a250b255d8f",
"index": 8854,
"step-1": "<mask token>\n\n\ndef find_and_display_patter_in_series(*, series, pattern):\n \"\"\"I used that function when i don't remeber full name of a given column\"\"\"\n res = series.loc[series.str.contains(pattern)]\n return res... | [
4,
5,
7,
8,
10
] |
y = 10
x = 'Тишь да гладь'
print(f'Текст:{x}')
print(f'Число:{y}')
a1 = input('Введите первое число: ')
a2 = input('Введите второе число: ')
b1 = input('Введите первую строку: ')
b2 = input('Введите вторую строку: ')
print(f'Вы ввели числа: {a1}/{a2}')
print(f'Вы ввели строки: {b1} / {b2}')
| normal | {
"blob_id": "2fabb03f0f6b0b297245354782e650380509424b",
"index": 8054,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(f'Текст:{x}')\nprint(f'Число:{y}')\n<mask token>\nprint(f'Вы ввели числа: {a1}/{a2}')\nprint(f'Вы ввели строки: {b1} / {b2}')\n",
"step-3": "y = 10\nx = 'Тишь да гладь'\nprint(f'Т... | [
0,
1,
2
] |
# coding=utf-8
import pytest
from twitter_tunes.scripts import redis_data
from mock import patch
REDIS_PARSE = [
(b"{'trend3': 'url3', 'trend2': 'url2', 'trend1': 'url1'}",
{'trend1': 'url1', 'trend2': 'url2', 'trend3': 'url3'}),
(b"{}", {}),
(b"{'hello':'its me'}", {'hello': 'its me'}),
(b"{'... | normal | {
"blob_id": "7f4a5779564efde7eaf08741d00254dd4aa37569",
"index": 4218,
"step-1": "<mask token>\n\n\n@pytest.mark.parametrize('data, parsed', REDIS_PARSE)\ndef test_parse_redis_data(data, parsed):\n \"\"\"Test to see if data dict in bytes is parsed.\"\"\"\n assert redis_data.parse_redis_data(data) == parsed... | [
7,
8,
10,
11,
12
] |
from unittest import mock
import pytest
from lms.models import GroupInfo
from lms.services.group_info import GroupInfoService
from tests import factories
class TestGroupInfoService:
AUTHORITY = "TEST_AUTHORITY_PROVIDED_ID"
def test_upsert_group_info_adds_a_new_if_none_exists(self, db_session, svc, params):... | normal | {
"blob_id": "07452795a677836b89eef85b6fb25b33eb464d91",
"index": 1919,
"step-1": "<mask token>\n\n\nclass TestGroupInfoService:\n <mask token>\n\n def test_upsert_group_info_adds_a_new_if_none_exists(self, db_session,\n svc, params):\n course = factories.Course(authority_provided_id=self.AUTH... | [
7,
11,
13,
14,
15
] |
import logging
from typing import Sequence
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.db.models import F, Q
from django.utils import timezone
from sentry_sdk import capture_exception
from sentry.models import (
Environment,
Project,
Release,
Rel... | normal | {
"blob_id": "eb4271aa5abe3ddc05048858205e6ef807a4f8ac",
"index": 6863,
"step-1": "<mask token>\n\n\n@instrumented_task(name=\n 'sentry.release_health.tasks.monitor_release_adoption', queue=\n 'releasemonitor', default_retry_delay=5, max_retries=5)\ndef monitor_release_adoption(**kwargs) ->None:\n metric... | [
3,
4,
5,
6,
7
] |
"""
This is the interface that allows for creating nested lists.
You should not implement it, or speculate about its implementation
class NestedInteger(object):
def isInteger(self):
# @return {boolean} True if this NestedInteger holds a single integer,
# rather than a nested list.
def getInteg... | normal | {
"blob_id": "bb81027ed5311e625591d98193997e5c7b533b70",
"index": 4945,
"step-1": "<mask token>\n\n\nclass Solution(object):\n\n def depthSum(self, nestedList):\n if len(nestedList) == 0:\n return 0\n from queue import Queue\n q = Queue()\n sum = 0\n depth = 1\n ... | [
2,
3,
4,
5,
6
] |
import os
from flask import Flask
from flask import request
result=""
app = Flask(__name__)
@app.route('/postjson', methods = ['POST'])
def postJsonHandler():
global result
#print (request.is_json)
content = request.get_json()
#print (content)
#print ("true")
#print (content["encode"])
#p... | normal | {
"blob_id": "607fc97c4520c7f54ee44e768776ceae2b70c378",
"index": 190,
"step-1": "import os\nfrom flask import Flask\nfrom flask import request\nresult=\"\" \napp = Flask(__name__)\n \n@app.route('/postjson', methods = ['POST'])\ndef postJsonHandler():\n global result\n #print (request.is_json)\n content... | [
0
] |
import pytest
from moa.primitives import NDArray, UnaryOperation, BinaryOperation, Function
from moa.yaccer import build_parser
@pytest.mark.parametrize("expression,result", [
("< 1 2 3>", NDArray(shape=(3,), data=[1, 2, 3], constant=False)),
])
def test_parse_vector(expression, result):
parser = build_parse... | normal | {
"blob_id": "a8b5cf45e5f75ae4b493f5fc9bb4555319f1a725",
"index": 5294,
"step-1": "<mask token>\n\n\n@pytest.mark.parametrize('expression,result', [('< 1 2 3>', NDArray(shape=(\n 3,), data=[1, 2, 3], constant=False))])\ndef test_parse_vector(expression, result):\n parser = build_parser(start='vector')\n ... | [
3,
4,
5,
6,
7
] |
import pickle
class myPickle:
def make(self, obj,fileName):
print("myPickle make file",fileName)
pickle.dump( obj, open(fileName,'wb') )
print(" DONE")
def load(self, fileName):
print("myPickle load file",fileName)
tr = pickle.load( open(fileName,'rb') ... | normal | {
"blob_id": "e50feccd583d7e33877d5fcc377a1d79dc247d3a",
"index": 3117,
"step-1": "<mask token>\n\n\nclass myPickle:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass myPickle:\n\n def make(self, obj, fileName):\n print('myPickle make file', fileName)\n pickle.dump(obj,... | [
1,
2,
3,
4,
5
] |
class Solution(object):
def smallestGoodBase(self, n):
"""
:type n: str
:rtype: str
"""
# k is the base and the representation is
# m bits of 1
# We then have from math
# (k**m - 1) / (k-1) = n
# m = log_k (n * k - n + 1)
# m needs to b... | normal | {
"blob_id": "de287d1bc644fdfd0f47bd8667580786b74444d0",
"index": 8863,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n <mask token>\n",
"step-3": "class Solution(object):\n <mask token>\n\n def solve_equation(self, m, n):\n k_l, k_h = 2, n - 1\n while... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# pymd2mc.xyzfile
"""
"""
__author__ = 'Mateusz Lis'
__version__= '0.1'
from optparse import OptionParser
import sys
from time import time
from constants import R, T
from energyCalc import EnergyCalculator
from latticeProjector import LatticeProjectorSimple
from lattices import HexLattice
from ... | normal | {
"blob_id": "a325feba1c2bb588321429a045133d6eede9e8cf",
"index": 9350,
"step-1": "#!/usr/bin/python\n# pymd2mc.xyzfile\n\"\"\"\n\n\"\"\"\n\n__author__ = 'Mateusz Lis'\n__version__= '0.1'\n\n\nfrom optparse import OptionParser\nimport sys\nfrom time import time\n\nfrom constants import R, T\nfrom energyCalc imp... | [
0
] |
from django.db import models
from django.utils import timezone
from django.utils.text import slugify
from django.db.models.signals import pre_save
from NetFlix.db.models import PublishStateOptions
from NetFlix.db.receivers import publicado_stado_pre_save, slugify_pre_save
class VideoQuerySet(models.QuerySet):
def... | normal | {
"blob_id": "9c98ecde2e8aac00a33da7db6e5e6023519e4b84",
"index": 7731,
"step-1": "<mask token>\n\n\nclass Video(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n ... | [
8,
14,
15,
16,
17
] |
#!/usr/bin/env python
#
# Copyright 2007 Google 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 law o... | normal | {
"blob_id": "e7ef8debbff20cb178a3870b9618cbb0652af5af",
"index": 1626,
"step-1": "#!/usr/bin/env python\n#\n# Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the Lice... | [
0
] |
import sys
sys.path.append("..")
from packages import bitso as BS
from packages import account as ACCOUNT
from packages import currency_pair as CP
account=ACCOUNT.Account('577e4a03-540f9610-f686d434-qz5c4v5b6n','dd7b02f5-c286e9d4-f2cc78c3-bfab3')
bs=BS.Bitso(account)
currency_pair=CP.CurrencyPair('btc','xmn')
depth=b... | normal | {
"blob_id": "03147de944c4f75417006a5087e75354dba644ec",
"index": 6339,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.append('..')\n<mask token>\n",
"step-3": "<mask token>\nsys.path.append('..')\n<mask token>\naccount = ACCOUNT.Account('577e4a03-540f9610-f686d434-qz5c4v5b6n',\n 'dd7b02f5-c... | [
0,
1,
2,
3,
4
] |
# testa se uma aplicacao em modo de teste esta sendo construida
def test_config(app):
assert app.testing
| normal | {
"blob_id": "96d7963faf720a3dc0d96b55ad65ee7ac83c1818",
"index": 5798,
"step-1": "<mask token>\n",
"step-2": "def test_config(app):\n assert app.testing\n",
"step-3": "# testa se uma aplicacao em modo de teste esta sendo construida\ndef test_config(app):\n assert app.testing\n",
"step-4": null,
"st... | [
0,
1,
2
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# groupby()
# groupby()把迭代器中相邻的重复元素挑出来放在一起:
import itertools
for key, group in itertools.groupby('ABAABBBCCAAA'):
print(key, list(group))
# 小结
# itertools模块提供的全部是处理迭代功能的函数,它们的返回值不是list,而是Iterator,只有用for循环迭代的时候才真正计算。
| normal | {
"blob_id": "b5568e84e19719f0fd72197ead47bd050e09f55d",
"index": 7310,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor key, group in itertools.groupby('ABAABBBCCAAA'):\n print(key, list(group))\n",
"step-3": "import itertools\nfor key, group in itertools.groupby('ABAABBBCCAAA'):\n print(key, l... | [
0,
1,
2,
3
] |
import hashlib
import math
import random
from set5.ch_4 import get_num_byte_len
class Server:
def __init__(self):
self.private_key = random.randint(0, 2**100)
self.salt = random.randint(0, 2**100)
self.salt_bytes = self.salt.to_bytes(
byteorder="big",
length=get_n... | normal | {
"blob_id": "cf7aeacedec211e76f2bfcb7f6e3cb06dbfdc36e",
"index": 3907,
"step-1": "<mask token>\n\n\nclass Server:\n\n def __init__(self):\n self.private_key = random.randint(0, 2 ** 100)\n self.salt = random.randint(0, 2 ** 100)\n self.salt_bytes = self.salt.to_bytes(byteorder='big', leng... | [
17,
19,
20,
24,
26
] |
import sys
import pygame
import pygame.camera
from pygame.locals import *
from PIL import Image
pygame.init()
pygame.camera.init()
camlist = pygame.camera.list_cameras()
print(camlist)
# images = map(Image.open, ['Test1.jpg', 'Test2.jpg', 'Test3.jpg'])
# widths, heights = zip(*(i.size for i in images))
# total_wi... | normal | {
"blob_id": "aae280e049c00e70e2214662a07eee8bfa29227e",
"index": 6632,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npygame.init()\npygame.camera.init()\n<mask token>\nprint(camlist)\n",
"step-3": "<mask token>\npygame.init()\npygame.camera.init()\ncamlist = pygame.camera.list_cameras()\nprint(camlist... | [
0,
1,
2,
3,
4
] |
import cv2
import imutils
import detect
def detectByPathVideo(path, writer):
video = cv2.VideoCapture(path)
check, frame = video.read()
if check == False:
print('Video Not Found. Please Enter a Valid Path (Full path of Video Should be Provided).')
return
print('Detecting p... | normal | {
"blob_id": "5044b8bc8cabd7762df6a0327828df4546ab8d96",
"index": 9000,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef detectByPathVideo(path, writer):\n video = cv2.VideoCapture(path)\n check, frame = video.read()\n if check == False:\n print(\n 'Video Not Found. Please... | [
0,
1,
2,
3,
4
] |
import pytest
from domain.story import Story
from tests.dot_dictionary import DotDict
@pytest.fixture()
def deployed_story_over_a_weekend():
revision_0 = DotDict({
'CreationDate': "2019-07-11T14:33:20.000Z"
})
revision_1 = DotDict({
'CreationDate': "2019-07-31T15:33:20.000Z",
'Descr... | normal | {
"blob_id": "d10c74338ea18ef3e5fb6a4dd2224faa4f94aa62",
"index": 9950,
"step-1": "<mask token>\n\n\ndef test_find_current_start_state():\n assert 'In-Progress' == Story.find_current_state_name({'Backlog',\n 'To-Do', 'In-Progress', 'Completed', 'Ready For Prod', 'Deployed'},\n {'In-Progress', 'De... | [
1,
2,
3,
4,
5
] |
from .base import paw_test
class warning_test(paw_test):
def test_warning_badchars(self):
self.paw.cset_lookup(self.badchar)
self.assertEqual(1, self.paw.wcount)
| normal | {
"blob_id": "b4c6075aabe833f6fe23471f608d928edd25ef63",
"index": 372,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass warning_test(paw_test):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass warning_test(paw_test):\n\n def test_warning_badchars(self):\n self.paw.cset_lookup(s... | [
0,
1,
2,
3
] |
# Generated by Django 2.1.2 on 2018-10-26 12:40
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0007_auto_20181010_0852'),
('accounts', '0004_playercards'),
]
operations = [
migrations.RenameModel(
old_name='PlayerCa... | normal | {
"blob_id": "59596c69df6a2c453fd147a9c8a2c7d47ed79fb3",
"index": 3222,
"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 = [('core', '000... | [
0,
1,
2,
3,
4
] |
import math
import backtrader as bt
from datetime import datetime
from bots.TelegramBot import TelegramBot
import logging
class Volume(bt.Strategy):
params = (('avg_volume_period', 10), ('ticker', 'hpg'), ('ratio', 1.25))
def __init__(self):
self.mysignal = (self.data.volume / bt.ind.Average(self.data... | normal | {
"blob_id": "acbe9a9501c6a8532249496f327c2470c1d2f8e0",
"index": 898,
"step-1": "<mask token>\n\n\nclass Volume(bt.Strategy):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Volume(bt.Strategy):\n <mask token>\n\n def __init__(self):\n self.mysignal = s... | [
1,
2,
4,
5,
6
] |
import os
import requests
from pprint import pprint as pp
from lxml import html
from bs4 import BeautifulSoup
from dotenv import load_dotenv
import datetime
load_dotenv()
class PrometeoAPI:
def __init__(self, user, pwd):
self.base_url = 'https://prometeoapi.com'
self.session = requests.Session()... | normal | {
"blob_id": "f3e654a589cc1c16b36203dd358671d0426556e6",
"index": 2676,
"step-1": "<mask token>\n\n\nclass PrometeoAPI:\n\n def __init__(self, user, pwd):\n self.base_url = 'https://prometeoapi.com'\n self.session = requests.Session()\n self.__user = user\n self.__pwd = pwd\n ... | [
5,
6,
8,
9,
10
] |
from pydispatch import dispatcher
import time
import serial
import threading
from queue import Queue
PORT='/dev/ttys005'
#PORT='/dev/tty.usbmodem1461'
SPEED=4800.0
class GcodeSender(object):
PEN_LIFT_PULSE = 1500
PEN_DROP_PULSE = 800
def __init__(self, **kwargs):
super(GcodeSender, self).__init_... | normal | {
"blob_id": "10d35ba3c04d9cd09e152c575e74b0382ff60572",
"index": 48,
"step-1": "<mask token>\n\n\nclass GcodeSender(object):\n <mask token>\n <mask token>\n\n def __init__(self, **kwargs):\n super(GcodeSender, self).__init__(**kwargs)\n self._stop = threading.Event()\n self.parsing_... | [
9,
14,
15,
16,
18
] |
# coding=utf-8
# __author__ = 'liwenxuan'
import random
chars = "1234567890ABCDEF"
ids = ["{0}{1}{2}{3}".format(i, j, k, l) for i in chars for j in chars for k in chars for l in chars]
def random_peer_id(prefix="F"*8, server_id="0000"):
"""
用于生成随机的peer_id(后四位随机)
:param prefix: 生成的peer_id的前八位, 测试用prefix为... | normal | {
"blob_id": "c77ca4aa720b172d75aff2ceda096a4969057a00",
"index": 9735,
"step-1": "# coding=utf-8\n# __author__ = 'liwenxuan'\n\nimport random\n\nchars = \"1234567890ABCDEF\"\nids = [\"{0}{1}{2}{3}\".format(i, j, k, l) for i in chars for j in chars for k in chars for l in chars]\n\n\ndef random_peer_id(prefix=\"F... | [
0
] |
# coding:utf-8
import requests
import io
from zipfile import ZipFile
if __name__ == '__main__':
sentence_url = "http://www.manythings.org/anki/deu-eng.zip"
r = requests.get(sentence_url)
z = ZipFile(io.BytesIO(r.content))
file = z.read('deu.txt')
eng_ger_data = file.decode()
eng_ger_data = eng_... | normal | {
"blob_id": "559c665e5544dd864d2f020c967ac8a8665af134",
"index": 6805,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n sentence_url = 'http://www.manythings.org/anki/deu-eng.zip'\n r = requests.get(sentence_url)\n z = ZipFile(io.BytesIO(r.content))\n file = z.read(... | [
0,
1,
2,
3
] |
from tensorflow import keras
class SkippableSeq(keras.utils.Sequence):
def __init__(self, seq):
super(SkippableSeq, self).__init__()
self.start = 0
self.seq = seq
def __iter__(self):
return self
def __next__(self):
res = self.seq[self.start]
self.start = (self.start + 1) % len(self)
... | normal | {
"blob_id": "2417dd4f3787742832fec53fec4592165d0fccfc",
"index": 9513,
"step-1": "<mask token>\n\n\nclass SkippableSeq(keras.utils.Sequence):\n\n def __init__(self, seq):\n super(SkippableSeq, self).__init__()\n self.start = 0\n self.seq = seq\n\n def __iter__(self):\n return se... | [
9,
10,
11,
12,
13
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
@project= Life_is_short_you_need_python
@file= judgement
@author= wubingyu
@create_time= 2017/12/21 下午2:58
"""
#a if condition else b
#(falseValue,trueValue)[test]
#(falseValue,trueValue)[test==True]
#(falseValue,trueValue)[bool(<expression>)]
| normal | {
"blob_id": "73e23b3560294ca24428e7dd4cc995b97767335c",
"index": 4202,
"step-1": "<mask token>\n",
"step-2": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\"\"\"\n@project= Life_is_short_you_need_python\n@file= judgement\n@author= wubingyu\n@create_time= 2017/12/21 下午2:58\n\"\"\"\n\n#a if condition else b\n#(fa... | [
0,
1
] |
from PyQt5 import QtCore
from PyQt5.QtWidgets import QTableWidgetItem, QDialog
from QT_view.PassportAdd import PassportAddDialog
from QT_view.PassportWin import Ui_Dialog
from Repository.Rep_Passport import PassportRepository
class PassportQt(QDialog):
def __init__(self):
super(PassportQt, self... | normal | {
"blob_id": "3f1715763a066fb337b3ff3d03e3736d0fb36b3f",
"index": 7325,
"step-1": "<mask token>\n\n\nclass PassportQt(QDialog):\n\n def __init__(self):\n super(PassportQt, self).__init__()\n self.passport_rep = PassportRepository()\n self.initUI()\n <mask token>\n\n def click_add(sel... | [
4,
6,
7,
8,
9
] |
from flask import Flask
from flask import render_template
# Creates a Flask application called 'app'
app = Flask(__name__, template_folder='C:\Users\jwhitehead\Documents\Webdev\Angular Web App')
# The route to display the HTML template on
@app.route('/')
def host():
return render_template('index.html')
# Run the... | normal | {
"blob_id": "3e1e2de555667bf09162cd6c62cad35dabbd0f54",
"index": 2482,
"step-1": "from flask import Flask\nfrom flask import render_template\n\n# Creates a Flask application called 'app'\napp = Flask(__name__, template_folder='C:\\Users\\jwhitehead\\Documents\\Webdev\\Angular Web App')\n\n# The route to display ... | [
0
] |
from django.apps import AppConfig
class AutomationserverConfig(AppConfig):
name = 'automationserver'
| normal | {
"blob_id": "3153218fe1d67fdc1c1957ffcfdb380688c159c1",
"index": 6483,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass AutomationserverConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass AutomationserverConfig(AppConfig):\n name = 'automationserver'\n",
"step-4": "... | [
0,
1,
2,
3
] |
from IPython import display
display.Image("./image.png") | normal | {
"blob_id": "3f5096ef5677373a1e436f454109c7b7577c0205",
"index": 6169,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndisplay.Image('./image.png')\n",
"step-3": "from IPython import display\ndisplay.Image('./image.png')\n",
"step-4": "from IPython import display\ndisplay.Image(\"./image.png\")",
"s... | [
0,
1,
2,
3
] |
from manim import *
class SlidingDoorIllustration(Scene):
def construct(self):
waiting_room = Rectangle(color=BLUE, stroke_width=8)
waiting_room.shift(LEFT + DOWN)
workspace = Rectangle(color=BLUE, stroke_width=8)
workspace.next_to(waiting_room, RIGHT + UP, buff=0)
workspac... | normal | {
"blob_id": "e93d5461a2604d3b8015489397c68e16d1cb222e",
"index": 3695,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass SlidingDoorIllustration(Scene):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass SlidingDoorIllustration(Scene):\n\n def construct(self):\n waiting_room = Re... | [
0,
1,
2,
3,
4
] |
import random
import string
import steembase
import struct
import steem
from time import sleep
from time import time
from steem.transactionbuilder import TransactionBuilder
from steembase import operations
from steembase.transactions import SignedTransaction
from resultthread import MyThread
from charm.toolbox.pairingg... | normal | {
"blob_id": "a90b7e44cc54d4f96a13e5e6e2d15b632d3c4983",
"index": 290,
"step-1": "<mask token>\n\n\nclass GroupSignature:\n\n def __init__(self, groupObj):\n global util, group\n util = SecretUtil(groupObj, debug)\n self.group = groupObj\n\n def pkGen(self, h1str):\n gstr = (\n ... | [
10,
19,
22,
24,
31
] |
class Date:
def __init__(self, strDate):
strDate = strDate.split('.')
self.day = strDate[0]
self.month = strDate[1]
self.year = strDate[2]
| normal | {
"blob_id": "805fc9a26650f85227d14da972311ffbd9dbd555",
"index": 16,
"step-1": "<mask token>\n",
"step-2": "class Date:\n <mask token>\n",
"step-3": "class Date:\n\n def __init__(self, strDate):\n strDate = strDate.split('.')\n self.day = strDate[0]\n self.month = strDate[1]\n ... | [
0,
1,
2
] |
from flask import Flask, render_template, url_for, request, jsonify
from model.model import load_site_config, load_hero_mapping, load_pretrained_model, valid_input, data_to_feature
from model.model import combine_list, hero_ids
from itertools import product
import numpy as np
app = Flask(__name__,static_folder='./stat... | normal | {
"blob_id": "06605bbd91c62a02a66770ca3f37a9d2d1401ccb",
"index": 9929,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef demo():\n return render_template('home.html', hero_mapping=hero_mapping)\n\n\n@app.route('/predict', methods=['POST'])\ndef predict():\n valid, res = valid_input(list(request.json))\n ... | [
3,
4,
5,
6,
7
] |
# coding=UTF-8
#!/usr/bin/env python
# for models.py
from django.db import models
from django.db.models import F, Q, Sum, Avg
from django.db import transaction
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.contrib.sites.models import Site
# from ... | normal | {
"blob_id": "d551cab1856fbdb91918f9171d5c02b8dab84aba",
"index": 8223,
"step-1": "<mask token>\n",
"step-2": "from django.db import models\nfrom django.db.models import F, Q, Sum, Avg\nfrom django.db import transaction\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.contrib.contenttype... | [
0,
1,
2
] |
"""
Implements Single Instance Learning SVM
From https://github.com/garydoranjr/misvm/blob/master/misvm/sil.py
Modified by Nicolas
"""
from __future__ import print_function, division
import numpy as np
import inspect
from sklearn.svm import LinearSVC as SVM
from milsvm.util import slices
class SIL(SVM):
"""
S... | normal | {
"blob_id": "f125269d5b52da41734ce94683139c44f0c4a66a",
"index": 3402,
"step-1": "<mask token>\n\n\nclass SIL(SVM):\n <mask token>\n <mask token>\n\n def fit(self, bags, y):\n \"\"\"\n @param bags : a sequence of n bags; each bag is an m-by-k array-like\n object contai... | [
3,
4,
7,
8,
10
] |
from numpy import exp, array, dot
from read import normalized
class NeuralNetwork():
def __init__(self, layer1, layer2):
self.layer1 = layer1
self.layer2 = layer2
def __sigmoid(self, x):
return 1 / (1 + exp(-x))
def __sigmoid_derivative(self, x):
return x * (1 - x)
d... | normal | {
"blob_id": "8109fcc136b967e0ed4ca06077b32612605d5e5f",
"index": 1136,
"step-1": "<mask token>\n\n\nclass NeuralNetwork:\n\n def __init__(self, layer1, layer2):\n self.layer1 = layer1\n self.layer2 = layer2\n <mask token>\n <mask token>\n <mask token>\n\n def think(self, inputs):\n ... | [
3,
6,
8,
9,
10
] |
import torch
import torch.nn as nn
import numpy as np
class EuclideanLoss(nn.Module):
def __init__(self, c_p, c_h):
super().__init__()
self.c_p = c_p
self.c_h = c_h
def forward(self, y, d):
'''
y: prediction, size = (n_product, n_obs)
d: actual sales, size = ... | normal | {
"blob_id": "67be25e8fdf004515e18e1c20b8d0238222a2172",
"index": 1401,
"step-1": "<mask token>\n\n\nclass EuclideanLoss(nn.Module):\n <mask token>\n <mask token>\n\n\nclass CostFunction(nn.Module):\n\n def __init__(self, c_p, c_h):\n super().__init__()\n self.c_p = c_p\n self.c_h = ... | [
4,
5,
6,
7,
8
] |
#Recursively parse a string for a pattern that can be either 1 or 2 characters long | normal | {
"blob_id": "4d524bb4b88b571c9567c651be1b1f1f19fd3c0b",
"index": 6296,
"step-1": "#Recursively parse a string for a pattern that can be either 1 or 2 characters long",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
1
]
} | [
1
] |
# -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-01-13 15:01
import pickle
import numpy as np
from bert_serving.client import BertClient
from pyhanlp import *
CharTable = JClass('com.hankcs.hanlp.dictionary.other.CharTable')
# bc = BertClient(ip='192.168.1.88') # ip address of the server
bc = BertClient(ip='127... | normal | {
"blob_id": "38e167630519b73bffea4ff527bc7b7272a49f1a",
"index": 348,
"step-1": "<mask token>\n\n\ndef embed_last_token(text):\n result = bc.encode(text, show_tokens=True)\n batch = []\n for sent, tensor, tokens in zip(text, result[0], result[1]):\n valid = []\n tid = 0\n buffer = '... | [
3,
4,
5,
6,
7
] |
from django.core.urlresolvers import reverse
from keptar import settings
import os, os.path
import Image
try:
from collections import OrderedDict
except ImportError:
from keptar.odict import OrderedDict
class AccessDenied(Exception):
pass
class FileNotFound(Exception):
pass
class NotDirectory(Excepti... | normal | {
"blob_id": "d9156c20e046f608563bc6779575e14cc60f4c25",
"index": 896,
"step-1": "<mask token>\n\n\nclass AccessDenied(Exception):\n pass\n\n\nclass FileNotFound(Exception):\n pass\n\n\nclass NotDirectory(Exception):\n pass\n\n\n<mask token>\n\n\ndef get_parent(path):\n \"\"\"A megadott elem szulokony... | [
5,
6,
10,
11,
12
] |
from djitellopy import Tello
import time
import threading
import pandas as pd
class DataTello:
def __init__(self):
# Inicia objeto de controle do Tello
self.tello = Tello()
# Array onde será armazenado a lista de dados coletado pelo Tello
self.__data = []
self.... | normal | {
"blob_id": "9e751bbddabbec7c5e997578d99ef1b8c35efe06",
"index": 8108,
"step-1": "<mask token>\n\n\nclass DataTello:\n\n def __init__(self):\n self.tello = Tello()\n self.__data = []\n self.__array = []\n self.tempoVoo = 420000\n \"\"\"\n ___Padrão para nome dos arqui... | [
6,
7,
8,
9,
10
] |
import chainer
import chainer.functions as F
import numpy as np
import argparse
from model import Generator, Discriminator
from chainer import cuda, serializers
from pathlib import Path
from utils import set_optimizer
from dataset import DatasetLoader
xp = cuda.cupy
cuda.get_device(0).use()
class CycleGANVC2LossCal... | normal | {
"blob_id": "32105a245f6945dbe8749140d811b20d634289bc",
"index": 2481,
"step-1": "<mask token>\n\n\nclass CycleGANVC2LossCalculator:\n\n def __init__(self):\n pass\n <mask token>\n\n @staticmethod\n def gen_loss(discriminator, y):\n y_dis = discriminator(y)\n return F.mean(F.soft... | [
3,
7,
8,
9,
11
] |
import unittest
def is_multiple(value, base):
return 0 == (value % base)
def fizz_buzz(value):
if is_multiple(value, 5) and is_multiple(value, 3):
return "FizzBuzz"
if is_multiple(value, 3):
return "Fizz"
if is_multiple(value, 5):
return "Buzz"
return str(value)
class F... | normal | {
"blob_id": "59d543ed443c156ac65f9c806ba5bada6bcd0c21",
"index": 6891,
"step-1": "<mask token>\n\n\nclass FizzBuzzTest(unittest.TestCase):\n\n def check_fizz_buzz(self, value, expected):\n result = fizz_buzz(value)\n self.assertEqual(expected, result)\n <mask token>\n\n def test_fizz_buzz_... | [
7,
10,
11,
12,
14
] |
import requests
from urllib.parse import urlparse, urlencode
from json import JSONDecodeError
from requests.exceptions import HTTPError
def validate_response(response):
"""
raise exception if error response occurred
"""
r = response
try:
r.raise_for_status()
except HTTPError as e:
... | normal | {
"blob_id": "5bd2cf2ae68708d2b1dbbe0323a5f83837f7b564",
"index": 7842,
"step-1": "<mask token>\n\n\nclass CpmsConnector:\n <mask token>\n <mask token>\n\n def __init__(self, config):\n \"\"\"initialize with config\n config(dict): must supply username, api_key, api_url\n \"\"\"\n ... | [
13,
16,
17,
19,
20
] |
import mclient
from mclient import instruments
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
#from pulseseq import sequencer, pulselib
mpl.rcParams['figure.figsize']=[6,4]
qubit_info = mclient.get_qubit_info('qubit_info')
qubit_ef_info = mclient.get_qubit_info('qubit_ef_info')
... | normal | {
"blob_id": "ba13bcf9e89ae96e9a66a42fc4e6ae4ad33c84b4",
"index": 4497,
"step-1": "import mclient\r\nfrom mclient import instruments\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib as mpl\r\n#from pulseseq import sequencer, pulselib\r\n\r\nmpl.rcParams['figure.figsize']=[6,4]\r\n\r\n... | [
0
] |
from django.db import models
from django.conf import settings
from django.utils.text import slugify
from six import python_2_unicode_compatible
from ckeditor_uploader.fields import RichTextUploadingField
from ckeditor.fields import RichTextField
# Create your models here.
class topic(models.Model):
name = models.Ch... | normal | {
"blob_id": "31801f62942337b0cdf0e022dc75a9e125be54e3",
"index": 4191,
"step-1": "<mask token>\n\n\nclass article(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(sel... | [
5,
7,
9,
10,
11
] |
"""Main application for FastAPI"""
from typing import Dict
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from cool_seq_tool.routers import default, mane, mappings, SERVICE_NAME
from cool_seq_tool.version import __version__
app = FastAPI(
docs_url=f"/{SERVICE_NAME}",
openapi_url=... | normal | {
"blob_id": "c6fa8c33630fc2f7ffb08aace1a260e6805ddfa2",
"index": 7670,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp.include_router(default.router)\napp.include_router(mane.router)\napp.include_router(mappings.router)\n\n\ndef custom_openapi() ->Dict:\n \"\"\"Generate custom fields for OpenAPI re... | [
0,
2,
3,
4,
5
] |
class product(object):
def __init__(self, item_name, price, weight, brand, status = "for sale"):
self.item_name = item_name
self.price = price
self.weight = weight
self.brand = brand
self.cost = price
self.status = status
self.displayInfo()
def displayInfo... | normal | {
"blob_id": "303d56c18cce922ace45de1b8e195ebfdd874e23",
"index": 7394,
"step-1": "class product(object):\n def __init__(self, item_name, price, weight, brand, status = \"for sale\"):\n self.item_name = item_name\n self.price = price\n self.weight = weight\n self.brand = brand\n ... | [
0
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 31 14:35:49 2019
@author: devinpowers
"""
# Lab 1 in CSE 231
#Quadratic Formula
# Find the roots in the Quadratic Formula
import math
a = float(input("Enter the coeddicient a: "))
b = float(input("Enter the coeddicient b: "))
c = float(input(... | normal | {
"blob_id": "2acfd0bbad68bb9d55aeb39b180f4326a225f6d5",
"index": 1218,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(' Coefficients:')\nprint(' Coefficient of a = ', a)\nprint(' Coefficient of b = ', b)\nprint(' Coefficient of c = ', c)\n<mask token>\nprint('The roots of the equation:')\nprint(' R... | [
0,
1,
2,
3,
4
] |
from django.urls import path
from .authentication import GetToken, RegisterUserAPIView
from .resurses import *
urlpatterns = [
path('register/', RegisterUserAPIView.as_view()),
path('get/token/', GetToken.as_view()),
path('card/list/', ShowCardsAPIView.as_view()),
path('card/create/', CreateCardAPIVie... | normal | {
"blob_id": "aac334256c1e05ef33a54da19925911af6645a10",
"index": 9529,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('register/', RegisterUserAPIView.as_view()), path(\n 'get/token/', GetToken.as_view()), path('card/list/', ShowCardsAPIView.\n as_view()), path('card/create/', C... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import airflow
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.operators import BashOperator, DummyOperator
from datetime import datetime, timedelta
# -----------------------------------------------------... | normal | {
"blob_id": "49492ad1a1734be02ebefb77095fd560a7a7efd8",
"index": 7155,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndefault_args = {'owner': 'Jaimin', 'depends_on_past': False, 'start_date':\n datetime.now(), 'email': ['airflow@airflow.com'], 'email_on_failure': \n False, 'email_on_retry': False,... | [
0,
1,
2,
3
] |
from django.contrib import admin
from django.urls import path, include
from serverside.router import router
from rest_framework.authtoken import views as auth_views
from . import views
from .views import CustomObtainAuthToken
urlpatterns = [path('users/', views.UserCreateAPIView.as_view(), name=
'user-list'), path(... | normal | {
"blob_id": "49d76458b8adcf6eea9db2ef127609ff96e03ad1",
"index": 6270,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('users/', views.UserCreateAPIView.as_view(), name=\n 'user-list'), path('users/login/', CustomObtainAuthToken.as_view()),\n path('users/<int:pk>/', views.ReadUse... | [
0,
1,
2
] |
from django.conf.urls import url
from . import views
from .import admin
urlpatterns = [
url(r'^$', views.showberanda, name='showberanda'),
url(r'^sentimenanalisis/$', views.showsentimenanalisis, name='showsentimenanalisis'),
url(r'^bantuan/$', views.showbantuan, name='showbantuan'),
url(r'^tweets/', vi... | normal | {
"blob_id": "077c596f71aae22e85589fdaf78d5cdae8085443",
"index": 8710,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('^$', views.showberanda, name='showberanda'), url(\n '^sentimenanalisis/$', views.showsentimenanalisis, name=\n 'showsentimenanalisis'), url('^bantuan/$', views.s... | [
0,
1,
2,
3
] |
from mathgraph3D.core.plot import *
from mathgraph3D.core.functions import *
| normal | {
"blob_id": "b58cc08f8f10220373fa78f5d7249bc883b447bf",
"index": 6991,
"step-1": "<mask token>\n",
"step-2": "from mathgraph3D.core.plot import *\nfrom mathgraph3D.core.functions import *\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
from django.db import models
class Survey(models.Model):
"""Survey representation.
"""
name = models.CharField(max_length=255)
description = models.TextField()
start_date = models.DateTimeField()
end_date = models.DateTimeField()
def __str__(self):
return self.name
class Questi... | normal | {
"blob_id": "2c4f27e7d1bfe6d68fd0836094b9e350946913f6",
"index": 5480,
"step-1": "<mask token>\n\n\nclass Question(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.text\n\n\nclass AnswerChoice(models.Model):\n ... | [
14,
17,
18,
20,
22
] |
# -*- coding: utf-8 -*-
from plone import api
from plone.dexterity.content import Container
from sc.microsite.interfaces import IMicrosite
from zope.interface import implementer
@implementer(IMicrosite)
class Microsite(Container):
"""A microsite."""
def getLocallyAllowedTypes(self):
"""
By no... | normal | {
"blob_id": "3d5d88edca5d746b830363cc9451bda94c1d7aa4",
"index": 2905,
"step-1": "<mask token>\n\n\n@implementer(IMicrosite)\nclass Microsite(Container):\n <mask token>\n\n def getLocallyAllowedTypes(self):\n \"\"\"\n By now we allow all allowed types without constrain.\n TODO: fully i... | [
2,
3,
4,
5,
6
] |
from . import colorbar_artist
from . import subplot_artist
from . import surface_3d_with_shadows
from .colorbar_artist import *
from .subplot_artist import *
from .surface_3d_with_shadows import *
__all__ = ['colorbar_artist', 'subplot_artist', 'surface_3d_with_shadows']
__all__.extend(colorbar_artist.__all__)
__all__.... | normal | {
"blob_id": "16c4dbd472f9d32e5fa48a28dff4a40914f7d29e",
"index": 8231,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__.extend(colorbar_artist.__all__)\n__all__.extend(subplot_artist.__all__)\n__all__.extend(surface_3d_with_shadows.__all__)\n",
"step-3": "<mask token>\n__all__ = ['colorbar_artist... | [
0,
1,
2,
3
] |
"""Utilities for AnalysisModules."""
import inspect
from mongoengine import QuerySet
from numpy import percentile
from .modules import AnalysisModule
def get_primary_module(package):
"""Extract AnalysisModule primary module from package."""
def test_submodule(submodule):
"""Test a submodule to see ... | normal | {
"blob_id": "3472dc0c9d00c10ab0690c052e70fbf6a4bdb13d",
"index": 7889,
"step-1": "<mask token>\n\n\ndef boxplot(values):\n \"\"\"Calculate percentiles needed for a boxplot.\"\"\"\n percentiles = percentile(values, [0, 25, 50, 75, 100])\n result = {'min_val': percentiles[0], 'q1_val': percentiles[1],\n ... | [
4,
6,
7,
8,
9
] |
from setuptools import setup
import os.path
# Get the long description from the README file
with open('README.rst') as f:
long_description = f.read()
setup(name='logging_exceptions',
version='0.1.8',
py_modules=['logging_exceptions'],
author="Bernhard C. Thiel",
author_email="thiel@tbi.un... | normal | {
"blob_id": "7f7adc367e4f3b8ee721e42f5d5d0770f40828c9",
"index": 9365,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('README.rst') as f:\n long_description = f.read()\nsetup(name='logging_exceptions', version='0.1.8', py_modules=[\n 'logging_exceptions'], author='Bernhard C. Thiel', auth... | [
0,
1,
2,
3
] |
import json
import datetime
import string
import random
import logging
import jwt
from main import db
from main.config import config
def execute_sql_from_file(filename):
# Open and read the file as a single buffer
fd = open(filename, 'r')
sql_file = fd.read()
fd.close()
# All SQL commands (spli... | normal | {
"blob_id": "a724b49c4d86400b632c02236ceca58e62ba6c86",
"index": 9116,
"step-1": "import json\nimport datetime\nimport string\nimport random\nimport logging\n\nimport jwt\n\nfrom main import db\nfrom main.config import config\n\n\ndef execute_sql_from_file(filename):\n # Open and read the file as a single buf... | [
0
] |
from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import ProcessPoolExecutor
import ATLAS1
import ATLAS_v2
from atlas.config import dbConfig
import pandas as pd
import ContentCategories
import NgramMapping
import SentimentAnalysis_2
import TrigDriv_2
import TopicModeling
import logging
import tr... | normal | {
"blob_id": "41698e9d8349ddf3f42aa3d4fc405c69077d1aa3",
"index": 3160,
"step-1": "from concurrent.futures import ThreadPoolExecutor\nfrom concurrent.futures import ProcessPoolExecutor\nimport ATLAS1\nimport ATLAS_v2\nfrom atlas.config import dbConfig\nimport pandas as pd\nimport ContentCategories\nimport NgramMa... | [
0
] |
from django.db.models import Q
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponseRedirect
from django.shortcuts import render, redirect
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView
from carga_horaria.models import Profesor, Asignat... | normal | {
"blob_id": "d0d86d8b5b276218add6dd11a44d5c3951cc4e14",
"index": 3846,
"step-1": "<mask token>\n\n\nclass AsistenteDetailView(LoginRequiredMixin, DetailView):\n \"\"\"\n Detalle de Asistente\n \"\"\"\n model = Asistente\n template_name = 'carga_horaria/asistente/detalle_asistente.html'\n\n\ncl... | [
52,
53,
56,
73,
85
] |
import sys
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow, QApplication
#---Import that will load the UI file---#
from PyQt5.uic import loadUi
import detechRs_rc #---THIS IMPORT WILL DISPLAY THE IMAGES STORED IN THE QRC FILE AND _rc.py FILE--#
#--CLASS CREATED THAT WILL LOAD THE UI FILE... | normal | {
"blob_id": "a9b1cc9b928b8999450b6c95656b863c476b273b",
"index": 7355,
"step-1": "<mask token>\n\n\nclass Login(QMainWindow):\n\n def __init__(self):\n super(Login, self).__init__()\n loadUi('login_UI.ui', self)\n self.loginButton.clicked.connect(self.loginFunction)\n\n def loginFuncti... | [
3,
4,
5,
6,
7
] |
from pyparsing import ParseException
from pytest import raises
from easymql.expressions import Expression as exp
class TestComparisonExpression:
def test_cmp(self):
assert exp.parse('CMP(1, 2)') == {'$cmp': [1, 2]}
with raises(ParseException):
exp.parse('CMP(1)')
with raises(P... | normal | {
"blob_id": "91959f6621f05b1b814a025f0b95c55cf683ded3",
"index": 5856,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TestComparisonExpression:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TestComparisonExpression:\n\n def test_cmp(self):\n assert exp.parse('CMP(1, 2)') ... | [
0,
1,
2,
3
] |
from objet import Objet
class Piece(Objet):
""" Représente une piece qui permet d'acheter dans la boutique """
def ramasser(self, joueur):
joueur.addPiece()
def depenser(self,joueur):
joueur.depenserPiece()
def description(self):
return "Vous avez trouvé une piece... | normal | {
"blob_id": "b6898b923e286c66673df1e07105adf789c3151c",
"index": 6335,
"step-1": "<mask token>\n\n\nclass Piece(Objet):\n <mask token>\n\n def ramasser(self, joueur):\n joueur.addPiece()\n\n def depenser(self, joueur):\n joueur.depenserPiece()\n <mask token>\n",
"step-2": "<mask token... | [
3,
4,
5,
6,
7
] |
import glob
pyfiles = glob.glob('*.py')
modulenames = [f.split('.')[0] for f in pyfiles]
# print(modulenames)
for f in pyfiles:
contents = open(f).read()
for m in modulenames:
v1 = "import " + m
v2 = "from " + m
if v1 or v2 in contents:
contents = contents.replace(v1, "im... | normal | {
"blob_id": "d6a73365aa32c74798b6887ff46c0ed2323ed1a6",
"index": 2324,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor f in pyfiles:\n contents = open(f).read()\n for m in modulenames:\n v1 = 'import ' + m\n v2 = 'from ' + m\n if v1 or v2 in contents:\n contents =... | [
0,
1,
2,
3,
4
] |
import pandas as pd
import numpy as np
import urllib.request
import urllib.parse
import json
def predict(input_text):
URL = "http://127.0.0.1:8000/api/v1/predict/"
values = {
"format": "json",
"input_text": input_text,
}
data = urllib.parse.urlencode({'input_text': i... | normal | {
"blob_id": "b7632cc7d8fc2f9096f7a6bb61c471dc61689f70",
"index": 8342,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef predict(input_text):\n URL = 'http://127.0.0.1:8000/api/v1/predict/'\n values = {'format': 'json', 'input_text': input_text}\n data = urllib.parse.urlencode({'input_text'... | [
0,
1,
2,
3,
4
] |
# Return min number of hacks (swap of adjacent instructions)
# in p so that total damage <= d.
# If impossible, return -1
def min_hacks(d, p):
# list containing number of shoot commands per
# damage level. Each element is represents a
# damage level; 1, 2, 4, 8, ... and so on.
shots = [0]
damage = 0
for c ... | normal | {
"blob_id": "607700faebc2018327d66939419cc24a563c3900",
"index": 6515,
"step-1": "<mask token>\n",
"step-2": "def min_hacks(d, p):\n shots = [0]\n damage = 0\n for c in p:\n if c == 'S':\n shots[-1] += 1\n damage += 2 ** (len(shots) - 1)\n else:\n shots.a... | [
0,
1,
2,
3,
4
] |
from matasano import *
ec = EC_M(233970423115425145524320034830162017933,534,1,4,order=233970423115425145498902418297807005944)
assert(ec.scale(4,ec.order) == 0)
aPriv = randint(1,ec.order-1)
aPub = ec.scale(4,aPriv)
print("Factoring...")
twist_ord = 2*ec.prime+2 - ec.order
factors = []
x = twist_ord
for... | normal | {
"blob_id": "b5275fc068526063fd8baf13210052971b05503f",
"index": 585,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nassert ec.scale(4, ec.order) == 0\n<mask token>\nprint('Factoring...')\n<mask token>\nfor i in range(2, 2 ** 24):\n if x % i == 0:\n if x % (i * i) != 0:\n factors.app... | [
0,
1,
2,
3,
4
] |
from ImageCoord import ImageCoord
import os
import sys
from folium.features import DivIcon
# Chemin du dossier ou l'on recupere les images
racine = tkinter.Tk()
racine.title("listPhoto")
racine.directory = filedialog.askdirectory()
cheminDossier = racine.directory
dirImage = os.listdir(cheminDossier)
listImage = []
... | normal | {
"blob_id": "f5b8d8c291d18c6f320704a89985acbcae97ca2f",
"index": 2954,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nracine.title('listPhoto')\n<mask token>\nfor index in range(0, len(dirImage)):\n img = ImageCoord(cheminDossier + '\\\\' + dirImage[index])\n if img.has_coord():\n listImage.... | [
0,
1,
2,
3,
4
] |
import konlpy
import nltk
# POS tag a sentence
sentence = u'만 6세 이하의 초등학교 취학 전 자녀를 양육하기 위해서는'
words = konlpy.tag.Twitter().pos(sentence)
# Define a chunk grammar, or chunking rules, then chunk
grammar = """
NP: {<N.*>*<Suffix>?} # Noun phrase
VP: {<V.*>*} # Verb phrase
AP: {<A.*>*} # Adjective... | normal | {
"blob_id": "6b647dc2775f54706a6c18ee91145ba60d70be21",
"index": 4453,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('# Print whole tree')\nprint(chunks.pprint())\nprint(\"\"\"\n# Print noun phrases only\"\"\")\nfor subtree in chunks.subtrees():\n if subtree.label() == 'NP':\n print(' '.... | [
0,
1,
2,
3,
4
] |
from flask import Flask
from flask import render_template
import datetime
from person import Person
import requests
from post import Post
app = Flask(__name__)
all_posts = all_posts = requests.get(
"https://api.npoint.io/5abcca6f4e39b4955965").json()
post_objects = []
for post in all_posts:
post_obj = Post(po... | normal | {
"blob_id": "895ece0b8d45cd64e43f8ddc54824f7647254185",
"index": 2547,
"step-1": "<mask token>\n\n\n@app.route('/guess/<name>')\ndef guesser(name):\n person = Person(name=name)\n return render_template('guess.html', name=person.name, gender=person.\n gender, age=person.age, country=person.country)\n... | [
2,
5,
6,
7,
8
] |
# Generated by Django 2.1.2 on 2018-10-19 22:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='mascota',
name='descripcion',
... | normal | {
"blob_id": "fcfec60a2302ee0c1385add053d4371040a2aff4",
"index": 3667,
"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 = [('core', '000... | [
0,
1,
2,
3,
4
] |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void findSubNode(Node root) {
}
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
... | normal | {
"blob_id": "6d0a945c9eaf6564a327928880df1f0aeed2e5d0",
"index": 9649,
"step-1": "import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void findSubNode(Node root) {\n\n }\n\n public static void main(String args[]) throws ... | [
0
] |
# name: Ali
# date: 7/12/2016
# description: uses openweathermap.org's api to get weather data about
# the city that is inputted
# unbreakable? = idk
import json
import urllib2
from collections import OrderedDict
from pprint import pprint
api_key = "&APPID=507e30d896f751513350c41899382d89"
city_name_url = "http://api.... | normal | {
"blob_id": "94540561ba29d2fc1766dac7b199e0cbbbeecdfc",
"index": 8046,
"step-1": "# name: Ali\n# date: 7/12/2016\n# description: uses openweathermap.org's api to get weather data about\n# the city that is inputted\n\n# unbreakable? = idk\nimport json\nimport urllib2\nfrom collections import OrderedDict\nfrom ppr... | [
0
] |
from Config_paar import *
from Envelopefkt import *
from Kinematik import *
def A_m_n(M,N,x_plus,p_el,p_pos,k_photon,k_laser):
def f1(p):
return -(m*a0)/(pk(p)) * g(phi,sigma,Envelope) *( pe(1,p) * cos(ksi) * cos(phi) + pe(2,p) * sin(ksi) * sin(phi) )
def f2(p):
return -(m*a0)**2/(2.... | normal | {
"blob_id": "ad170f67e5b9f54d950ead91dd60cd4f3b753eca",
"index": 6660,
"step-1": "from Config_paar import *\nfrom Envelopefkt import *\nfrom Kinematik import *\n\n\ndef A_m_n(M,N,x_plus,p_el,p_pos,k_photon,k_laser):\n\n def f1(p):\n return -(m*a0)/(pk(p)) * g(phi,sigma,Envelope) *( pe(1,p) * cos(ksi) *... | [
0
] |
from external.odds.betclic.api import get_odds
# FDJ parsing is broken - their UI has been refactored with JS framework &
# protected async JSON API usage (requires HEADERS) and more complex to isolate & group match odds
# hence move to another betting website - which is still full html rendered
| normal | {
"blob_id": "8b583ee55df409020a605b467479236e610a2efe",
"index": 3646,
"step-1": "<mask token>\n",
"step-2": "from external.odds.betclic.api import get_odds\n",
"step-3": "from external.odds.betclic.api import get_odds\n\n# FDJ parsing is broken - their UI has been refactored with JS framework &\n# protected... | [
0,
1,
2
] |
from xgboost import XGBRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
import pandas as pd
import numpy as np
from ghg import GHGPredictor
predictor = GHGPredictor()
dataset_df = pd.read_csv("db-wheat.csv", index_col=0)
# print(dataset_df.iloc[1])
dataset_d... | normal | {
"blob_id": "0ebd3ca5fd29b0f2f2149dd162b37f39668f1c58",
"index": 7397,
"step-1": "<mask token>\n\n\ndef predict(model, row):\n preds = []\n for perc in range(-10, 11):\n new_row = row.copy()\n row_copy = row.copy()\n new_row = new_row.drop(labels=['Area', 'Year', 'Crop',\n '... | [
1,
2,
3,
4,
5
] |
import pygame
import time as time_
import random
import os
from pygame.locals import *
from math import sin, cos, pi
from sys import exit
# ---------------------------
from unzip import *
unzip()
# ---------------------------
from others import *
from gaster_blaster import *
from board import *
from bone import *
from ... | normal | {
"blob_id": "46fd4b976526a1bc70cf902bdb191feea8b84ad9",
"index": 2633,
"step-1": "<mask token>\n\n\ndef set_turn_time(time):\n\n def next_turn(screen):\n global stop\n stop = False\n tasks.append(Task(next_turn, time))\n\n\ndef add_attack(func):\n attacks.append(func)\n return func\n\n\... | [
16,
26,
28,
32,
47
] |
# Generated by Django 2.2.3 on 2019-07-11 22:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app1', '0002_property_details'),
]
operations = [
migrations.AlterField(
model_name='property_details',
name='flat_t... | normal | {
"blob_id": "8cdd7646dbf23259e160186f332b5cb02b67291b",
"index": 5121,
"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 = [('app1', '000... | [
0,
1,
2,
3,
4
] |
import numpy as np
#1
def longest_substring(string1,string2):
mat=np.zeros(shape=(len(string1),len(string2)))
for x in range(len(string1)):
for y in range(len(string2)):
if x==0 or y==0:
if string1[x]==string2[y]:
mat[x,y]=1
else:
... | normal | {
"blob_id": "6bb7dafea73aff7aca9b0ddc1393e4db6fcf0151",
"index": 4828,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef longest_substring(string1, string2):\n mat = np.zeros(shape=(len(string1), len(string2)))\n for x in range(len(string1)):\n for y in range(len(string2)):\n ... | [
0,
1,
2,
3,
4
] |
import os
import sqlite3
from typing import Any
from direct_geocoder import get_table_columns
from reverse_geocoder import is_point_in_polygon
from utils import zip_table_columns_with_table_rows, get_average_point
def get_organizations_by_address_border(city: str,
nodes: list[... | normal | {
"blob_id": "79f945694f853e5886b590020bb661ecd418510d",
"index": 4567,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_organizations_by_address_border(city: str, nodes: list[tuple[float,\n float]]) ->list[dict[str, Any]]:\n result = []\n radius = 0.0025\n with sqlite3.connect(os.pa... | [
0,
1,
2,
3
] |
from django.db import models
from django.contrib.auth.models import User, Group
from userena.models import UserenaBaseProfile
from django.db.models.signals import post_save
from tastypie.models import create_api_key
class UserProfile(UserenaBaseProfile):
# user reference
user = models.OneToOneField(User)
... | normal | {
"blob_id": "6e6f153857879da625f57f0382f1997fcae4f6c8",
"index": 6041,
"step-1": "<mask token>\n\n\nclass UserProfile(UserenaBaseProfile):\n user = models.OneToOneField(User)\n facebook_id = models.CharField(max_length=128, blank=True, null=True)\n\n\n class Meta:\n permissions = ('change_profile... | [
2,
3,
4,
5,
6
] |
import os
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, replace_in_file, rmdir
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
requi... | normal | {
"blob_id": "fe1c499efe492dbd4f5c9b99bd6339c503c7902b",
"index": 5766,
"step-1": "<mask token>\n\n\nclass RuyConan(ConanFile):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <... | [
4,
12,
14,
15,
17
] |
#!/usr/bin/env python
# $Id: iprscan5_urllib2.py 2809 2015-03-13 16:10:25Z uludag $
# ======================================================================
#
# Copyright 2009-2014 EMBL - European Bioinformatics Institute
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file ex... | normal | {
"blob_id": "3dd9ce6d5d1ba0bebadae4068e2c898802180e1d",
"index": 8825,
"step-1": "#!/usr/bin/env python\n# $Id: iprscan5_urllib2.py 2809 2015-03-13 16:10:25Z uludag $\n# ======================================================================\n#\n# Copyright 2009-2014 EMBL - European Bioinformatics Institute\n#\n#... | [
0
] |
import numpy as np
import pickle as p
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from numpy.random import randn
from neural_network import network
net = network([1,8,8,1], filename='./data/x', bias=True)
# net.load_random()
net.load()
n = 32
x = np.array([[x] for x in np.linspace(0,1,n)]... | normal | {
"blob_id": "cf07344808f2d91d8949cfc4beb9f923926e6851",
"index": 6208,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnet.load()\n<mask token>\nplt.plot(x, y)\n<mask token>\nfor ii in range(1001):\n c = net.retarded_training(x, y)\n print(ii, c)\n net.save()\n<mask token>\nplt.plot(X, Y, 'ro')\n... | [
0,
1,
2,
3,
4
] |
frase = "todos somos promgramadores"
palabras = frase.split()
for p in palabras:
print(palabras[p])
#if p[-2] == "o":
| normal | {
"blob_id": "00c57e7e26a3181ab23697a25257aca479d9ee05",
"index": 5755,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor p in palabras:\n print(palabras[p])\n",
"step-3": "frase = 'todos somos promgramadores'\npalabras = frase.split()\nfor p in palabras:\n print(palabras[p])\n",
"step-4": "fra... | [
0,
1,
2,
3
] |
import json
import requests as requests
from flask import Flask
from flask import request
from tools import AESCipher, tokenId, TokenKey, appId
from tools import TCApplyNeedleUrl, TCCreditNeedleUrl, TCWJNeedleUrl
app = Flask(__name__)
@app.route('/', methods=['POST'])
def hello_world():
if reques... | normal | {
"blob_id": "4652cd5548b550cc21d126fc4fbe3e316ecb71b2",
"index": 143,
"step-1": "<mask token>\n\n\n@app.route('/', methods=['POST'])\ndef hello_world():\n if request.method == 'POST':\n json_data = request.get_data().decode('utf-8')\n _data = json.loads(json_data)\n orderNo = _data['order... | [
1,
2,
3,
4,
5
] |
balance=42
annualInterestRate=0.20
monthlyPaymentRate=0.04
monthlyir = annualInterestRate/12
rb=balance
for i in range(12):
mp = monthlyPaymentRate * rb
rb=rb-mp
rb=rb+rb*monthlyir
print('remaining balance: ',round(rb,2))
| normal | {
"blob_id": "1429524b0ae3b679bc3d4386dd17ed50b0fff381",
"index": 146,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(12):\n mp = monthlyPaymentRate * rb\n rb = rb - mp\n rb = rb + rb * monthlyir\nprint('remaining balance: ', round(rb, 2))\n",
"step-3": "balance = 42\nannualInter... | [
0,
1,
2,
3
] |
#!/usr/bin/env python3
#
# nextskeleton - An assembler skeleton for the ZX Spectrum Next
#
# Copyright (C) 2020 Richard "Shred" Körber
# https://github.com/shred/nextskeleton
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You ma... | normal | {
"blob_id": "0744ec646e7b9303c67c25dff2997568c6171b91",
"index": 108,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nparser.add_argument('nex', help='path of the .nex file to be launched')\nparser.add_argument('file', help='autoexec.bas file to be generated')\n<mask token>\ncontents += bytearray((0, 10))... | [
0,
1,
2,
3,
4
] |
__author__ = 'Administrator'
import socket,os,time
server = socket.socket()
server.bind(("localhost",9999))
server.listen()
while True:
conn,addr = server.accept()
while True:
data = conn.recv(1024)
if not data:
break
cmd,filename = data.decode().split()
if o... | normal | {
"blob_id": "0a19efea0c8d7e5e248ca3265ffcb55604dc500c",
"index": 7576,
"step-1": "__author__ = 'Administrator'\n\nimport socket,os,time\n\nserver = socket.socket()\n\nserver.bind((\"localhost\",9999))\n\nserver.listen()\n\nwhile True:\n conn,addr = server.accept()\n\n while True:\n data = conn.recv... | [
0
] |
import cv2
import numpy as np
import copy
imgpath = 'D:\\DIP-Project1/b.jpg'
img = cv2.imread(imgpath)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow('img', img)
row = len(img)
col = len(img[0])
def medianflt(img, i, j, msize, mr, mc):
pxls = []
for a in range(msize):
for b in range(msize):
... | normal | {
"blob_id": "cfcce8c760f6ba49ce450d78782cb8f3b5fc1188",
"index": 2857,
"step-1": "<mask token>\n\n\ndef medianflt(img, i, j, msize, mr, mc):\n pxls = []\n for a in range(msize):\n for b in range(msize):\n mi = i + a - mr\n mj = j + b - mc\n pxls.append(img[mi][mj])\n... | [
2,
3,
4,
5
] |
import numpy as np
import torch
import torch.nn as nn
from torch.nn.functional import interpolate
from torchvision.ops.boxes import batched_nms
class MTCNN():
def __init__(self, device=None, model=None):
if device is None:
device = 'cuda' if torch.cuda.is_available() else 'cpu'
self.device = device
url = '... | normal | {
"blob_id": "865121e7eb5f9c70adf44d33d21f30c22f13ec56",
"index": 7012,
"step-1": "<mask token>\n\n\nclass MTCNN:\n\n def __init__(self, device=None, model=None):\n if device is None:\n device = 'cuda' if torch.cuda.is_available() else 'cpu'\n self.device = device\n url = 'https... | [
17,
18,
19,
21,
23
] |
from django.urls import path
from .views import *
from .utils import *
app_name = 'gymapp'
urlpatterns = [
# CLIENT PATHS ##
# CLIENT PATHS ##
# CLIENT PATHS ##
# CLIENT PATHS ##
# general pages
path('', ClientHomeView.as_view(), name='clienthome'),
path('about/', ClientAboutView.as_v... | normal | {
"blob_id": "48a4331e4b26ea81f1c52ae76db1e92a57cb378c",
"index": 2654,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp_name = 'gymapp'\nurlpatterns = [path('', ClientHomeView.as_view(), name='clienthome'), path(\n 'about/', ClientAboutView.as_view(), name='clientabout'), path(\n 'contact/', Clie... | [
0,
1,
2,
3
] |
import xadmin
from .models import EmailVerifyRecord,Banner
from xadmin import views
class EmailVerifyRecordAdmin(object):
pass
class BannerAdmin(object):
list_display=('title','url','index')
class BaseSetting(object):
enable_themes=True
user_bootswatch=True
#设置xadmin页面标题和页脚
class GlobalSetting(objec... | normal | {
"blob_id": "263a853f33eb9724101ca87f12b914282dea9981",
"index": 1441,
"step-1": "<mask token>\n\n\nclass BannerAdmin(object):\n list_display = 'title', 'url', 'index'\n\n\nclass BaseSetting(object):\n enable_themes = True\n user_bootswatch = True\n\n\nclass GlobalSetting(object):\n site_title = '西游记... | [
6,
7,
8,
9,
10
] |
# aylat
# This program will calculate an individual's body mass index (BMI),
# based on their height and their weight
# Prompt user to input information
Name = input('Enter your full name: ')
Weight = float(input('Enter your weight in pounds: '))
Height = float(input('Enter your height in inches: '))
# Perform BMI ... | normal | {
"blob_id": "8b009451e9f65ef12e5db1321a9d5347ef7fd756",
"index": 9593,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('\\n')\nif BMI < 18.5:\n print(Name, ', your BMI calculation is ', format(BMI, '.1f'),\n ', which indicates your weight category is underweight.', sep='')\nelif BMI < 24.9... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.