code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
"""
- input: is a 'special' array (heavily nested array)
- output: return the product sum
- notes:
- special array is a non-empty array that contains either integers or other 'special' arrays
- product sum of a special array is the sum of its elements, where 'special' arrays inside are summed themselves and then mu... | normal | {
"blob_id": "87e5a615157db59d1eac4967c321829c878d00a5",
"index": 2234,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef product_sum_helper(array, depth):\n sum = 0\n for ele in array:\n if type(ele) is int:\n sum += ele\n else:\n sum += product_sum_helper(e... | [
0,
1,
2,
3
] |
"""
* Team Id : LM#4787
* Author List : Arjun S, Vinod, Arvind, Vishnu
* Filename: ArenaPreprocessor.py
* Theme: Launch A Module
* Functions: arena_preprocess, getTransformationMatrix, get_robot_space
* Global Variables: None
"""
import cv2
import numpy as np
"""
* Function Name... | normal | {
"blob_id": "228852f960e9343d9f45abdd3204cfab7bb54bc6",
"index": 8230,
"step-1": "<mask token>\n\n\ndef arena_preprocess(frame, M):\n processed_arena = cv2.warpPerspective(frame, M, (900, 600))\n in_corners = np.array([[10, 18], [10, 590], [890, 590], [890, 15]])\n h, w = processed_arena.shape[:2]\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class Producer:
def __init__(self, topic):
kafka_uname = os.environ['KAFKA_USERNAME']
kafka_pwd = os.environ['KAFKA_PASSWORD']
kafka_hosts = os.environ['KAFKA_HOSTS']
ssl_truststore_file = '/opt/scripts/ca-cert.cer'
self.topic_name = topic
... | flexible | {
"blob_id": "283b93437072f0fd75d75dab733ecab05dc9e1f3",
"index": 3872,
"step-1": "<mask token>\n\n\nclass Producer:\n\n def __init__(self, topic):\n kafka_uname = os.environ['KAFKA_USERNAME']\n kafka_pwd = os.environ['KAFKA_PASSWORD']\n kafka_hosts = os.environ['KAFKA_HOSTS']\n ssl... | [
4,
7,
8,
9,
11
] |
#! py -3
# -*- coding: utf-8 -*-
import requests
from urllib.parse import quote
import logging
from urllib.parse import urlparse
logger = logging.getLogger(__name__)
logger = logging.getLogger()
# 配置日志级别,如果不显示配置,默认为Warning,表示所有warning级别已下的其他level直接被省略,
# 内部绑定的handler对象也只能接收到warning级别以上的level,你可以理解为总开关
logger.setLeve... | normal | {
"blob_id": "c5d92ec592250d5bc896d32941364b92ff1d21e9",
"index": 3793,
"step-1": "<mask token>\n\n\ndef request_dyn():\n logger.info('dyn: 开始测试请求')\n postUrl = '%s/raframework/browse/dyn' % serverUrl\n postData = {'page': '/conf/CDSConfig.jsp', 'amp': '', 'action':\n 'returnXML', 'LOCALE_LANGUAGE... | [
3,
5,
6,
8,
9
] |
<|reserved_special_token_0|>
def code(N):
code = []
for i in range(N - 4):
for j in range(49, 53):
if S[i][j] == '1':
code = S[i]
return code
def code_s(code):
for x in range(M - 1, 0, -1):
if code[x] == '1':
return code[x - 55:x + ... | flexible | {
"blob_id": "b739c1de6c008158ee3806bed9fa2865eb484b4f",
"index": 5596,
"step-1": "<mask token>\n\n\ndef code(N):\n code = []\n for i in range(N - 4):\n for j in range(49, 53):\n if S[i][j] == '1':\n code = S[i]\n return code\n\n\ndef code_s(code):\n for x ... | [
3,
4,
5,
6,
7
] |
import math
def solve():
a = int(input())
b = int(input())
return math.sqrt(a * a + b * b)
print(solve())
| normal | {
"blob_id": "a22d38f7e8122d6339d1beab3bf08fa41c36d61d",
"index": 9648,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef solve():\n a = int(input())\n b = int(input())\n return math.sqrt(a * a + b * b)\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef solve():\n a = int(input())\n... | [
0,
1,
2,
3
] |
import swipe
def scheduleMultipoint(driver):
driver.find_element_by_id('com.dentist.android:id/calendarBt').click()
driver.find_element_by_id('com.dentist.android:id/addIb').click()
def time(driver):#就诊时间
driver.find_element_by_id('com.dentist.android:id/cureHourLl').click()#就诊时间
drive... | normal | {
"blob_id": "02bc97b963b970993fc947cfa41c73230dd4d9e4",
"index": 2649,
"step-1": "<mask token>\n\n\ndef scheduleMultipoint(driver):\n driver.find_element_by_id('com.dentist.android:id/calendarBt').click()\n driver.find_element_by_id('com.dentist.android:id/addIb').click()\n\n\ndef time(driver):\n driver... | [
4,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
class StdIOFactory(Factory):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class StandardInput(LineReceiver, StandardIO):
"""
Reads stdin and writes every line received as a message to the
server. No fancy editing or anythin... | flexible | {
"blob_id": "532bcf8ae0ee40dc3eb4bd7170acfcb5d21cc4b9",
"index": 1984,
"step-1": "<mask token>\n\n\nclass StdIOFactory(Factory):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass StandardInput(LineReceiver, StandardIO):\n \"\"\"\n Reads stdin and writes every line received as a message to th... | [
7,
12,
13,
14,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@pytest.mark.parametrize(['inp1', 'inp2', 'res'], [('112', 1, '11'), (
'11000002000304', 4, '4'), ('9119801020', 6, '20'), ('111111', 3, '111'
), ('1432219', 3, '1219'), ('10200', 1, '200'), ('10', 2, '0'), ('10',
1... | flexible | {
"blob_id": "7eb4efb64a5a5b2e8c2dfa965411ff4c7aad6e35",
"index": 6525,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.mark.parametrize(['inp1', 'inp2', 'res'], [('112', 1, '11'), (\n '11000002000304', 4, '4'), ('9119801020', 6, '20'), ('111111', 3, '111'\n ), ('1432219', 3, '1219'), ('1... | [
0,
1,
2,
3
] |
import sys
sys.path.append("../")
import numpy as np
import tensorflow as tf
from utils import eval_accuracy_main_cdan
from models import mnist2mnistm_shared_discrepancy, mnist2mnistm_predictor_discrepancy
import keras
import argparse
import pickle as pkl
parser = argparse.ArgumentParser(description='Traini... | normal | {
"blob_id": "465d5baae8d5be77fbf3d550d10667da420a8fbe",
"index": 8608,
"step-1": "<mask token>\n\n\n@tf.function\ndef train_discrepancy_1(main_data, main_labels, target_data):\n with tf.GradientTape(persistent=True) as tape:\n shared_main = [shared[i](main_data, training=True) for i in range(\n ... | [
1,
3,
4,
5,
7
] |
from django.db import models
import os
from uuid import uuid4
class Card_profile(models.Model):
def path_and_rename(self, filename):
upload_to = 'uploads'
ext = filename.split('.')[-1]
filename = '{}.{}'.format(uuid4().hex, ext)
return os.path.join(upload_to, filename)
MALE ... | normal | {
"blob_id": "01153a695b4744465b706acb4c417217c5e3cefd",
"index": 3516,
"step-1": "<mask token>\n\n\nclass Card_profile(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>... | [
2,
3,
4,
5,
6
] |
import time
import numpy as np
import matplotlib.pyplot as plt
import cv2
import matplotlib.image as mpimg
import random
import skimage
import scipy
from PIL import Image
def readimg(dirs, imgname):
img = cv2.imread(dirs + imgname)
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
return img
def readimg_color(d... | normal | {
"blob_id": "e08ab06be0957e5e173df798742abc493eac84d0",
"index": 6006,
"step-1": "<mask token>\n\n\ndef readimg(dirs, imgname):\n img = cv2.imread(dirs + imgname)\n img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)\n return img\n\n\ndef readimg_color(dirs, imgname):\n img = cv2.imread(dirs + imgname)\n ... | [
9,
11,
14,
15,
16
] |
from launch import LaunchDescription
from launch_ros.actions import Node
import os
params = os.path.join('INSERT_PATH/src/beckhoff_ros', 'config', 'params.yaml')
def generate_launch_description():
return LaunchDescription([Node(package='beckhoff_ros', executable=
'beckhoff_ros_node', name='beckhoff_ros_no... | normal | {
"blob_id": "ae4f8eb71939ff212d05d12f65edeaecf66f2205",
"index": 4874,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef generate_launch_description():\n return LaunchDescription([Node(package='beckhoff_ros', executable=\n 'beckhoff_ros_node', name='beckhoff_ros_node', parameters=[params],... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
from . import chequeador_camion
from . import chequeador_camion_modelo
from . import chequeador_destino_tipo
from . import chequeador_destino
from . import chequeador_origen
from . import chequeador_minerales
| flexible | {
"blob_id": "bf7319996043a41b7d0ef4e6098c3609e5db101e",
"index": 9809,
"step-1": "<mask token>\n",
"step-2": "from . import chequeador_camion\nfrom . import chequeador_camion_modelo\nfrom . import chequeador_destino_tipo\nfrom . import chequeador_destino\nfrom . import chequeador_origen\nfrom . import chequead... | [
0,
1
] |
'''
手写识别系统
构建识别类
Recognize
调用getResult()函数即可
'''
import operator
from numpy import *
from PIL import Image
from os import listdir
from io import BytesIO
def classify(inX, dataSet, labels, k):
dataSetSize = dataSet.shape[0] #训练数据集的行数
# 计算距离
diffMat = tile(inX, (dataSetSize,1)) - dataSet
sqDiffMat = ... | normal | {
"blob_id": "1ab5147ed8ce808de9667052b6d17f320d62484f",
"index": 4694,
"step-1": "<mask token>\n\n\ndef classify(inX, dataSet, labels, k):\n dataSetSize = dataSet.shape[0]\n diffMat = tile(inX, (dataSetSize, 1)) - dataSet\n sqDiffMat = diffMat ** 2\n sqDistances = sqDiffMat.sum(axis=1)\n distances... | [
3,
5,
6,
7,
8
] |
def entete():
entete='''
<!DOCTYPE HTML>
<html lang=“fr”>
<head>
<title>AMAP'PATATE</title>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="/IENAC15/amapatate/css/font-awesome.min.css" />
<link rel="s... | normal | {
"blob_id": "933758002c5851a2655ed4c51b2bed0102165116",
"index": 4742,
"step-1": "def entete():\n entete = \"\"\"\n <!DOCTYPE HTML>\n<html lang=“fr”>\n <head>\n <title>AMAP'PATATE</title>\n <meta charset=\"UTF-8\" />\n <link rel=\"stylesheet... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def prefix_doubling_suffix_array(n):
n_len = len(n)
if n_len == 0:
return []
if n_len == 1:
return [0]
suffixes = []
for i in range(n_len):
suffixes.append((i, {}))
suffixes[i]... | flexible | {
"blob_id": "5a2106f5255493d2f6c8cb9e06a2666c8c55ed38",
"index": 3852,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef prefix_doubling_suffix_array(n):\n n_len = len(n)\n if n_len == 0:\n return []\n if n_len == 1:\n return [0]\n suffixes = []\n for i in range(n_len):\... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def mult(a, b):
if a > 9 or b > 9 or a < 1 or b < 1:
print(-1)
else:
print(a * b)
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def mult(a, b):
if a > 9... | flexible | {
"blob_id": "991fa5f9c83a1821e62f7baacbc56a4d31982312",
"index": 3681,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef mult(a, b):\n if a > 9 or b > 9 or a < 1 or b < 1:\n print(-1)\n else:\n print(a * b)\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef mult(a, b):\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class RouteForm(forms.ModelForm):
error_messages = {'duplicate_title':
'Please enter a unique name for the crawl'}
title = forms.CharField(max_length=128, help_text=
'Please enter the name of the Crawl')
views = forms.IntegerField(widget=forms.HiddenInput(), in... | flexible | {
"blob_id": "abf25cf3d4435754b916fa06e5e887b1e3589a1c",
"index": 5073,
"step-1": "<mask token>\n\n\nclass RouteForm(forms.ModelForm):\n error_messages = {'duplicate_title':\n 'Please enter a unique name for the crawl'}\n title = forms.CharField(max_length=128, help_text=\n 'Please enter the n... | [
6,
7,
8,
9,
10
] |
"""You are given a string .
Your task is to find out if the string contains:
alphanumeric characters, alphabetical characters, digits,
lowercase and uppercase characters."""
s = raw_input()
print(any(i.isalnum()for i in s))
print(any(i.isalpha()for i in s))
print(any(i.isdigit()for i in s))
print(any(i.islow... | normal | {
"blob_id": "f29fa3d796d9d403d6bf62cb28f5009501c55545",
"index": 3650,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(any(i.isalnum() for i in s))\nprint(any(i.isalpha() for i in s))\nprint(any(i.isdigit() for i in s))\nprint(any(i.islower() for i in s))\nprint(any(i.isupper() for i in s))\n<mask t... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test_detector():
detector = Detector(n_jobs=1)
assert detector['n_jobs'] == 1
assert type(detector) == Detector
inputFname = os.path.join(get_test_data_path(), 'input.jpg')
out = detector.detect_image(inp... | flexible | {
"blob_id": "753bdbf080e7a8652c39e40beeae51f74382d606",
"index": 1300,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_detector():\n detector = Detector(n_jobs=1)\n assert detector['n_jobs'] == 1\n assert type(detector) == Detector\n inputFname = os.path.join(get_test_data_path(),... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test_firmware_squashfs():
"""
Test: Open hello-world.srec, scan for signatures
verify that only one signature is returned
verify that the only signature returned is Motorola S-rec data-signature
"""
e... | flexible | {
"blob_id": "d55043c2a18b935478d9be442aaf7305231edc7d",
"index": 5828,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_firmware_squashfs():\n \"\"\"\n Test: Open hello-world.srec, scan for signatures\n verify that only one signature is returned\n verify that the only signature ret... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def create_tables(db_engine):
"""RUN SQL STATEMENTS TO CREATE TABLES"""
with db_engine.connect() as conn:
create_table_stmts = []
create_drugs_table = """
DROP TABLE IF EXISTS drugs CASCADE;
CREATE TABLE drugs (
drugbank_id char(7) PRIM... | flexible | {
"blob_id": "f4c3b6ee6389b31c6a280bf7cfe920a2791c1299",
"index": 4125,
"step-1": "<mask token>\n\n\ndef create_tables(db_engine):\n \"\"\"RUN SQL STATEMENTS TO CREATE TABLES\"\"\"\n with db_engine.connect() as conn:\n create_table_stmts = []\n create_drugs_table = \"\"\"\n DROP TABLE I... | [
1,
2,
3,
4,
5
] |
from django.apps import AppConfig
class NombreaplicacionConfig(AppConfig):
name = 'nombreAplicacion'
| normal | {
"blob_id": "0c7efa99dc22154f9835b277cba5057b213a28e7",
"index": 2414,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass NombreaplicacionConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass NombreaplicacionConfig(AppConfig):\n name = 'nombreAplicacion'\n",
"step-4": "... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
TMP = getenv('TMP', '/tmp')
PYBITES_FAKER_DIR = Path(getenv('PYBITES_FAKER_DIR', TMP))
CACHE_FILENAME = 'pybites-fake-data.pkl'
FAKE_DATA_CACHE = PYBITES_FAKER_DIR / CACHE_FILENAME
BITE_FEED = 'https://codechalleng.es/api/bites/'
... | flexible | {
"blob_id": "7336b8dec95d23cbcebbff2a813bbbd5575ba58f",
"index": 2327,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nTMP = getenv('TMP', '/tmp')\nPYBITES_FAKER_DIR = Path(getenv('PYBITES_FAKER_DIR', TMP))\nCACHE_FILENAME = 'pybites-fake-data.pkl'\nFAKE_DATA_CACHE = PYBITES_FAKER_DIR / CACHE_FILENAME\nBI... | [
0,
1,
2,
3
] |
#!/usr/bin/env python3
import subprocess
import sys
import pickle
if len(sys.argv) != 3:
print('Usage: std_dev_eval.py <std_dir> <ans>')
quit()
std_dir=sys.argv[1]
std_ans=sys.argv[2]
subprocess.call('rm -f {}/result'.format(std_dir), shell=True)
op_f = open('{}/jobs'.format(std_dir), 'w')
command = 'utils... | normal | {
"blob_id": "ba216642935d19b85e379b66fb514854ebcdedd9",
"index": 666,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif len(sys.argv) != 3:\n print('Usage: std_dev_eval.py <std_dir> <ans>')\n quit()\n<mask token>\nsubprocess.call('rm -f {}/result'.format(std_dir), shell=True)\n<mask token>\nwith op... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with tf.Session() as sess:
sess.run(init_op)
print(sess.run(state))
for _ in range(10):
sess.run(new_value)
print(sess.run(new_value))
<|reserved_special_token_1|>
<|reserved_special_token_0|>
state ... | flexible | {
"blob_id": "cf4582f4d0c6c94e617270a45425fe0b770142e0",
"index": 2937,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith tf.Session() as sess:\n sess.run(init_op)\n print(sess.run(state))\n for _ in range(10):\n sess.run(new_value)\n print(sess.run(new_value))\n",
"step-3": "<m... | [
0,
1,
2,
3,
4
] |
# Problem 20: Factorial digit sum
def factorial(num):
sum = 1
while num != 0:
sum *= num
num -= 1
return sum
def sum_digits(num):
sum = 0
while num != 0:
sum += num % 10
num //= 10
return sum
print(sum_digits(factorial(100))) | normal | {
"blob_id": "cc6f02f9e1633fa15b97af5f926e083a65a8336e",
"index": 5977,
"step-1": "<mask token>\n",
"step-2": "def factorial(num):\n sum = 1\n while num != 0:\n sum *= num\n num -= 1\n return sum\n\n\n<mask token>\n",
"step-3": "def factorial(num):\n sum = 1\n while num != 0:\n ... | [
0,
1,
2,
3,
4
] |
print("HELLO3")
| normal | {
"blob_id": "74be250df785590ecf45e048b0d6189e2b445889",
"index": 2181,
"step-1": "<mask token>\n",
"step-2": "print('HELLO3')\n",
"step-3": "print(\"HELLO3\")\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
# coding: utf-8
from sqlalchemy import Column, DateTime, Integer, String
from sqlalchemy.schema import FetchedValue
from application import db
class BmExam(db.Model):
__tablename__ = 'bm_exam'
id = db.Column(db.Integer, primary_key=True)
status = db.Column(db.Integer, nullable=False, server_default=db.Fe... | normal | {
"blob_id": "6be2cc99d03596715d76cda41d63b8c91c829498",
"index": 2211,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass BmExam(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask toke... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class ModelIncrStateFlattener(BaseIncrStateFlattener):
<|reserved_special_token_0|>
def reorder_decoder_incremental_state(self, flat_incr_state: Dict[str,
torch.Tensor], inds: torch.Tensor) ->Dict[str, torch.Tensor]:
structured_incr_state = self._unflatten_incr_st... | flexible | {
"blob_id": "27d5ff5b0253eea36d6b492e929c4220f4b4a5eb",
"index": 1564,
"step-1": "<mask token>\n\n\nclass ModelIncrStateFlattener(BaseIncrStateFlattener):\n <mask token>\n\n def reorder_decoder_incremental_state(self, flat_incr_state: Dict[str,\n torch.Tensor], inds: torch.Tensor) ->Dict[str, torch.... | [
24,
31,
32,
36,
43
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "a1db566f4da16e7725212aeab29e946ef7c1672e",
"index": 5610,
"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 = [('home_applic... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class MVAN(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def _setup_training(self):
if self.hparams.save_dirpath == 'checkpoints/':
self.save_dirpath = os.path.join(self.hparams.root_dir, self.
... | flexible | {
"blob_id": "4d1900c1a0a8d7639e0ec16fb0128fd8efc2e8a1",
"index": 9913,
"step-1": "<mask token>\n\n\nclass MVAN(object):\n <mask token>\n <mask token>\n <mask token>\n\n def _setup_training(self):\n if self.hparams.save_dirpath == 'checkpoints/':\n self.save_dirpath = os.path.join(se... | [
4,
6,
7,
8,
10
] |
from .base import GnuRecipe
class CAresRecipe(GnuRecipe):
def __init__(self, *args, **kwargs):
super(CAresRecipe, self).__init__(*args, **kwargs)
self.sha256 = '45d3c1fd29263ceec2afc8ff9cd06d5f' \
'8f889636eb4e80ce3cc7f0eaf7aadc6e'
self.name = 'c-ares'
self.ve... | normal | {
"blob_id": "bf7676dc2c47d9cd2f1ce2d436202ae2c5061265",
"index": 8634,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass CAresRecipe(GnuRecipe):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass CAresRecipe(GnuRecipe):\n\n def __init__(self, *args, **kwargs):\n super(CAresRecipe... | [
0,
1,
2,
3,
4
] |
import calendar
import json
from datetime import datetime
from datapoller.download import download
from datapoller.settings import *
from messaging.Messaging import sendMessage
from messaging.settings import RABBIT_NOTIFY_QUEUE
from sessioncontroller.utils import is_level_interesting_for_kp
__author__ = 'arik'
shared... | normal | {
"blob_id": "e8f090a02bfd5ee8a6832351357594af2d6692f9",
"index": 8702,
"step-1": "<mask token>\n\n\ndef registerModelStorage(dict):\n global sharedDict\n sharedDict = dict\n\n\ndef updateModel():\n lastLevels, validTime = download(NOWCAST_DATA_URL)\n sharedDict['lastLevels'] = lastLevels\n sharedD... | [
3,
4,
5,
6,
8
] |
<|reserved_special_token_0|>
def mat_line(speed_time_info, interface, direction, last_time):
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111)
import matplotlib.dates as mdate
ax.xaxis.set_major_formatter(mdate.DateFormatter('%H:%M:%S'))
import matplotlib.ticker as mtick
ax.yaxis.set_... | flexible | {
"blob_id": "0aa419b0045914b066fbec457c918d83276f2583",
"index": 3556,
"step-1": "<mask token>\n\n\ndef mat_line(speed_time_info, interface, direction, last_time):\n fig = plt.figure(figsize=(6, 6))\n ax = fig.add_subplot(111)\n import matplotlib.dates as mdate\n ax.xaxis.set_major_formatter(mdate.Da... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class DecompFactors(object):
<|reserved_special_token_0|>
def __init__(self, control, params, state, fluxes, met_data):
"""
Parameters
----------
control : integers, structure
model control flags
params: floats, structure
... | flexible | {
"blob_id": "74f3b4001a0520a25a314ff537719b679ba0fca4",
"index": 2578,
"step-1": "<mask token>\n\n\nclass DecompFactors(object):\n <mask token>\n\n def __init__(self, control, params, state, fluxes, met_data):\n \"\"\"\n Parameters\n ----------\n control : integers, structure\n ... | [
2,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def finite_automate(word: str) ->str:
"""Реализация конечного автомата для проверки символьных строк"""
state: str = INITIAL_STATE
for ind, char in enumerate(word):
yield f'{word[ind:]} --> {state}'
state = RULE.get((state, char))
if not state:
... | flexible | {
"blob_id": "86ea1c46383b5a8790eb187163107f4100395ef3",
"index": 8962,
"step-1": "<mask token>\n\n\ndef finite_automate(word: str) ->str:\n \"\"\"Реализация конечного автомата для проверки символьных строк\"\"\"\n state: str = INITIAL_STATE\n for ind, char in enumerate(word):\n yield f'{word[ind:... | [
2,
3,
4,
5,
6
] |
from django.urls import path
from django.views.decorators.csrf import csrf_exempt
from .views import TestView, index, setup_fraud_detection, verify_testing_works
urlpatterns = [
path('test/<str:name>/', index, name='index'),
path('ml/setup/', setup_fraud_detection, name='fraud_detection_setup'),
path('ml/... | normal | {
"blob_id": "263347d1d445643f9c84e36a8cbb5304581ebaf6",
"index": 3888,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('test/<str:name>/', index, name='index'), path(\n 'ml/setup/', setup_fraud_detection, name='fraud_detection_setup'), path\n ('ml/verify/', verify_testing_works, ... | [
0,
1,
2,
3
] |
# coding=utf-8
# Copyright 2019 SK T-Brain Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | normal | {
"blob_id": "b6e4214ace89165f6cfde9f2b97fcee8be81f2ed",
"index": 4301,
"step-1": "<mask token>\n\n\ndef get_onnx_kobert_model(cachedir='.cache'):\n \"\"\"Get KoBERT ONNX file path after downloading\"\"\"\n onnx_kobert = {'url':\n 's3://skt-lsl-nlp-model/KoBERT/models/kobert.onnx1.8.0.onnx',\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class VisitaSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Visita
fields = 'id', 'usuario', 'lugar', 'fecha_visita', 'hora_visita'
<|reserved_special_token_1|>
from rest_framewor... | flexible | {
"blob_id": "72bbd100a37a86dec7684257f2bec85d7367c009",
"index": 5810,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass VisitaSerializer(serializers.HyperlinkedModelSerializer):\n\n\n class Meta:\n model = Visita\n fields = 'id', 'usuario', 'lugar', 'fecha_visita', 'hora_visita'\... | [
0,
1,
2,
3
] |
from os import read
from cryptography.fernet import Fernet
#create a key
# key = Fernet.generate_key()
#When every we run this code we will create a new key
# with open('mykey.key','wb') as mykey:
# mykey.write(key)
#To avoid create a new key and reuse the same key
with open('mykey.key','rb') as myk... | normal | {
"blob_id": "df828344b81a40b7101adcc6759780ea84f2c6b4",
"index": 4698,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('mykey.key', 'rb') as mykey:\n key = mykey.read()\n<mask token>\nwith open('encryptedpassword.txt', 'rb') as encrypted_password_file:\n encrypte_file = encrypted_password_... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def get_data():
df = pd.read_csv('./data/filteredCorpus.csv')
df_filt = df[df['outcome'] == True]
df_filt = df_filt[df_filt['role'] == 'speaker']
df_filt = df_filt[df_filt['source'] == 'human']
utt = df_filt['contents']
utt_filt = [u.lower() for u in utt if len(u.s... | flexible | {
"blob_id": "613b060ee50b49417342cfa70b36f77d112dcc58",
"index": 2951,
"step-1": "<mask token>\n\n\ndef get_data():\n df = pd.read_csv('./data/filteredCorpus.csv')\n df_filt = df[df['outcome'] == True]\n df_filt = df_filt[df_filt['role'] == 'speaker']\n df_filt = df_filt[df_filt['source'] == 'human']... | [
4,
5,
6,
7,
8
] |
"""Visit module to add odoo checks
"""
import os
import re
import astroid
import isort
from pylint.checkers import utils
from six import string_types
from .. import misc, settings
ODOO_MSGS = {
# C->convention R->refactor W->warning E->error F->fatal
# Visit odoo module with settings.BASE_OMODULE_ID
'C... | normal | {
"blob_id": "9f34f94422f4847859e9111f34ade2e1274cb543",
"index": 8775,
"step-1": "<mask token>\n\n\nclass ModuleChecker(misc.WrapperModuleChecker):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @utils.check_messages('consider-merging-classes-inherited')\n def... | [
24,
28,
33,
42,
46
] |
<|reserved_special_token_0|>
def create_players(num):
players_list = []
for i in range(num):
name = input(f'Player {i + 1}, what is your name? ')
while name == '':
name = input('Please enter your name: ')
players_list.append(people.Player(name, 1000))
print(
'\n... | flexible | {
"blob_id": "a7050ebd545c4169b481672aed140af610aea997",
"index": 4879,
"step-1": "<mask token>\n\n\ndef create_players(num):\n players_list = []\n for i in range(num):\n name = input(f'Player {i + 1}, what is your name? ')\n while name == '':\n name = input('Please enter your name:... | [
7,
19,
20,
21,
22
] |
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 21 15:09:26 2017
@author: Jieun
"""
from scipy.stats import invgauss
from scipy.stats import norm
# rv = invgauss.ppf(0.95,mu)
# a = 8/(2*rv)
# print a
# norm.ppf uses mean = 0 and stddev = 1, which is the "standard" normal distribution
# can use a different mean and s... | normal | {
"blob_id": "c9e0586942430fcd5b81c5716a06a4eef2c2f203",
"index": 3178,
"step-1": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Feb 21 15:09:26 2017\n\n@author: Jieun\n\"\"\"\n\nfrom scipy.stats import invgauss\nfrom scipy.stats import norm\n\n# rv = invgauss.ppf(0.95,mu) \n# a = 8/(2*rv)\n# print a\n# norm.pp... | [
0
] |
import pandas as pd
import os
"""
This code relies heavily on the form of the data. Namely it will fail if
the authors of the same book are not comma separated. It will also be inaccurate
or even fail if the same author for different books is not spelt in exactly the
same way.
"""
loc = r'C:\Users\james\OneDrive\Do... | normal | {
"blob_id": "f57490c8f4a5ba76824c3b41eb18905eb2213c23",
"index": 5107,
"step-1": "<mask token>\n\n\ndef split(string):\n \"\"\"\n Function takes input of a string and returns an array of strings\n the original string should be comma separated with a space after\n the comma in order for this function ... | [
1,
2,
3,
4,
5
] |
# Ejercicio 1
print('Pepito')
print('Cumpleaños: 22 de enero')
edad = 42
print('Tengo', edad, 'años')
cantante = 'Suzanne Vega'
comida = 'rúcula'
ciudad = 'Barcelona'
print('Me gusta la música de', cantante)
print('Me gusta cenar', comida)
print('Vivo en', ciudad) | normal | {
"blob_id": "f26c624e8ae9711eb835e223407256e60dfc6d6e",
"index": 8945,
"step-1": "<mask token>\n",
"step-2": "print('Pepito')\nprint('Cumpleaños: 22 de enero')\n<mask token>\nprint('Tengo', edad, 'años')\n<mask token>\nprint('Me gusta la música de', cantante)\nprint('Me gusta cenar', comida)\nprint('Vivo en', ... | [
0,
1,
2,
3
] |
import requests, csv, configuration
headers = {'Authorization': f'Bearer {configuration.CARRIERX_API_TOKEN}'}
url = f'{configuration.BASE_CARRIERX_API_URL}/core/v2/calls/call_drs'
date = configuration.DATE
i = 1
params = {'limit': '1', 'order': 'date_stop asc', 'filter':
f'date_stop ge {date}'}
r = requests.get(url... | normal | {
"blob_id": "8262d8b5bbb156eccae021c1c9333d3cd1a6260f",
"index": 9030,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif len(dr_items):\n with open('calls.csv', 'w', encoding='UTF8') as csv_file:\n csv_writer = csv.writer(csv_file)\n csv_header = ['dr_sid', 'date_start', 'number_src', 'n... | [
0,
1,
2,
3
] |
import unittest
from month import Month
class MonthUnitTests(unittest.TestCase):
def test_header(self):
cal = Month(5, 2012)
result = cal.header()
self.assertEqual(" May 2012", result)
def test_header_different_month(self):
cal = Month(3, 2012)
result = cal.header()
self.assertEqual(" March 20... | normal | {
"blob_id": "36c1d75171d772138b820651e11a3a7bc3a6521c",
"index": 8226,
"step-1": "<mask token>\n\n\nclass MonthUnitTests(unittest.TestCase):\n\n def test_header(self):\n cal = Month(5, 2012)\n result = cal.header()\n self.assertEqual(' May 2012', result)\n\n def test_header_differ... | [
13,
14,
15,
16,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class RequiredEntry(ValidatedMixin, ttk.Entry):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class RequiredEntry(ValidatedMixin, ttk.Entry):
def _focusout_validate(self, ev... | flexible | {
"blob_id": "59047a113d76c64be48858258441fae5da505790",
"index": 5792,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass RequiredEntry(ValidatedMixin, ttk.Entry):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass RequiredEntry(ValidatedMixin, ttk.Entry):\n\n def _focusout_validate(self... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
def twoSum(self, numbers, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
... | flexible | {
"blob_id": "51b3beee8659bccee0fbb64b80fdce18b693674b",
"index": 9481,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n",
"step-3": "class Solution(object):\n\n def twoSum(self, numbers, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n ... | [
0,
1,
2,
3
] |
#!/usr/bin/python3
################################################################################
# Usefull functions to shorten some of my plotting routine #####################
################################################################################
import matplotlib.pyplot as plt
import seaborn as sns
i... | normal | {
"blob_id": "b935c48210b1965ebb0de78384f279b71fc17d5d",
"index": 7044,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef set_sns_standard(context='paper', font_scale=1.4, linewidth=1.5, font=\n 'serif'):\n rc_params = {'lines.linewidth': linewidth, 'text.usetex': True}\n sns.set(style='tick... | [
0,
2,
3,
4,
5
] |
#This is just a test
print("this is something new")
for a in range(10):
print(sum(a))
print("the loop worked")
| normal | {
"blob_id": "df317e914073f5b236f73b616b87f86ae378ef38",
"index": 8755,
"step-1": "<mask token>\n",
"step-2": "print('this is something new')\nfor a in range(10):\n print(sum(a))\nprint('the loop worked')\n",
"step-3": "#This is just a test\nprint(\"this is something new\")\nfor a in range(10):\n print(su... | [
0,
1,
2
] |
def play():
print("playing tank games...")
print("runing tank now!!!") | normal | {
"blob_id": "8c7fe90972feec19e280d3bccd39391af666608a",
"index": 9410,
"step-1": "<mask token>\n",
"step-2": "def play():\n print('playing tank games...')\n\n\n<mask token>\n",
"step-3": "def play():\n print('playing tank games...')\n\n\nprint('runing tank now!!!')\n",
"step-4": "def play():\n pri... | [
0,
1,
2,
3
] |
print((9*int(input())/5)+32) | normal | {
"blob_id": "4e9a968842c2b3eca79690f0b56c8e176b203138",
"index": 362,
"step-1": "<mask token>\n",
"step-2": "print(9 * int(input()) / 5 + 32)\n",
"step-3": "print((9*int(input())/5)+32)",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
<|reserved_special_token_0|>
class RSIStrategy(bt.Strategy):
def __init__(self):
self.order = None
self.position.size = 0
self.sellAlert1 = False
self.sellAlert2 = False
self.buyAlert = False
self.failureNum = 0
self.successNum = 0
self.rsi_1 = bt.i... | flexible | {
"blob_id": "9119fc1c75de980bbcf74f1e06a36ba587fc490b",
"index": 102,
"step-1": "<mask token>\n\n\nclass RSIStrategy(bt.Strategy):\n\n def __init__(self):\n self.order = None\n self.position.size = 0\n self.sellAlert1 = False\n self.sellAlert2 = False\n self.buyAlert = False... | [
3,
4,
5,
6,
7
] |
import simple_draw as sd
import random
# sd.resolution = (1400, 900)
# Prepare data for the sun function
def sun_prepare(xpoint, ypoint, radius, color, angle):
delta_list = []
radius_list = []
for delta in range(0, 360, angle):
delta_list.append(delta)
radius_list.append(random.randint(ra... | normal | {
"blob_id": "46babde9c26a944c9d29121b6bbf89a32f242a81",
"index": 251,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef sun_prepare(xpoint, ypoint, radius, color, angle):\n delta_list = []\n radius_list = []\n for delta in range(0, 360, angle):\n delta_list.append(delta)\n rad... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class DefaultStorageTesting(unittest.TestCase):
def setUp(self):
gludb.config.default_database(gludb.config.Database('sqlite',
filename=':memory:'))
SimpleStorage.ensure_table()
def tearDown(self):
gludb.config.clear_database_config()
<|re... | flexible | {
"blob_id": "7383ae97d6a1368896d05d0cafc9846c24004701",
"index": 2690,
"step-1": "<mask token>\n\n\nclass DefaultStorageTesting(unittest.TestCase):\n\n def setUp(self):\n gludb.config.default_database(gludb.config.Database('sqlite',\n filename=':memory:'))\n SimpleStorage.ensure_table... | [
16,
21,
24,
25,
28
] |
<|reserved_special_token_0|>
@app.route('/')
def redirect_to_swagger():
return redirect('/swagger', 302)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open(path / '../schemas.json', 'r') as fp:
schemas = load(fp)
with open(path / '../config.json', 'r') as fp:
config = load(fp)
<|reserv... | flexible | {
"blob_id": "631904ae96584bd19756f9335175a419397ac252",
"index": 8562,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef redirect_to_swagger():\n return redirect('/swagger', 302)\n",
"step-2": "<mask token>\nwith open(path / '../schemas.json', 'r') as fp:\n schemas = load(fp)\nwith open(path / '../config... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def button_add():
global first_num
global math
math = 'addition'
first_num = e.get()
e.delete(0, END)
<|reserved_special_token_0|>
def button_sub():
global first_num
global math
math = 'subtraction'
first_num = e.get()
e.delete(0, END)
def but... | flexible | {
"blob_id": "59a75f78c7a146dcf55d43be90f71abce2bcf753",
"index": 4934,
"step-1": "<mask token>\n\n\ndef button_add():\n global first_num\n global math\n math = 'addition'\n first_num = e.get()\n e.delete(0, END)\n\n\n<mask token>\n\n\ndef button_sub():\n global first_num\n global math\n m... | [
4,
5,
6,
7,
11
] |
<|reserved_special_token_0|>
def redo(text: str, aword: str, subs: list) ->str:
""" заменятель """
return re.sub(f'(\\W){aword}(\\W)', '\\1' + random.choice(subs) + '\\2',
' ' + text + ' ').strip()
def test1():
""" тестировщик """
w = 'we'
s = ['they', 'he', 'she']
print(w, '->', s, ... | flexible | {
"blob_id": "d1a179acfda9e76a11f362671fafb50773e2b9d3",
"index": 9405,
"step-1": "<mask token>\n\n\ndef redo(text: str, aword: str, subs: list) ->str:\n \"\"\" заменятель \"\"\"\n return re.sub(f'(\\\\W){aword}(\\\\W)', '\\\\1' + random.choice(subs) + '\\\\2',\n ' ' + text + ' ').strip()\n\n\ndef te... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [path('', views.home, name='home'), path('category/', include
('api.category.urls')), path('product/', include('api.product.urls')),
path('user/', include('api.user.urls')), path('order/', include(
'api.o... | flexible | {
"blob_id": "fe12f6d3408ab115c5c440c5b45a9014cfee6539",
"index": 564,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', views.home, name='home'), path('category/', include\n ('api.category.urls')), path('product/', include('api.product.urls')),\n path('user/', include('api.user... | [
0,
1,
2,
3
] |
staff = ['инженер-конструктор Игорь', 'главный бухгалтер МАРИНА',
'токарь высшего разряда нИКОЛАй', 'директор аэлита']
def employee_name(name):
getting_a_name = name.split()
name_staff = getting_a_name[-1]
name_staff = name_staff.capitalize()
return name_staff
i = 0
while i < len(staff):
nam... | normal | {
"blob_id": "4c4275b96d3eceb5ff89a746c68d7f8736a1c2a5",
"index": 8561,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef employee_name(name):\n getting_a_name = name.split()\n name_staff = getting_a_name[-1]\n name_staff = name_staff.capitalize()\n return name_staff\n\n\n<mask token>\n",... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
property_viewed = django.dispatch.Signal(providing_args=['property', 'user',
'request', 'response'])
<|reserved_special_token_1|>
import django.dispatch
property_viewed = django.dispatch.Signal(providing_args=['property', '... | flexible | {
"blob_id": "00099cab0c816c76fc0fa94d7905175feb6919cf",
"index": 9795,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nproperty_viewed = django.dispatch.Signal(providing_args=['property', 'user',\n 'request', 'response'])\n",
"step-3": "import django.dispatch\nproperty_viewed = django.dispatch.Signal... | [
0,
1,
2,
3
] |
class Rover(object):
DIRECTIONS = 'NESW'
MOVEMENTS = {
'N': (0, 1),
'E': (1, 0),
'S': (0, -1),
'W': (-1, 0)
}
def __init__(self, init_string, plateau_dimensions):
'''
give the rover a sense of the plateau it's on
'''
max_x, max_y = p... | normal | {
"blob_id": "1f49d2341f0bcc712baede28f41c208a01b92e6d",
"index": 2998,
"step-1": "class Rover(object):\n\n DIRECTIONS = 'NESW'\n MOVEMENTS = {\n 'N': (0, 1),\n 'E': (1, 0),\n 'S': (0, -1),\n 'W': (-1, 0)\n }\n\n def __init__(self, init_string, plateau_dimensions):\n ... | [
0
] |
import os, sys, time, random, subprocess
def load_userdata(wallet, pool, ww, logger, adminka):
with open("D:\\msys64\\xmrig-master\\src\\ex.cpp", "r") as f:
file = f.read()
file = file.replace("%u%", wallet)
file = file.replace("%p%", pool)
file = file.replace("%w%", ww)
wi... | normal | {
"blob_id": "d1254e558217cce88de2f83b87d5c54333f1c677",
"index": 9938,
"step-1": "<mask token>\n\n\ndef load_userdata(wallet, pool, ww, logger, adminka):\n with open('D:\\\\msys64\\\\xmrig-master\\\\src\\\\ex.cpp', 'r') as f:\n file = f.read()\n file = file.replace('%u%', wallet)\n file =... | [
6,
7,
8,
9,
11
] |
# 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
] |
import math
class Point:
def __init__(self, x: int, y: int):
self.x = x
self.y = y
def create_point(self):
point = [self.x, self.y]
return point
@staticmethod
def calculate_distance(point_1: [], point_2: []):
side_a = abs(point_1.x - point_2.x)
side_b... | normal | {
"blob_id": "cda7595e46528739cad49a5d62a80bc7b2087157",
"index": 1911,
"step-1": "<mask token>\n\n\nclass Point:\n\n def __init__(self, x: int, y: int):\n self.x = x\n self.y = y\n\n def create_point(self):\n point = [self.x, self.y]\n return point\n\n @staticmethod\n def ... | [
4,
5,
6,
7
] |
#!/usr/bin/python3
experiment_name = "nodes10"
wall = "wall2"
wall_image = "irati_110"
mr_dif_policy = True
spn_dif_policy = True
destination_ip = "2001:40b0:7500:286:84:88:81:57"
| normal | {
"blob_id": "78db25586f742b0a20bc3fad382b0d4f1a271841",
"index": 3970,
"step-1": "<mask token>\n",
"step-2": "experiment_name = 'nodes10'\nwall = 'wall2'\nwall_image = 'irati_110'\nmr_dif_policy = True\nspn_dif_policy = True\ndestination_ip = '2001:40b0:7500:286:84:88:81:57'\n",
"step-3": "#!/usr/bin/python3... | [
0,
1,
2
] |
speed, lic_plate = input().split()
salary = int(0)
while lic_plate != "A999AA":
if int(speed) > 60:
if lic_plate[1] == lic_plate[2] and lic_plate [2] == lic_plate[3]:
salary += 1000
elif lic_plate[1] == lic_plate[2] or lic_plate [1] == lic_plate[3]:
salary += 500
elif... | normal | {
"blob_id": "ff8ffeb418bf4f9bc7d5dadd126ebc7c34c5c2cd",
"index": 4454,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile lic_plate != 'A999AA':\n if int(speed) > 60:\n if lic_plate[1] == lic_plate[2] and lic_plate[2] == lic_plate[3]:\n salary += 1000\n elif lic_plate[1] == ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class CleanCommand(commands.Command):
<|reserved_special_token_0|>
def __init__(self):
super().__init__('clean', 'Clean up Pavilion working directory.',
short_help='Clean up Pavilion working diretory.')
def _setup_arguments(self, parser):
parser.a... | flexible | {
"blob_id": "18aafb71d7e6f5caa2f282126c31eb052c08ad3c",
"index": 4307,
"step-1": "<mask token>\n\n\nclass CleanCommand(commands.Command):\n <mask token>\n\n def __init__(self):\n super().__init__('clean', 'Clean up Pavilion working directory.',\n short_help='Clean up Pavilion working dire... | [
4,
5,
6,
7,
8
] |
import torch
import numpy as np
import cv2
import torchvision
from PIL import Image
def people_on_image(path_to_image):
color_map = [
(255, 255, 255), # background
(255, 255, 255), # aeroplane
(255, 255, 255), # bicycle
(255, 255, 255), ... | normal | {
"blob_id": "2193c97b7f1fcf204007c2528ecc47cbf3c67e81",
"index": 9992,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef people_on_image(path_to_image):\n color_map = [(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, \n 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255), ... | [
0,
1,
2,
3
] |
import serial
import time
from Files_management import get_mov_parameters,change_mov_parameters
#-------------------------------------------------------------------------------
def create_port():
port = get_mov_parameters()[1]
try:
ser = serial.Serial(port=port,baudrate=9600,timeout=1)
return s... | normal | {
"blob_id": "72cda573bf9c744213a2957d51171f437f211353",
"index": 3467,
"step-1": "<mask token>\n\n\ndef send_value(value):\n port = create_port()\n status = get_mov_parameters()[0]\n if port_status(port):\n if status == '1' or status == 'True':\n string = ''.join([str(value), ' \\n'])\... | [
1,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
def func3(a, b):
return
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def func1(a):
print(f'这是有参数的打印:{a}')
<|reserved_special_token_0|>
def func2(a, b):
return a + b
<|reserved_special_token_0|>
def func3(a, b):
retur... | flexible | {
"blob_id": "be892250c31198e801836dba24fa8218dd50e811",
"index": 1178,
"step-1": "<mask token>\n\n\ndef func3(a, b):\n return\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef func1(a):\n print(f'这是有参数的打印:{a}')\n\n\n<mask token>\n\n\ndef func2(a, b):\n return a + b\n\n\n<mask token>\n\n\ndef func... | [
1,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(11):
print(n, ' X ', i, ' = ', n * i)
<|reserved_special_token_1|>
n = int(input('please enter the number : '))
for i in range(11):
print(n, ' X ', i, ' = ', n * i)
<|reserved_special_token_1|>
n=int(... | flexible | {
"blob_id": "ea4a55ed17c5cc2c6f127112af636ca885159c86",
"index": 5768,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(11):\n print(n, ' X ', i, ' = ', n * i)\n",
"step-3": "n = int(input('please enter the number : '))\nfor i in range(11):\n print(n, ' X ', i, ' = ', n * i)\n",
"... | [
0,
1,
2,
3
] |
import time #melakukan import library time
import zmq #melakukan import library ZeroMQ
context = zmq.Context() #melakukan inisialisasi context ZeroMQ pada variable context
socket = context.socket(zmq.REP) #menginisialisasikan socket(Reply) pada variable context(ZeroMQ)
socket.bind("tcp://10.20.32.221:5555") #melakuka... | normal | {
"blob_id": "ccba923fa4b07ca9c87c57797e1e6c7da3a71183",
"index": 4315,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsocket.bind('tcp://10.20.32.221:5555')\nwhile True:\n message = socket.recv()\n print('Received request: %s' % message)\n time.sleep(1)\n socket.send(b'World')\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class MathBlockLexer(mistune.BlockLexer):
<|reserved_special_token_0|>
def __init__(self, rules=None, **kwargs):
if rules is None:
rules = MathBlockGrammar()
super(MathBlockLexer, self).__init__(rules, **kwargs)
def parse_block_math(self, m):
... | flexible | {
"blob_id": "a6c45ab3df0a692cd625d8203e1152e942a4cd6c",
"index": 5908,
"step-1": "<mask token>\n\n\nclass MathBlockLexer(mistune.BlockLexer):\n <mask token>\n\n def __init__(self, rules=None, **kwargs):\n if rules is None:\n rules = MathBlockGrammar()\n super(MathBlockLexer, self).... | [
15,
17,
19,
24,
25
] |
import numpy as np
class Constants():
DNN_DEFAULT_ACTIVATION = 'relu'
DNN_DEFAULT_KERNEL_REGULARIZATION = [0, 5e-5]
DNN_DEFAULT_BIAS_REGULARIZATION = [0, 5e-5]
DNN_DEFAULT_LOSS = 'mean_squared_error'
DNN_DEFAULT_VALIDATION_SPLIT = 0.2
DNN_DEFAULT_EPOCHS = 100
DNN_DEFAULT_CHECKPOINT_PERIOD =... | normal | {
"blob_id": "b2bb7393bf7955f5de30c59364b495b8f888e178",
"index": 4073,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Constants:\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 ... | [
0,
1,
2,
3,
4
] |
from django.shortcuts import render, redirect
from datetime import datetime
from fichefrais.models import FicheFrais, Etat, LigneFraisForfait, LigneFraisHorsForfait, Forfait
def home_admin(request):
"""
:view home_admin: Menu principale des Administrateurs
:template home_admin.html:
"""
if not re... | normal | {
"blob_id": "b453c8e9cc50066d1b5811493a89de384a000f37",
"index": 4929,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef home_admin(request):\n \"\"\"\n :view home_admin: Menu principale des Administrateurs\n :template home_admin.html:\n \"\"\"\n if not request.user.is_authenticated()... | [
0,
1,
2,
3
] |
{
"targets": [
{
"target_name": "force-layout",
"sources": [ "src/main.cc", "src/layout.cc", "src/quadTree.cc" ],
'conditions': [
['OS=="win"', {
'cflags': [
'/WX', "/std:latest", "/m"
],
}, { # OS != "win"
'cflags': [
... | normal | {
"blob_id": "0f916a1f638bf149f6992355cf8f33f74bc9bdb1",
"index": 8439,
"step-1": "<mask token>\n",
"step-2": "{'targets': [{'target_name': 'force-layout', 'sources': ['src/main.cc',\n 'src/layout.cc', 'src/quadTree.cc'], 'conditions': [['OS==\"win\"', {\n 'cflags': ['/WX', '/std:latest', '/m']}, {'cflags... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
try:
fh = open('testfile.txt', 'w')
fh.write('This is my test file for exception handling! !')
except IOError:
print("Error: can't find file or read data")
else:
print('written content in the file successfully')
... | flexible | {
"blob_id": "c5b40b373953a2375eeca453a65c49bdbb8715f1",
"index": 6586,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n fh = open('testfile.txt', 'w')\n fh.write('This is my test file for exception handling! !')\nexcept IOError:\n print(\"Error: can't find file or read data\")\nelse:\n p... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class BasketPageLocators:
BASKET_STATUS = By.CSS_SELECTOR, '#content_inner'
NAME_OF_ADDED_SHIPMENT = (By.CSS_SELECTOR,
'#messages .alert:nth-child(1) > .alertinner strong')
PRICE_OF_ADDED_SHIPMENT = (By.CSS_SELECTOR,
'#messages .alert:nth-child(3) > .alertinner... | flexible | {
"blob_id": "5d3b9005b8924da36a5885201339aa41082034cd",
"index": 8692,
"step-1": "<mask token>\n\n\nclass BasketPageLocators:\n BASKET_STATUS = By.CSS_SELECTOR, '#content_inner'\n NAME_OF_ADDED_SHIPMENT = (By.CSS_SELECTOR,\n '#messages .alert:nth-child(1) > .alertinner strong')\n PRICE_OF_ADDED_S... | [
4,
5,
6,
8,
10
] |
<|reserved_special_token_0|>
@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_parser(start='vector')
assert parser.parse(expression) == result
<|reserved_special_token_0|>
@pyte... | flexible | {
"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
] |
<|reserved_special_token_0|>
def embed_last_token(text):
result = bc.encode(text, show_tokens=True)
batch = []
for sent, tensor, tokens in zip(text, result[0], result[1]):
valid = []
tid = 0
buffer = ''
words = sent.lower().split()
for i, t in enumerate(tokens):
... | flexible | {
"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.shortcuts import *
from shop.models import *
from django.db import transaction
from django.core.exceptions import *
@transaction.atomic
def computers(request):
ctx = {}
computer = Computer.objects.all()
ctx['brand'] = Brand.objects.all()
if request.method == 'POST':
if request.POST['computer_i... | normal | {
"blob_id": "18689741a33e6d17e694ee0619a1f36d8d178cbb",
"index": 3223,
"step-1": "<mask token>\n\n\n@transaction.atomic\ndef computers(request):\n ctx = {}\n computer = Computer.objects.all()\n ctx['brand'] = Brand.objects.all()\n if request.method == 'POST':\n if request.POST['computer_id'] !... | [
1,
3,
4,
5,
6
] |
f=open('p102_triangles.txt')
def cross(a,b,c):
t1=b[0]-a[0]
t2=b[1]-a[1]
t3=c[0]-a[0]
t4=c[1]-a[1]
return t1*t4-t2*t3
x=[0,0]
y=[0,0]
z=[0,0]
origin=(0,0)
ans=0
for i in f.xreadlines():
x[0],x[1],y[0],y[1],z[0],z[1]=map(int,i.split(','))
area1=abs(cross(x,y,z))
area2=abs(cross(x,y,orig... | normal | {
"blob_id": "c34ff2bbb0ba743268ace77c110ce0b283a25eba",
"index": 8637,
"step-1": "f=open('p102_triangles.txt')\n\ndef cross(a,b,c):\n t1=b[0]-a[0]\n t2=b[1]-a[1]\n t3=c[0]-a[0]\n t4=c[1]-a[1]\n return t1*t4-t2*t3\n\nx=[0,0]\ny=[0,0]\nz=[0,0]\norigin=(0,0)\nans=0\nfor i in f.xreadlines():\n x[0]... | [
0
] |
<|reserved_special_token_0|>
class TemplateParser:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def __init__(self, template=None, providers=None, date_generator=None):
self.fake = Faker()
self.fake.add_provider(FileDataSourceProvider)
self.fake.add_provider(NumbersPro... | flexible | {
"blob_id": "38f9cddfde4787ead2314fc70c1f4d91a3da9687",
"index": 1307,
"step-1": "<mask token>\n\n\nclass TemplateParser:\n <mask token>\n <mask token>\n\n def __init__(self, template=None, providers=None, date_generator=None):\n self.fake = Faker()\n self.fake.add_provider(FileDataSourceP... | [
3,
4,
6,
7,
8
] |
from os import environ
from process import process
from s3Service import put_object
environ['ACCESS_KEY'] = '1234567890'
environ['SECRET_KEY'] = '1234567890'
environ['ENDPOINT_URL'] = 'http://localhost:4566'
environ['REGION'] = 'us-east-1'
environ['BUCKET_GLOBAL'] = 'fl2-statement-global'
environ['BUCKET_GLOBAL_BACKUP... | normal | {
"blob_id": "a4eca0f5b7d5a03ca3600554ae3fe3b94c59fc68",
"index": 8622,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef execute(event, context):\n print(event)\n pass\n",
"step-3": "<mask token>\nenviron['ACCESS_KEY'] = '1234567890'\nenviron['SECRET_KEY'] = '1234567890'\nenviron['ENDPOINT_U... | [
0,
1,
2,
3,
4
] |
import torch
import torch.nn as nn
import torch.nn.functional as F
class Encoder(nn.Module):
def __init__(self):
super(Encoder, self).__init__()
self.conv1 = nn.Conv2d(1, 32, kernel_size=5, stride=1)
self.bn1 = nn.BatchNorm2d(32)
self.conv2 = nn.Conv2d(32, 48, kernel_size=5, stride... | normal | {
"blob_id": "9140da0b6c04f39a987a177d56321c56c01586e8",
"index": 3739,
"step-1": "<mask token>\n\n\nclass Classifier(nn.Module):\n\n def __init__(self, args, prob=0.5):\n super(Classifier, self).__init__()\n self.fc1 = nn.Linear(48 * 4 * 4, 100)\n self.bn1_fc = nn.BatchNorm1d(100)\n ... | [
5,
7,
8,
10,
11
] |
#Created by Jake Hansen for Zebra interview take home assessment, July 2020.
import csv, os, sys, pickle
from datetime import date
#Class For storing information about each file generally. Helpful for future
#use cases to remember the indicies from a file, if file has thousands of fields
#Also can be used as a log to ... | normal | {
"blob_id": "38c1b82a29a5ad0b4581e63fb083ca2487a79817",
"index": 9544,
"step-1": "<mask token>\n\n\nclass DataSource:\n\n def __init__(self, name, usableRows, errorRows, indices):\n self.name = name\n self.usableRows = usableRows\n self.errorRows = errorRows\n self.indices = indice... | [
5,
6,
8,
9,
10
] |
import json
import sys
from copy import deepcopy
from argparse import ArgumentParser
# TODO: Ord category's IDs after deletion
def return_cat_name(json_coco, category):
"""Return the category name of a category ID
Arguments:
json_coco {dict} -- json dict file from coco file
category {int} --... | normal | {
"blob_id": "467327b98ab99bdad429943c701c751be4f67940",
"index": 9378,
"step-1": "<mask token>\n\n\ndef main():\n \"\"\"Remove a category from a coco json file\n \"\"\"\n parser = ArgumentParser(description=\n 'Category Filter: Filter a List of Categories from a JSON')\n parser.add_argument('j... | [
1,
2,
3,
4,
5
] |
from models.readingtip import ReadingTip
from database import db
class ReadingTipRepository:
def __init__(self):
pass
def get_tips(self, user, tag="all"):
if tag == "all":
return ReadingTip.query.filter_by(user=user).all()
else:
return ReadingTip.query.filter_by... | normal | {
"blob_id": "d82b68d5c83ae538d7a8b5ae5547b43ac4e8a3d4",
"index": 6910,
"step-1": "<mask token>\n\n\nclass ReadingTipRepository:\n <mask token>\n\n def get_tips(self, user, tag='all'):\n if tag == 'all':\n return ReadingTip.query.filter_by(user=user).all()\n else:\n retur... | [
4,
7,
9,
11,
12
] |
# -*- coding: utf-8 -*-
# Copyright 2019, IBM.
#
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=undefined-loop-variable
"""
Run through RB for different qubit numbers to check that it's working
and that... | normal | {
"blob_id": "995e42312e286d82fa101128795d8aa60c1a6548",
"index": 4203,
"step-1": "<mask token>\n\n\nclass TestRB(unittest.TestCase):\n <mask token>\n\n @staticmethod\n def choose_pattern(pattern_type, nq):\n \"\"\"\n Choose a valid field for rb_opts['rb_pattern']\n :param pattern_ty... | [
6,
7,
8,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if type(video_path).__name__ == 'str':
videoReader = cv2.VideoCapture(video_path)
print('Load live video from file...')
elif type(video_path).__name__ == 'int':
videoReader = cv2.VideoCapture(video_path)
print('Get... | flexible | {
"blob_id": "08408cf096bbe23f9a832cc0cf2e017abdbd359f",
"index": 4591,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif type(video_path).__name__ == 'str':\n videoReader = cv2.VideoCapture(video_path)\n print('Load live video from file...')\nelif type(video_path).__name__ == 'int':\n videoReade... | [
0,
1,
2,
3,
4
] |
import os
import json
def load_json_if_exists(path):
if not os.path.isfile(path):
return {}
with open(path) as f:
return json.load(f)
def json_dump(obj, file_path):
with open(file_path, 'w') as f:
json.dump(obj, f)
def get_folder_paths(directory):
return [os.path.join(directo... | normal | {
"blob_id": "3788888a17e2598e781803f89cd63ac9c3219f59",
"index": 4341,
"step-1": "<mask token>\n\n\ndef json_dump(obj, file_path):\n with open(file_path, 'w') as f:\n json.dump(obj, f)\n\n\n<mask token>\n\n\ndef get_repo_path(file_path):\n if os.path.isfile(file_path):\n folder_path = os.path... | [
8,
9,
12,
13,
14
] |
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponse
# Create your views here.
def check(request):
if not request.user.is_authenticated:
return redirect('/auth/login/')
else:
return redirect('/worker/')
... | normal | {
"blob_id": "fc2afc99dc754b58c36bc76c723727337851cc3e",
"index": 5326,
"step-1": "<mask token>\n\n\ndef check(request):\n if not request.user.is_authenticated:\n return redirect('/auth/login/')\n else:\n return redirect('/worker/')\n\n\ndef loginpg(request):\n return render(request, 'regis... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
import json
from django.conf import settings
from pdf_generator.utils import build_pdf_stream_from
from django.http import JsonResponse
from helpers.views import ApiView
from pdf_generator.forms import PdfTempStoreForm
from pdf_generator.serializers import PdfTempStoreSerializer
class Report... | normal | {
"blob_id": "789f95095346262a04e7de0f9f9c5df6177e8fbc",
"index": 5114,
"step-1": "<mask token>\n\n\nclass ReportPdfView(ApiView):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass ReportPdfView(ApiView):\n <mask token>\n\n def post(self, request, *args, **kwargs):\n data =... | [
1,
2,
3,
4,
5
] |
# Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | normal | {
"blob_id": "2064fe029bc7db14505a5b38750e324b55556abb",
"index": 7032,
"step-1": "<mask token>\n\n\nclass ConcatOffsetNet(nn.Cell):\n\n def __init__(self, axis):\n super(ConcatOffsetNet, self).__init__()\n self.op = G.ConcatOffset(2, axis)\n\n def construct(self, x0, x1):\n return self... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with con:
cur = con.cursor()
cur.execute('CREATE TABLE Cars(Id INT, Name TEXT, Price INT)')
cur.execute("INSERT INTO Cars VALUES(1, 'car1', 10)")
cur.execute("INSERT INTO Cars VALUES(2, 'car2', 20)")
cur.execut... | flexible | {
"blob_id": "db22e568c86f008c9882181f5c1d88d5bca28570",
"index": 5416,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith con:\n cur = con.cursor()\n cur.execute('CREATE TABLE Cars(Id INT, Name TEXT, Price INT)')\n cur.execute(\"INSERT INTO Cars VALUES(1, 'car1', 10)\")\n cur.execute(\"INSER... | [
0,
1,
2,
3,
4
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.