code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
from .mail_utils import send_mail
from .request_utils import get_host_url
| normal | {
"blob_id": "74b0ccb5193380ce596313d1ac3f898ff1fdd2f3",
"index": 930,
"step-1": "<mask token>\n",
"step-2": "from .mail_utils import send_mail\nfrom .request_utils import get_host_url\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
def simple_divide(item, denom):
try:
return item / denom
except ZeroDivisionError:
return 0
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def simple_divide(item, denom):
try:
return item / denom
except ZeroDivisionError:
return 0
<|reserved_special_toke... | flexible | {
"blob_id": "1fbdb0b40f0d65fffec482b63aa2192968b01d4b",
"index": 9766,
"step-1": "def simple_divide(item, denom):\n try:\n return item / denom\n except ZeroDivisionError:\n return 0\n\n\n<mask token>\n",
"step-2": "def simple_divide(item, denom):\n try:\n return item / denom\n ... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright 2020, Yutong Xie, UIUC.
Using recursion to construct binary tree from postorder and inorder traversal
'''
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
... | normal | {
"blob_id": "b59dfd97a2b52ddef4e37557ea96bff9edf34989",
"index": 1342,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution(object):\n\n def buildTree(self, inorder, postorder):\n \"\"\"\n :type ino... | [
0,
1,
2,
3,
4
] |
class Region:
<|reserved_special_token_0|>
def __init__(self, coords, r_votes, d_votes, o_votes):
self.coords = coords
def lats(self):
"""Return a list of the latitudes of all the coordinates in the region"""
return [y for x, y in self.coords]
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "517436d61ac9993bee5ecfd932f272dbb8bec60b",
"index": 7608,
"step-1": "class Region:\n <mask token>\n\n def __init__(self, coords, r_votes, d_votes, o_votes):\n self.coords = coords\n\n def lats(self):\n \"\"\"Return a list of the latitudes of all the coordinates in the region\"... | [
6,
7,
8,
9,
10
] |
import cv2
import os
import numpy as np
import sys
from os.path import expanduser
np.random.seed(0)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description='Generate artificial videos with one subject in Casia-B')
parser.add_argument('--dataset', type=str, required=False... | normal | {
"blob_id": "6b32f829648b92da4b638ffd79692ffb86be80fe",
"index": 8761,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnp.random.seed(0)\nif __name__ == '__main__':\n import argparse\n parser = argparse.ArgumentParser(description=\n 'Generate artificial videos with one subject in Casia-B')\n ... | [
0,
1,
2,
3
] |
import csv
from itertools import chain, combinations
import generation
import time
pi = []
wi = []
di = []
n = input("How many tasks do you want to schedule ? \n")
k=tuple(range(1,n+1))
#la fonction qui supprime un element dans l'ensemble des taches, elle facilite comment retrouver les sous taches de J
def ... | normal | {
"blob_id": "ddab4d014c000dd96bad932adac75e4eec065483",
"index": 9644,
"step-1": "<mask token>\n\n\ndef all_subsets(ss, i):\n return chain(*map(lambda x: combinations(ss, x), range(i, i + 1)))\n\n\n<mask token>\n\n\ndef f1(i):\n return wi[i[0] - 1] * max(0, pi[i[0] - 1] - di[i[0] - 1])\n\n\ndef f2(i):\n ... | [
3,
5,
6,
7,
8
] |
import json
def get_json_data(page):
with open('geekshop/json_data.json', encoding='utf-8-sig') as file:
json_data = json.load(file)
return json_data[page]
def get_json_products_data(file_path):
with open(file_path, encoding='utf-8-sig') as file:
json_data = json.load(file)
return js... | normal | {
"blob_id": "08b53ba116b0c5875d39af4ce18296d547d5891d",
"index": 5692,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_json_products_data(file_path):\n with open(file_path, encoding='utf-8-sig') as file:\n json_data = json.load(file)\n return json_data\n",
"step-3": "<mask token... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def simulation(cnt, a, b):
df, df_collist = datamake.make_df(
'/Users/masato/Desktop/UTTdata/prog/PyProgramming/DA_algorithm/Mavo/csvdata/sinhuri2018.csv'
)
n, m, k = datamake.stu_num()
df_stu = np.zeros((1, n + 1))
for j in range(cnt):
random.seed(... | flexible | {
"blob_id": "cad00f80afa142b69ced880de000b6b5b230640c",
"index": 6228,
"step-1": "<mask token>\n\n\ndef simulation(cnt, a, b):\n df, df_collist = datamake.make_df(\n '/Users/masato/Desktop/UTTdata/prog/PyProgramming/DA_algorithm/Mavo/csvdata/sinhuri2018.csv'\n )\n n, m, k = datamake.stu_num()... | [
1,
2,
3,
4,
5
] |
from time import sleep
from uuid import uuid1
from pprint import pprint
from shutil import copy2
from multiprocessing import Process, Queue, Pool, Manager
from ad_grabber_classes import *
from adregex import *
from pygraph.classes.digraph import digraph
import os
import json
import jsonpickle
import subprocess
import ... | normal | {
"blob_id": "fdae984f7cf5e1c20dee197d3f2518a0c7c38bdc",
"index": 8085,
"step-1": "<mask token>\n\n\ndef check_duplicate(fp1, fp2):\n \"\"\"takes two files, does a diff on them, returns True if same\"\"\"\n try:\n subprocess.check_output(['diff', fp1, fp2])\n return True\n except subprocess... | [
10,
14,
15,
16,
18
] |
import FWCore.ParameterSet.Config as cms
maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
readFiles = cms.untracked.vstring()
source = cms.Source ("PoolSource",fileNames = readFiles, lumisToProcess = cms.untracked.VLuminosityBlockRange(*('1:11169', '1:11699', '1:16592', '1:23934', '1:17699', '1:22722',... | normal | {
"blob_id": "15821bb33c2949f5a3e72e23cf7b5d8766dfce70",
"index": 4568,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nreadFiles.extend([\n '/store/mc/RunIIFall17MiniAODv2/TTbarDMJets_Dilepton_pseudoscalar_LO_TuneCP5_13TeV-madgraph-mcatnlo-pythia8/MINIAODSIM/PU2017_12Apr2018_rp_94X_mc2017_realistic_v14... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def adj_to_bias(adj):
"""Add self loop to adj and make sure only one hop neighbors are engaged in computing"""
num_graphs = adj.shape[0]
adj_temp = np.empty(adj.shape)
for i in range(num_graphs):
adj_temp[i] = adj[i] + np.eye(adj.shape[1])
return -1000000000.0 ... | flexible | {
"blob_id": "eb50f50e3c072c2f6e74ff9ef8c2fa2eef782aae",
"index": 6718,
"step-1": "<mask token>\n\n\ndef adj_to_bias(adj):\n \"\"\"Add self loop to adj and make sure only one hop neighbors are engaged in computing\"\"\"\n num_graphs = adj.shape[0]\n adj_temp = np.empty(adj.shape)\n for i in range(num_... | [
2,
3,
4,
5,
6
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@author: Allen(Zifeng) An
@course:
@contact: anz8@mcmaster.ca
@file: 17. Letter Combinations of a Phone Number.py
@time: 2020/2/2 21:18
'''
from typing import List
class Solution:
def letterCombinations(self, digits: str) -> List[str]:
d={2:'abc',
... | normal | {
"blob_id": "de925b8f6bd31bfdfd1f04628659847b0761899d",
"index": 340,
"step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n\n def letterCombinations(self, digits: str) ->List[str]:\n d = {(2): 'abc', (3): 'def', (4): 'ghi',... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def MergeSort(array):
if len(array) <= 1:
return array
mid = len(array) // 2
left, right = MergeSort(array[:mid]), MergeSort(array[mid:])
return Merge(left, right, array.copy())
<|reserved_special_token... | flexible | {
"blob_id": "c64c542b57107c06de2ce0751075a81fcb195b61",
"index": 4293,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef MergeSort(array):\n if len(array) <= 1:\n return array\n mid = len(array) // 2\n left, right = MergeSort(array[:mid]), MergeSort(array[mid:])\n return Merge(lef... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Node:
def __init__(self, val, children=None, parent=None):
self.id = str(val)
self.val = val
self.parent = parent
self.depth = -1
self.size = -1
self.index = -1
self.attrs = {}
self._index = []
self.childre... | flexible | {
"blob_id": "881afd6877508243fa5056d2a82d88ba69ffb8c0",
"index": 7801,
"step-1": "<mask token>\n\n\nclass Node:\n\n def __init__(self, val, children=None, parent=None):\n self.id = str(val)\n self.val = val\n self.parent = parent\n self.depth = -1\n self.size = -1\n s... | [
21,
22,
25,
29,
33
] |
import konlpy
import nltk
# POS tag a sentence
sentence = u'만 6세 이하의 초등학교 취학 전 자녀를 양육하기 위해서는'
words = konlpy.tag.Twitter().pos(sentence)
# Define a chunk grammar, or chunking rules, then chunk
grammar = """
NP: {<N.*>*<Suffix>?} # Noun phrase
VP: {<V.*>*} # Verb phrase
AP: {<A.*>*} # Adjective... | normal | {
"blob_id": "6b647dc2775f54706a6c18ee91145ba60d70be21",
"index": 4453,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('# Print whole tree')\nprint(chunks.pprint())\nprint(\"\"\"\n# Print noun phrases only\"\"\")\nfor subtree in chunks.subtrees():\n if subtree.label() == 'NP':\n print(' '.... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class iVectorExtractorConfig(object):
"""
Configuration class for i-vector extractor training
Attributes
----------
ivector_dim : int
Dimension of the extracted i-vector
ivector_period : int
Number of frames between i-vector extractions
num_ite... | flexible | {
"blob_id": "7cfca56907f0bca7fd62e506414641f942527d1a",
"index": 9624,
"step-1": "<mask token>\n\n\nclass iVectorExtractorConfig(object):\n \"\"\"\n Configuration class for i-vector extractor training\n\n Attributes\n ----------\n ivector_dim : int\n Dimension of the extracted i-vector\n ... | [
13,
24,
27,
29,
36
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(0, 100, 10):
print(i + 10)
<|reserved_special_token_1|>
# Midterm Review Class!
'''
This is a Multi line comment:
'''
# Break and Continue
# for i in range(10):
# if i == 5:
# contin... | flexible | {
"blob_id": "3d3b77630d275f830daf9f6e0d50a77ef624521e",
"index": 7139,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(0, 100, 10):\n print(i + 10)\n",
"step-3": "# Midterm Review Class!\n\n'''\nThis is a Multi line comment:\n'''\n\n# Break and Continue\n # for i in range(10):\n ... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
while True:
user = input('> ').split(' ')
score = int(user[0])
name = user[1]
scores.append([score, name])
scores.sort(reverse=True)
if len(scores) < 3:
highscores = scores
else:
highsco... | flexible | {
"blob_id": "54e5feee3c8bb35c351361fd3ed4b5e237e5973d",
"index": 6701,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n user = input('> ').split(' ')\n score = int(user[0])\n name = user[1]\n scores.append([score, name])\n scores.sort(reverse=True)\n if len(scores) < 3:\n ... | [
0,
1,
2
] |
from __future__ import division, print_function
import numpy as np
from copy import deepcopy
class IntegratedRegressor():
regs = []
def __init__(self, reg, predict_log=True):
self.reg = reg
self.predict_log = predict_log
def fit(self, X, y):
self.regs = []
for target in ... | normal | {
"blob_id": "72d41f939a586fbd8459927983d9d62a96b650e2",
"index": 1844,
"step-1": "<mask token>\n\n\nclass IntegratedRegressor:\n <mask token>\n <mask token>\n\n def fit(self, X, y):\n self.regs = []\n for target in y.columns:\n tmp = deepcopy(self.reg)\n if self.predi... | [
6,
7,
8,
10,
11
] |
<|reserved_special_token_0|>
class RobotFrameworkServerApi(PythonLanguageServer):
<|reserved_special_token_0|>
def __init__(self, read_from, write_to, libspec_manager=None, observer:
Optional[IFSObserver]=None):
from robotframework_ls.impl.libspec_manager import LibspecManager
if libs... | flexible | {
"blob_id": "18b43ea8696e2e54f4c1cbbece4cde1fd3130145",
"index": 194,
"step-1": "<mask token>\n\n\nclass RobotFrameworkServerApi(PythonLanguageServer):\n <mask token>\n\n def __init__(self, read_from, write_to, libspec_manager=None, observer:\n Optional[IFSObserver]=None):\n from robotframewo... | [
19,
33,
35,
44,
51
] |
<|reserved_special_token_0|>
class UserTest(DemoTestCase):
<|reserved_special_token_0|>
def test_login_bad_password(self):
r = self.post('/api/connect', {'user': 'admin', 'password':
'badpassword'})
self.assertEqual(401, r.status_code)
def test_login_good_password(self):
... | flexible | {
"blob_id": "0a1d102075cebee13e25f3eb703811d1e22f53c2",
"index": 1957,
"step-1": "<mask token>\n\n\nclass UserTest(DemoTestCase):\n <mask token>\n\n def test_login_bad_password(self):\n r = self.post('/api/connect', {'user': 'admin', 'password':\n 'badpassword'})\n self.assertEqual... | [
3,
4,
5,
6
] |
#!/usr/bin/env python
import os, sys, json
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python_task_helper', 'files'))
from task_helper import TaskHelper
hosts_file = open("/etc/hosts", "r").read()
resolv_file = open("/etc/resolv.conf", "r").read()
output = hosts_file + resolv_file
class Gen... | normal | {
"blob_id": "24813e03de05058925a42847042157fa65450d21",
"index": 3773,
"step-1": "<mask token>\n\n\nclass Generate(TaskHelper):\n\n def task(self, args):\n return {'result': output}\n\n\n<mask token>\n",
"step-2": "<mask token>\nsys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',\n ... | [
2,
3,
4,
5,
6
] |
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompa... | normal | {
"blob_id": "653c8db6741a586694d91bd9928d8326cce9e41d",
"index": 6373,
"step-1": "<mask token>\n\n\ndef get_application_name(default=_marker, prompt=True):\n global _selected_app\n result = None\n try:\n result = fileoperations.get_config_setting('global', 'application_name'\n )\n e... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def progresses_format(users):
json = dict()
json['users_progresses'] = list()
for user in users:
json['users_progresses'].append(progress_format(user))
return json
<|reserved_special_token_0|>
<|reser... | flexible | {
"blob_id": "6ebf6bdfc6a4a1fe49f4eed1a2c1802f8adeef08",
"index": 1195,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef progresses_format(users):\n json = dict()\n json['users_progresses'] = list()\n for user in users:\n json['users_progresses'].append(progress_format(user))\n re... | [
0,
1,
2,
3,
4
] |
import math
import pygame
from TestingFunctions.FunctionExample import FunctionExample
class FunctionPygameCircle(FunctionExample):
def __init__(self, data_len, width=500, height=500, dot_size=5):
self.angle = (2 * math.pi) / (data_len)
self.width = width
self.height = height
self... | normal | {
"blob_id": "2faf39f8d12197e20948b2bf4288b7ee406f5b86",
"index": 2025,
"step-1": "<mask token>\n\n\nclass FunctionPygameCircle(FunctionExample):\n\n def __init__(self, data_len, width=500, height=500, dot_size=5):\n self.angle = 2 * math.pi / data_len\n self.width = width\n self.height = ... | [
4,
6,
7,
8,
9
] |
import pandas as pd
import numpy as np
#I'm adding these too avoid any type of na value.
missing_values = ["n/a", "na", "--", " ?","?"]
# Name Data Type Meas. Description
# ---- --------- ----- -----------
# Sex nominal M, F, and I (infant)
# Length continuous mm Longest shell measurement
# Diameter con... | normal | {
"blob_id": "1b773f2ca01f07d78d2d7edc74cd2df6630aa97a",
"index": 4968,
"step-1": "<mask token>\n\n\ndef tt(X, y, sample):\n X_train, X_valid, y_train, y_valid = train_test_split(X, y, train_size=\n sample, random_state=1)\n return {'X_train': X_train, 'X_valid': X_valid, 'y_train': y_train,\n ... | [
1,
2,
3,
4,
5
] |
import smtplib
from email.message import EmailMessage
from functools import wraps
from threading import Thread
import flask_login
from flask import flash, current_app
from togger import db
from togger.auth.models import User, Role
from togger.calendar.models import Calendar
def get_user(username):
if username i... | normal | {
"blob_id": "fab3e524edf6783775fabf402f9148bf31ac06d6",
"index": 2914,
"step-1": "<mask token>\n\n\ndef get_user_by_id(id):\n if id is None:\n return\n user = User.query.filter(User.alias_id == id).first()\n return user\n\n\n<mask token>\n\n\ndef update_user(first_name, last_name):\n user = fl... | [
11,
12,
13,
15,
16
] |
class Formater():
def clean_number (posible_number):
sanitize_number = posible_number.replace(' ', '')
number_of_dots = sanitize_number.count('.')
if number_of_dots > 1:
return None
if number_of_dots == 1:
dot_position = sanitize_number.index('.')
... | normal | {
"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
] |
import os
import sys
import time
from collections import deque
import pickle
import random
import string
from tensorflow.python.framework.errors import InvalidArgumentError
from baselines.ddpg.ddpg import DDPG
import baselines.common.tf_util as U
from baselines.ddpg import prosthetics_env
from baselines import logger... | normal | {
"blob_id": "3f92bf194058c97a40cd5728cfc7c9d1be6b2548",
"index": 8099,
"step-1": "<mask token>\n\n\ndef train(env, nb_epochs, nb_epoch_cycles, render_eval, reward_scale,\n render, param_noise, actor, critic, normalize_returns,\n normalize_observations, critic_l2_reg, actor_lr, critic_lr,\n action_noise,... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def decode(hash):
hash = base64.b64decode(hash.encode('utf-8'))
key = DesKey(b'7ly6UznJ')
return key.decrypt(hash, initial=b'XuVUm5fR', padding=True).decode('utf-8')
<|reserved_special_token_0|>
<|reserved_specia... | flexible | {
"blob_id": "136215a3ba99f74160373181c458db9bec4bb6b7",
"index": 977,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef decode(hash):\n hash = base64.b64decode(hash.encode('utf-8'))\n key = DesKey(b'7ly6UznJ')\n return key.decrypt(hash, initial=b'XuVUm5fR', padding=True).decode('utf-8')\n\n... | [
0,
1,
2,
3,
4
] |
def sumIntervals(input):
interval = set()
if len(input) > 0:
for data in input:
if len(data) == 2 and data[0] < data[1]:
for i in range(data[0], data[1]):
interval.add(i)
else:
return 1
return len(interval)
else:
... | normal | {
"blob_id": "25434fccff4401df2cebc9b0c4d0231f056b4e81",
"index": 6346,
"step-1": "<mask token>\n",
"step-2": "def sumIntervals(input):\n interval = set()\n if len(input) > 0:\n for data in input:\n if len(data) == 2 and data[0] < data[1]:\n for i in range(data[0], data[1]... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
plus = True
inde... | flexible | {
"blob_id": "02a228c479a6c94858f7e8ef73a7c8528def871e",
"index": 9423,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n",
"step-3": "class Solution(object):\n\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n ... | [
0,
1,
2,
3
] |
import FitImport as imp
import numpy as np
from math import *
from sklearn.kernel_ridge import KernelRidge
from sklearn.grid_search import GridSearchCV
from sklearn import cross_validation
from sklearn.cross_validation import train_test_split
from sklearn.metrics import mean_squared_error
GSFOLDS = 3
FOLDS = 5
NPTS = ... | normal | {
"blob_id": "7d3a33968a375141c1c451ecd531ce8d97906c7f",
"index": 3065,
"step-1": "<mask token>\n\n\ndef GetPrediction(X, regr):\n return regr.predict(X)\n\n\ndef GetRMSE(Y, YP):\n return sqrt(mean_squared_error(Y, YP))\n\n\ndef SplitFitGKRR(X, Y):\n Xt, XT, Yt, YT = cross_validation.train_test_split(X, ... | [
5,
7,
8,
10,
11
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def solution(name):
Len = len(name)
nameList = [name[i] for i in range(Len)]
nameField = ['A' for i in range(Len)]
answer = 0
for i in range(Len):
a = ord(nameField[i])
b = ord(nameList[i])
if b - a <= 13:
... | flexible | {
"blob_id": "8766003a85b1ed83927988df147b0b3004cb91f9",
"index": 7691,
"step-1": "<mask token>\n",
"step-2": "def solution(name):\n Len = len(name)\n nameList = [name[i] for i in range(Len)]\n nameField = ['A' for i in range(Len)]\n answer = 0\n for i in range(Len):\n a = ord(nameField[i]... | [
0,
1,
2
] |
import random
def less(i1, i2):
return i1[0] * i2[1] < i2[0] * i1[1]
def equal(i1, i2):
return i1[0] * i2[1] == i2[0] * i1[1]
def more(i1, i2):
return i1[0] * i2[1] > i2[0] * i1[1]
def partition(x, l, r, pivot):
il = l
ir = l
for i in range(l, r):
if x[i] < pivot and ir < r:
... | normal | {
"blob_id": "a5e693a79211570f2d27575657496992f8fee164",
"index": 9075,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef less(i1, i2):\n return i1[0] * i2[1] < i2[0] * i1[1]\n\n\ndef equal(i1, i2):\n return i1[0] * i2[1] == i2[0] * i1[1]\n\n\ndef more(i1, i2):\n return i1[0] * i2[1] > i2[0]... | [
0,
5,
7,
8,
9
] |
'''
Confeccionar un programa que genere un número aleatorio entre 1 y 100 y no se muestre.
El operador debe tratar de adivinar el número ingresado.
Cada vez que ingrese un número mostrar un mensaje "Gano" si es igual al generado o "El número aleatorio el mayor" o "El número aleatorio es menor".
Mostrar cuando gana el j... | normal | {
"blob_id": "8498ba69e4cc5c5f480644ac20d878fb2a632bee",
"index": 5128,
"step-1": "<mask token>\n\n\ndef generar_numero_aleatorio():\n return random.randint(1, 100)\n\n\ndef es_el_numero(resp_usuario, resp_correc):\n return resp_usuario == resp_correc\n\n\ndef numero_dado_es_mayor(resp_usuario, resp_correc)... | [
5,
6,
7,
9,
10
] |
def digitSum(x):
if x < 10:
return x
return x % 10 + digitSum(x // 10)
def solve(S, n):
Discriminante = S * S + 4 * n
r = int(Discriminante ** 0.5)
if r * r == Discriminante:
if r % 2 == S % 2:
return (r - S) // 2
else:
return -1
else:
re... | normal | {
"blob_id": "f89800e0d8d4026c167381f275ca86c2cf7f011e",
"index": 4066,
"step-1": "<mask token>\n\n\ndef solve(S, n):\n Discriminante = S * S + 4 * n\n r = int(Discriminante ** 0.5)\n if r * r == Discriminante:\n if r % 2 == S % 2:\n return (r - S) // 2\n else:\n retur... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if number_of_terms >= 1:
add_approximation = 0
for count in range(1, number_of_terms):
approximation = (-1) ** (count + 1) / (2 * count - 1)
add_approximation = approximation + add_approximation
solutio... | flexible | {
"blob_id": "466148395a4141793b5f92c84513fd093876db76",
"index": 9964,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif number_of_terms >= 1:\n add_approximation = 0\n for count in range(1, number_of_terms):\n approximation = (-1) ** (count + 1) / (2 * count - 1)\n add_approximation ... | [
0,
1,
2,
3
] |
from odoo import models, fields, api
from datetime import datetime, timedelta
from odoo import exceptions
import logging
import math
_logger = logging.getLogger(__name__)
class BillOfLading(models.Model):
_name = 'freight.bol'
_description = 'Bill Of Lading'
_order = 'date_of_issue desc, writ... | normal | {
"blob_id": "f8e287abc7e1a2af005aa93c25d95ce770e29bf9",
"index": 7378,
"step-1": "<mask token>\n\n\nclass BillOfLading(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>... | [
30,
32,
38,
47,
49
] |
#!/usr/bin/env python
# ! -*- coding: utf-8 -*-
'''
@Time : 2020/6/4 16:33
@Author : MaohuaYang
@Contact : maohuay@hotmail.com
@File : pinganFudan-GUI.py
@Software: PyCharm
'''
import time
import requests
import tkinter as tk
from login import Ehall
def set_win_center(root, curWidth='', curHight=''):
"""
... | normal | {
"blob_id": "d133a07f69d2dadb5559d881b01050abb2a9602b",
"index": 3891,
"step-1": "<mask token>\n\n\ndef main():\n root = tk.Tk()\n root.title('DailyFudan')\n set_win_center(root, 700, 350)\n root.resizable(0, 0)\n lblid = tk.Label(root, text='学号:')\n lblid.grid(row=0, column=0)\n entID = tk.... | [
1,
3,
4,
5,
6
] |
from django.shortcuts import render
from django.views.generic import TemplateView
# Create your views here.
def index(request):
context = 'Welcome home'
return render(request,'base.html',{'context':context})
class HomePageView(TemplateView):
template_name = 'base.html'
| normal | {
"blob_id": "f0a54feaa165a393c4e87cbac2a38347633acf5a",
"index": 1425,
"step-1": "<mask token>\n\n\nclass HomePageView(TemplateView):\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass HomePageView(TemplateView):\n template_name = 'base.html'\n",
"step-3": "<mask token>\n\n\ndef index(request):\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
start_time = time.time()
elapsed = time.time() - start_time
while elapsed < TIMEOUT:
a_test = random.choice(REGRESSION_TESTS)
print('Running ' + str(a_test.__name__))
... | flexible | {
"blob_id": "710bb0e0efc2c4a3ba9b1ae85e1c22e81f8ca68e",
"index": 7960,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n start_time = time.time()\n elapsed = time.time() - start_time\n while elapsed < TIMEOUT:\n a_test = random.choice(REGRESSION_TESTS)\n p... | [
0,
1,
2,
3,
4
] |
from logging import getLogger
from time import sleep
from uuid import UUID
from zmq import Context, Poller, POLLIN, ZMQError, ETERM # pylint: disable-msg=E0611
from zhelpers import zpipe
from dcamp.service.configuration import Configuration
from dcamp.types.messages.control import SOS
from dcamp.types.specs import E... | normal | {
"blob_id": "fee757b91f8c2ca1c105d7e67636772a8b5eafd5",
"index": 8158,
"step-1": "<mask token>\n\n\n@runnable\nclass RoleMixin(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def _add_service(self, cls, *args, **kwargs):\n pipe, p... | [
4,
10,
11,
14,
15
] |
# Generated by Django 3.1.5 on 2021-05-30 14:27
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('fuser', '0009_movement_type'),
]
operations = [
migrations.AlterField(
model_name='movementpass... | normal | {
"blob_id": "848374ea7d706bbd2ef5a76489cabeff998acb82",
"index": 6040,
"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 = [('fuser', '00... | [
0,
1,
2,
3,
4
] |
'''
Functional tests for the Write Stream
'''
from behave import given, when, then
from OSC import OSCClient, OSCMessage, OSCServer
@given('I want to send an integer')
def step_impl (context):
pass
@given('I want to send a float')
def step_impl (context):
pass
@given('I want to send two integers with one ... | normal | {
"blob_id": "3770e59c5bd6837a0fb812f80c6549024e06a9e4",
"index": 5957,
"step-1": "<mask token>\n\n\n@given('I want to send an integer')\ndef step_impl(context):\n pass\n\n\n<mask token>\n\n\n@given('I want to send two integers with one channel')\ndef step_impl(context):\n pass\n\n\n@given('I want to send t... | [
8,
10,
12,
13,
15
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if REQUEST is not None:
raise Unauthorized
<|reserved_special_token_0|>
document.submit()
return document.getRelativeUrl()
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if REQUEST is not None:
raise Unauthor... | flexible | {
"blob_id": "6c27f70e820202f6cc4348de3c9198e7b20ec7d9",
"index": 4470,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif REQUEST is not None:\n raise Unauthorized\n<mask token>\ndocument.submit()\nreturn document.getRelativeUrl()\n",
"step-3": "<mask token>\nif REQUEST is not None:\n raise Unauth... | [
0,
1,
2,
3,
4
] |
from flask import Flask,Response,render_template,url_for,request,jsonify
from flask_bootstrap import Bootstrap
import pandas as pd
import gpt_2_simple as gpt2
import json
app = Flask(__name__)
Bootstrap(app)
#Main Page
@app.route('/')
def interactive_input():
return render_template('main.html')
#Creating the diff... | normal | {
"blob_id": "1e41cc5d2661f1fb4f3a356318fabcb2b742cbdf",
"index": 1826,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef interactive_input():\n return render_template('main.html')\n\n\n@app.route('/food_1_star')\ndef food_1_star():\n return render_template('food_1.html')\n\n\n<mask token>\n\n\n@app.route('... | [
6,
7,
9,
11,
13
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def my_queue(n=5):
return deque([], n)
pass
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def my_queue(n=5):
return deque([], n)
pass
if __name__ == '__main__':
... | flexible | {
"blob_id": "499baaa8c739c1bd846edc944e510542d76bbed5",
"index": 9312,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef my_queue(n=5):\n return deque([], n)\n pass\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef my_queue(n=5):\n return deque([], n)\n pass\n\n\nif __name__ == '_... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class LvmamaHotelSpider(Spider):
def get_comment_info2(self, shop_data):
params_list_comment1 = self.params_dict.get(ParamType.COMMENT_INFO_1)
comment_len = shop_data.get(FieldName.SHOP_COMMENT_NUM)
while True:
comments_list_len = (self.
... | flexible | {
"blob_id": "931e73ffce6d24dbfb92501670245e20fc403a7a",
"index": 7969,
"step-1": "<mask token>\n\n\nclass LvmamaHotelSpider(Spider):\n\n def get_comment_info2(self, shop_data):\n params_list_comment1 = self.params_dict.get(ParamType.COMMENT_INFO_1)\n comment_len = shop_data.get(FieldName.SHOP_CO... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def mergeSort(original_list):
return subSort(original_list)
def subSort(sub_list):
if len(sub_list) < 2:
return sub_list
index = len(sub_list) // 2
left_list = sub_list[0:index]
right_list = sub_list[index:len(sub_list)]
left_list = subSort(left_list)
... | flexible | {
"blob_id": "294229849dcfac8d4afeab79dae3c652c853fc47",
"index": 1924,
"step-1": "<mask token>\n\n\ndef mergeSort(original_list):\n return subSort(original_list)\n\n\ndef subSort(sub_list):\n if len(sub_list) < 2:\n return sub_list\n index = len(sub_list) // 2\n left_list = sub_list[0:index]\n... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(';'.join(a))
<|reserved_special_token_1|>
a = ['a', 'b', 'c', 'd', 'e']
print(';'.join(a))
| flexible | {
"blob_id": "a10403d7809b97c1bcdfa73224b8c365519cc456",
"index": 7275,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(';'.join(a))\n",
"step-3": "a = ['a', 'b', 'c', 'd', 'e']\nprint(';'.join(a))\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
#!/usr/bin/env python
import sys
import subprocess
import mystem
def run(args, fin=sys.stdin, fout=sys.stdout, ferr=sys.stderr, input_data=None):
'''\
Generic wrapper for MyStem
'''
mystem_path = mystem.util.find_mystem()
# make utf-8 a default encoding
if '-e' not in args:
args.exten... | normal | {
"blob_id": "d4a4ea67a06107ad7ea18bb21fb1ec9e74ccd7c1",
"index": 7187,
"step-1": "<mask token>\n\n\ndef main(args):\n return run(args)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef run(args, fin=sys.stdin, fout=sys.stdout, ferr=sys.stderr, input_data=None\n ):\n \"\"\" Generic wrapper for ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def runLogger():
while True:
log_path = '/home/pi/Desktop/Projects/rose/robot_code/logs/'
try:
os.makedirs(log_path)
except FileExistsError:
pass
file_name = log_path + 'Logs-' + str(datetime.date.today())
if not queues.l... | flexible | {
"blob_id": "91188b55b0f5d8277812d82711f5bcde82819b30",
"index": 9563,
"step-1": "<mask token>\n\n\ndef runLogger():\n while True:\n log_path = '/home/pi/Desktop/Projects/rose/robot_code/logs/'\n try:\n os.makedirs(log_path)\n except FileExistsError:\n pass\n ... | [
3,
4,
5,
6,
7
] |
import math
import os
import pathfinder as pf
from constants import X_ROBOT_LENGTH, Y_ROBOT_WIDTH, Y_WALL_TO_EXCHANGE_FAR, \
X_WALL_TO_SWITCH_NEAR
from utilities.functions import GeneratePath
class settings():
order = pf.FIT_HERMITE_QUINTIC
samples = 1000000
period = 0.02
maxVelocity =... | normal | {
"blob_id": "5e06dfb7aac64b5b98b4c0d88a86f038baf44feb",
"index": 5412,
"step-1": "<mask token>\n\n\nclass settings:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass settings:\n order = pf.FIT_... | [
1,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class Paddle:
def __init__(self):
self.center = Point(390, 50)
self.velocity = Velocity(0, 5)
<|reserved_special_token_0|>
def move_up(self):
if self.center.y < config.SCREEN_HEIGHT - config.PADDLE_HEIGHT / 2:
self.center.y = self.center.y... | flexible | {
"blob_id": "cb3c1adb9d91aecee5b21774d61dfe9400a330fa",
"index": 619,
"step-1": "<mask token>\n\n\nclass Paddle:\n\n def __init__(self):\n self.center = Point(390, 50)\n self.velocity = Velocity(0, 5)\n <mask token>\n\n def move_up(self):\n if self.center.y < config.SCREEN_HEIGHT - ... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Form(BaseForm):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Form(BaseForm):
def as_ul(self):
widget = ListWidget()
return widget(self)
<|rese... | flexible | {
"blob_id": "5dffda8215b8cfdb2459ec6a9e02f10a352a6fd0",
"index": 3173,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Form(BaseForm):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Form(BaseForm):\n\n def as_ul(self):\n widget = ListWidget()\n return widget(self)\n"... | [
0,
1,
2,
3
] |
#coding: utf8
import sqlite3
from random import shuffle
import argparse
def wordCount(db):
words = {}
for sent, labels in iterReviews(db):
for word in sent:
if word not in words:
words[word] = 1
else:
words[word] += 1
return words
def filt... | normal | {
"blob_id": "04867e8911f7cb30af6cefb7ba7ff34d02a07891",
"index": 7970,
"step-1": "<mask token>\n\n\ndef wordCount(db):\n words = {}\n for sent, labels in iterReviews(db):\n for word in sent:\n if word not in words:\n words[word] = 1\n else:\n words... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def create_segmentation_test_data(data_path, raw_key, label_key, shape, chunks
):
with h5py.File(data_path, 'a') as f:
f.create_dataset(raw_key, data=np.random.rand(*shape), chunks=chunks)
f.create_datase... | flexible | {
"blob_id": "e3417980599448f1293b56cb95312088e7a8abe3",
"index": 9713,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef create_segmentation_test_data(data_path, raw_key, label_key, shape, chunks\n ):\n with h5py.File(data_path, 'a') as f:\n f.create_dataset(raw_key, data=np.random.rand... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
@njit
def hammingWeight(n):
res = 0
for i in range(32):
if n & 1 << i:
res += 1
return res
@njit
def getStates():
spinUpStates = [i for i in range(1 << L) if hammingWeight(i) == Nup]
spinDownStates = [i for i in range(1 << L) if hammingWeight(i) =... | flexible | {
"blob_id": "325cc2fd82c44d0b7e291384159bd48d068e60f1",
"index": 1428,
"step-1": "<mask token>\n\n\n@njit\ndef hammingWeight(n):\n res = 0\n for i in range(32):\n if n & 1 << i:\n res += 1\n return res\n\n\n@njit\ndef getStates():\n spinUpStates = [i for i in range(1 << L) if hammin... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def showMenu():
print('---Please Choose Menu---')
print('1. Vat7')
print('2. Calculation')
print('3. Vat Calulation')
return menuSelect()
<|reserved_special_token_0|>
def priceResult():
price1 = int(input('ราคาชิ้นที่ 1 : '))
price2 = int(input('ราคาชิ้นที่... | flexible | {
"blob_id": "34dd6966a971e3d32e82a17cd08c3b66bb88163b",
"index": 1277,
"step-1": "<mask token>\n\n\ndef showMenu():\n print('---Please Choose Menu---')\n print('1. Vat7')\n print('2. Calculation')\n print('3. Vat Calulation')\n return menuSelect()\n\n\n<mask token>\n\n\ndef priceResult():\n pri... | [
2,
4,
5,
6,
7
] |
import requests
from app.main.model.location import Location
from app.main.util.db_util import save_changes
key = 'a544aecdde85a1f52a56292f77ecde6e'
def save_location(ip_addr):
try:
existing_location = Location.query.filter_by(ip=ip_addr).first()
if existing_location:
location_data = e... | normal | {
"blob_id": "eb8aec947cc1eeeb56b3884286b46ec7468dcc23",
"index": 9035,
"step-1": "<mask token>\n\n\ndef save_location(ip_addr):\n try:\n existing_location = Location.query.filter_by(ip=ip_addr).first()\n if existing_location:\n location_data = existing_location.location\n else:... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class LogisticsPlanningTool(Document):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class LogisticsPlanningTool(Document):
def autoname(self):
if self.customer:
self.name = '{0}-{1}-... | flexible | {
"blob_id": "4cbb78234ef6e63b856099060ecaeea1779d6ac5",
"index": 8412,
"step-1": "<mask token>\n\n\nclass LogisticsPlanningTool(Document):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass LogisticsPlanningTool(Document):\n\n def autoname(self):\n if self.customer:\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def setup():
global capture
createCanvas(390, 240)
capture = createCapture(VIDEO)
capture.size(320, 240)
def draw():
background(255)
image(capture, 0, 0, 320, 240)
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def s... | flexible | {
"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
] |
input("")
things = []
class thing():
def __init__(self, loc, mass = 1, xrad = 1, yrad = 1):
global things
things += [self]
self.location = loc
self.gravity = [0, -0.5]
self.__velocity = [0, 0]
self.mass = mass
self.xrad = xrad
self.yrad = yrad
self.immobile = False
self.collidab... | normal | {
"blob_id": "0afb07d9b48ec91909aac6782dd3cf2fbe388fb4",
"index": 2834,
"step-1": "input(\"\")\r\nthings = []\r\n\r\nclass thing():\r\n\tdef __init__(self, loc, mass = 1, xrad = 1, yrad = 1):\r\n\t\tglobal things\r\n\t\tthings += [self]\r\n\t\t\r\n\t\tself.location = loc\r\n\t\tself.gravity = [0, -0.5]\r\n\t\tse... | [
0
] |
import time
import pytest
from pytest_bdd import scenarios, given, when, then
from conf import Constants
from page_components.page import PageComponent
from page_components.overall import OverallPage
# Scenarios
scenarios('overall_rating.feature', features_base_dir=Constants.FEATURE_FILES_BASE_DIR)
# Fixtures
... | normal | {
"blob_id": "2809ed3a5ea1e527609e169bca1440e0db2761b9",
"index": 8408,
"step-1": "<mask token>\n\n\n@pytest.fixture\ndef home_page(getBrowser):\n aHome = HomePage(getBrowser)\n return aHome\n\n\n@pytest.fixture\ndef overall_page(getBrowser):\n aOverall = OverallPage(getBrowser)\n return aOverall\n\n\... | [
14,
15,
17,
18,
19
] |
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import xml.etree.ElementTree as ET
tree = ET.parse('iliad1.xml')
root = tree.getroot()
file = open('iliad1_clean.txt','w')
for l in root.iter('l'):
file.write(''.join(l.itertext()) + "\n")
file.close() | normal | {
"blob_id": "cfea7848dfb41c913e5d8fec2f0f4f8afaaa09f3",
"index": 5928,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nreload(sys)\nsys.setdefaultencoding('utf-8')\n<mask token>\nfor l in root.iter('l'):\n file.write(''.join(l.itertext()) + '\\n')\nfile.close()\n",
"step-3": "<mask token>\nreload(sys... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: WuTian
# @Date : 2018/5/3
# @Contact : jsj0804wt@126.com
# @Desc :使用广度优先搜索查找芒果商
from collections import deque
graph = {}
graph["you"] = ["alice", "bob", "claire"]
graph["bob"] = ["anuj", "peggy"]
graph["alice"] = ["peggy"]
graph["claire"] = ["thom", "jonny"]
g... | normal | {
"blob_id": "e881fcfce933d8f3bafcbaab039ddcf98827bf5e",
"index": 4244,
"step-1": "<mask token>\n\n\ndef is_mango_seller(name):\n return name[-1] == 'm'\n\n\ndef search_mango_seller(name):\n search_queue = deque()\n searched = []\n global graph\n search_queue += graph[name]\n while search_queue:... | [
2,
3,
4,
5,
6
] |
from package.pack import *
add(2, 2)
sub(2, 3)
| normal | {
"blob_id": "9583a97ae4b1fbf5ecdf33d848b13bf0b28d2eb4",
"index": 2452,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadd(2, 2)\nsub(2, 3)\n",
"step-3": "from package.pack import *\nadd(2, 2)\nsub(2, 3)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
from collections import defaultdict as dd
def grouping(w):
d = dd(list)
for k, v in ((len([y for y in x if y.isupper()]), x) for x in sorted(w,
key=str.casefold)):
d[k].append(v)
return dict(sorted(d.items()))
| normal | {
"blob_id": "545794cf4f0b2ab63b6a90951a78f8bdaca3c9e6",
"index": 390,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef grouping(w):\n d = dd(list)\n for k, v in ((len([y for y in x if y.isupper()]), x) for x in sorted(w,\n key=str.casefold)):\n d[k].append(v)\n return dict(so... | [
0,
1,
2
] |
import world
import items
class Quest:
def __init__(self):
raise NotImplementedError("Do not create raw quest classes")
def __str__(self):
return self.quest_name
def give_reward(self, player):
print("You receive: \n{} gold\n{} exp".format(self.reward_gold, self.reward_exp))
for item in self.reward_it... | normal | {
"blob_id": "4d31985cf1266619406d79a7dbae269c10f21bda",
"index": 5510,
"step-1": "<mask token>\n\n\nclass Quest:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass NoobQuest(Quest):\n\n def __init__(self):\n self.quest_status = 0\n self.quest_name = 'Kill the Rat!'\n self.re... | [
5,
6,
8,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
print('Hello', end='')
print(', my name ', end='')
print('is B-max', end='')
print()
for i in range(40):
print('*', end='')
print()
for i in range(20):
print('x*', end='')
print()
for i in range(5):
for i in range(5):
print('x*', end='')
... | flexible | {
"blob_id": "41aebc4ee9cb058c3351029773be05cdc4f84ffa",
"index": 7282,
"step-1": "<mask token>\n",
"step-2": "print('Hello', end='')\nprint(', my name ', end='')\nprint('is B-max', end='')\nprint()\nfor i in range(40):\n print('*', end='')\nprint()\nfor i in range(20):\n print('x*', end='')\nprint()\nfor... | [
0,
1,
2
] |
"""
Config module for storage read only disks
"""
from rhevmtests.storage.config import * # flake8: noqa
TEST_NAME = "read_only"
VM_NAME = "{0}_vm_%s".format(TEST_NAME)
VM_COUNT = 2
DISK_NAMES = dict() # dictionary with storage type as key
DISK_TIMEOUT = 600
# allocation policies
SPARSE = True
DIRECT_LUNS = UNUSE... | normal | {
"blob_id": "ecdc8f5f76b92c3c9dcf2a12b3d9452166fcb706",
"index": 1098,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nTEST_NAME = 'read_only'\nVM_NAME = '{0}_vm_%s'.format(TEST_NAME)\nVM_COUNT = 2\nDISK_NAMES = dict()\nDISK_TIMEOUT = 600\nSPARSE = True\nDIRECT_LUNS = UNUSED_LUNS\nDIRECT_LUN_ADDRESSES = U... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class CliKsconfCombineTestCase(unittest.TestCase):
def build_test01(self, twd):
twd.write_file(
'etc/apps/Splunk_TA_aws/default.d/10-upstream/props.conf',
"""
[aws:config]
SHOULD_LINEMERGE = false
TRUNCATE = 8388608
TIME... | flexible | {
"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|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Solution(object):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Solution(object):
def countBits(self, n):
"""
:type n: int
:rtype: List[i... | flexible | {
"blob_id": "4cd1e385d18086b1045b1149d5f4573eaf9270c3",
"index": 6223,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution(object):\n\n def countBits(self, n):\n \"\"\"\n :type n: int\n :rty... | [
0,
1,
2,
3
] |
############################################################
# Hierarchical Reinforcement Learning for Relation Extraction
# Multiprocessing with CUDA
# Require: PyTorch 0.3.0
# Author: Tianyang Zhang, Ryuichi Takanobu
# E-mail: keavilzhangzty@gmail.com, truthless11@gmail.com
###########################################... | normal | {
"blob_id": "699410536c9a195024c5abbcccc88c17e8e095e3",
"index": 6003,
"step-1": "<mask token>\n\n\nclass BotModel(nn.Module):\n\n def __init__(self, dim, statedim, rel_count):\n super(BotModel, self).__init__()\n self.dim = dim\n self.hid2state = nn.Linear(dim * 3 + statedim * 2, statedi... | [
7,
9,
10,
11,
12
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
password = '#Garb1122'
| flexible | {
"blob_id": "918358f6e8e3f1c601b18a3c08fc6b7c024721ba",
"index": 5547,
"step-1": "<mask token>\n",
"step-2": "password = '#Garb1122'\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
def get_analyse(curse):
'''
要求curse数据中index为时间,columns为策略名称,每一列为该策略净值
'''
qf_drawdown = []
qf_yeild = []
qf_std = []
date = curse.index
y = curse.copy()
for i in curse.columns:
# 计算当前日之前的资金曲线最高点
y["max2here"] = y[i].expanding().max()
# 计算历史最高值到... | normal | {
"blob_id": "56d90835e64bd80fd9a6bb3a9b414e154d314d4a",
"index": 5108,
"step-1": "<mask token>\n",
"step-2": "def get_analyse(curse):\n \"\"\"\n 要求curse数据中index为时间,columns为策略名称,每一列为该策略净值\n\n \"\"\"\n qf_drawdown = []\n qf_yeild = []\n qf_std = []\n date = curse.index\n y = curse.copy()\... | [
0,
1,
2
] |
<|reserved_special_token_0|>
def lookup_and_render(request):
try:
dbres = esgfDatabaseManager.lookupUserSubscriptions(request.user)
except Exception as e:
error_cond = str(e)
print(traceback.print_exc())
return render(request, 'cog/subscription/subscribe_done.html', {
... | flexible | {
"blob_id": "d583661accce8c058f3e6b8568a09b4be1e58e4e",
"index": 4877,
"step-1": "<mask token>\n\n\ndef lookup_and_render(request):\n try:\n dbres = esgfDatabaseManager.lookupUserSubscriptions(request.user)\n except Exception as e:\n error_cond = str(e)\n print(traceback.print_exc())\n... | [
4,
5,
6,
7,
8
] |
<|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": "8cd290dc1e682222c97172a0f23e5b93c54838a7",
"index": 2201,
"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 = [('leasing', '... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
'''
Usage:
dep_tree.py [-h] [-v] [-p P] [-m component_map]
repos_root top_dir [top_depfile]
Parse design dependency tree and generate build scripts and other useful files
positional arguments:
repos_root repository root
top_dir top level design directory
top_depfile ... | normal | {
"blob_id": "ccfc78ae430f835244e0618afdeebe960c868415",
"index": 6126,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n lCommandLineArgs = CommandLineParser().parse()\n lPathmaker = Pathmaker(lCommandLineArgs.root, lCommandLineArgs.top,\n lCommandLineArgs.componentmap, lComma... | [
0,
1,
2,
3,
4
] |
from .entity import EventBase, event_class
from .. import LOG as _LOG
LOG = _LOG.getChild('entity.event')
@event_class()
class FunctionCallEvent(EventBase):
"""
function call
"""
deferred = True
def parse_jsondict(self, jsdict):
assert 'func_name' in jsdict['option'], 'func_name required'
... | normal | {
"blob_id": "9a665d126d7b48adbd876b48c3d8806eabea1108",
"index": 3716,
"step-1": "<mask token>\n\n\n@event_class()\nclass FunctionCallEvent(EventBase):\n <mask token>\n <mask token>\n <mask token>\n\n\n@event_class()\nclass PacketEvent(EventBase):\n \"\"\"\n L7 packet message\n \"\"\"\n defe... | [
11,
12,
13,
15,
17
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 17/02/17 at 11:48 PM
@author: neil
Program description here
Version 0.0.1
"""
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
import sys
# detect python version
# if python 3 do this:
if (sys.version_info > (3, 0)):
import tkint... | normal | {
"blob_id": "1576693264a334153c2752ab6b3b4b65daa7c37c",
"index": 8928,
"step-1": "<mask token>\n\n\nclass Add_Buttons(object):\n <mask token>\n\n def validate_inputs(self):\n try:\n self.button_labels = list(self.button_labels)\n for it in self.button_labels:\n i... | [
6,
8,
9,
10,
13
] |
<|reserved_special_token_0|>
def test_url():
dymo = Dymo()
assert dymo.uri == 'https://127.0.0.1:41951/DYMO/DLS/Printing'
def test_status():
dymo = Dymo()
status = dymo.get_status()
assert isinstance(status, dict)
assert status['status_code'] == 200
<|reserved_special_token_0|>
def test_... | flexible | {
"blob_id": "766098753ec579e2d63893fcbd94e8819b46bc0b",
"index": 6867,
"step-1": "<mask token>\n\n\ndef test_url():\n dymo = Dymo()\n assert dymo.uri == 'https://127.0.0.1:41951/DYMO/DLS/Printing'\n\n\ndef test_status():\n dymo = Dymo()\n status = dymo.get_status()\n assert isinstance(status, dict... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def get_extensions():
libraries = []
sources = []
sources.append(os.path.join(REPROJECT_ROOT, '_overlap.c'))
sources.append(os.path.join(REPROJECT_ROOT, 'overlapArea.c'))
sources.append(os.path.join(REPROJECT_ROOT, 'reproject_slice_c.c'))
include_dirs = ['numpy']
... | flexible | {
"blob_id": "ad079876476f6f291ad52aece8d0d5afdd5a8bcf",
"index": 9892,
"step-1": "<mask token>\n\n\ndef get_extensions():\n libraries = []\n sources = []\n sources.append(os.path.join(REPROJECT_ROOT, '_overlap.c'))\n sources.append(os.path.join(REPROJECT_ROOT, 'overlapArea.c'))\n sources.append(os... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python
# coding: utf-8
import time
class Timer(object):
def __init__(self):
self.time_ = 0.
self.start_ = 0.
def reset(self):
self.time_ = 0.
self.start_ = 0.
def start(self):
self.start_ = time.clock()
def end(self):
self.time_ += time... | normal | {
"blob_id": "0cf5b009f384d2ca7162b5a88699afb3702ae1f6",
"index": 1147,
"step-1": "<mask token>\n\n\nclass Timer(object):\n <mask token>\n\n def reset(self):\n self.time_ = 0.0\n self.start_ = 0.0\n\n def start(self):\n self.start_ = time.clock()\n\n def end(self):\n self.t... | [
4,
5,
6,
7,
8
] |
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 차트에 한글 가능하도록
from matplotlib import font_manager, rc, rcParams
font_name = font_manager.FontProperties(
fname="c:/windows/Fonts/malgun.ttf").get_name()
rc('font',family=font_name)... | normal | {
"blob_id": "fb82724aab7e0819c9921d41dcb612b304b25753",
"index": 9723,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nrc('font', family=font_name)\n<mask token>\nprint(df1)\ndf1.plot()\nplt.show()\n",
"step-3": "<mask token>\nfont_name = font_manager.FontProperties(fname='c:/windows/Fonts/malgun.ttf'\n... | [
0,
1,
2,
3,
4
] |
# Copyright 2020 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": "eb50f50e3c072c2f6e74ff9ef8c2fa2eef782aae",
"index": 6718,
"step-1": "<mask token>\n\n\ndef adj_to_bias(adj):\n \"\"\"Add self loop to adj and make sure only one hop neighbors are engaged in computing\"\"\"\n num_graphs = adj.shape[0]\n adj_temp = np.empty(adj.shape)\n for i in range(num_... | [
2,
3,
4,
5,
6
] |
# Interprets the AST
class Program:
def __init__(self, code):
self.code = code
def eval(self, binding):
return self.code.eval(binding)
class Code:
def __init__(self, statements):
self.statements = statements
def eval(self, binding):
val = 0
for statement in ... | normal | {
"blob_id": "5fa91a5061a5e87a4a2b8fece0378299e87e5a48",
"index": 6694,
"step-1": "<mask token>\n\n\nclass Binding:\n\n def __init__(self, parent, binding):\n self.parent = parent\n self.binding = binding\n <mask token>\n\n def add(self, var_name, value):\n self.binding[var_name] = v... | [
42,
50,
56,
68,
73
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
def isBalanced(self, root: TreeNode) ->bool:
self.mem = dict()
if root is None:
return True
... | flexible | {
"blob_id": "9e98a361ef20049cba488b86ad06eb92b3d29d11",
"index": 3584,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n <mask token>\n",
"step-3": "class Solution:\n\n def isBalanced(self, root: TreeNode) ->bool:\n self.mem = dict()\n if root is None:\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class Load(Command):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def find_groupname(self, g, s):
tries = 0
while True:
groups = s.groups()
if g not in groups:
return g
... | flexible | {
"blob_id": "eb5256543d6095668d6eeaf6cfdc9f744d7c73c5",
"index": 2267,
"step-1": "<mask token>\n\n\nclass Load(Command):\n <mask token>\n <mask token>\n <mask token>\n\n def find_groupname(self, g, s):\n tries = 0\n while True:\n groups = s.groups()\n if g not in g... | [
2,
3,
5,
6,
7
] |
# coding=utf-8
# pylint: disable=too-many-lines
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRe... | normal | {
"blob_id": "fb258521fdfded0062cbe30651268bf5410d3384",
"index": 9864,
"step-1": "<mask token>\n\n\nclass KnowledgeBaseAnswer(_serialization.Model):\n \"\"\"Represents knowledge base answer.\n\n :ivar questions: List of questions associated with the answer.\n :vartype questions: list[str]\n :ivar ans... | [
36,
37,
51,
56,
72
] |
import re
import datetime
from django import forms
from django.utils.translation import ugettext as _
from vcg.util.forms import mobile_number_validation
from vcg.company_management.models import ConfigurationContact, ConfigurationLogo, ConfigurationHomepage, ConfigurationLocation
class ConfigurationContactForm(for... | normal | {
"blob_id": "f6f1cd95e4aaa5e434c3cf3cff0d46b45fc7b830",
"index": 6190,
"step-1": "<mask token>\n\n\nclass ConfigurationContactForm(forms.ModelForm):\n\n\n class Meta:\n model = ConfigurationContact\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def clean_phone_number_ext... | [
11,
13,
15,
16,
18
] |
<|reserved_special_token_0|>
def get_course_by_id(course_id):
return Course.query.filter_by(id=course_id).first()
<|reserved_special_token_0|>
def create_course(subject_code, course_num, title):
optional_course = get_course_by_subject_and_course_num(subject_code,
course_num)
if optional_course... | flexible | {
"blob_id": "b3f0aae91c885d0e15ff3e456b5cab43fca65b67",
"index": 4184,
"step-1": "<mask token>\n\n\ndef get_course_by_id(course_id):\n return Course.query.filter_by(id=course_id).first()\n\n\n<mask token>\n\n\ndef create_course(subject_code, course_num, title):\n optional_course = get_course_by_subject_and... | [
4,
5,
6,
7,
8
] |
a, b = input().split()
def test_input_text(expected_result, actual_result):
assert expected_result == actual_result, \
f'expected {expected_result}, got {actual_result}'
test_input_text(a,b)
| normal | {
"blob_id": "63391b31d1746f9b3583df5353ae160a430943a9",
"index": 9027,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_input_text(expected_result, actual_result):\n assert expected_result == actual_result, f'expected {expected_result}, got {actual_result}'\n\n\n<mask token>\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
def generateMatrix(self, n):
"""
与 54 思路类似,注意边界...
:type n: int
:rtype: List[List[int]]
"""
array = [[(0)... | flexible | {
"blob_id": "f6bfb055e1c1750702580fc9c9295b8528218910",
"index": 7416,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def generateMatrix(self, n):\n \"\"\"\n 与 54 思路类似,注意边界...\n :type n: int\n :rtype: List[List[in... | [
0,
1,
2,
3
] |
num = int(input())
bull_str = input().split(' ')
bull_list = []
for i in range(len(bull_list)):
bull_list.append(int(bull_str[i]))
flag = 0
while True:
flag += 1
for i in range(len(bull_list)):
if bull_list[i] == 1:
for j in range(bull_list.index(bull_list[i]), len(bull_list)):
... | normal | {
"blob_id": "4d30f4294a9f3aab8cae20dca9d280c53b37ed25",
"index": 1471,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(len(bull_list)):\n bull_list.append(int(bull_str[i]))\n<mask token>\nwhile True:\n flag += 1\n for i in range(len(bull_list)):\n if bull_list[i] == 1:\n ... | [
0,
1,
2
] |
"""
bubble sort
start at beginning switch to left if smaller - very naive approach
n-1 comparisons, n-1 iterations
(n-1)^2
worst case: O(n^2) = average case
best case: O(n)
space complexity: O(1)
"""
def bubbleSort(list):
for num in range(len(list)-1,0,-1):
for i in range(num):
if list[i] > list... | normal | {
"blob_id": "29c25721a4754650f0d5d63d6cc3215cb0ea1b3e",
"index": 7849,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef bubbleSort(list):\n for num in range(len(list) - 1, 0, -1):\n for i in range(num):\n if list[i] > list[i + 1]:\n temp = list[i]\n ... | [
0,
1,
2,
3,
4
] |
# phase 3 control unit
#Dennis John Salewi,Olaniyi Omiwale, Nobert Kimario
from MIPSPhase1 import BoolArray
class RegisterFile:
def __init__(self):
# The register file is a list of 32 32-bit registers (BoolArray)
# register 29 is initialized to "000003E0" the rest to "00000000"
# an instanc... | normal | {
"blob_id": "1913bbffd8c3c9864a8eeba36c6f06e30d2dd2c8",
"index": 4740,
"step-1": "<mask token>\n\n\nclass RegisterFile:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Memory:\n\n def __init__(self):\n self.dicti = {}\n for i in range(0, 1021)... | [
7,
10,
11,
13,
15
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ユークリッド距離
# http://en.wikipedia.org/wiki/Euclidean_space
# 多次元空間中での 2 点間の距離を探索する
def euclidean(p,q):
sumSq=0.0
# 差の平方を加算
for i in range(len(p)):
sumSq+=(p[i]-q[i])**2
# 平方根
return (sumSq**0.5)
#print euclidean([3,4,5],[4,5,6])
| normal | {
"blob_id": "11a7ebac3dad1f91a6d46b62f557b51ded8e3d7a",
"index": 1271,
"step-1": "<mask token>\n",
"step-2": "def euclidean(p, q):\n sumSq = 0.0\n for i in range(len(p)):\n sumSq += (p[i] - q[i]) ** 2\n return sumSq ** 0.5\n",
"step-3": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# ユーク... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
d.text(xy=(320, 420), text=text, font=fnt, fill=(0, 0, 0))
img.save(text + '.png')
<|reserved_special_token_1|>
<|reserved_special_token_0|>
img = Image.new('RGB', (1024, 1024), color=(255, 255, 255))
text = sys.argv[1]
fnt = I... | flexible | {
"blob_id": "053fa80c80d40cd28acb7d6a8bf1b2c30be9b36e",
"index": 7786,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nd.text(xy=(320, 420), text=text, font=fnt, fill=(0, 0, 0))\nimg.save(text + '.png')\n",
"step-3": "<mask token>\nimg = Image.new('RGB', (1024, 1024), color=(255, 255, 255))\ntext = sys.... | [
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.