code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
# Spelling bee NYT puzzle solver
with open('words.txt') as words_fh:
# Converts strips and lowercases lexicon (space seperated txt file)
# Use set to remove duplicates (decasing)
lexicon = set(list(map(lambda x: x.strip().lower(), words_fh.readlines())))
# NOTE: Could add a CLI to allow users to input... | normal | {
"blob_id": "aacd5d671090c3305a53d62c3c6c25d4c033f42d",
"index": 6420,
"step-1": "<mask token>\n",
"step-2": "with open('words.txt') as words_fh:\n lexicon = set(list(map(lambda x: x.strip().lower(), words_fh.readlines())))\n<mask token>\nprint(sorted_valid_words)\n",
"step-3": "with open('words.txt') as ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class ReflecBeatColette(BaseClient):
<|reserved_special_token_0|>
def verify_pcb_boot(self, loc: str) ->None:
call = self.call_node()
pcb = Node.void('pcb')
pcb.set_attribute('method', 'boot')
pcb.add_child(Node.string('lid', loc))
call.add... | flexible | {
"blob_id": "f781377a52400abd617e7f0c5529726120b78476",
"index": 3426,
"step-1": "<mask token>\n\n\nclass ReflecBeatColette(BaseClient):\n <mask token>\n\n def verify_pcb_boot(self, loc: str) ->None:\n call = self.call_node()\n pcb = Node.void('pcb')\n pcb.set_attribute('method', 'boot... | [
13,
14,
16,
18,
20
] |
import pygame
from pygame.sprite import Sprite
import spritesheet
class Bunker(Sprite):
def __init__(self, ai_settings, bunker_x, bunker_y, screen, images):
"""Initialize the ship and set its starting position"""
super(Bunker, self).__init__()
self.screen = screen
self.images = ima... | normal | {
"blob_id": "d088aadc4d88267b908c4f6de2928c812ef36739",
"index": 1603,
"step-1": "<mask token>\n\n\nclass Bunker(Sprite):\n <mask token>\n <mask token>\n\n def blitme(self):\n \"\"\"Draw the ship at its current location\"\"\"\n self.screen.blit(self.image, self.rect)\n",
"step-2": "<mask... | [
2,
3,
4,
5,
6
] |
class Odwroc:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Odwroc:
def __init__(self, dane):
self.dane = dane
self.indeks = len(dane)
<|reserved_special_token_0|>
def ... | flexible | {
"blob_id": "763c0baf919b48ff135f7aa18974da5b85ee40f5",
"index": 1133,
"step-1": "class Odwroc:\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "class Odwroc:\n\n def __init__(self, dane):\n self.dane = dane\n self.indeks = len(dane)\n <mask token>\n\n ... | [
1,
3,
4,
5,
6
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: wenshu/actions.py
# Author: Carolusian <https://github.com/carolusian>
# Date: 22.09.2018
# Last Modified Date: 22.09.2018
#
# Copyright 2018 Carolusian
import time
import itertools
import re
import requests
import json
import os
from random import randint
from se... | normal | {
"blob_id": "01de85b0d480c105c8cc1a8154c3de936ab3226d",
"index": 9143,
"step-1": "<mask token>\n\n\ndef sleep(min_seconds=1, max_seconds=10):\n \"\"\"Allow a browser instance to wait for a few seconds before do something\"\"\"\n time.sleep(randint(min_seconds, max_seconds))\n\n\ndef click(elem):\n try:\... | [
5,
6,
7,
8,
9
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'wenchao.hao'
"""
data.guid package.
"""
from .guid import Guid
| normal | {
"blob_id": "88a379747f955b0410ab2bb33c1165034c701673",
"index": 8597,
"step-1": "<mask token>\n",
"step-2": "__author__ = 'wenchao.hao'\n<mask token>\n",
"step-3": "__author__ = 'wenchao.hao'\n<mask token>\nfrom .guid import Guid\n",
"step-4": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n__author__ = ... | [
0,
1,
2,
3
] |
def myswap(a, b):
temp = a
a = b
b = temp
if a < b:
print(a, b)
else:
print(b, a)
a, b = map(int, input().split())
myswap(a, b)
| normal | {
"blob_id": "e6efd2de5f92d66f1b734a2173fc8681af3c4cc8",
"index": 8040,
"step-1": "<mask token>\n",
"step-2": "def myswap(a, b):\n temp = a\n a = b\n b = temp\n if a < b:\n print(a, b)\n else:\n print(b, a)\n\n\n<mask token>\n",
"step-3": "def myswap(a, b):\n temp = a\n a = ... | [
0,
1,
2,
3
] |
import numpy as np
import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed, Layout, VBox, HBox
import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib.tri as tri
import matplotlib.colors as colors
from matplotlib.colors import LinearSegmentedColormap
import scipy.stats as sps... | normal | {
"blob_id": "e5a4ae2ec0fab1ca8cdce229c69725ece2dcc476",
"index": 8272,
"step-1": "<mask token>\n\n\ndef forc(X):\n Xi = X['Xi']\n Yi = X['Yi']\n Zi = X['Zi']\n SEi = X['SEi']\n Pi = X['Pi']\n Hc1 = X['Hc1']\n Hc2 = X['Hc2']\n Hb1 = X['Hb1']\n Hb2 = X['Hb2']\n style = {'description_w... | [
6,
7,
8,
9,
10
] |
<|reserved_special_token_0|>
class BaseExecution:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class BaseExecution:
def __init__(self, flag, parser):
self.flag = flag
self.parser = parser
<|reserved_special_to... | flexible | {
"blob_id": "d8af43d24a2f2b99bc8b5098f251e017852d6d86",
"index": 1085,
"step-1": "<mask token>\n\n\nclass BaseExecution:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass BaseExecution:\n\n def __init__(self, flag, parser):\n self.flag = flag\n self.parser = parser\n ... | [
1,
2,
3,
4
] |
import config
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
def check_db_exists(opt):
try:
conn = psycopg2.connect(opt)
cur = conn.cursor()
cur.close()
print('Database exists.')
return True
except:
print("Database doesn't exist.")
return False
def create_db(opt):
if check... | normal | {
"blob_id": "09792da1c3cc38c7df7def2b487c2078de4e8912",
"index": 9514,
"step-1": "<mask token>\n\n\ndef check_db_exists(opt):\n try:\n conn = psycopg2.connect(opt)\n cur = conn.cursor()\n cur.close()\n print('Database exists.')\n return True\n except:\n print(\"Dat... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class Relation_type(models.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def __str__(self):
return str(self.name)
class Relation(models.Model):
id_relation = models.AutoField(primary_key=True)
id_person1 = models.ForeignKey(Person, on_del... | flexible | {
"blob_id": "914f477518918619e0e42184bd03c2a7ed16bb01",
"index": 86,
"step-1": "<mask token>\n\n\nclass Relation_type(models.Model):\n <mask token>\n <mask token>\n\n def __str__(self):\n return str(self.name)\n\n\nclass Relation(models.Model):\n id_relation = models.AutoField(primary_key=True... | [
9,
18,
20,
21,
24
] |
# -*- coding: utf-8 *-*
import MySQLdb
conn = MySQLdb.connect('localhost', 'ABarbara', 'root', '1dawabarbara') # Abro la conexión
def crearTabla(query): # Le paso la cadena que realizará el create como parámetro.
cursor = conn.cursor() #En un cursor (de la conexión) almaceno lo que quiero enviar a la base de da... | normal | {
"blob_id": "8a2b7376369513ce403a2542fb8c6d5826b2169b",
"index": 9949,
"step-1": "# -*- coding: utf-8 *-*\nimport MySQLdb \n\nconn = MySQLdb.connect('localhost', 'ABarbara', 'root', '1dawabarbara') # Abro la conexión \n\ndef crearTabla(query): # Le paso la cadena que realizará el create como parámetro.\n\tcurs... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@npm_decorator(3)
def scenario():
"""
1. Check each peer's genesis block
2. Generate new blocks on each peer
2.1. 2 blocks on peer #1
2.2. 4 blocks on peer #2
2.3. 2 blocks on peer #3
3. C... | flexible | {
"blob_id": "91cf1f4cf34ac9723be4863e81149c703adca27a",
"index": 3583,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@npm_decorator(3)\ndef scenario():\n \"\"\"\n 1. Check each peer's genesis block\n 2. Generate new blocks on each peer\n 2.1. 2 blocks on peer #1\n 2.2. 4 block... | [
0,
1,
2,
3,
4
] |
import sys
sys.stdin = open('retire.txt', 'r')
def counseling(pay, row):
global max_sum
if row == N - 1:
if arr[row][0] == 1:
pay += arr[row][1]
max_sum = max(pay, max_sum)
return
if row == N:
max_sum = max(pay, max_sum)
return
if row > N - 1:
... | normal | {
"blob_id": "9db2377f15aaf28373959dad88c6ec7b6dacffd2",
"index": 9512,
"step-1": "<mask token>\n\n\ndef counseling(pay, row):\n global max_sum\n if row == N - 1:\n if arr[row][0] == 1:\n pay += arr[row][1]\n max_sum = max(pay, max_sum)\n return\n if row == N:\n max... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class TaskSolver:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def task_calculate_cosin_similarity(self, word1, word2, print_to_screen
=True):
sim = 0
if word1 in self.W2V_DICT and word2 in self.W2V_DICT:
... | flexible | {
"blob_id": "c23bd136991bfb41f153321420c2fcfba0c843f4",
"index": 1513,
"step-1": "<mask token>\n\n\nclass TaskSolver:\n <mask token>\n <mask token>\n <mask token>\n\n def task_calculate_cosin_similarity(self, word1, word2, print_to_screen\n =True):\n sim = 0\n if word1 in self.W2... | [
7,
11,
12,
15,
16
] |
<|reserved_special_token_0|>
class DataEncoding:
@staticmethod
def segment_decode(segment):
arr = bytearray(segment)
ack_binary = bytearray([arr[i] for i in range(4)])
tip_binary = bytearray([arr[4]])
len_binary = bytearray([arr[i] for i in (5, 6)])
ack = int.from_byte... | flexible | {
"blob_id": "47c5375816ab35e8225e5f3695f7ee2ab5336076",
"index": 4312,
"step-1": "<mask token>\n\n\nclass DataEncoding:\n\n @staticmethod\n def segment_decode(segment):\n arr = bytearray(segment)\n ack_binary = bytearray([arr[i] for i in range(4)])\n tip_binary = bytearray([arr[4]])\n ... | [
6,
8,
9,
10,
11
] |
<|reserved_special_token_0|>
def doMath(btn):
global result, n1, n2, isFirst, calc
inputNumber()
if btn == 'Add':
calc = 'a'
if btn == 'Substract':
calc = 's'
if btn == 'Multiply':
calc = 'm'
if btn == 'Divide':
calc = 'd'
app.clearEntry('Number')
def calc... | flexible | {
"blob_id": "084299da1c2f41de96e60d37088466c7b61de38e",
"index": 9750,
"step-1": "<mask token>\n\n\ndef doMath(btn):\n global result, n1, n2, isFirst, calc\n inputNumber()\n if btn == 'Add':\n calc = 'a'\n if btn == 'Substract':\n calc = 's'\n if btn == 'Multiply':\n calc = 'm... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class CycleGANVC2LossCalculator:
def __init__(self):
pass
<|reserved_special_token_0|>
@staticmethod
def gen_loss(discriminator, y):
y_dis = discriminator(y)
return F.mean(F.softplus(-y_dis))
<|reserved_special_token_0|>
<|reserved_special... | flexible | {
"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
] |
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 28 16:36:56 2018
@author: Alex
"""
#%% Import packages
import pickle
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
import os
os.chdir('C:\\Users\\Alex\\Documents\\GitHub\\insight-articles-project\\src\\topic modeling\\')
from plotly_network ... | normal | {
"blob_id": "d98db745be2ab9c506a98539b25e9b46e4997136",
"index": 3422,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nos.chdir(\n 'C:\\\\Users\\\\Alex\\\\Documents\\\\GitHub\\\\insight-articles-project\\\\src\\\\topic modeling\\\\'\n )\n<mask token>\nwith open(filename, 'rb') as fp:\n topic_assi... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# caixinjun
import argparse
from sklearn import metrics
import datetime
import jieba
from sklearn.feature_extraction.text import TfidfVectorizer
import pickle
from sklearn import svm
import os
import warnings
warnings.filterwarnings('ignore')
def get_data(train_file):
targ... | normal | {
"blob_id": "199872ea459a9dba9975c6531034bdbc1e77f1db",
"index": 5875,
"step-1": "<mask token>\n\n\ndef train(cls, data, target, model_path):\n cls = cls.fit(data, target)\n with open(model_path, 'wb') as f:\n pickle.dump(cls, f)\n\n\n<mask token>\n\n\ndef load_models(matrix_path, model_path):\n ... | [
3,
4,
5,
6,
8
] |
<|reserved_special_token_0|>
class Top(Elaboratable):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Top(Elaboratable):
<|reserved_special_token_0|>
def elaborate(self, platform):
m = Module()
m.d.comb += ... | flexible | {
"blob_id": "22b6ea64cdb109e1c6b2536b50935d09d37a7e1a",
"index": 3057,
"step-1": "<mask token>\n\n\nclass Top(Elaboratable):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Top(Elaboratable):\n <mask token>\n\n def elaborate(self, platform):\n m = Module()\n m.d.c... | [
1,
2,
3,
4
] |
from rest_framework import serializers
#from rest_framework.response import Response
from .models import Category, Product
class RecursiveSerializer(serializers.Serializer):
def to_representation(self, value):
serializer = self.parent.parent.__class__(value, context=self.context)
return ... | normal | {
"blob_id": "cd9cc656a62728b3649b00c03ca8d05106015007",
"index": 7949,
"step-1": "<mask token>\n\n\nclass CategorySerializers(serializers.ModelSerializer):\n childcategories = RecursiveSerializer(many=True, read_only=True)\n\n\n class Meta:\n model = Category\n fields = 'id', 'name', 'parent'... | [
3,
4,
5,
6,
7
] |
# 把函数视作对象
def factorial(n):
"""returns n!"""
return 1 if n < 2 else n * factorial(n - 1)
fact = factorial
print(list(map(fact, range(6)))) # 构建 0! 和 5! 的一个阶乘列表。
print([fact(n) for n in range(6)]) # 使用列表推导执行相同的操作。
# filter() 函数用于过滤序列,过滤掉不符合条件的元素,返回一个迭代器对象,如果要转换为列表,可以使用 list() 来转换。
# 该接收两个参数,第... | normal | {
"blob_id": "4411c81351ac76d72512faaa6b498cd577815691",
"index": 2572,
"step-1": "<mask token>\n",
"step-2": "def factorial(n):\n \"\"\"returns n!\"\"\"\n return 1 if n < 2 else n * factorial(n - 1)\n\n\n<mask token>\n",
"step-3": "def factorial(n):\n \"\"\"returns n!\"\"\"\n return 1 if n < 2 el... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def ggwave(message: str, protocolId: int=1, sampleRate: float=48000, volume:
int=50, payloadLength: int=-1):
url = 'https://ggwave-to-file.ggerganov.com/'
params = {'m': message, 'p': protocolId, 's': sampleRate, 'v': volume,
'l': payloadLength}
response = requests... | flexible | {
"blob_id": "f5d285b3a82151b5d7efdcd07d56cc5aaaac5836",
"index": 7213,
"step-1": "<mask token>\n\n\ndef ggwave(message: str, protocolId: int=1, sampleRate: float=48000, volume:\n int=50, payloadLength: int=-1):\n url = 'https://ggwave-to-file.ggerganov.com/'\n params = {'m': message, 'p': protocolId, 's... | [
1,
2,
3,
4,
5
] |
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from .document import ParsedDocument,XmlDocument
from .corenlp import StanfordCoreNLP
from .annotation import KBPAnnMgr,ApfAnnMgr
import os
import codecs
import sys
from . import _list_files
def _sequence_tag_bio(doc):
outlines = u''
mentions= doc._... | normal | {
"blob_id": "80b8b77498f915a85185f829e8c7d5becdab8068",
"index": 9286,
"step-1": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\nfrom .document import ParsedDocument,XmlDocument\nfrom .corenlp import StanfordCoreNLP\nfrom .annotation import KBPAnnMgr,ApfAnnMgr\nimport os\nimport codecs\nimport ... | [
0
] |
'''
python open() 函数用于打开一个文件,创建一个 file 对象,相关的方法才可以调用它进行读写。
更多文件操作可参考:Python 文件I/O。
函数语法
open(name[, mode[, buffering]])
参数说明:
name : 一个包含了你要访问的文件名称的字符串值。
mode : mode 决定了打开文件的模式:只读,写入,追加等。所有可取值见如下的完全列表。这个参数是非强制的,默认文件访问模式为只读(r)。
buffering : 如果 buffering 的值被设为 0,就不会有寄存。如果 buffering 的值取 1,访问文件时会寄存行。如果将 buffering 的值设为大于 1 的... | normal | {
"blob_id": "3a65565af4c55fa5479e323a737c48f7f2fdb8ce",
"index": 596,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(f.read())\n<mask token>\n",
"step-3": "<mask token>\nf = open('1.txt', 'r', encoding='utf-8')\nprint(f.read())\n<mask token>\n",
"step-4": "'''\npython open() 函数用于打开一个文件,创建一个 fil... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Rational(object):
<|reserved_special_token_0|>
def __init__(self, num, den):
"""
simple constructor
"""
if den == 0:
raise ZeroDivisionError('division by zero')
if num == 0:
self._num = 0
self._den ... | flexible | {
"blob_id": "b1ab28a99fdcce66f0a1e4e25821073673f531cf",
"index": 657,
"step-1": "<mask token>\n\n\nclass Rational(object):\n <mask token>\n\n def __init__(self, num, den):\n \"\"\"\n simple constructor\n \"\"\"\n if den == 0:\n raise ZeroDivisionError('division by zer... | [
17,
30,
33,
35,
41
] |
<|reserved_special_token_0|>
def fun1():
s_cut = [('72af8ecf3609a546bac3150c20f70455', ['老凤祥', '六福珠宝', '周生生',
'亚一珠宝', '亚一金店']), ('3e78397f7dbb88ffbd78ba52d0e925fa', ['老庙', '谢瑞麟',
'中国黄金', '明牌珠宝']), ('6bee32b2f0719ea45cc194847efd8917', ['周大福',
'潮宏基', '东华美钻', '周大生'])]
num = 1
city_cod... | flexible | {
"blob_id": "66f8fa5fc12dc80b8f46684c39781c2e4634de4a",
"index": 3479,
"step-1": "<mask token>\n\n\ndef fun1():\n s_cut = [('72af8ecf3609a546bac3150c20f70455', ['老凤祥', '六福珠宝', '周生生',\n '亚一珠宝', '亚一金店']), ('3e78397f7dbb88ffbd78ba52d0e925fa', ['老庙', '谢瑞麟',\n '中国黄金', '明牌珠宝']), ('6bee32b2f0719ea45cc1... | [
1,
2,
3,
4,
5
] |
import json
import redis
redis_client = redis.StrictRedis(host="redis", port=6379, db=1, password="pAssw0rd")
def publish_data_on_redis(data, channel):
redis_client.publish(channel, json.dumps(data)) | normal | {
"blob_id": "d61024ecbd092852fc3396e6919d6d3c8aa554db",
"index": 6178,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef publish_data_on_redis(data, channel):\n redis_client.publish(channel, json.dumps(data))\n",
"step-3": "<mask token>\nredis_client = redis.StrictRedis(host='redis', port=6379,... | [
0,
1,
2,
3,
4
] |
/Users/sterlingbutters/anaconda3/lib/python3.6/encodings/cp037.py | normal | {
"blob_id": "85dfb30a380dc73f5a465c8f4be84decccfbcb59",
"index": 1290,
"step-1": "/Users/sterlingbutters/anaconda3/lib/python3.6/encodings/cp037.py",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
<|reserved_special_token_0|>
def test_components_to_conf_and_back():
for Component in comp_list:
x = Component()
y = x.to_conf().make()
assert x == y
<|reserved_special_token_0|>
class TestEfConf:
def test_conf_export(self):
conf = EfConf(sources=[ParticleSource()], inner_... | flexible | {
"blob_id": "edcccc673994a8de281a683b747de52d2115f89e",
"index": 347,
"step-1": "<mask token>\n\n\ndef test_components_to_conf_and_back():\n for Component in comp_list:\n x = Component()\n y = x.to_conf().make()\n assert x == y\n\n\n<mask token>\n\n\nclass TestEfConf:\n\n def test_conf... | [
4,
5,
6,
8,
9
] |
#!/usr/bin/python
# Find minimal distances between clouds in one bin, average these per bin
# Compute geometric and arithmetical mean between all clouds per bin
from netCDF4 import Dataset as NetCDFFile
from matplotlib import pyplot as plt
import numpy as np
from numpy import ma
from scipy import stats
from haversin... | normal | {
"blob_id": "1c6e6394a6bd26b152b2f5ec87eb181a3387f794",
"index": 5894,
"step-1": "#!/usr/bin/python\n\n# Find minimal distances between clouds in one bin, average these per bin\n# Compute geometric and arithmetical mean between all clouds per bin\n\nfrom netCDF4 import Dataset as NetCDFFile\nfrom matplotlib impo... | [
0
] |
from discord.ext import commands
def is_owner():
async def predicate(ctx):
return ctx.author.id == 98208218022428672
return commands.check(predicate)
class Staff(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(
name='stop',
aliases=['shutdow... | normal | {
"blob_id": "23b2cc5b561a11ae7757a281a141491d5b7e23ca",
"index": 2683,
"step-1": "<mask token>\n\n\nclass Staff(commands.Cog):\n <mask token>\n\n @commands.command(name='stop', aliases=['shutdown'], description=\n 'This is a command for staff only to stop the bot')\n @is_owner()\n async def st... | [
1,
2,
3,
4,
5
] |
#Opens the file that the user specifies
fileopen = open(input("Please enter the name of the file that you wish to open."), 'r')
#Reads the lines within the file and determines the length of the file
lines = fileopen.readlines()
count = len(lines)
#Count is how long the file is, so number is the index values basically... | normal | {
"blob_id": "258b28153124ce42578c9eede429354069d8a7d6",
"index": 2869,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile number < count:\n print(number, '.', lines[number])\n number = number + 1\nfileopen.close()\n",
"step-3": "fileopen = open(input(\n 'Please enter the name of the file tha... | [
0,
1,
2,
3
] |
from job_description import JobDescription
from resume import Resume
from resume_manager import ResumeManager
| normal | {
"blob_id": "a998433e45c1d5135749c5164e8ec1f2eb0e572a",
"index": 1693,
"step-1": "<mask token>\n",
"step-2": "from job_description import JobDescription\nfrom resume import Resume\nfrom resume_manager import ResumeManager\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
... | [
0,
1
] |
<|reserved_special_token_0|>
class TwitterWorker(Thread):
<|reserved_special_token_0|>
def run(self):
streamListener = MyStreamListener()
self.stream = tweepy.Stream(auth=self.api.auth, listener=streamListener
)
self.stream.filter(track=['#HACKPSUHELPLINE'])
<|reserved_s... | flexible | {
"blob_id": "c475e095571b211693e66583637442edbf72c260",
"index": 7741,
"step-1": "<mask token>\n\n\nclass TwitterWorker(Thread):\n <mask token>\n\n def run(self):\n streamListener = MyStreamListener()\n self.stream = tweepy.Stream(auth=self.api.auth, listener=streamListener\n )\n ... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
def main():
print(generatePassword())
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def generatePassword():
numLowerCase = numUpperCase = numSpecialCase = numNumber = 0
password = ''
randomChars = '-|@.,?/!~#%^&*(){}[]\\=*'
... | flexible | {
"blob_id": "3956d4cdb0a8654b6f107975ac003ce59ddd3de1",
"index": 4485,
"step-1": "<mask token>\n\n\ndef main():\n print(generatePassword())\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef generatePassword():\n numLowerCase = numUpperCase = numSpecialCase = numNumber = 0\n password = ''\n ran... | [
1,
2,
3,
4,
5
] |
#-*- coding: utf-8 -*-
"""
Django settings for HyperKitty + Postorius
Pay attention to settings ALLOWED_HOSTS and DATABASES!
"""
from os.path import abspath, dirname, join as joinpath
from ConfigParser import SafeConfigParser
def read_cfg(path, section=None, option=None):
config = SafeConfigParser()
config.r... | normal | {
"blob_id": "0dd17d8872b251fbc59a322bf3c695bd8079aba4",
"index": 3338,
"step-1": "<mask token>\n\n\ndef read_cfg(path, section=None, option=None):\n config = SafeConfigParser()\n config.read(path)\n\n def get(section, option):\n return config.get(section, option) if config.has_option(section, opt... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Formater:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Formater:
def clean_number(posible_number):
sanitize_number = posible_number.replace(' ', '')
number_of_dots = sanitize_number.count('.')
if nu... | flexible | {
"blob_id": "02c32cf04529ff8b5edddf4e4117f8c4fdf27da9",
"index": 8612,
"step-1": "<mask token>\n",
"step-2": "class Formater:\n <mask token>\n",
"step-3": "class Formater:\n\n def clean_number(posible_number):\n sanitize_number = posible_number.replace(' ', '')\n number_of_dots = sanitize... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
model.add(Dense(5, input_dim=1, activation='relu'))
model.add(Dense(3))
model.add(Dense(1))
model.summary()
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
x = np.array([1, 2, 3, 4, 5, 6, ... | flexible | {
"blob_id": "43d9edd9120351ce5065eb266d482ccaa2e56177",
"index": 2416,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmodel.add(Dense(5, input_dim=1, activation='relu'))\nmodel.add(Dense(3))\nmodel.add(Dense(1))\nmodel.summary()\n<mask token>\n",
"step-3": "<mask token>\nx = np.array([1, 2, 3, 4, 5, 6,... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
import unittest
# Allow interactive execution from CLI, cd tests; ./test_cli.py
if __package__ is None:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from ksconf.con... | normal | {
"blob_id": "1bb953b665f48638691986e2fcae73b10a1c2ce0",
"index": 7729,
"step-1": "<mask token>\n\n\nclass CliKsconfCombineTestCase(unittest.TestCase):\n\n def build_test01(self, twd):\n twd.write_file(\n 'etc/apps/Splunk_TA_aws/default.d/10-upstream/props.conf',\n \"\"\"\n ... | [
7,
8,
10,
11,
12
] |
<|reserved_special_token_0|>
def isheadless():
if len(argv) > 1:
if argv[1] == 'head':
return False
else:
raise ValueError("optional arg must be : 'head'")
return True
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def exec... | flexible | {
"blob_id": "f379092cefe83a0a449789fbc09af490081b00a4",
"index": 3818,
"step-1": "<mask token>\n\n\ndef isheadless():\n if len(argv) > 1:\n if argv[1] == 'head':\n return False\n else:\n raise ValueError(\"optional arg must be : 'head'\")\n return True\n\n\n<mask token>\... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def _build(_input, *nodes):
x = _input
for node in nodes:
if callable(node):
x = node(x)
elif isinstance(node, list):
x = [_build(x, branch) for branch in node]
elif isinstance(node, tuple):
x = _build(x, *node)
e... | flexible | {
"blob_id": "ebc050544da69837cc2b8977f347380b94474bab",
"index": 576,
"step-1": "<mask token>\n\n\ndef _build(_input, *nodes):\n x = _input\n for node in nodes:\n if callable(node):\n x = node(x)\n elif isinstance(node, list):\n x = [_build(x, branch) for branch in node]... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
setup(name='gromacsplotter', version='0.1', description=
'Read xvg files created with gromacs for plotting with matplotlib', url
='', author='Ilyas Kuhlemann', author_email='ilyasp.ku@gmail.com',
license='MIT', package... | flexible | {
"blob_id": "cfa862988edf9d70aa5e975cca58b4e61a4de847",
"index": 759,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='gromacsplotter', version='0.1', description=\n 'Read xvg files created with gromacs for plotting with matplotlib', url\n ='', author='Ilyas Kuhlemann', author_email='ilya... | [
0,
1,
2,
3
] |
import ctypes
from game import GameWindow
import start_window as m_window
def start_button_callback(obj, w, h, amount):
_max = int(w.get()) * int(h.get())
if not (obj.validation_check(w) and obj.validation_check(h) and obj.validation_check(amount, _max)):
ctypes.windll.user32.MessageBoxW(0, "Wprowadź... | normal | {
"blob_id": "65eb7d01ccea137605d54d816b707c2cd3709931",
"index": 2067,
"step-1": "<mask token>\n\n\ndef start_button_callback(obj, w, h, amount):\n _max = int(w.get()) * int(h.get())\n if not (obj.validation_check(w) and obj.validation_check(h) and obj.\n validation_check(amount, _max)):\n ct... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(img.height):
for j in range(img.width):
pixel_val = pixels[i][j]
color_idx = None
if saturation_color == 'R':
color_idx = 0
elif saturation_color == 'G':
c... | flexible | {
"blob_id": "96ef95d8997eeab3d85a1bb6e4f8c86c9bfbb0a2",
"index": 4732,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(img.height):\n for j in range(img.width):\n pixel_val = pixels[i][j]\n color_idx = None\n if saturation_color == 'R':\n color_idx = 0\n ... | [
0,
1,
2,
3,
4
] |
from pydis.datastruct.sds import SdsImp
class RPCStub(object):
def __init__(self):
pass
def SET(self, key, value):
self
print("{}: {}".format(key, value))
| normal | {
"blob_id": "74f85732b4e1f4ef2b82a48818cbaedb18a56083",
"index": 8122,
"step-1": "<mask token>\n\n\nclass RPCStub(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass RPCStub(object):\n\n def __init__(self):\n pass\n <mask token>\n",
"step-3": "<mask token>\n\n\ncl... | [
1,
2,
3,
4,
5
] |
class UnknownResponseFormat(Exception):
pass
| normal | {
"blob_id": "e5e460eb704e2ab5f747d1beee05e012ea95fbd2",
"index": 3871,
"step-1": "<mask token>\n",
"step-2": "class UnknownResponseFormat(Exception):\n pass\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
import numpy as np
class LayerBase(object):
def __init__(self, units_count, activation_func):
self.current_layer_dim = units_count
self.activation_func = activation_func
self.weights = None
self.bias = None
self.pre_activation = None
self.activation_layer = None
... | normal | {
"blob_id": "389ccddcbe2214ae5c012bc82a404a81942792d8",
"index": 1770,
"step-1": "<mask token>\n\n\nclass LayerBase(object):\n\n def __init__(self, units_count, activation_func):\n self.current_layer_dim = units_count\n self.activation_func = activation_func\n self.weights = None\n ... | [
4,
7,
9,
10,
12
] |
def Return():
s = raw_input('Enter a s: ')
i = 0
s1 = ''
leng = len(s)
while i < leng:
if s[i] == s[i].lower():
s1 += s[i].upper()
else:
s1 += s[i].lower()
i += 1
return s1
if __name__ == '__main__':
print Return()
| normal | {
"blob_id": "6dafb60b79a389499ae2a0f17f9618426faf45a9",
"index": 8880,
"step-1": "def Return():\n s = raw_input('Enter a s: ')\n i = 0\n s1 = ''\n leng = len(s)\n while i < leng:\n if s[i] == s[i].lower():\n s1 += s[i].upper()\n else:\n s1 += s[i].lower()\n ... | [
0
] |
<|reserved_special_token_0|>
def register(locator: str, entry_point, **kwargs):
"""Register an AgentSpec with the zoo.
In order to load a registered AgentSpec it needs to be reachable from a
directory contained in the PYTHONPATH.
Args:
locator:
A string in the format of 'locator-... | flexible | {
"blob_id": "b77c40c89c88b49c851e9a14c67cf0799d6de847",
"index": 9235,
"step-1": "<mask token>\n\n\ndef register(locator: str, entry_point, **kwargs):\n \"\"\"Register an AgentSpec with the zoo.\n\n In order to load a registered AgentSpec it needs to be reachable from a\n directory contained in the PYTH... | [
2,
3,
4,
5,
6
] |
from math import log2
from egosplit.benchmarks.data_structures.cover_benchmark import *
from egosplit.benchmarks.evaluation.utility import create_line
from networkit.stopwatch import clockit
# Analyse the result cover of a benchmark run
@clockit
def analyze_cover(benchmarks, result_dir, calc_f1, append):
if not app... | normal | {
"blob_id": "dc5b9600828857cc5ea434a7b010cd8aa2589d22",
"index": 6568,
"step-1": "<mask token>\n\n\n@clockit\ndef analyze_cover(benchmarks, result_dir, calc_f1, append):\n if not append:\n print_headers(result_dir)\n for benchmark in benchmarks:\n count_benchmark_cover(result_dir, calc_f1, be... | [
2,
3,
5,
6,
7
] |
def sort(L):
n = len(L)
if n < 2:
return L
L1, L2 = L[:n // 2], L[n // 2:]
return merge(sort(L1), sort(L2))
def merge(L1, L2):
if L1 == []:
return L2
if L2 == []:
return L1
x1, R1 = L1[0], L1[1:]
x2, R2 = L2[0], L2[1:]
if x1 <= x2:
return [x1] + merg... | normal | {
"blob_id": "056636e2220e529d3f66872a4a48c0984cda1ce4",
"index": 6617,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef merge(L1, L2):\n if L1 == []:\n return L2\n if L2 == []:\n return L1\n x1, R1 = L1[0], L1[1:]\n x2, R2 = L2[0], L2[1:]\n if x1 <= x2:\n return ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class ChainedTest(BitcoinTestFramework):
def set_test_params(self):
""" our test network requires a peer node so that getblocktemplate succeeds """
self.num_nodes = 2
chained_args = ['-limitancestorcount=2000',
'-limitdescendantcount=2000', '-limit... | flexible | {
"blob_id": "661eef8500309191514fd760b7518014dee2bb5f",
"index": 9225,
"step-1": "<mask token>\n\n\nclass ChainedTest(BitcoinTestFramework):\n\n def set_test_params(self):\n \"\"\" our test network requires a peer node so that getblocktemplate succeeds \"\"\"\n self.num_nodes = 2\n chaine... | [
7,
8,
9,
10,
13
] |
# -*- coding: utf-8 -*-
########### SVN repository information ###################
# $Date: $
# $Author: $
# $Revision: $
# $URL: $
# $Id: $
########### SVN repository information ###################
'''
*GSASIIfpaGUI: Fundamental Parameters Routines*
===============================================
This module contain... | normal | {
"blob_id": "3b1426e0f29093e1e462765bcf1d351a064b9639",
"index": 142,
"step-1": "<mask token>\n\n\ndef SetCu2Wave():\n \"\"\"Set the parameters to the two-line Cu K alpha 1+2 spectrum\n \"\"\"\n parmDict['wave'] = {i: v for i, v in enumerate((1.540596, 1.544493))}\n parmDict['int'] = {i: v for i, v i... | [
7,
8,
9,
10,
11
] |
import sqlalchemy
from .base import Base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
class ModelSpellVariantPair(Base):
__tablename__ = "spell_variant_pair"
uuid = Column(
UUID(as_uuid=True),
... | normal | {
"blob_id": "4958d6d88b762e6fbe860123b7274c16b6452605",
"index": 7674,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ModelSpellVariantPair(Base):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ModelSpellVariantPair(Base):\n _... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def read_jla_mock(mock_filename):
fp = open(mock_filename, 'r')
lines = fp.readlines()
fp.close()
jla = []
for line in lines:
sn = line.split()
temp = []
temp.append(float(sn[1]))
temp.append(float(sn[2]))
temp.append(float(sn[3]... | flexible | {
"blob_id": "ac35672661e1dd0b97567ae4335f537dc69f98f7",
"index": 6240,
"step-1": "<mask token>\n\n\ndef read_jla_mock(mock_filename):\n fp = open(mock_filename, 'r')\n lines = fp.readlines()\n fp.close()\n jla = []\n for line in lines:\n sn = line.split()\n temp = []\n temp.ap... | [
1,
2,
3,
4,
5
] |
from p5 import *
capture = None
def setup():
global capture
createCanvas(390, 240)
capture = createCapture(VIDEO)
capture.size(320, 240)
def draw():
background(255)
image(capture, 0, 0, 320, 240)
run()
| normal | {
"blob_id": "93bfca1e756951faacd29871ad19afad374e25d6",
"index": 9647,
"step-1": "<mask token>\n\n\ndef setup():\n global capture\n createCanvas(390, 240)\n capture = createCapture(VIDEO)\n capture.size(320, 240)\n\n\ndef draw():\n background(255)\n image(capture, 0, 0, 320, 240)\n\n\n<mask tok... | [
2,
3,
4,
5
] |
from django.contrib.auth import authenticate
from django.http import JsonResponse, HttpResponse
from django.shortcuts import render
import json
from userprofile.models import Profile
from .models import *
#发送私信
def sendmessage(request):
if request.method == "POST":
data = json.loads(request.body)
... | normal | {
"blob_id": "f25db7d797f1f88bd0374d540adcb396e16740a0",
"index": 8953,
"step-1": "<mask token>\n\n\ndef getmessage(request):\n if request.method == 'POST':\n data = json.loads(request.body)\n uid = data.get('userid')\n msglist = []\n mres = Message.objects.filter(tuid_id=uid).all()... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def run(name, dim_k, dump='dump', add_cmd=''):
res = all_res[name]
model = 'ATT_ts' if res.split('_')[1] == 'att' else 'LastItem'
cmd = (
f'python main.py -model={model} -ds=v3 -restore_model={res} -k={dim_k} -show_detail -{dump} -nb_topk=2000 -nb_rare_k=1000 -msg={nam... | flexible | {
"blob_id": "548a236c4c485091d312593dcb0fa331ff98f1a8",
"index": 6359,
"step-1": "<mask token>\n\n\ndef run(name, dim_k, dump='dump', add_cmd=''):\n res = all_res[name]\n model = 'ATT_ts' if res.split('_')[1] == 'att' else 'LastItem'\n cmd = (\n f'python main.py -model={model} -ds=v3 -restore_mod... | [
1,
3,
4,
5,
6
] |
import pytest
from chess.board import Board, ImpossibleMove
from chess.pieces import King, Rook, Pawn, Knight
def test_board_has_32_pieces():
board = Board()
assert board.pieces_quantity() == 32
def test_board_can_be_instatiated_with_any_set_of_pieces():
board = Board(initial_pieces={'a2': Pawn('white'... | normal | {
"blob_id": "5f471fb75b1c4f6fc7aa4cb4f99f9c1a1a9f0ea1",
"index": 8595,
"step-1": "<mask token>\n\n\ndef test_board_can_be_instatiated_with_any_set_of_pieces():\n board = Board(initial_pieces={'a2': Pawn('white'), 'a6': Pawn('black')})\n assert board.pieces_quantity() == 2\n\n\ndef test_piece_cant_capture_a... | [
3,
7,
9,
10,
11
] |
class Restaurant:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def open_restaurant(self):
"""Message indicating the restaurant is open."""
print('The restaurant is now open!')
<|reserved_special_token_1|>
class Restaurant:
<|reserved_spec... | flexible | {
"blob_id": "4ecf976a7d655efb5af427083ec1943cae6fe56d",
"index": 3672,
"step-1": "class Restaurant:\n <mask token>\n <mask token>\n <mask token>\n\n def open_restaurant(self):\n \"\"\"Message indicating the restaurant is open.\"\"\"\n print('The restaurant is now open!')\n",
"step-2":... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class Auction(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Auction(object):
def __init__(self, name, type, status, start_price, buy_now_price):
self.name = name
self.typ... | flexible | {
"blob_id": "9e05f883d80d7583c9f7e16b2fb5d3f67896388d",
"index": 5629,
"step-1": "<mask token>\n\n\nclass Auction(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Auction(object):\n\n def __init__(self, name, type, status, start_price, buy_now_price):\n self.name = ... | [
1,
2,
3,
4
] |
sair = True
while sair:
num = int(input("informe um numero inteiro:"))
if num <16:
fatorial = 1
x = num
while x>=1:
print(x,".")
fatorial = fatorial*x
x -= 1
print("Valor total do Fatorial do %d = %d "%(num,fatorial))
else:
... | normal | {
"blob_id": "421e7ed0cc5a8c8acc9b98fae4ee6cc784d9b068",
"index": 9683,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile sair:\n num = int(input('informe um numero inteiro:'))\n if num < 16:\n fatorial = 1\n x = num\n while x >= 1:\n print(x, '.')\n fat... | [
0,
1,
2,
3
] |
# Problem Statement – An automobile company manufactures both a two wheeler (TW) and a four wheeler (FW). A company manager wants to make the production of both types of vehicle according to the given data below:
# 1st data, Total number of vehicle (two-wheeler + four-wheeler)=v
# 2nd data, Total number of wheels = W
... | normal | {
"blob_id": "74939f81e999b8e239eb64fa10b56f48c47f7d94",
"index": 1622,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif w < 2 or w % 2 != 0 or w <= v:\n print('INVALID INPUT')\nelse:\n x = (4 * v - w) // 2\n print('TW={0} FW={1}'.format(x, v - x))\n",
"step-3": "v = int(input())\nw = int(inpu... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
@app.route('/hello')
@app.route('/hello/<name>')
def hello(name=None):
name = 'World' if not name else name
return 'Hello %s' % name
@app.route('/')
def index():
return render_template('index.html', title='home')
@app.route('/distance', methods=['POST', 'GET'])
def distanc... | flexible | {
"blob_id": "05052e9ccbd076e71e9ec6148887ce7b82ed316d",
"index": 6256,
"step-1": "<mask token>\n\n\n@app.route('/hello')\n@app.route('/hello/<name>')\ndef hello(name=None):\n name = 'World' if not name else name\n return 'Hello %s' % name\n\n\n@app.route('/')\ndef index():\n return render_template('inde... | [
3,
4,
5,
6,
7
] |
import cpt_tools
from gui_helpers.gui_config import *
chisqr_str = '\u03c72'
mu_str = '\u03bc'
sigma_str = '\u03c3'
class FitWidget( object ) :
def __init__( self, plotter_widget, analyzer = None ) :
self.plotter_widget = plotter_widget
self.plotter = plotter_widget.plotter
s... | normal | {
"blob_id": "aa51b2d4bfe4051f3302d14cf2123a3881a8a2e3",
"index": 5668,
"step-1": "<mask token>\n\n\nclass FitWidget(object):\n\n def __init__(self, plotter_widget, analyzer=None):\n self.plotter_widget = plotter_widget\n self.plotter = plotter_widget.plotter\n self.hists = self.plotter.al... | [
2,
5,
6,
7,
8
] |
from datetime import date
from django.test import TestCase
from model_mommy import mommy
from apps.debtors.models import Debtor
from apps.invoices.models import Invoice, InvoiceStatusChoices
from apps.invoices.services import InvoiceService
class InvoiceServiceTestCase(TestCase):
def setUp(self) ->None:
... | normal | {
"blob_id": "5f77e93d63c696363c30f019019acd22c694308b",
"index": 4529,
"step-1": "<mask token>\n\n\nclass InvoiceServiceTestCase(TestCase):\n <mask token>\n\n def test_create_invoice(self):\n invoice = self.invoice_service.create_invoice(amount=12.1, status=\n InvoiceStatusChoices.OVERDUE... | [
3,
4,
5,
6
] |
from platypush.message.event import Event
class ClipboardEvent(Event):
def __init__(self, text: str, *args, **kwargs):
super().__init__(*args, text=text, **kwargs)
# vim:sw=4:ts=4:et:
| normal | {
"blob_id": "9b02ce0b3acb14bdd6463c5bdba865b28253767c",
"index": 7896,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ClipboardEvent(Event):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ClipboardEvent(Event):\n\n def __init__(self, text: str, *args, **kwargs):\n super().... | [
0,
1,
2,
3,
4
] |
import math
getal1 = 5
getal2 = 7
getal3 = 8
getal4 = -4
getal5 = 2
print(getal1 * getal2 + getal3)
print(getal1 * (getal2 + getal3))
print(getal2 + getal3 / getal1)
print((getal2 + getal3) / getal1)
print(getal2 + getal3 % getal1)
print(abs(getal4 * getal1))
print(pow(getal3, getal5))
print(round(getal5 / getal2, 2))
... | normal | {
"blob_id": "30d75aafd9612ac02557b947fc4e3c2f7322a7fd",
"index": 3555,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(getal1 * getal2 + getal3)\nprint(getal1 * (getal2 + getal3))\nprint(getal2 + getal3 / getal1)\nprint((getal2 + getal3) / getal1)\nprint(getal2 + getal3 % getal1)\nprint(abs(getal4 *... | [
0,
1,
2,
3
] |
from typing import Tuple, List
import math
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
self.constraints = []
def __str__(self):
return f"({self.x}, {self.y})"
class Line:
def __init__(self, point1, point2):
if isinstance(point1, Point):
... | normal | {
"blob_id": "e59a51641dc2966b0170678de064e2845e170cf5",
"index": 4943,
"step-1": "<mask token>\n\n\nclass Line:\n\n def __init__(self, point1, point2):\n if isinstance(point1, Point):\n self.p1 = point1\n elif isinstance(point1, (Tuple, List)):\n self.p1 = Point(*point1)\n ... | [
11,
12,
15,
17,
18
] |
<|reserved_special_token_0|>
class MyThingsDashboardModule(DashboardModule):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def init_with_context(self, context):
user = context['request'].user
slices = Slice.objects.filter(group__in=user.groups.... | flexible | {
"blob_id": "90324392e763ac6ea78c77b909c4bea667d45e6c",
"index": 5896,
"step-1": "<mask token>\n\n\nclass MyThingsDashboardModule(DashboardModule):\n <mask token>\n <mask token>\n <mask token>\n\n def init_with_context(self, context):\n user = context['request'].user\n slices = Slice.ob... | [
2,
4,
5,
6,
7
] |
#!/usr/bin/env python2
# coding=utf8
from __future__ import absolute_import, division, print_function
from sqlalchemy import func
from walis.model.walis import walis_session
from walis.model.zeus import zeus_session, zeus_db_handler
from walis.model.zeus.activity import (
SubsidyProcessRecord,
SubsidyPayReco... | normal | {
"blob_id": "68d537cb8488ae4f2c8300e885be78540952dec0",
"index": 450,
"step-1": "<mask token>\n\n\ndef get_new_pay_records(process_at, limit=200):\n with zeus_session() as session:\n result = session.query(SubsidyPayRecord.id, SubsidyPayRecord.\n restaurant_id, SubsidyProcessRecord.card_id,\... | [
11,
13,
14,
16,
19
] |
from itertools import count, islice
from math import sqrt
def is_prime(x):
if x<2:
return False
for i in range(2, int(sqrt(x)) + 1):
if x%i == 0:
return False
return True
def primes(x):
return islice((p for p in count() if is_prime(p)), x)
print(list(primes(1000))[-10:])
... | normal | {
"blob_id": "0f1bad350faaff6aab339944b4d24c4801fa8c64",
"index": 4965,
"step-1": "<mask token>\n\n\ndef is_prime(x):\n if x < 2:\n return False\n for i in range(2, int(sqrt(x)) + 1):\n if x % i == 0:\n return False\n return True\n\n\ndef primes(x):\n return islice((p for p in... | [
2,
3,
4,
5,
6
] |
import requests
from bs4 import BeautifulSoup
class Book:
def __init__(self, url):
self.url = url
self.title = ""
self.category = ""
self.upc=""
self.price_including_tax=""
self.price_excluding_tax=""
self.number_available=""
self.description=""
... | normal | {
"blob_id": "3dc83168264fbb4f9b0ab2980b845dffdc4417bb",
"index": 7588,
"step-1": "<mask token>\n\n\nclass Book:\n\n def __init__(self, url):\n self.url = url\n self.title = ''\n self.category = ''\n self.upc = ''\n self.price_including_tax = ''\n self.price_excluding_... | [
11,
12,
13,
15,
16
] |
from django.contrib.auth.decorators import login_required
from django.contrib.auth import login, authenticate
from django.shortcuts import render, redirect
from mysite.core.forms import SignUpForm,UserProfileForm
from django.views.generic import UpdateView
from .models import Profile
from django.contrib.auth.mixins im... | normal | {
"blob_id": "21d261dec6668a24030f37b7dcb87c0132e63528",
"index": 1365,
"step-1": "<mask token>\n\n\nclass EditUserProfileView(LoginRequiredMixin, UpdateView):\n model = Profile\n form_class = UserProfileForm\n template_name = 'profile.html'\n",
"step-2": "<mask token>\n\n\n@login_required\ndef home(re... | [
2,
3,
4,
5,
6
] |
from accessor import *
from order import Order
from copy import deepcopy
import pandas as pd
import numpy as np
import util
class Broker:
def __init__(self, equity):
self.execute = Execute(equity) # Execute
def make_order(self, unit, limit_price, stop_loss, stop_profit):
ord... | normal | {
"blob_id": "ca0aedcfb997299240870649823fb872e0d9f99a",
"index": 6023,
"step-1": "<mask token>\n\n\nclass Broker:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def liquidation(self, pos, price, date, commission):\n \"\"\"\n clean the last position\... | [
9,
11,
12,
16,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class CfCoreConfig(AppConfig):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class CfCoreConfig(AppConfig):
name = 'cf_core'
<|reserved_special_token_1|>
from django.apps ... | flexible | {
"blob_id": "01847c9e601eae6775cd4324483740c30e344557",
"index": 382,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass CfCoreConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass CfCoreConfig(AppConfig):\n name = 'cf_core'\n",
"step-4": "from django.apps import AppCon... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
def evalRPN(self, tokens: List[str]) ->int:
def operation(op1, op2, op):
if op == '+':
return op1 + op2
if o... | flexible | {
"blob_id": "6b597f1570c022d17e4476e2ab8817e724a166a7",
"index": 1096,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def evalRPN(self, tokens: List[str]) ->int:\n\n def operation(op1, op2, op):\n if op == '+':\n ... | [
0,
1,
2,
3
] |
from numpy import array
import xspec as xs
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import Grid
from spectralTools.step import Step
class xspecView(object):
def __init__(self):
#xs.Plot.device="/xs"
xs.Plot.xAxis='keV'
self.swift = []
self.nai=[]
s... | normal | {
"blob_id": "ba34bae7849ad97f939c1a7cb91461269cd58b64",
"index": 8994,
"step-1": "<mask token>\n\n\nclass xspecView(object):\n <mask token>\n\n def LoadSwiftPHAs(self, phaFiles):\n \"\"\"\n Load The Swift PHAs in time order\n\n \"\"\"\n for pha in phaFiles:\n s = xs.S... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
def get_slots_query(scene: GameScene, entity: int):
"""Return a query that resolves to entity's equipment slots and their equipped items."""
def query():
paper_doll: PaperDoll = scene.cm.get_one(PaperDoll, entity)
equipment = paper_doll.get_equipment()
ret... | flexible | {
"blob_id": "f1547e0893ce9c4661b546e49f3fc998745390d9",
"index": 4397,
"step-1": "<mask token>\n\n\ndef get_slots_query(scene: GameScene, entity: int):\n \"\"\"Return a query that resolves to entity's equipment slots and their equipped items.\"\"\"\n\n def query():\n paper_doll: PaperDoll = scene.cm... | [
2,
3,
4,
5,
6
] |
"""
This file contains the general data storage classes used throughout Logician.
"""
import csv
import json
import os
from collections import OrderedDict
VALID_CHANNEL_COUNTS = [4]
class Acquisition:
"""
The acqusition object contains data from all of the acquired channels.
Parameters
----------
... | normal | {
"blob_id": "ec44e12624fbee3148cfa4f886e86ba437e920ec",
"index": 4158,
"step-1": "<mask token>\n\n\nclass Acquisition:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def csv_string(self):\n out_string = '#sample_rate=%d' % self.sample_rate\n for row... | [
13,
15,
19,
20,
24
] |
source = open("input.txt", "r")
total = 0
def calculateWeight( weight ):
fuel = calculateFuel(weight)
if fuel > 0:
sum = fuel + calculateWeight(fuel)
return sum
else:
return max(0, fuel)
def calculateFuel ( weight ):
return weight // 3 -2
for line in source.readlines():
t... | normal | {
"blob_id": "bea1a5bc9c92d095a2f187a4c06d18d0a939f233",
"index": 3376,
"step-1": "<mask token>\n\n\ndef calculateFuel(weight):\n return weight // 3 - 2\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef calculateWeight(weight):\n fuel = calculateFuel(weight)\n if fuel > 0:\n sum = fuel + ca... | [
1,
2,
3,
4,
5
] |
import matplotlib.pyplot as plt
Ci_MSB = [32,16,8,4,2,1]
Ci_LSB = [16,8,4,2,1]
CB = 1
CP_B = 0
CP_LSB = (32-1)*(CB+CP_B-1)+10
print(CP_LSB)
CP_MSB = 0
Csum_LSB = sum(Ci_LSB)+CP_LSB
Csum_MSB = sum(Ci_MSB)+CP_MSB
Cx = Csum_LSB*Csum_MSB+(CB+CP_B)*Csum_LSB+(CB+CP_B)*Csum_MSB
Wi_MSB = [Ci_MSB[i]*(CB+CP_B+Csum_LSB)/Cx for i... | normal | {
"blob_id": "b5ac3695a224d531f5baa53a07d3c894d44e8c4c",
"index": 395,
"step-1": "<mask token>\n\n\ndef AtoD(vin):\n code = [(0) for i in range(12)]\n code[0] = 1 if vin > 0 else 0\n for i in range(6):\n vin = vin - Wi_MSB[i] * (code[i] - 0.5) * 2\n code[i + 1] = 1 if vin > 0 else 0\n fo... | [
2,
3,
4,
5,
6
] |
import numpy as np
import dl_style_transfer.workspace.data_helpers
import os
here = os.path.dirname(os.path.abspath(__file__))
sents = list(open(os.path.join(here, 'yelp_sentences.txt'))) + list(open(os.path.join(here, 'shake_sentences.txt')))
thresh = 5
col = dict()
word_to_ind = dict()
ind_to_word = dict()
def... | normal | {
"blob_id": "2317a2fff493588ad6cc3a4ac2b600fbf1c5583c",
"index": 8594,
"step-1": "<mask token>\n\n\ndef __line_into_col__(line):\n tokens = dl_style_transfer.workspace.data_helpers.clean_str(line).split(' '\n )\n for wor in tokens:\n if col.get(wor) is None:\n col[wor] = 1\n ... | [
2,
4,
6,
8,
10
] |
<|reserved_special_token_0|>
def calc_frames(new_time):
old_time = datetime(new_time.year - 1, 11, 30, 23)
days = (new_time - old_time).days
sec = (new_time - old_time).seconds
hours = days * 24 + sec / 3600
return int(hours)
def read_point_fixtime(filname, fixtime, flonl, flonr, flats, flatn):
... | flexible | {
"blob_id": "09a468e11651eb60e0805c151bda270e0ebecca9",
"index": 4853,
"step-1": "<mask token>\n\n\ndef calc_frames(new_time):\n old_time = datetime(new_time.year - 1, 11, 30, 23)\n days = (new_time - old_time).days\n sec = (new_time - old_time).seconds\n hours = days * 24 + sec / 3600\n return in... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
os.chdir('c:\\users\\patty\\desktop')
if not os.path.isdir('DailyBibleVerse'):
os.makedirs('DailyBibleVerse')
<|reserved_special_token_0|>
res.raise_for_status()
<|reserved_special_token_0|>
while os.path.exists(
'c:\\user... | flexible | {
"blob_id": "a8fb8ac3c102e460d44e533b1e6b3f8780b1145d",
"index": 4609,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nos.chdir('c:\\\\users\\\\patty\\\\desktop')\nif not os.path.isdir('DailyBibleVerse'):\n os.makedirs('DailyBibleVerse')\n<mask token>\nres.raise_for_status()\n<mask token>\nwhile os.pat... | [
0,
1,
2,
3,
4
] |
#!/usr1/local/bin/python
import os, sys, re, shutil, random
from tempfile import *
# program location
prog_dir = '/home/jpei/test_promals3d_package/bar/promals_package/bin/'
# program names
promals_web = prog_dir + "progress_for_web.py"
csv_cutoff_g = 5
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV... | normal | {
"blob_id": "b9386cf8c17b28fd1fea6e587ca4401de247cbea",
"index": 7779,
"step-1": "#!/usr1/local/bin/python\n\nimport os, sys, re, shutil, random\nfrom tempfile import *\n\n\n# program location\nprog_dir = '/home/jpei/test_promals3d_package/bar/promals_package/bin/'\n\n# program names\npromals_web = prog_dir + \"... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for face in detected_faces:
x, y, w, h = face
cv.rectangle(original_image_5, (x, y), (x + w, y + h), (0, 255, 0), 2)
cv.imshow('orig_img', original_image_5)
cv.waitKey(0)
cv.destroyAllWindows()
<|reserved_special_token_1... | flexible | {
"blob_id": "d0bd08bea65878f5fccfc4affecdf53cc36179df",
"index": 6633,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor face in detected_faces:\n x, y, w, h = face\n cv.rectangle(original_image_5, (x, y), (x + w, y + h), (0, 255, 0), 2)\ncv.imshow('orig_img', original_image_5)\ncv.waitKey(0)\ncv.... | [
0,
1,
2,
3,
4
] |
#Use bisection search to determine square root
def square_calculator(user_input):
"""
accepts input from a user to determine the square root
returns the square root of the user input
"""
precision = .000000000001
counter = 0
low = 0
high = user_input
guess = (low + high) / 2.0
w... | normal | {
"blob_id": "2bc20f3410d068e0592c8a45e3c13c0559059f24",
"index": 4498,
"step-1": "<mask token>\n",
"step-2": "def square_calculator(user_input):\n \"\"\"\n accepts input from a user to determine the square root\n returns the square root of the user input\n \"\"\"\n precision = 1e-12\n counter... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def link_bits(num: str=None, bit_i: str='0', bit_j: str='0', write: bool=True
) ->int:
if num is None:
num, bit_i, bit_j = read_input()
num = int(num, 2)
num_len = num.bit_length()
mask = 2 ** num_len... | flexible | {
"blob_id": "113572682ca83408b7c22e0e178f29945d741142",
"index": 6672,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef link_bits(num: str=None, bit_i: str='0', bit_j: str='0', write: bool=True\n ) ->int:\n if num is None:\n num, bit_i, bit_j = read_input()\n num = int(num, 2)\n ... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
import xml.dom.minidom
import os
import matplotlib.pyplot as plt
import cPickle as p
import numpy as np
def modifyXML(name,numCar):
DOMTree = xml.dom.minidom.parse(name)
objects=DOMTree.getElementsByTagName('object')
for object in objects:
if object.getElementsByTagName('name')[0].childNodes[0].... | normal | {
"blob_id": "1c13a9ca3617dc6f1a1f1aa8249cce37062a449b",
"index": 8243,
"step-1": "#!/usr/bin/python\nimport xml.dom.minidom\nimport os\nimport matplotlib.pyplot as plt\nimport cPickle as p\nimport numpy as np\n\ndef modifyXML(name,numCar):\n\tDOMTree = xml.dom.minidom.parse(name)\n\tobjects=DOMTree.getElementsBy... | [
0
] |
'''
Generate the output images and videos, including rendering of the pipeline
'''
import os
import matplotlib.image as mpimg
import cv2
from moviepy.editor import VideoFileClip
from networkx.drawing.nx_agraph import to_agraph
import lanespipeline
import lanefinder
from compgraph import CompGraph, CompGraphRunner
C... | normal | {
"blob_id": "456d79a69c170a59af742648f16e0171cd5a2412",
"index": 1412,
"step-1": "<mask token>\n\n\ndef create_dir(directory):\n if not os.path.exists(directory):\n os.makedirs(directory)\n\n\ndef get_full_paths_to_files(files_dir, filenames):\n return [os.path.join(files_dir, f) for f in filenames]... | [
5,
6,
7,
8,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def Schout2ConTank(a, b, d):
th = d * b / sqrt(a ** 2 - b ** 2)
k = 1 / (d * sqrt(a ** 2 - b ** 2))
s = sqrt(d / sqrt(a ** 2 - b ** 2))
return th, k, s
<|reserved_special_token_1|>
from numpy import sqrt
def... | flexible | {
"blob_id": "4dda122a8c3a2aab62bb202945f6fb9cb73cf772",
"index": 8330,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef Schout2ConTank(a, b, d):\n th = d * b / sqrt(a ** 2 - b ** 2)\n k = 1 / (d * sqrt(a ** 2 - b ** 2))\n s = sqrt(d / sqrt(a ** 2 - b ** 2))\n return th, k, s\n",
"step... | [
0,
1,
2,
3
] |
import json
from .errors import TorrentNotValid, TorrentHashNotFound, FailedLogin, HttpException
class QBittorrentClient:
"""
QBittorent client
"""
def __init__(self, *, connector):
self.connector = connector
def login(self, username: str, password: str):
return self.connector.l... | normal | {
"blob_id": "8ce2db0a28de8ddd504b744f3c9210d1a0ed7d45",
"index": 699,
"step-1": "<mask token>\n\n\nclass QBittorrentClient:\n <mask token>\n <mask token>\n\n def login(self, username: str, password: str):\n return self.connector.login(username, password)\n\n def logout(self):\n return s... | [
8,
11,
13,
14
] |
import multiprocessing
name = "flask_gunicorn"
workers = multiprocessing.cpu_count() * 2 + 1
loglevel = "debug"
bind = f"0.0.0.0:18080"
| normal | {
"blob_id": "2ad326f739b42b9c7c252078b8c28e90da17b95d",
"index": 1802,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nname = 'flask_gunicorn'\nworkers = multiprocessing.cpu_count() * 2 + 1\nloglevel = 'debug'\nbind = f'0.0.0.0:18080'\n",
"step-3": "import multiprocessing\nname = 'flask_gunicorn'\nworke... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
import sys, re, urllib, urllib2, string, time, os
from urllib2 import Request, urlopen, URLError, HTTPError
from urlparse import urlparse
joomla_version="undefined" #used for joomla veersin info
provided_url="" #the selected provided url
verbose_flag = 0 # If set to 1, prints... | normal | {
"blob_id": "9de2589cfb5bebba789ece8df9a0fcfbedb01173",
"index": 2440,
"step-1": "#!/usr/bin/env python\r\n\r\nimport sys, re, urllib, urllib2, string, time, os\r\nfrom urllib2 import Request, urlopen, URLError, HTTPError\r\nfrom urlparse import urlparse\r\n\r\njoomla_version=\"undefined\" #used for joomla... | [
0
] |
<|reserved_special_token_0|>
class Question:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def findSecond(self, sentenceDoc, verb, children):
for child in children:
if child.dep_ == 'attr' or child.dep_ == 'nsubj':
temp = self.nounArray.findWord(child.orth_... | flexible | {
"blob_id": "4d63a5f09164b78faa731af6dce41969edc2c4f5",
"index": 848,
"step-1": "<mask token>\n\n\nclass Question:\n <mask token>\n <mask token>\n\n def findSecond(self, sentenceDoc, verb, children):\n for child in children:\n if child.dep_ == 'attr' or child.dep_ == 'nsubj':\n ... | [
3,
4,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if r == n:
print('too late')
else:
l = list(range(1, r + 1))
for _ in range(n):
l.remove(int(input()))
print(l[0])
<|reserved_special_token_1|>
r, n = map(int, input().split())
if r == n:
print('too ... | flexible | {
"blob_id": "381d3f0890a2916d2e0a21a6a47a5f87afde622d",
"index": 9241,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif r == n:\n print('too late')\nelse:\n l = list(range(1, r + 1))\n for _ in range(n):\n l.remove(int(input()))\n print(l[0])\n",
"step-3": "r, n = map(int, input().s... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class AnnouncedPuResults(models.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class Meta:
... | flexible | {
"blob_id": "5ce5fbfa33c241fc316d5e414df01a39bfc9be18",
"index": 7063,
"step-1": "<mask token>\n\n\nclass AnnouncedPuResults(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n managed = False\n... | [
15,
17,
19,
21,
22
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.