code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
<|reserved_special_token_0|>
class StudentMotionPlanner(GreedyBestFirstSearch):
<|reserved_special_token_0|>
def __init__(self, scenario, planningProblem, automata, plot_config=
DefaultPlotConfig):
super().__init__(scenario=scenario, planningProblem=planningProblem,
automaton=auto... | flexible | {
"blob_id": "6ecbe119c8a14776373d165dc05e81f91084893c",
"index": 4229,
"step-1": "<mask token>\n\n\nclass StudentMotionPlanner(GreedyBestFirstSearch):\n <mask token>\n\n def __init__(self, scenario, planningProblem, automata, plot_config=\n DefaultPlotConfig):\n super().__init__(scenario=scen... | [
9,
11,
12,
13,
17
] |
<|reserved_special_token_0|>
class Sliders(timelapse.TimeLapse):
def __init__(self, server_list, nick='Sliders', channel='#sliders',
realname='Sliders', sliding_window=60, **params):
super().__init__(server_list, nick=nick, channel=channel, **params)
self.lapsed = merge(self.lapsed, slidi... | flexible | {
"blob_id": "c651d49c98a4cf457c8252c94c6785dea8e9af60",
"index": 3909,
"step-1": "<mask token>\n\n\nclass Sliders(timelapse.TimeLapse):\n\n def __init__(self, server_list, nick='Sliders', channel='#sliders',\n realname='Sliders', sliding_window=60, **params):\n super().__init__(server_list, nick... | [
3,
4,
5,
6,
7
] |
import pygame
class BackGround:
def __init__(self, x, y):
self.y = y
self.x = x
def set_image(self, src):
self.image = pygame.image.load(src)
self.rect = self.image.get_rect()
self.rect.y = self.y
self.rect.x = self.x
def draw(self, screen):
scree... | normal | {
"blob_id": "071e3cf6b4337e0079bbb2c7694fff2468142070",
"index": 6505,
"step-1": "<mask token>\n\n\nclass BackGround:\n\n def __init__(self, x, y):\n self.y = y\n self.x = x\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass BackGround:\n\n def __init__(self, x, y):\... | [
2,
3,
4,
5
] |
#!/C:\Program Files (x86)\Python35-32
#importar librarias necesarias
from urllib.request import urlopen
from bs4 import BeautifulSoup
| normal | {
"blob_id": "7a59c8c883a9aaa723175783e01aa62e23503fde",
"index": 376,
"step-1": "<mask token>\n",
"step-2": "from urllib.request import urlopen\nfrom bs4 import BeautifulSoup\n",
"step-3": "#!/C:\\Program Files (x86)\\Python35-32\n\n#importar librarias necesarias\nfrom urllib.request import urlopen\nfrom bs4... | [
0,
1,
2
] |
from abc import ABC, abstractmethod
class DatasetFileManager(ABC):
@abstractmethod
def read_dataset(self):
pass
| normal | {
"blob_id": "5ef65ace397be17be62625ed27b5753d15565d61",
"index": 555,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass DatasetFileManager(ABC):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass DatasetFileManager(ABC):\n\n @abstractmethod\n def read_dataset(self):\n pass\n",... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class MyGame(arcade.Window):
def __init__(self, width, height, title):
super().__init__(width, height, title)
self.drawer = 0
self.wardrobe = 0
self.bookshelves = 0
self.door = 0
self.bed = 0
self.book_1 = 0
self.book_2 ... | flexible | {
"blob_id": "37d079ca6a22036e2660507f37442617d4842c4e",
"index": 4060,
"step-1": "<mask token>\n\n\nclass MyGame(arcade.Window):\n\n def __init__(self, width, height, title):\n super().__init__(width, height, title)\n self.drawer = 0\n self.wardrobe = 0\n self.bookshelves = 0\n ... | [
6,
8,
12,
13,
15
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 25 19:21:32 2019
@author: Nikos
"""
import torch
import torch.optim as optim
from utilities import *
from model import *
from torch.autograd import Variable
import numpy as np
import random
class A2C_agent(object):
def __init__(self, env, actor_h... | normal | {
"blob_id": "72b086e833ab3ee4ec3102869d74513ef3657675",
"index": 1926,
"step-1": "<mask token>\n\n\nclass A2C_agent(object):\n <mask token>\n\n def act(self, state):\n action_distribution = self.actor_network.forward(state)\n action = np.random.choice(self.num_of_actions, p=\n acti... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
setup(name='qn', version='0.2.2', description=
'Handy functions I use everyday.', url='https://github.com/frlender/qn',
author='Qiaonan Duan', author_email='geonann@gmail.com', license='MIT',
packages=find_packages(), ... | flexible | {
"blob_id": "3b307ae7f8b8b25c93eb2dc54b2603b1291b6232",
"index": 1789,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='qn', version='0.2.2', description=\n 'Handy functions I use everyday.', url='https://github.com/frlender/qn',\n author='Qiaonan Duan', author_email='geonann@gmail.com', ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def load_stations(filename):
with open(filename, 'r') as f:
sta_data = f.readlines()
sta_list = []
for l in range(1, len(sta_data)):
sta_info = sta_data[l]
net_name = re.split(',', sta_info)[0]
sta_name = re.split(',', sta_info)[1]
chan_... | flexible | {
"blob_id": "34db3c9998e1d7647dd954e82e18147504cc74fc",
"index": 6736,
"step-1": "<mask token>\n\n\ndef load_stations(filename):\n with open(filename, 'r') as f:\n sta_data = f.readlines()\n sta_list = []\n for l in range(1, len(sta_data)):\n sta_info = sta_data[l]\n net_name = re.s... | [
3,
5,
6,
7,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def main(args):
init_logging()
records = []
def handler(stats):
records.append(stats)
data_dir = args.data_dir or os.environ.get('HAIL_BENCHMARK_DIR'
) or '/tmp/hail_benchmark_data'
profiler_... | flexible | {
"blob_id": "d4625dd743dd6648044e40b02743ae80f4caea36",
"index": 9572,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(args):\n init_logging()\n records = []\n\n def handler(stats):\n records.append(stats)\n data_dir = args.data_dir or os.environ.get('HAIL_BENCHMARK_DIR'\n ... | [
0,
1,
2,
3,
4
] |
#Main program:
#reads IMU data from arduino uart
#receives PS3 Controller input
#Mantains Controller input frequency with CST
#!/usr/bin/env python
from map import mapControllerToDeg
from map import constrain
from map import wrap_180
from map import motorOutputLimitHandler
from uart1 import IMUDevice
import socket
fro... | normal | {
"blob_id": "5626e5a4a448630fbbbc92a67ae08f3ed24e1b9e",
"index": 4417,
"step-1": "#Main program:\n#reads IMU data from arduino uart\n#receives PS3 Controller input\n#Mantains Controller input frequency with CST\n\n#!/usr/bin/env python\nfrom map import mapControllerToDeg\nfrom map import constrain\nfrom map impo... | [
0
] |
def check(root, a, b):
if root:
if (root.left == a and root.right == b) or (root.left ==b and root.right==a):
return False
return check(root.left, a, b) and check(root.right, a, b)
return True
def isCousin(root, a, b):
# Your code here
if check(root, a, b)==False:
ret... | normal | {
"blob_id": "96cfee85194c9c30b3d74bbddc2a31b6933eb032",
"index": 2226,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef isCousin(root, a, b):\n if check(root, a, b) == False:\n return False\n q = []\n q.insert(0, root)\n tmp = set()\n while len(q):\n l = len(q)\n ... | [
0,
1,
2,
3
] |
import BlockDeviceHandler
import json
import LocalMachine
import os
""" This module automaticly format the disk based on diskconf.json """
def module_print(text):
print_text = "[ autoformat disk ] " + str(text)
print(print_text)
def parse_config_file_from_disk(path, confname="diskconf.json"):
json_path =... | normal | {
"blob_id": "927470fe0087b17e5fe67a9b8b3cc13a40d8be1a",
"index": 7554,
"step-1": "<mask token>\n\n\ndef parse_config_file_from_disk(path, confname='diskconf.json'):\n json_path = str(path) + '/' + str(confname)\n if not os.path.exists(json_path):\n module_print('\\tPath not exists: ' + str(json_path... | [
7,
8,
9,
10,
11
] |
<|reserved_special_token_0|>
class Function:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def foward(self, x):
raise NotImplementedError()
class Square(Function):
def foward(self, x):
return x ** 2
class Exp(Function):
def foward(self, x):
return np.exp(... | flexible | {
"blob_id": "9efd83524ebb598f30c8fb6c0f9f0c65333578e6",
"index": 6292,
"step-1": "<mask token>\n\n\nclass Function:\n <mask token>\n <mask token>\n\n def foward(self, x):\n raise NotImplementedError()\n\n\nclass Square(Function):\n\n def foward(self, x):\n return x ** 2\n\n\nclass Exp(F... | [
6,
10,
11,
12,
14
] |
# 라이브러리 환경
import pandas as pd
import numpy as np
# sklearn 테이터셋에서 iris 데이터셋 로딩
from sklearn import datasets
iris = datasets.load_iris()
# iris 데이터셋은 딕셔너리 형태이므로, key 값 확인
'''
print(iris.keys())
print(iris['DESCR'])
print("데이터 셋 크기:", iris['target'])
print("데이터 셋 내용:\n", iris['target'])
'''
# data 속성의 데이터셋 크기
print("... | normal | {
"blob_id": "dc2c9293040204f0ec2156c41b8be624f4e5cf99",
"index": 8389,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('데이터 셋 크기:', iris['data'].shape)\n<mask token>\nprint(type(data1))\n<mask token>\nprint(df)\n<mask token>\nprint('데이터셋 내용:\\n', iris['data'][:7, :])\n<mask token>\nprint('데이터 프레임의 형... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.s... | normal | {
"blob_id": "65264f52f641b67c707b6a827ecfe1bf417748e8",
"index": 2379,
"step-1": "<mask token>\n\n\nclass Ui_MainWindow(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Ui_MainWindow(object):\n\n def setupUi(self, MainWindow):\n MainWindow.setObjectName('MainWindow'... | [
1,
2,
3,
4,
5
] |
# hw.shin@konantech.com
#leekiljae@ogqcorp.com | normal | {
"blob_id": "193d48237b4b1e406eb565943cf01f0423449fca",
"index": 3682,
"step-1": "# hw.shin@konantech.com\n#leekiljae@ogqcorp.com",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
1
]
} | [
1
] |
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import copy
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from .. import _ut... | normal | {
"blob_id": "2332783c96b24caa383bf47d82384e1c40a48e94",
"index": 8566,
"step-1": "<mask token>\n\n\n@pulumi.input_type\nclass DashboardArgs:\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... | [
14,
21,
22,
23,
28
] |
from numpy.testing import assert_almost_equal
from fastats.maths.norm_cdf import norm_cdf
def test_norm_cdf_basic_sanity():
assert_almost_equal(0.5, norm_cdf(0.0, 0, 1))
def test_norm_cdf_dartmouth():
"""
Examples taken from:
https://math.dartmouth.edu/archive/m20f12/public_html/matlabnormal
sto... | normal | {
"blob_id": "0229783467b8bcd0361baf6be07e3261f34220c7",
"index": 6581,
"step-1": "<mask token>\n\n\ndef test_norm_cdf_dartmouth():\n \"\"\"\n Examples taken from:\n https://math.dartmouth.edu/archive/m20f12/public_html/matlabnormal\n stored in literature directory as dartmouth_normcdf_norminv.pdf\n ... | [
1,
2,
3,
4
] |
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import cv2
import imageio
import pandas as pd
import glob, os
import numpy as np
fileDir = os.getcwd()
# os.chdir("./train-jpg")
# there are 40480 training examples
# we will allocate 39000 for training
# and the remaining ... | normal | {
"blob_id": "a4deb67d277538e61c32381da0fe4886016dae33",
"index": 85,
"step-1": "<mask token>\n\n\nclass Net(nn.Module):\n\n def __init__(self, input_size, hidden_size, num_classes):\n super(Net, self).__init__()\n self.h1 = nn.Linear(input_size, hidden_size)\n self.h2 = nn.Linear(hidden_s... | [
3,
4,
5,
6,
7
] |
# Formatters example
#
# Requirements:
# Go to the ../hello_world directory and do: python prepare_data.py
#
# Instructions:
#
# Just run this file:
#
# python table.py
# Output:
# * standard input – text table
# * table.html
# * cross_table.html
#
from cubes import Workspace, create_forma... | normal | {
"blob_id": "55e743cb027d27cc6b668424c1584f27a8e8c51a",
"index": 5707,
"step-1": "# Formatters example\n#\n# Requirements:\n# Go to the ../hello_world directory and do: python prepare_data.py\n#\n# Instructions:\n#\n# Just run this file:\n#\n# python table.py\n# Output:\n# * standard inp... | [
0
] |
<|reserved_special_token_0|>
def manage_prev_page():
global session, request
if ('profile' not in request.referrer and 'change_password' not in
request.referrer and 'forgot_password' not in request.referrer and
'request_password' not in request.referrer):
session['prev_page'] = reques... | flexible | {
"blob_id": "4e66fe0485d987da590d11c848009b2e1665b3dc",
"index": 5445,
"step-1": "<mask token>\n\n\ndef manage_prev_page():\n global session, request\n if ('profile' not in request.referrer and 'change_password' not in\n request.referrer and 'forgot_password' not in request.referrer and \n 'r... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
slaves = []
<|reserved_special_token_1|>
# -*- python -*-
# ex: set syntax=python:
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# See... | flexible | {
"blob_id": "e807cef534226f3efb4a8df471598727fa068f02",
"index": 3805,
"step-1": "<mask token>\n",
"step-2": "slaves = []\n",
"step-3": "# -*- python -*-\n# ex: set syntax=python:\n\n# Copyright (c) 2012 The Chromium Authors. All rights reserved.\n# Use of this source code is governed by a BSD-style license ... | [
0,
1,
2
] |
import json
import time
from typing import Dict
import threading
"""
Note: każdy request uruchamia osobny wątek.
Przegląd: `top -H -p <process_id>`
"""
from flask import Flask, jsonify, request
app = Flask(__name__)
# https://www.tutorialspoint.com/flask/flask_http_methods.htm
# ładowanie konfiguracji aplika... | normal | {
"blob_id": "8fcc2a13fd5a803e2d755a567c78c8274bd88aad",
"index": 7283,
"step-1": "<mask token>\n\n\nclass Auth:\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\n@app.route('/welcome/<username>/suffix/<message>')\ndef welcome(username, message):\n return jsonify({'comment': f'Hello {usern... | [
1,
3,
6,
9,
10
] |
# encoding:utf-8
import tensorflow as tf
import p182.py as p182
# 创建文件列表,并通过文件列表创建输入文件队列。在调用输入数据处理流程前,需要
# 统一所有原始数据的格式并将它们存储到TFRcord文件中。下面给出的文件列表应该包含所
# 有提供训练数据的TFRcord文件
files = tf.train.match_filenames_once("/home/shenxj/tf-work/datasets/file_pattern-*")
filename_queue = tf.train.string_input_producer(files, shuffle=... | normal | {
"blob_id": "1685a2c49bea14e6fcaffb03634f6875f8fa1049",
"index": 3726,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndecoded_image.set_shape([height, width, channels])\n<mask token>\nwith tf.Session() as sess:\n tf.initialize_all_variables().run()\n coord = tf.train.Coordinator()\n threads = tf... | [
0,
1,
2,
3,
4
] |
class Background(object):
def __init__(self, name):
self.name = name
self.description = ''
self.prTraits = []
self.ideals = []
self.bonds = []
self.flaws = []
def getBackName(self):
return self.name
def setBackDesc(self,desc):
self.descriptio... | normal | {
"blob_id": "45449e728dadd241b00f5c4bfb3fd3950f04037c",
"index": 2627,
"step-1": "class Background(object):\n\n def __init__(self, name):\n self.name = name\n self.description = ''\n self.prTraits = []\n self.ideals = []\n self.bonds = []\n self.flaws = []\n\n def ... | [
11,
13,
14,
15,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def main(req: func.HttpRequest) ->func.HttpResponse:
return func.HttpResponse(body=json.dumps(cosmos_client.DB.Goals),
mimetype='application/json', charset='utf-8')
<|reserved_special_token_1|>
import azure.functi... | flexible | {
"blob_id": "e38be2890526c640ba8d9db5a376ff57ba9e0aa2",
"index": 8703,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(req: func.HttpRequest) ->func.HttpResponse:\n return func.HttpResponse(body=json.dumps(cosmos_client.DB.Goals),\n mimetype='application/json', charset='utf-8')\n",
... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def hexStringtoBytes(hexstring):
byteArray = bytes.fromhex(hexstring)
return byteArray
def xorBytes(bytes1, bytes2):
xored = bytes([(x ^ bytes2[i]) for i, x in enumerate(bytes1)])
return xored
<|reserved_special_token_0|>
def scoreString(input):
arr = [(chr(x) in... | flexible | {
"blob_id": "a32fb683f8d46f901e8dcd2d075ace22ee81e076",
"index": 451,
"step-1": "<mask token>\n\n\ndef hexStringtoBytes(hexstring):\n byteArray = bytes.fromhex(hexstring)\n return byteArray\n\n\ndef xorBytes(bytes1, bytes2):\n xored = bytes([(x ^ bytes2[i]) for i, x in enumerate(bytes1)])\n return xo... | [
3,
4,
5,
6,
7
] |
import discord, requests
from random import choice
TOKEN = 'TOKEN'
CONTACT_EMAIL = None #'Contact email for getting 10000 words/day instead of 1000'
translate_command = '$t'
id_start = '<@!'
client = discord.Client()
def unescape(text):
return text.replace(''', '\'').replace('<','<').replace(... | normal | {
"blob_id": "1ab69874a89311b22220dda541dfe03462a98a55",
"index": 2243,
"step-1": "<mask token>\n\n\ndef unescape(text):\n return text.replace(''', \"'\").replace('<', '<').replace('>', '>')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef unescape(text):\n return text.replace(''', \"'... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class simple_drawing_window1(simple_drawing_window):
<|reserved_special_token_0|>
def paintEvent(self, e):
p = QPainter()
p.begin(self)
"""
p.setPen(QColor(0,0,0))
p.setBrush(QColor(0,127,0))... | flexible | {
"blob_id": "6fc43919f521234d0dc9e167bb72f014e9c0bf17",
"index": 2102,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass simple_drawing_window1(simple_drawing_window):\n <mask token>\n\n def paintEvent(self, e):\n p = QPainter()\n p.begin(self)\n \"\"\"\n\t\tp.setPen(QCo... | [
0,
2,
3,
4,
5
] |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
import os
from solid import *
from solid.utils import *
from shapes import *
import sys
# Assumes SolidPython is in site-packages or elsewhwere in sys.path
from solid import *
from solid.utils import *
def voxels():
# shape = cube([1,... | normal | {
"blob_id": "27ca60435c614e4d748917da45fc2fc75ee59f1c",
"index": 1682,
"step-1": "<mask token>\n\n\ndef voxels():\n shape = []\n for x in range(-5, 4, 1):\n for y in range(-5, 4, 1):\n for z in range(0, 10, 1):\n translate([x, y, z])\n new_cube = color([0, 0,... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
@csrf_exempt
def create(request):
if request.method == 'POST':
json_data = request.body
stream = io.BytesIO(json_data)
pythondata = JSONParser().parse(stream)
serializer = StudentSerializer(data=pythondata)
if serializer.is_valid():
... | flexible | {
"blob_id": "99785ffb4b594db1fac05ca3d3f5764151b2b7b6",
"index": 103,
"step-1": "<mask token>\n\n\n@csrf_exempt\ndef create(request):\n if request.method == 'POST':\n json_data = request.body\n stream = io.BytesIO(json_data)\n pythondata = JSONParser().parse(stream)\n serializer = ... | [
1,
2,
3,
4,
5
] |
from model import *
from data import *
import os
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix
data_gen_args = dict(horizontal_flip = True,
vertical_flip = True)
imageTargetSize = (256, 256)
trainPath = '/work/scratch/zhangbin/EmbryoTracking_ClaireBinZhang/Motili... | normal | {
"blob_id": "ba379ed90bccd05d058f69f33a960779f8b8bcd5",
"index": 5632,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsaveResult(\n '/work/scratch/zhangbin/EmbryoTracking_ClaireBinZhang/MotilityAnalysis/20160317 10 dpf 60 fps 15 min (2)/here'\n , results)\n<mask token>\nplt.plot(epoch_count, traini... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def update_mode(args):
"""
This method is the main method for running this program in Update mode.
Update mode takes in a specifically formated XLSX file and outputs a JSON
file containing all of the data for races and subraces needed by the
program in run mode
A... | flexible | {
"blob_id": "022c8d6c31ad5494b03bfe93d17396eac25b011e",
"index": 8706,
"step-1": "<mask token>\n\n\ndef update_mode(args):\n \"\"\"\n This method is the main method for running this program in Update mode.\n\n Update mode takes in a specifically formated XLSX file and outputs a JSON\n file containing... | [
2,
3,
4,
5,
6
] |
import requests
import json
data = json.load(open("dummy_data/data.json"))
for one in data:
print(one)
r = requests.post("http://localhost:8080/sumari", json=one)
print(r.text)
| normal | {
"blob_id": "8bc40ed4fe1091ecdb40cd55ff9cf53010078823",
"index": 361,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor one in data:\n print(one)\n r = requests.post('http://localhost:8080/sumari', json=one)\n print(r.text)\n",
"step-3": "<mask token>\ndata = json.load(open('dummy_data/data.j... | [
0,
1,
2,
3,
4
] |
import os
# didnt endup using this
import time
# from django.contrib.gis.utils import LayerMapping
from django.contrib.gis.geos import fromstr
# from models import Harbord
import csv
from pygeocoder import Geocoder
# from django.contrib.gis.geos import (Point, fromstr, fromfile,
# GEOSGeometry, Multi... | normal | {
"blob_id": "40b9114e4348bab5d76d68a937b3abe95a90c230",
"index": 4130,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(tree_csv, 'rU') as csvinput:\n with open('../harbordvillage/outfile.csv', 'w+') as csvoutput:\n writer = csv.writer(csvoutput, quoting=csv.QUOTE_NONNUMERIC)\n r... | [
0,
1,
2,
3,
4
] |
from CategoryReplacer.CategoryReplcaers import CountEncoder
from CategoryReplacer.CategoryReplcaers import CombinCountEncoder
from CategoryReplacer.CategoryReplcaers import FrequencyEncoder
from CategoryReplacer.CategoryReplcaers import NullCounter
from CategoryReplacer.CategoryReplcaers import AutoCalcEncoder
from Cat... | normal | {
"blob_id": "d28e517e72c3689e973a5b1255d414648de418fb",
"index": 1658,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['CountEncoder', 'CombinCountEncoder', 'FrequencyEncoder',\n 'NullCounter', 'AutoCalcEncoder', 'extract_obj_cols']\n",
"step-3": "from CategoryReplacer.CategoryReplcaers im... | [
0,
1,
2,
3
] |
from numpy import empty
import pickle
from dataset import Dataset
from image import Image
f = open("./digitdata/trainingimages", "r")
reader = f.readlines()
labels = open("./digitdata/traininglabels", "r")
lreader = labels.readlines()
trainImageList = []
j = 0
i = 0
while(j < len(reader)):
image_array = empty([... | normal | {
"blob_id": "aff439361716c35e5f492680a55e7470b4ee0c42",
"index": 5905,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile j < len(reader):\n image_array = empty([28, 28])\n for r in range(0, 28):\n row = reader[j]\n j += 1\n for c in range(0, 28):\n if row[c] == '#... | [
0,
1,
2,
3,
4
] |
import numpy as np
import matplotlib.pyplot as plt
def f(x:float,y:np.ndarray) -> np.ndarray:
"""
Работает с вектором { y , y'}
"""
# return some function result
return np.array([y[1], np.sqrt(abs(-np.exp(y[1])*y[0] + 2.71*y[0]**2/np.log(x)+1/x**2))])
# return np.array([y[1], -y[0]... | normal | {
"blob_id": "daccc5aafb3e250e7fa7ac9db69a147b7e916736",
"index": 193,
"step-1": "<mask token>\n\n\ndef f(x: float, y: np.ndarray) ->np.ndarray:\n \"\"\"\n Работает с вектором { y , y'}\n \"\"\"\n return np.array([y[1], np.sqrt(abs(-np.exp(y[1]) * y[0] + 2.71 * y[0] **\n 2 / np.log(x) + 1 / x *... | [
2,
3,
4,
5,
6
] |
import pycmc
# open project, get Crag, CragVolumes, and intensity images
crag = ...
cragVolumes = ...
raw = ...
membrane = ...
nodeFeatures = ...
edgeFeatures = ...
statisticsFeatureProvider = pycmc.StatisticsFeatureProvider(cragVolumes, raw, "raw")
shapeFeatureProvider = pycmc.ShapeFeatureProvider(cragVolumes)
... | normal | {
"blob_id": "37d817436ce977339594867ef917177e7371a212",
"index": 6847,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfeatureProvider.add(shapeFeatureProvider)\nfeatureProvider.add(statisticsFeatureProvider)\n<mask token>\nfeatureExtractor.extractFeatures(nodeFeatures, edgeFeatures, featureProvider)\n",
... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [path('admin/', admin.site.urls), url('^$', IndexView.as_view
(), name='index'), url('^register/', RegistrationView.as_view(), name=
'register'), url('^home/', HomeView.as_view(), name='home'), url(
'^hom... | flexible | {
"blob_id": "da062dfe494b363c8ef3ec9f19af912736aaf77b",
"index": 9018,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('admin/', admin.site.urls), url('^$', IndexView.as_view\n (), name='index'), url('^register/', RegistrationView.as_view(), name=\n 'register'), url('^home/', Hom... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(1, n + 1, 1):
tempo = int(input('Digite o tempo:'))
if i == 1:
tempo1 = tempo
elif i == n:
f = tempo + 10
<|reserved_special_token_0|>
print(x)
<|reserved_special_token_1|>
pessoas = i... | flexible | {
"blob_id": "f98120d191e9e4b92984a6b59b25b1331b5d8c3a",
"index": 1970,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, n + 1, 1):\n tempo = int(input('Digite o tempo:'))\n if i == 1:\n tempo1 = tempo\n elif i == n:\n f = tempo + 10\n<mask token>\nprint(x)\n",
"st... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def test_fails_1():
assert long_repeat('') == 0, 'Empty String'
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test_fails_1():
assert long_repeat('') == 0, 'Empty String'
def test_fails_2():
assert long_repeat('aa') == 2
<... | flexible | {
"blob_id": "b459919e779063247c176e127368c687c903cf0f",
"index": 7869,
"step-1": "<mask token>\n\n\ndef test_fails_1():\n assert long_repeat('') == 0, 'Empty String'\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_fails_1():\n assert long_repeat('') == 0, 'Empty String'\n\n\ndef test_fails_2(... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class ArticleLinkedUrl(TimeStampedModel):
article = models.ForeignKey(Article, on_delete=models.CASCADE)
url = models.CharField(max_length=2000, unique=True)
title = models.CharField(max_length=500)
content_box = models.ForeignKey(ArticleContentBox, null=True, on_delete
... | flexible | {
"blob_id": "9bc15f063adc7d2a5ea81d090736ab6ce66a03d4",
"index": 5028,
"step-1": "<mask token>\n\n\nclass ArticleLinkedUrl(TimeStampedModel):\n article = models.ForeignKey(Article, on_delete=models.CASCADE)\n url = models.CharField(max_length=2000, unique=True)\n title = models.CharField(max_length=500)... | [
9,
18,
21,
22,
28
] |
<|reserved_special_token_0|>
class TestSets(unittest.TestCase):
def test_is_set(self):
"""Test set validator (Exercise 3a)."""
cards = numpy.array([[1, 1, 1, 2, 0], [0, 1, 2, 2, 2], [0, 1, 2, 2,
2], [0, 1, 2, 2, 2]])
self.assertTrue(set_solver.is_set(cards, [0, 1, 2]))
... | flexible | {
"blob_id": "6065fae2a11f6b525ef10346e297505ec9d4e9d5",
"index": 8550,
"step-1": "<mask token>\n\n\nclass TestSets(unittest.TestCase):\n\n def test_is_set(self):\n \"\"\"Test set validator (Exercise 3a).\"\"\"\n cards = numpy.array([[1, 1, 1, 2, 0], [0, 1, 2, 2, 2], [0, 1, 2, 2,\n 2],... | [
2,
3,
4,
5
] |
# coding: utf-8
"""
StockX API
PRERELEASE API - Subject to change before release. Provides access to StockX's public services, allowing end users to query for product and order information. # noqa: E501
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git... | normal | {
"blob_id": "ae88418ccfdaa4b357a2491f6450dbcda55b1c21",
"index": 2013,
"step-1": "<mask token>\n\n\nclass TestPortfolioIdDelResponsePortfolioItemProductMedia(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n pass\n\n def tearDown(self):\n pass\n\n def testPortfolioIdDelResponseP... | [
4,
5,
6,
7,
8
] |
# Copyright (c) 2016 EMC Corporation
# 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. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | normal | {
"blob_id": "2d48a343ca7f0f8ba7de8b520aad71d774d9b4ba",
"index": 9302,
"step-1": "<mask token>\n\n\nclass VirtualArray(common.CoprHDResource):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def varray_list(self, vdcname=None):\n \"\"\"Returns all the varrays in a vdc.\n\n ... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class Dot(LibFcn):
name = prefix + 'dot'
sig = Sigs([Sig([{'x': P.Array(P.Array(P.Double()))}, {'y': P.Array(P.
Double())}], P.Array(P.Double())), Sig([{'x': P.Map(P.Map(P.Double(
)))}, {'y': P.Map(P.Double())}], P.Map(P.Double())), Sig([{'x': P.
Array(P.Ar... | flexible | {
"blob_id": "780dc49c3eaef3fb25ca0aac760326b1c3adc633",
"index": 6002,
"step-1": "<mask token>\n\n\nclass Dot(LibFcn):\n name = prefix + 'dot'\n sig = Sigs([Sig([{'x': P.Array(P.Array(P.Double()))}, {'y': P.Array(P.\n Double())}], P.Array(P.Double())), Sig([{'x': P.Map(P.Map(P.Double(\n )))},... | [
26,
42,
47,
53,
59
] |
from tkinter import *
from tkinter import messagebox
root = Tk()
def hello():
messagebox.showinfo("Say Hello", "Hello World")
B1 = Button(root, text = "Say Hello", command = hello, font='arial 20')
B1.pack()
mainloop()
| normal | {
"blob_id": "61e38ae6ae2a1ed061f9893742f45b3e44f19a68",
"index": 6110,
"step-1": "<mask token>\n\n\ndef hello():\n messagebox.showinfo('Say Hello', 'Hello World')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef hello():\n messagebox.showinfo('Say Hello', 'Hello World')\n\n\n<mask token>\nB1.pack()... | [
1,
2,
3,
4,
5
] |
from django.db import models
#Precisa existir uma conversao ticker -> ticker_id mais facil, ou definir como trabalhar com o ticker.name,
#na maioria dos casos só tenho o nome do ticker, nao o id.
class User(models.Model):
""" Usuario que pode operar ativos """
name = models.CharField(max_length=200)
... | normal | {
"blob_id": "13e7484a80e4e45ee911f15837b9d82a1ef4d0b1",
"index": 7259,
"step-1": "from django.db import models\r\n\r\n#Precisa existir uma conversao ticker -> ticker_id mais facil, ou definir como trabalhar com o ticker.name,\r\n#na maioria dos casos só tenho o nome do ticker, nao o id.\r\n\r\nclass User(models... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
argparser.add_argument('ch', nargs='?', help='channel', type=int)
<|reserved_special_token_0|>
if args.ch is None:
for channel in range(0, 8):
print(f'== CHANNEL {channel} ==')
TCA9548A.write8(0, 1 << channel)
... | flexible | {
"blob_id": "46aa795bb72db0fcd588b1747e3559b8828be17c",
"index": 6927,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nargparser.add_argument('ch', nargs='?', help='channel', type=int)\n<mask token>\nif args.ch is None:\n for channel in range(0, 8):\n print(f'== CHANNEL {channel} ==')\n T... | [
0,
1,
2,
3,
4
] |
from nose.tools import *
from packt_offer import *
from bs4 import BeautifulSoup
class TestPacktOffer:
def setUp(self):
self.proper_soup = BeautifulSoup(
""""
<div id="deal-of-the-day" class="cf">
<div class="dotd-main-book cf">
<div class="section-inner">
... | normal | {
"blob_id": "a29f89750ef3a55116959b217b8c9100b294c66c",
"index": 3766,
"step-1": "<mask token>\n\n\nclass TestPacktOffer:\n <mask token>\n <mask token>\n <mask token>\n\n def test_offer_title_extracter_proper(self):\n result = offer_title_extracter(self.proper_soup)\n assert_equals(resu... | [
3,
7,
8,
11,
12
] |
"""product_ingredient unique constraint
Revision ID: a07768b0d4c0
Revises: a80cd9a35e58
Create Date: 2017-05-18 11:39:52.258266
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a07768b0d4c0'
down_revision = 'a80cd9a35e58'
branch_labels = None
depends_on = None
... | normal | {
"blob_id": "d0a73385db0dd6f729d267095ef83b9fec72e40c",
"index": 1464,
"step-1": "<mask token>\n\n\ndef upgrade():\n op.create_unique_constraint('_unique_name_unit', 'ingredient', ['name',\n 'unit'])\n op.create_unique_constraint(None, 'product', ['nappi_code'])\n op.add_column('product_ingredien... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
@csrf_exempt
def callback(request):
if request.method == 'POST':
signature = request.META['HTTP_X_LINE_SIGNATURE']
body = request.body.decode('utf-8')
try:
events = parser.parse(body, signature)
except InvalidSignatureError:
retu... | flexible | {
"blob_id": "19f202c32e1cf9f7ab2663827f1f98080f70b83e",
"index": 8313,
"step-1": "<mask token>\n\n\n@csrf_exempt\ndef callback(request):\n if request.method == 'POST':\n signature = request.META['HTTP_X_LINE_SIGNATURE']\n body = request.body.decode('utf-8')\n try:\n events = pa... | [
1,
2,
3,
4,
5
] |
from . import colorbar_artist
from . import subplot_artist
from . import surface_3d_with_shadows
from .colorbar_artist import *
from .subplot_artist import *
from .surface_3d_with_shadows import *
__all__ = ['colorbar_artist', 'subplot_artist', 'surface_3d_with_shadows']
__all__.extend(colorbar_artist.__all__)
__all__.... | normal | {
"blob_id": "16c4dbd472f9d32e5fa48a28dff4a40914f7d29e",
"index": 8231,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__.extend(colorbar_artist.__all__)\n__all__.extend(subplot_artist.__all__)\n__all__.extend(surface_3d_with_shadows.__all__)\n",
"step-3": "<mask token>\n__all__ = ['colorbar_artist... | [
0,
1,
2,
3
] |
x = 'From marquard@uct.ac.za'
print(x[8])
x = 'From marquard@uct.ac.za'
print(x[14:17])
greet = 'Hello Bob'
xa = "aaa"
print(greet.upper())
print(len('banana')*7)
data = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
pos = data.find('.')
print(data[pos:pos+3])
stuff = dict()
print(stuff.get('candy',-1... | normal | {
"blob_id": "e26f673dfae38148a56927ce82d5ea7ea2545e12",
"index": 8540,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(x[8])\n<mask token>\nprint(x[14:17])\n<mask token>\nprint(greet.upper())\nprint(len('banana') * 7)\n<mask token>\nprint(data[pos:pos + 3])\n<mask token>\nprint(stuff.get('candy', -1... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class PacketSender:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<... | flexible | {
"blob_id": "47c1ad4bd1ceffa38eef467ea8eb59dbd2fc2ebb",
"index": 262,
"step-1": "<mask token>\n\n\nclass PacketSender:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def awa... | [
3,
5,
9,
10,
11
] |
from ctypes import *
class GF_IPMPX_Data(Structure):
_fields_=[
("tag", c_char),
("Version", c_char),
("dataID", c_char)
] | normal | {
"blob_id": "b3f4815495c781fe6cc15f77b4ee601680117419",
"index": 8592,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass GF_IPMPX_Data(Structure):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass GF_IPMPX_Data(Structure):\n _fields_ = [('tag', c_char), ('Version', c_char), ('dataID', ... | [
0,
1,
2,
3,
4
] |
# Planet Class
from turtle import *
class Planet:
def __init__(self, x, y, radius):
self.radius = radius
self.x = x
self.y = y
canvas = Screen()
canvas.setup(800, 800)
self.turtle = Turtle()
def circumference(self):
return 2*3.1415*self.radius... | normal | {
"blob_id": "668b63d1f1bd035226e3e12bc6816abc897affc3",
"index": 9975,
"step-1": "<mask token>\n\n\nclass Planet:\n\n def __init__(self, x, y, radius):\n self.radius = radius\n self.x = x\n self.y = y\n canvas = Screen()\n canvas.setup(800, 800)\n self.turtle = Turtle... | [
4,
6,
7,
8,
9
] |
# -*- coding: utf-8 -*-
import os
import logging
import subprocess
import json
import sys
ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(ROOT_PATH)
from src.datafactory.common import json_util
from src.datafactory.config import constant
class SegmentProcess... | normal | {
"blob_id": "96ea9b2b4d892ac88f7fac9594a6d2ad5d69a7c7",
"index": 7479,
"step-1": "# -*- coding: utf-8 -*-\n\nimport os\nimport logging\nimport subprocess\nimport json\nimport sys\n\nROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\nsys.path.append(ROOT_PATH)\n\nfrom src.da... | [
0
] |
<|reserved_special_token_0|>
class TestFactorMult(ParTestBase):
def __init__(self):
super().__init__()
<|reserved_special_token_0|>
def par_test_1(self):
"""
f(X, Y), scalar
"""
for i in range(4):
self.XY_par_factor.setMaxDepth(i)
self.XY_p... | flexible | {
"blob_id": "0aad96de65cc125e5c026dfd72a9cc9f4ebd3dd2",
"index": 6486,
"step-1": "<mask token>\n\n\nclass TestFactorMult(ParTestBase):\n\n def __init__(self):\n super().__init__()\n <mask token>\n\n def par_test_1(self):\n \"\"\"\n f(X, Y), scalar\n \"\"\"\n for i in r... | [
12,
14,
15,
16,
19
] |
def sieve(limit):
numbers = list(range(3, limit, 2))
for prime in numbers:
for multiplier in reversed(range(2, limit)):
try:
numbers.remove(prime * multiplier)
except ValueError:
pass
return [2] + numbers
| normal | {
"blob_id": "ec7ca03f627eaa635aac56e302b9c40bf0a3da38",
"index": 1796,
"step-1": "<mask token>\n",
"step-2": "def sieve(limit):\n numbers = list(range(3, limit, 2))\n for prime in numbers:\n for multiplier in reversed(range(2, limit)):\n try:\n numbers.remove(prime * mult... | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def isVPS(phrase):
testlist = []
for char in phrase:
if char == '(':
testlist.append(char)
elif len(testlist) == 0:
return 'NO'
else:
testlist.pop()
if len(... | flexible | {
"blob_id": "d9f055301f050eea4281ce418974546c1245ac7e",
"index": 4621,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef isVPS(phrase):\n testlist = []\n for char in phrase:\n if char == '(':\n testlist.append(char)\n elif len(testlist) == 0:\n return 'NO'\n... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class MilkingListView(ListView):
<|reserved_special_token_0|>
def get_queryset(self, *args, **kwargs):
try:
animal = Animal.objects.get(self.kwargs.get('slug', None))
qs = Milking.objects.filter(animal__primary_breed__genus__slug=
s... | flexible | {
"blob_id": "3ecc9ce82d9c902958a4da51ce7ee3c39b064b2b",
"index": 3591,
"step-1": "<mask token>\n\n\nclass MilkingListView(ListView):\n <mask token>\n\n def get_queryset(self, *args, **kwargs):\n try:\n animal = Animal.objects.get(self.kwargs.get('slug', None))\n qs = Milking.ob... | [
7,
10,
13,
15,
16
] |
<|reserved_special_token_0|>
def refreshCam03():
try:
tmp_photo = URL2PhotoImage(cameraURL03)
image03_label.configure(image=tmp_photo)
image03_label.image = tmp_photo
except:
pass
if rootWindow.state() == 'normal':
Timer(0.05, refreshCam03).start()
<|reserved_spec... | flexible | {
"blob_id": "be63e8e6e98c9afed66cae033a7f41f1be1561a8",
"index": 8077,
"step-1": "<mask token>\n\n\ndef refreshCam03():\n try:\n tmp_photo = URL2PhotoImage(cameraURL03)\n image03_label.configure(image=tmp_photo)\n image03_label.image = tmp_photo\n except:\n pass\n if rootWind... | [
3,
10,
11,
14,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def get_msg_body(msg):
type = msg.get_content_maintype()
if type == 'multipart':
for part in msg.get_payload():
if part.get_content_maintype() == 'text':
return part.get_payload()
... | flexible | {
"blob_id": "cc99811321083147540a00e8029b792c8afc2ada",
"index": 3233,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_msg_body(msg):\n type = msg.get_content_maintype()\n if type == 'multipart':\n for part in msg.get_payload():\n if part.get_content_maintype() == 'text... | [
0,
2,
3,
4,
5
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ==============================================================================
# Created By : Karl Thompson
# Created Date: Mon March 25 17:34:00 CDT 2019
# ==============================================================================
"""nasdaq_itch_vwap - Genera... | normal | {
"blob_id": "806124926008078e592141d80d08ccfbb3046dbf",
"index": 7092,
"step-1": "<mask token>\n\n\ndef calculate_vwap():\n add_order_df = pd.read_csv('add_order_data.csv', index_col=None, names=\n ['Stock', 'Timestamp', 'Reference', 'Shares', 'Price'])\n ord_exec_df = pd.read_csv('ord_exec_data.csv... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open(filename) as f:
numbers = json.load(f)
print(numbers)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
filename = 'numbers.json'
with open(filename) as f:
numbers = json.load(f)
print(numbers)
<|res... | flexible | {
"blob_id": "8da775bd87bfeab5e30956e62bcdba6c04e26b27",
"index": 6720,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(filename) as f:\n numbers = json.load(f)\nprint(numbers)\n",
"step-3": "<mask token>\nfilename = 'numbers.json'\nwith open(filename) as f:\n numbers = json.load(f)\nprin... | [
0,
1,
2,
3,
4
] |
import pytest
import sys
sys.path.insert(0, '..')
from task_05 import task5
def test_mults():
assert task5.mults(3, 5, 10) == 23
assert task5.mults(5, 3, 10) == 23
assert task5.mults(3, 2, 10) == 32
assert task5.mults(7, 8, 50) == 364
| normal | {
"blob_id": "1c8622167240243da05a241e3630f79cdf36d7a8",
"index": 4776,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_mults():\n assert task5.mults(3, 5, 10) == 23\n assert task5.mults(5, 3, 10) == 23\n assert task5.mults(3, 2, 10) == 32\n assert task5.mults(7, 8, 50) == 364\n",
... | [
0,
1,
2,
3
] |
/home/lidija/anaconda3/lib/python3.6/sre_constants.py | normal | {
"blob_id": "700b0b12c75fa502da984319016f6f44bc0d52cc",
"index": 5126,
"step-1": "/home/lidija/anaconda3/lib/python3.6/sre_constants.py",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@singlevideos.route('/')
def index():
return render_template('singlevideos/single.html')
<|reserved_special_token_1|>
<|reserved_special_token_0|>
singlevideos = Blueprint('singlevideos', __name__, template_folder='templa... | flexible | {
"blob_id": "ee10bca1126b20378c4e9cea4d2dc7ed6a2044ab",
"index": 9187,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@singlevideos.route('/')\ndef index():\n return render_template('singlevideos/single.html')\n",
"step-3": "<mask token>\nsinglevideos = Blueprint('singlevideos', __name__, templa... | [
0,
1,
2,
3
] |
def sum_string(string):
list_chars = [zerone for zerone in string if zerone in ["0", "1"]]
return list_chars
def check_triads(trio, final_str):
list_occur_zero = [i for i in range(len(final_str)) if final_str.startswith(trio + '0', i)]
list_occur_one = [i for i in range(len(final_str)) if final_str.st... | normal | {
"blob_id": "29304bdbf93b0b1308025db1d35a92346c6dcbe0",
"index": 3799,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef check_triads(trio, final_str):\n list_occur_zero = [i for i in range(len(final_str)) if final_str.\n startswith(trio + '0', i)]\n list_occur_one = [i for i in range(l... | [
0,
1,
2,
3,
5
] |
# Accepted
def bubble_sort(a_list, n):
num_reverse = 0
for i in range(n):
for j in range(n - i - 1):
# With a for roop (reversed order),
# index starts -1, -2 ,...,
# NOT -0, -1, ...
if a_list[-j - 2] > a_list[-j - 1]:
tmp_elem = a_list[-... | normal | {
"blob_id": "fef1273552350bfaf075d90279c9f10a965cae25",
"index": 2939,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n n = int(input())\n a_list = list(map(int, input().split()))\n a_list_reversed, num_reverse = bubble_sort(a_list, n)\n print(' '.join(map(str, a_list_reversed... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('D0')
print(D0)
print('D1')
print(D1)
print('D2')
print(D2)
print('D3')
print(D3)
<|reserved_special_token_0|>
print('D2')
print(D2)
<|reserved_special_token_0|>
print('D3')
print(D3)
<|reserved_special_token_0|>
print('*** ... | flexible | {
"blob_id": "a868ecb6ea6a5c7a186ddd8fa4fb76d96efeb21d",
"index": 4140,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('D0')\nprint(D0)\nprint('D1')\nprint(D1)\nprint('D2')\nprint(D2)\nprint('D3')\nprint(D3)\n<mask token>\nprint('D2')\nprint(D2)\n<mask token>\nprint('D3')\nprint(D3)\n<mask token>\np... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class SaleAdvancePaymentInv(models.TransientModel):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class SaleAdva... | flexible | {
"blob_id": "75b1674066958a8fa28e74121a35d688bcc473d9",
"index": 9743,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass SaleAdvancePaymentInv(models.TransientModel):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass SaleAdvancePaymentInv(models.Transie... | [
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 levelOrder(self, root):
if root is None:
return []
currentList = [root]
nextList = []
solution = []
w... | flexible | {
"blob_id": "d9f176262dcaf055414fbc43b476117250249b63",
"index": 4696,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def levelOrder(self, root):\n if root is None:\n return []\n currentList = [root]\n nextList = ... | [
0,
1,
2
] |
import typ
@typ.typ(items=[int])
def gnome_sort(items):
"""
>>> gnome_sort([])
[]
>>> gnome_sort([1])
[1]
>>> gnome_sort([2,1])
[1, 2]
>>> gnome_sort([1,2])
[1, 2]
>>> gnome_sort([1,2,2])
[1, 2, 2]
"""
i = 0
n = len(items)
while i < n:
if i and items[i] < items[i - 1]:
... | normal | {
"blob_id": "70aba6c94b7050113adf7ae48bd4e13aa9a34587",
"index": 1023,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@typ.typ(items=[int])\ndef gnome_sort(items):\n \"\"\"\n >>> gnome_sort([])\n []\n >>> gnome_sort([1])\n [1]\n >>> gnome_sort([2,1])\n [1, 2]\n >>> gnome_sort([1,2])\n [1, ... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def main():
a, b = map(int, input().split())
diff = abs(max(b, a) - min(a, b))
if diff % 2 != 0:
print('IMPOSSIBLE')
else:
bigger = max(a, b)
ans = bigger - diff // 2
print(ans)
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "f73cbc25152a63bb6552e2cd8272c67a1f4277ba",
"index": 9044,
"step-1": "<mask token>\n",
"step-2": "def main():\n a, b = map(int, input().split())\n diff = abs(max(b, a) - min(a, b))\n if diff % 2 != 0:\n print('IMPOSSIBLE')\n else:\n bigger = max(a, b)\n ans = bigger... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class RedshiftClusterSubnetGroup(resource.BaseResource):
<|reserved_special_token_0|>
def __init__(self, cmd_prefix):
super(RedshiftClusterSubnetGroup, self).__init__(user_managed=False)
self.cmd_prefix = cmd_prefix
self.name = 'pkb-' + FLAGS.run_uri
... | flexible | {
"blob_id": "9cebce7f97a1848885883692cd0f494cce6bae7f",
"index": 5263,
"step-1": "<mask token>\n\n\nclass RedshiftClusterSubnetGroup(resource.BaseResource):\n <mask token>\n\n def __init__(self, cmd_prefix):\n super(RedshiftClusterSubnetGroup, self).__init__(user_managed=False)\n self.cmd_pre... | [
4,
5,
6,
7,
8
] |
import pandas as pd
import json
import spacy
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import NMF
nlp = spacy.load('en_core_web_sm')
list_data = []
list_data_only_reviews = []
list_data_reviewerid = []
result = []
l = []
for line in open('Automotive_5.json', 'r'):
li... | normal | {
"blob_id": "43b519d7db2e46a0bf9317eddac1f5cf6b7b79e3",
"index": 6417,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in open('Automotive_5.json', 'r'):\n list_data.append(json.loads(line))\nfor item in list_data:\n list_data_only_reviews.append(item['reviewText'])\n list_data_revieweri... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class ServerProfileLearning(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def process_distance(self, streaming_data):
t0 = time.time()
cluster_name = self.hostname + '_gener... | flexible | {
"blob_id": "53dd753356d8a8d60975c8f4cdaf20de66c2db46",
"index": 3486,
"step-1": "<mask token>\n\n\nclass ServerProfileLearning(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def process_distance(self, streaming_data):\n t0 = time.time()\n cluster_name = sel... | [
2,
3,
4,
5,
8
] |
from config import Config
def test_stf_3_2_1_pos(fixture):
seed = fixture.common.get_seed()
fixture.stf.open_stf_exercise('3-2-1', seed)
fixture.stf.open_solution_url(seed)
assert fixture.stf.get_solution() == Config.test_pass_text
fixture.common.back_to_main_page()
def test_stf_3_2_1_neg(fixtur... | normal | {
"blob_id": "028b38a07c71232eb42bedecd734cf7188550239",
"index": 9602,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_stf_3_2_1_neg(fixture):\n seed = fixture.common.get_seed()\n fixture.stf.open_stf_exercise('3-2-1', seed)\n fixture.stf.open_solution_url('test')\n assert fixture... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
while case_num - 1 < T:
data = map(int, input_file.readline().rstrip('\n').split(' '))
typed = data[0]
length = data[1]
probs = map(float, input_file.readline().rstrip('\n').split(' '))
assert that(len(probs)).... | flexible | {
"blob_id": "10c8316aee2107dc84ce7c1427dd62f52a2ce697",
"index": 4549,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile case_num - 1 < T:\n data = map(int, input_file.readline().rstrip('\\n').split(' '))\n typed = data[0]\n length = data[1]\n probs = map(float, input_file.readline().rstri... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
__author__ = 'vidma'
<|reserved_special_token_1|>
"""
Contain meta-data related functions:
* accessing integration schema: fields, values, constraints on inputs/queries
* tracking fields available
* tracking known (input field... | flexible | {
"blob_id": "abdedad2c2b42b54cdba0e61e095ba3df0783b81",
"index": 1172,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__author__ = 'vidma'\n",
"step-3": "\"\"\"\nContain meta-data related functions:\n\n* accessing integration schema: fields, values, constraints on inputs/queries\n* tracking fields avai... | [
0,
1,
2
] |
import sys
def isPalin(s):
result = True
for i in range(len(s)/2):
if s[i] != s[-(i + 1)]:
result = False
break
return result
def main():
curr_large = 0
for i in xrange(900, 1000):
for j in xrange(900, 1000):
prod = i * j
# Turns out list comprehension is more succint, but I... | normal | {
"blob_id": "1c171c67ca5ef0e9b5f2941eec7a625a8823271f",
"index": 8463,
"step-1": "import sys\n\ndef isPalin(s):\n result = True\n for i in range(len(s)/2):\n if s[i] != s[-(i + 1)]:\n result = False\n break\n return result\n\n\ndef main():\n curr_large = 0\n for i in xrange(900, 1000):\n for... | [
0
] |
import pandas as pd
import sweetviz as sv
b = pd.read_csv("final_cricket_players.csv", low_memory=False)
b = b.replace(to_replace="-",value="")
b = b.replace(to_replace="[]",value="")
b = b.replace(to_replace="{}",value="")
b.drop(b.columns[b.columns.str.contains('unnamed',case = False)],axis = 1, inplace = Tru... | normal | {
"blob_id": "f93b7f2939bbee9b0cb5402d3e5f5d6c482d37c4",
"index": 6983,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nb.drop(b.columns[b.columns.str.contains('unnamed', case=False)], axis=1,\n inplace=True)\nb.to_csv('Cleaned_dataset.csv', index=False)\n<mask token>\nreport.show_html()\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
"""
A package that determines the current day of the week.
"""
from datetime import date
import calendar
# Set the first day of the week as Sunday.
calendar.firstday(calendar.SUNDAY)
def day_of_the_week(arg):
"""
Returns the current day of the week.
"""
if arg == "day":
... | normal | {
"blob_id": "7e23f5598ccfe9aff74d43eb662f860b0404b7ec",
"index": 8333,
"step-1": "#!/usr/bin/env python\n\n\"\"\"\nA package that determines the current day of the week.\n\"\"\"\n\nfrom datetime import date \nimport calendar\n\n# Set the first day of the week as Sunday.\n\ncalendar.firstday(calendar.SUNDAY)\n\nd... | [
0
] |
<|reserved_special_token_0|>
class BucketDatasetGenerator:
"""
Provide data distribution of different gears for the bert network.
Args:
data_set (Dataset): The training dataset.
batch_size (Int): The training batchsize.
bucket_list (List): List of different sentence lengths,such a... | flexible | {
"blob_id": "8ae10aada79b0a687732e341d275eb3823ec0e4a",
"index": 9475,
"step-1": "<mask token>\n\n\nclass BucketDatasetGenerator:\n \"\"\"\n Provide data distribution of different gears for the bert network.\n\n Args:\n data_set (Dataset): The training dataset.\n batch_size (Int): The trai... | [
8,
11,
12,
13,
14
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def crawler(pid):
print('hole reply start!')
cids = []
texts = []
names = []
try:
para = {'action': 'getcomment', 'pid': pid, 'token':
'pnh3dmks5fmo00u0177qplsre44qo4fk'}
r = reque... | flexible | {
"blob_id": "a74653f01b62445c74c8121739bd9185ce21c85a",
"index": 2764,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef crawler(pid):\n print('hole reply start!')\n cids = []\n texts = []\n names = []\n try:\n para = {'action': 'getcomment', 'pid': pid, 'token':\n '... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if people < cats:
print('Too many cats')
elif people > cats:
print('Not many cats')
else:
print('we cannnot decide')
<|reserved_special_token_1|>
people = 20
cats = 30
dogs = 15
if people < cats:
print('Too many... | flexible | {
"blob_id": "0465e33d65c2ce47ebffeec38db6908826bf4934",
"index": 299,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif people < cats:\n print('Too many cats')\nelif people > cats:\n print('Not many cats')\nelse:\n print('we cannnot decide')\n",
"step-3": "people = 20\ncats = 30\ndogs = 15\nif... | [
0,
1,
2,
3
] |
import numpy as np
import torch
def pad_sequences_1d(sequences, dtype=torch.long, device=torch.device("cpu"), fixed_length=None):
""" Pad a single-nested list or a sequence of n-d array (torch.tensor or np.ndarray)
into a (n+1)-d array, only allow the first dim has variable lengths.
Args:
sequence... | normal | {
"blob_id": "788d9fa03c4311a8077d492b1a2b06d1f88826a3",
"index": 5570,
"step-1": "<mask token>\n\n\ndef pad_sequences_1d(sequences, dtype=torch.long, device=torch.device('cpu'\n ), fixed_length=None):\n \"\"\" Pad a single-nested list or a sequence of n-d array (torch.tensor or np.ndarray)\n into a (n+1... | [
3,
4,
5,
6,
7
] |
# i have created this file-hitu
from django.http import HttpResponse
from django.shortcuts import render
from .forms import Sign_Up, Login
from .models import Student
# render is used to create and impot the templates
# render takes first arg = request, 2nd arg = name of the file you want to import, 3rd arg = parame... | normal | {
"blob_id": "cbbb314a3262713f6cb2bb2dd90709d7bf1ca8eb",
"index": 6095,
"step-1": "<mask token>\n\n\ndef login_name(request):\n if request.method == 'POST':\n form = Login(request.POST)\n if form.is_valid():\n email = form.cleaned_data['email']\n password = form.cleaned_data... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def hexdigest_sha256(*args):
r = hashlib.sha256()
for arg in args:
r.update(str(arg).encode('utf-8'))
return r.hexdigest()
<|reserved_special_token_0|>
def notify_by_email(template, data, subject, sender, dests, message_id, ref
=None):
if hasattr(settings, ... | flexible | {
"blob_id": "a35004e2b306ba1a8649ce66a1612f63a2b6bf39",
"index": 2673,
"step-1": "<mask token>\n\n\ndef hexdigest_sha256(*args):\n r = hashlib.sha256()\n for arg in args:\n r.update(str(arg).encode('utf-8'))\n return r.hexdigest()\n\n\n<mask token>\n\n\ndef notify_by_email(template, data, subject... | [
2,
3,
4,
5,
6
] |
import logging.config
import os
import sys
import yaml
sys.path.append(os.path.join(os.path.abspath('.'), '..', '..'))
def setup_logging(default_path='common/config/logging.yaml'):
path = default_path
if os.path.exists(path):
with open(path, 'rt') as f:
config = yaml.safe_load(f.read())
... | normal | {
"blob_id": "6657f0b51bc021e6b5867bbdd1a520c2b0cb92b3",
"index": 2367,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef setup_logging(default_path='common/config/logging.yaml'):\n path = default_path\n if os.path.exists(path):\n with open(path, 'rt') as f:\n config = yaml.sa... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
pwm1.freq(60)
pwm1.duty(0)
<|reserved_special_token_0|>
for i in range(10):
while step < 1000:
pwm1.duty(step)
time.sleep_ms(500)
step += 100
while step > 0:
pwm1.duty(step)
time.sle... | flexible | {
"blob_id": "9f31694d80f2dcc50a76b32aa296871694d3644d",
"index": 7838,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npwm1.freq(60)\npwm1.duty(0)\n<mask token>\nfor i in range(10):\n while step < 1000:\n pwm1.duty(step)\n time.sleep_ms(500)\n step += 100\n while step > 0:\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class MyDaemon(DaemonBase):
<|reserved_special_token_0|>
def __init__(self, api_url, monitor_port, pidfile, stdin='/dev/null',
stdout='/dev/null', stderr='/dev/null'):
self.api_url = api_url
self.monitor_port = monitor_port
super().__init__(pidfile... | flexible | {
"blob_id": "6e253747182716f84aa6326aafe15ff82be17378",
"index": 1351,
"step-1": "<mask token>\n\n\nclass MyDaemon(DaemonBase):\n <mask token>\n\n def __init__(self, api_url, monitor_port, pidfile, stdin='/dev/null',\n stdout='/dev/null', stderr='/dev/null'):\n self.api_url = api_url\n ... | [
4,
5,
7,
8,
9
] |
#!/usr/bin/env python
# encoding: utf-8
"""
PreScaledTriggers.py
Created by Bryn Mathias on 2011-11-02.
Copyright (c) 2011 Imperial College. All rights reserved.
"""
import sys
import os
from plottingUtils import *
# HLT_HT600_v1Pre_1_HLT_HT300_v9Pre_210
def main():
c1 = Print("HLT_HT550_HLT_HT250.pdf")
c1.open(... | normal | {
"blob_id": "e748420dfdb77fa8661111a92fc48b79f64bff10",
"index": 4128,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n c1 = Print('HLT_HT550_HLT_HT250.pdf')\n c1.open()\n diffList = []\n cumuList = []\n histList = 'HT_Nom', 'HT_Denom'\n dirs = ['HLT_HT550_v11_HLT_HT250_... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def GetAuditedSystemVersion():
global OSX_VERSION
SysVersion = 'Unknown system version'
SystemVersionPlist = False
SystemVersionPlist = core.UniversalReadPlist(
'/System/Library/CoreServices/SystemVersion.plist')
if SystemVersionPlist:
if 'ProductName' ... | flexible | {
"blob_id": "547d67bce7eb05e55e02c73a22342ca572e89f39",
"index": 9959,
"step-1": "<mask token>\n\n\ndef GetAuditedSystemVersion():\n global OSX_VERSION\n SysVersion = 'Unknown system version'\n SystemVersionPlist = False\n SystemVersionPlist = core.UniversalReadPlist(\n '/System/Library/CoreSe... | [
2,
3,
4,
5,
6
] |
from django.contrib import admin
from .models import Profile
from django.contrib.admin.templatetags.admin_list import admin_actions
admin.site.register(Profile)
# Register your models here.
| normal | {
"blob_id": "89c44d35559504501e4333ea6ff4d3528f1a4c4f",
"index": 5171,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(Profile)\n",
"step-3": "from django.contrib import admin\nfrom .models import Profile\nfrom django.contrib.admin.templatetags.admin_list import admin_actions\nadmin.... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Calculator(object):
<|reserved_special_token_0|>
def _float_to_string_(self, f, p=40):
result = f'{f:+1.{p}f}'
if '.' in result:
result = result.rstrip('0')
if result[-1] == '.':
result += '0'
return result
... | flexible | {
"blob_id": "ac14e88810b848dbf4ff32ea99fd274cd0285e1c",
"index": 3539,
"step-1": "<mask token>\n\n\nclass Calculator(object):\n <mask token>\n\n def _float_to_string_(self, f, p=40):\n result = f'{f:+1.{p}f}'\n if '.' in result:\n result = result.rstrip('0')\n if result[... | [
6,
7,
9,
10,
11
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.