code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
class cal4:
def setdata(self,n1):
self.n1 = n1
def display(self):
return n1*n1
n1 = int(input("Enter number: "))
c = cal4()
print(c.display()) | normal | {
"blob_id": "65b90fccd0ee74b369475aa9fe33f159881c8b82",
"index": 6645,
"step-1": "class cal4:\n\n def setdata(self, n1):\n self.n1 = n1\n <mask token>\n\n\n<mask token>\n",
"step-2": "class cal4:\n\n def setdata(self, n1):\n self.n1 = n1\n\n def display(self):\n return n1 * n1\... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class MLPNet(nn.Module):
<|reserved_special_token_0|>
def forward(self, x):
x = x.view(x.size(0), -1)
x = self.fc1(x)
x = torch.sigmoid(x)
x = self.fc2(x)
return x
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_... | flexible | {
"blob_id": "eff8b6a282ac73a116587e7ed04f386927c9f826",
"index": 9089,
"step-1": "<mask token>\n\n\nclass MLPNet(nn.Module):\n <mask token>\n\n def forward(self, x):\n x = x.view(x.size(0), -1)\n x = self.fc1(x)\n x = torch.sigmoid(x)\n x = self.fc2(x)\n return x\n <ma... | [
2,
3,
4,
5
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import paramiko
import commands
def ip_check():
"""
Parses attributes for given hosts,
then checks if hosts are up
and then calls path_check function with working hosts.
"""
hosts = []
valid_hosts = []
for item in sys.argv... | normal | {
"blob_id": "6e3aa677985d7bd91bfbbd2078665206839bac63",
"index": 3578,
"step-1": "<mask token>\n\n\ndef path_check(hosts):\n \"\"\"\n Parses username, port, host and local and remote path,\n finds all local and remote files, using find_local_files and find_remote_files functions,\n and then opens ssh... | [
4,
6,
7,
8,
9
] |
# -*- coding: utf-8 -*-
"""
This is a simple sample for seuif.py
License: this code is in the public domain
Author: Cheng Maohua
Email: cmh@seu.edu.cn
Last modified: 2016.4.20
"""
from seuif97 import *
import matplotlib.pyplot as plt
import numpy as np
p1,t1 = 16, 535
p2,t2 = 3.56,315
h1 = pt2h(p1, t1)
s1 = ... | normal | {
"blob_id": "ebe546794131eddea396bd6b82fbb41aeead4661",
"index": 572,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nplt.plot(point_p1_s, point_p1_h, 'bs-')\nplt.plot(point_p2_s, point_p2_h, 'bs-')\nplt.plot(point_is_s, point_is_h, 'ys-')\nplt.plot(point_hp_s, point_hp_h, 'rs-', label='Expansion Line')\n... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class AccessFilter(BaseFilter):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class FilterTests(helper.CPWebCase):
def testCPFilterList(self):
self.getPage('/cpfilterlist/')
self.assertBody('A horrorshow lomtick of cherry 3.14159')
self.get... | flexible | {
"blob_id": "8a412231c13df1b364b6e2a27549730d06048186",
"index": 9978,
"step-1": "<mask token>\n\n\nclass AccessFilter(BaseFilter):\n <mask token>\n\n\n<mask token>\n\n\nclass FilterTests(helper.CPWebCase):\n\n def testCPFilterList(self):\n self.getPage('/cpfilterlist/')\n self.assertBody('A ... | [
4,
5,
7,
8,
9
] |
<|reserved_special_token_0|>
class RequirementSerializer(serializers.ModelSerializer):
<|reserved_special_token_0|>
class Meta:
model = RoughRequirement
fields = ['id', 'index', 'title', 'description',
'detailed_requirements']
class OfferingCourseSerializer(serializers.ModelSer... | flexible | {
"blob_id": "596f7dfacc931f5e756c71b8622f4001df19934b",
"index": 5964,
"step-1": "<mask token>\n\n\nclass RequirementSerializer(serializers.ModelSerializer):\n <mask token>\n\n\n class Meta:\n model = RoughRequirement\n fields = ['id', 'index', 'title', 'description',\n 'detailed_r... | [
8,
11,
12,
13,
14
] |
from typing import List
class NURBS:
def __init__(self, degree: int) -> None:
self._degree = degree
self._points = [] # type: List[complex]
self._weights = [] # type: List[float]
self._knots = [] # type: List[float]
def addPoint(self, p: complex) -> None:
self._poin... | normal | {
"blob_id": "40b3cacf55f6c5056c3541d70d8b2c0e2cc7d01b",
"index": 2564,
"step-1": "<mask token>\n\n\nclass NURBS:\n <mask token>\n <mask token>\n\n def addKnot(self, knot: float) ->None:\n self._knots.append(knot)\n\n def pointCount(self) ->int:\n return len(self._points)\n <mask toke... | [
6,
7,
8,
9,
11
] |
# Generates an infinite series of odd numbers
def odds():
n = 1
while True:
yield n
n += 2
def pi_series():
odd_nums = odds()
approximation = 0
while True:
approximation += (4 / next(odd_nums))
yield approximation
approxim... | normal | {
"blob_id": "26ef7de89e2e38c419310cc66a33d5dc0575fc0d",
"index": 5012,
"step-1": "def odds():\n n = 1\n while True:\n yield n\n n += 2\n\n\n<mask token>\n",
"step-2": "def odds():\n n = 1\n while True:\n yield n\n n += 2\n\n\ndef pi_series():\n odd_nums = odds()\n ... | [
1,
2,
3,
4,
5
] |
from api.serializers.cart import CartSerializer
from api.serializers.product import ProductSerializer, ProductPopular
from api.serializers.type import TypeSerializer
from api.serializers.user import UserCreationSerializer, UserSerializer
from api.serializers.history import HistorySerializer
from api.serializers.order i... | normal | {
"blob_id": "f0ff15a2392b439a54c5ec304192117c08978755",
"index": 4930,
"step-1": "<mask token>\n",
"step-2": "from api.serializers.cart import CartSerializer\nfrom api.serializers.product import ProductSerializer, ProductPopular\nfrom api.serializers.type import TypeSerializer\nfrom api.serializers.user import... | [
0,
1
] |
# template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import simplegui
import random
import math
# initialize global variables used in your code
range = 100
guesses_made = 0
guesses_remaining = 0
highest_guess = 0
lowes... | normal | {
"blob_id": "783326ccec31dc7a0ff46c5e4b69806e99aeda57",
"index": 9136,
"step-1": "# template for \"Guess the number\" mini-project\n# input will come from buttons and an input field\n# all output for the game will be printed in the console\nimport simplegui\nimport random\nimport math\n\n# initialize global vari... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(response)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
ec2 = boto3.resource('ec2')
response = client.allocate_address(Domain='standard')
print(response)
<|reserved_special_token_1|>
import boto3
ec2 = boto... | flexible | {
"blob_id": "6424fccb7990b0a1722d5d787e7eb5acb4ff1a74",
"index": 1863,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(response)\n",
"step-3": "<mask token>\nec2 = boto3.resource('ec2')\nresponse = client.allocate_address(Domain='standard')\nprint(response)\n",
"step-4": "import boto3\nec2 = bot... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class AddBlogs(generics.CreateAPIView):
permission_classes = IsSuperUser,
serializer_class = BlogSerializer
queryset = BlogModel.objects.all()
class ViewBlog(generics.ListAPIView):
permission_classes = IsClient,
serializer_class = BlogSerializer
queryset = BlogMo... | flexible | {
"blob_id": "aec5280869a780bbd93ef24b659d9959f7b81426",
"index": 3545,
"step-1": "<mask token>\n\n\nclass AddBlogs(generics.CreateAPIView):\n permission_classes = IsSuperUser,\n serializer_class = BlogSerializer\n queryset = BlogModel.objects.all()\n\n\nclass ViewBlog(generics.ListAPIView):\n permiss... | [
182,
186,
190,
206,
212
] |
<|reserved_special_token_0|>
def get_symbolic_state_probabilities_1222():
num_of_servers = 1
threshold = 2
system_capacity = 2
buffer_capacity = 2
sym_pi_1222 = get_symbolic_pi(num_of_servers=num_of_servers, threshold=
threshold, system_capacity=system_capacity, buffer_capacity=
bu... | flexible | {
"blob_id": "9dd59fee46bd4bec87cc8c40099110b483ad0496",
"index": 6990,
"step-1": "<mask token>\n\n\ndef get_symbolic_state_probabilities_1222():\n num_of_servers = 1\n threshold = 2\n system_capacity = 2\n buffer_capacity = 2\n sym_pi_1222 = get_symbolic_pi(num_of_servers=num_of_servers, threshold... | [
5,
12,
13,
16,
17
] |
'''
we have source files with a certain format and each file has 200 columns and there is a process that takes the source
files and loads into hbase and moves it into sql data warehouse. We have to create automated test scripts that compares
with with is with hbase and sql data warehouse. load into hbase and query the ... | normal | {
"blob_id": "7b38c64174656d1c4ec2b0541e6ed8d6680af7d7",
"index": 9565,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nconnection.open()\nprint('list of hbase tables {}'.format(connection.tables()))\n<mask token>\nfor key, data in customers.scan():\n keys.append(key)\n data_list.append(data)\n<mask ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
<|reserved_special_token_0|>
_sym_db.RegisterMessage(NVLGPSStatus)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x... | flexible | {
"blob_id": "98d2196439a8dc3d511d176e61897aa67663a0b5",
"index": 4922,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n_sym_db.RegisterFileDescriptor(DESCRIPTOR)\n<mask token>\n_sym_db.RegisterMessage(NVLGPSStatus)\n",
"step-3": "<mask token>\n_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x:... | [
0,
1,
2,
3,
4
] |
# Given an integer, convert it to a roman numeral.
# Input is guaranteed to be within the range from 1 to 3999.
class Solution:
# @param {integer} num
# @return {string}
def intToRoman(self, num):
normalDic = {
1000: 'M',
500: 'D',
100: 'C',
50: 'L',... | normal | {
"blob_id": "7de06772a1024a81193ac69a1110ad2e8b7f64ac",
"index": 9085,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def intToRoman(self, num):\n normalDic = {(1000): 'M', (500): 'D', (100): 'C', (50): 'L', (10):\n 'X', (5): '... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from django.db import models
# Create your models here.
class Test(models.Model):
name = models.CharField(max_length=20)
def __unicode__(self):
return self.name
class Contact(models.Model):
GENDER_TYPES = (
('M', u'男'),
('F', u'女'),
('X', u'不告诉... | normal | {
"blob_id": "514a3fc312d36e6f9b601ede7f7a3940c138d39a",
"index": 2000,
"step-1": "<mask token>\n\n\nclass Contact(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __unicode__... | [
5,
8,
9,
10,
11
] |
import math
import operator as op
Symbol = str
Number = (int, float)
Atom = (Symbol, Number)
List = list
Exp = (Atom, List)
Env = dict
def standard_env() -> Env:
"An environment with some scheme standard procedures"
env = Env()
env.update(vars(math)) # sin, cos, sqrt, pi ...
env.update({
... | normal | {
"blob_id": "88862d6bee5d83dd5f1c656a06a9dc46a5254b10",
"index": 3608,
"step-1": "<mask token>\n\n\ndef standard_env() ->Env:\n \"\"\"An environment with some scheme standard procedures\"\"\"\n env = Env()\n env.update(vars(math))\n env.update({'+': op.add, '-': op.sub, '*': op.mul, '/': op.truediv, ... | [
5,
7,
8,
9,
10
] |
<|reserved_special_token_0|>
class AdicionarBolsaWizard(osv.TransientModel):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def _bolsas(self, cr, uid, ids, campos, args, context=None):
oferta_model = self.pool.get('ud.monitoria.oferta.disciplina')
... | flexible | {
"blob_id": "fd877f5952c1fc0b2115d0950a066501ee7545f8",
"index": 4150,
"step-1": "<mask token>\n\n\nclass AdicionarBolsaWizard(osv.TransientModel):\n <mask token>\n <mask token>\n <mask token>\n\n def _bolsas(self, cr, uid, ids, campos, args, context=None):\n oferta_model = self.pool.get('ud.m... | [
18,
20,
22,
24,
26
] |
<|reserved_special_token_0|>
def compute_accuracy(model, good, bad):
train_arrays = numpy.zeros((25000, 400))
train_labels = numpy.zeros(25000)
classifier = LogisticRegression()
for i in range(25000 / 2):
prefix_train_pos = 'good_' + str(i)
prefix_train_neg = 'bad_' + str(i)
po... | flexible | {
"blob_id": "95015c467dd6371f575fb5535fe652a914650ef1",
"index": 2016,
"step-1": "<mask token>\n\n\ndef compute_accuracy(model, good, bad):\n train_arrays = numpy.zeros((25000, 400))\n train_labels = numpy.zeros(25000)\n classifier = LogisticRegression()\n for i in range(25000 / 2):\n prefix_t... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(Londonlocaltime)
print(Londonlocaltime.strftime('%H'))
<|reserved_special_token_0|>
print(PDXlocaltime)
print(PDXlocaltime.strftime('%H'))
<|reserved_special_token_0|>
print(NYClocaltime)
print(NYClocaltime.strftime('%H'))
... | flexible | {
"blob_id": "d8cfd9de95e1f47fc41a5389f5137b4af90dc0f1",
"index": 3949,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(Londonlocaltime)\nprint(Londonlocaltime.strftime('%H'))\n<mask token>\nprint(PDXlocaltime)\nprint(PDXlocaltime.strftime('%H'))\n<mask token>\nprint(NYClocaltime)\nprint(NYClocaltime... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def post_create(request):
form = PostForm(request.POST or None, request.FILES or None)
if request.method == 'POST':
user = request.POST.get('user')
title = request.POST.get('title')
content = request.POST.get('content')
PostStudent.objects.create(us... | flexible | {
"blob_id": "e9fab2bb49cfda00b8cfedafab0009f691d11ec9",
"index": 9924,
"step-1": "<mask token>\n\n\ndef post_create(request):\n form = PostForm(request.POST or None, request.FILES or None)\n if request.method == 'POST':\n user = request.POST.get('user')\n title = request.POST.get('title')\n ... | [
5,
6,
7,
8,
10
] |
'''
Created on 17 june, 2018
@author: sp977u@att.com (Satish Palnati)
This class is for
'''
import sys
from PySide.QtGui import *
from PySide.QtCore import *
from PySide import QtGui
from PySide import QtCore
class PingWindow:
wind_close_flg = False
def __init__(self,last_parent):
... | normal | {
"blob_id": "75b1d2fb927063669a962f72deb57323001c0b7a",
"index": 5657,
"step-1": "<mask token>\n\n\nclass PingWindow:\n <mask token>\n\n def __init__(self, last_parent):\n self.last_parent = last_parent\n self.main_widget = QWidget()\n self.main_widget.setMaximumHeight(400)\n se... | [
3,
4,
5,
6,
7
] |
"""Copied from http://svn.sourceforge.jp/svnroot/slothlib/CSharp/Version1/SlothLib/NLP/Filter/StopWord/word/Japanese.txt"""
STOP_WORDS = set(
"""
あそこ
あたり
あちら
あっち
あと
あな
あなた
あれ
いくつ
いつ
いま
いや
いろいろ
うち
おおまか
おまえ
おれ
がい
かく
かたち
かやの
から
がら
きた
くせ
ここ
こっち
こと
ごと
こちら
ごっちゃ
これ
これら
ごろ
さまざま
さらい
さん
しかた
しよう
すか
ずつ
すね
すべて
ぜんぶ
そう
そこ
そちら
そっち... | normal | {
"blob_id": "254afebcc909c805d1e4972a0910eb4451d1e64e",
"index": 8704,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nSTOP_WORDS = set(\n \"\"\"\nあそこ\nあたり\nあちら\nあっち\nあと\nあな\nあなた\nあれ\nいくつ\nいつ\nいま\nいや\nいろいろ\nうち\nおおまか\nおまえ\nおれ\nがい\nかく\nかたち\nかやの\nから\nがら\nきた\nくせ\nここ\nこっち\nこと\nごと\nこちら\nごっちゃ\nこれ\nこれら\nごろ\nさま... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
for t in range(int(input())):
st = list(input())
N, j = len(st), 1
for i in range(N // 2):
if st[i] == '*' or st[-i - 1] == '*':
break
elif st[i] != st[-i - 1]:
j = 0
break
print('#{} Exist'.... | flexible | {
"blob_id": "21d499555b4bc4944996a57ae544a56aa317b00b",
"index": 4386,
"step-1": "<mask token>\n",
"step-2": "for t in range(int(input())):\n st = list(input())\n N, j = len(st), 1\n for i in range(N // 2):\n if st[i] == '*' or st[-i - 1] == '*':\n break\n elif st[i] != st[-i ... | [
0,
1
] |
def html_print(text, title=''):
from IPython.core.display import display, HTML
# create title for the content
display(HTML("<h4>" + str(title) + "</h4>"))
# create content
html = display(HTML("<font size=2 face=Verdana>" + text + "</font>"))
return html
| normal | {
"blob_id": "84a63f60a45f1f8fc1efec8f30345a43c3c30c63",
"index": 7332,
"step-1": "<mask token>\n",
"step-2": "def html_print(text, title=''):\n from IPython.core.display import display, HTML\n display(HTML('<h4>' + str(title) + '</h4>'))\n html = display(HTML('<font size=2 face=Verdana>' + text + '</f... | [
0,
1,
2
] |
#!/usr/bin/python
# -*- coding:utf-8 -*-
import numpy as np
from functools import reduce
def element_wise_op(x, operation):
for i in np.nditer(x, op_flags=['readwrite']):
i[...] = operation[i]
class RecurrentLayer(object):
def __init__(self, input_dim, state_dim, activator, learning_rate):
se... | normal | {
"blob_id": "b34ce3ac87a01b8e80abc3fde1c91638f2896610",
"index": 2392,
"step-1": "<mask token>\n\n\nclass RecurrentLayer(object):\n <mask token>\n\n def forward(self, input_vec):\n self.time += 1\n state = np.dot(self.U, input_vec) + np.dot(self.W, self.state_list[-1])\n element_wise_o... | [
3,
8,
9,
10,
12
] |
<|reserved_special_token_0|>
class CreateUser(APIView):
<|reserved_special_token_0|>
class EditUser(APIView):
def put(self, request, pk):
user = User.objects.filter(pk=pk, is_removed=False).first()
if user is None:
return Response({'error': 'User Does Not Exists', 'success':
... | flexible | {
"blob_id": "dff454cbde985a08b34377b80dd8e3b22f1cc13a",
"index": 3948,
"step-1": "<mask token>\n\n\nclass CreateUser(APIView):\n <mask token>\n\n\nclass EditUser(APIView):\n\n def put(self, request, pk):\n user = User.objects.filter(pk=pk, is_removed=False).first()\n if user is None:\n ... | [
8,
10,
11,
13,
15
] |
from speaker_verification import *
import numpy as np
region = 'westus'
api_key = load_json('./real_secrets.json')['api_key']
wav_path = './enrollment.wav'
temp_path = './temp.wav'
# If you want to list users by profile_id
print('All users are: ', list_users(api_key, region))
# This is handled by the development / p... | normal | {
"blob_id": "5195dcf262c0be08f83cf66e79d48e51811a67a0",
"index": 6866,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('All users are: ', list_users(api_key, region))\n<mask token>\nenroll_user(api_key, region, wav_path, profile_id)\nprint(f'Likelihood that {wav_path} came from this subject')\nident... | [
0,
1,
2,
3,
4
] |
# 只放置可执行文件
#
# from ..src import package
# data_dict = package.pack()
# from ..src.plugins import * #解释一遍全放入内存
# from ..src import plugins #导入这个文件夹(包,模块,类库),默认加载init文件到内存
#
#
# plugins.pack()
from ..src.script import run
if __name__ == '__main__':
run()
| normal | {
"blob_id": "4f870e0d86d9f9b8c620115a618ea32abc24c52d",
"index": 3008,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n run()\n",
"step-3": "from ..src.script import run\nif __name__ == '__main__':\n run()\n",
"step-4": "# 只放置可执行文件\n#\n# from ..src import package\n# d... | [
0,
1,
2,
3
] |
import time
import threading
lock_a = threading.Lock()
lock_b = threading.Lock()
def task1():
print('Task 1 is starting...')
print('Task 1 is waiting to acquire Lock A')
with lock_a:
print('Task 1 has acquired Lock A')
print('Task 1 is doing some calculations')
time.sleep(2)
... | normal | {
"blob_id": "c7d8a67587a6ca01c23ed922faabbaca8bbaf337",
"index": 6307,
"step-1": "<mask token>\n\n\ndef task1():\n print('Task 1 is starting...')\n print('Task 1 is waiting to acquire Lock A')\n with lock_a:\n print('Task 1 has acquired Lock A')\n print('Task 1 is doing some calculations')... | [
2,
3,
4,
5
] |
import cv2
import numpy as np
import time
import itertools
from unionfind import UnionFind
R = 512
C = 512
# Setup window
cv2.namedWindow('main')
#img_i = np.zeros((R, C), np.uint8)
img_i = cv2.imread("window1.png", cv2.IMREAD_GRAYSCALE)
#img_i = cv2.threshold(img_i, 127, 255, cv2.THRESH_BINARY)[1]
do... | normal | {
"blob_id": "86d3e90493ed04bbe23792716f46a68948911dc3",
"index": 6861,
"step-1": "<mask token>\n\n\nclass BFCell:\n <mask token>\n\n def __init__(self, r, c, id, occupied):\n \"\"\"BFCell(row, col)\"\"\"\n self.r = r\n self.c = c\n self.id = id\n self.occupied = occupied\... | [
7,
12,
15,
16,
20
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
files.sort()
<|reserved_special_token_0|>
for i, fname in enumerate(files):
sample = fname.split('/')[1].split('.')[0]
if sample in duplicates:
skipped += 1
if skipped % 100 == 99:
print(f'Skip ... | flexible | {
"blob_id": "74eea67b8640a03e616bebdadba49891017b921d",
"index": 8914,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfiles.sort()\n<mask token>\nfor i, fname in enumerate(files):\n sample = fname.split('/')[1].split('.')[0]\n if sample in duplicates:\n skipped += 1\n if skipped % 100... | [
0,
1,
2,
3,
4
] |
from django.urls import path
from . import views
urlpatterns = [
path('product', views.ProductCreateAndList.as_view()),
path('product/<int:pk>', views.ProductRetrieve.as_view()),
]
| normal | {
"blob_id": "d21b89285d4b4c73a08bda746cea31b5a13d1050",
"index": 1967,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('product', views.ProductCreateAndList.as_view()), path(\n 'product/<int:pk>', views.ProductRetrieve.as_view())]\n",
"step-3": "from django.urls import path\nfrom ... | [
0,
1,
2,
3
] |
class Patient(object):
def __init__(self, id_number, name, bed_number, *allergies):
self.id_number = id_number
self.name = name
self.allergies = allergies
self.bed_number = bed_number
class Hospital(object):
def __init__(self, name, capacity):
self.patients = []
... | normal | {
"blob_id": "259a4bb39496bdfc71d60edb4994d26351c6961d",
"index": 3621,
"step-1": "class Patient(object):\r\n def __init__(self, id_number, name, bed_number, *allergies):\r\n self.id_number = id_number\r\n self.name = name\r\n self.allergies = allergies\r\n self.bed_number = bed_num... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def main(a, b, a_mod=-1, b_mod=-1, N=40000000, a_fact=16807, b_fact=48271):
genA = generator(a_fact, a_mod)
genB = generator(b_fact, b_mod)
match = 0
mask = (255 << 8) + 255
for i in range(N):
a = gen... | flexible | {
"blob_id": "6162911befc8ad37591f7c19b14b349c655ccac0",
"index": 3856,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(a, b, a_mod=-1, b_mod=-1, N=40000000, a_fact=16807, b_fact=48271):\n genA = generator(a_fact, a_mod)\n genB = generator(b_fact, b_mod)\n match = 0\n mask = (255 <... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def index(request):
blogs = Post.objects.filter(status=1).order_by('-created_on')[:10]
context = {'Post': blogs}
return render(request, 'blogapp/index.html', context)
def blogs(request):
return render(request, template_name='blogapp/blog.html')
def detail(request, slug... | flexible | {
"blob_id": "aec374ffa368755350d0d75c96860f760e8524e1",
"index": 7301,
"step-1": "<mask token>\n\n\ndef index(request):\n blogs = Post.objects.filter(status=1).order_by('-created_on')[:10]\n context = {'Post': blogs}\n return render(request, 'blogapp/index.html', context)\n\n\ndef blogs(request):\n r... | [
6,
7,
8,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def PlotFunctions(phi_orthonormalized_list, StartFunctionIndex, Interval):
PlotSettings()
t_array = numpy.logspace(-7, numpy.log10(Interval[1]), 1000)
NumFunctions = len(phi_orthonormalized_list)
f = numpy.zeros(... | flexible | {
"blob_id": "81da2aab9ca11e63dafdd4eefc340d37b326fc6f",
"index": 1846,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef PlotFunctions(phi_orthonormalized_list, StartFunctionIndex, Interval):\n PlotSettings()\n t_array = numpy.logspace(-7, numpy.log10(Interval[1]), 1000)\n NumFunctions = le... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Block:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Block:
def __init__(self, index, transactions, previous_hash, nonce=0):
self.index = index
s... | flexible | {
"blob_id": "43a23958b8c8779e3292f0f523a37b6d712fdbac",
"index": 4448,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Block:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Block:\n\n def __init__(self, index, transactions, previous_hash, nonce=0):\n self.index = index\n ... | [
0,
1,
2,
3
] |
import pandas as pd
import matplotlib.pyplot as plt
loansData = pd.read_csv('loansData.csv')
# Print the first 5 rows of each of the column to see what needs to be cleaned
print loansData['Interest.Rate'][0:5]
print loansData['Loan.Length'][0:5]
print loansData['FICO.Range'][0:5]
# Clean up the columns
loansData['... | normal | {
"blob_id": "fc17b865815a7a5ec51f477a9fdda54667686eed",
"index": 1672,
"step-1": "import pandas as pd\nimport matplotlib.pyplot as plt\n\n\nloansData = pd.read_csv('loansData.csv')\n\n# Print the first 5 rows of each of the column to see what needs to be cleaned\nprint loansData['Interest.Rate'][0:5]\nprint loan... | [
0
] |
<|reserved_special_token_0|>
def drawPieChart(central_angles, angle_of_rest, probability_of_rest):
turtle.reset()
window.colormode(255)
turtle.fillcolor('gray')
turtle.speed(10)
turtle.begin_fill()
turtle.circle(120)
turtle.end_fill()
turtle.up()
angle_counter = 0
prev_angle = ... | flexible | {
"blob_id": "0ac99816248e3306ca6340f7bee8a518877bc3e9",
"index": 1186,
"step-1": "<mask token>\n\n\ndef drawPieChart(central_angles, angle_of_rest, probability_of_rest):\n turtle.reset()\n window.colormode(255)\n turtle.fillcolor('gray')\n turtle.speed(10)\n turtle.begin_fill()\n turtle.circle(... | [
2,
3,
4,
5,
6
] |
incremental_factors_file = '../2019_2020_IncrementalFactorsList.csv'
tax_pickle_for_apns = 'kmes_taxes.p'
tax_history_pickle = '../cusd_1percent_tax_history.p'
distribution_pickle_out = 'kmes_distribution.p'
cabrillo_key = 50200
def read_incremental_factors():
import csv
inc_file = open(incremental_factors_fil... | normal | {
"blob_id": "18dae039f6455f944cbaa97bcb9c36ed29ac9a21",
"index": 867,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef read_incremental_factors():\n import csv\n inc_file = open(incremental_factors_file, 'r')\n reader = csv.reader(inc_file)\n increment_map = dict()\n funding_code_map... | [
0,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for ticker in tickers:
params = urlencode([('market', market), ('em', tickers[ticker]), (
'code', ticker), ('apply', 0), ('df', start_date.day), ('mf',
start_date.month - 1), ('yf', start_date.year), ('from', ... | flexible | {
"blob_id": "9d22a90835f5cf293808ab359244fe1bde81f3e1",
"index": 2171,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor ticker in tickers:\n params = urlencode([('market', market), ('em', tickers[ticker]), (\n 'code', ticker), ('apply', 0), ('df', start_date.day), ('mf', \n start_date.... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
c.execute(
"SELECT a.Name, count(c.visitorID) FROM attraction as a, checkin c WHERE a.AttractionID = c.attraction AND a.Category like 'Thrill Rides%' GROUP BY a.AttractionID "
)
<|reserved_special_token_0|>
print(thrillRid... | flexible | {
"blob_id": "c19c3f580d7555379bd7e077b0264a3784179e93",
"index": 696,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nc.execute(\n \"SELECT a.Name, count(c.visitorID) FROM attraction as a, checkin c WHERE a.AttractionID = c.attraction AND a.Category like 'Thrill Rides%' GROUP BY a.AttractionID \"\n ... | [
0,
1,
2,
3,
4
] |
from .exec_generator import *
| normal | {
"blob_id": "b6ee3c980357ab22a7969c21207b34546c87092d",
"index": 7305,
"step-1": "<mask token>\n",
"step-2": "from .exec_generator import *\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
def normalize_for_url(text: str) ->str:
""" Takes the given text and makes it fit to be used for an url.
That means replacing spaces and other unwanted characters with '-',
lowercasing everything and turning unicode characters into their closest
ascii equivalent using Uni... | flexible | {
"blob_id": "084c9ad83091f6f96d19c0f0c28520ccda93bbaf",
"index": 7778,
"step-1": "<mask token>\n\n\ndef normalize_for_url(text: str) ->str:\n \"\"\" Takes the given text and makes it fit to be used for an url.\n\n That means replacing spaces and other unwanted characters with '-',\n lowercasing everythi... | [
35,
38,
46,
49,
61
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
logging.basicConfig(level=logging.DEBUG, format=
'%(asctime)s - %(levelname)s - %(message)s')
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
logging.basicConfig(level=logging.DEBUG, f... | flexible | {
"blob_id": "96e64b715dbfc1c59ba44d608ad2694b165017b5",
"index": 1975,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlogging.basicConfig(level=logging.DEBUG, format=\n '%(asctime)s - %(levelname)s - %(message)s')\n<mask token>\n",
"step-3": "<mask token>\nlogging.basicConfig(level=logging.DEBUG, fo... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def get_classes(html):
"""
returns a list of classes and titles, parsing through 'html'
"""
<|reserved_special_token_1|>
import sys
from bs4 import BeautifulSoup
def get_classes(html):
"""
returns a list... | flexible | {
"blob_id": "9bb8e0f732eac474dbc01c374f9c74178f65dc36",
"index": 3063,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_classes(html):\n \"\"\"\n returns a list of classes and titles, parsing through 'html'\n \"\"\"\n",
"step-3": "import sys\nfrom bs4 import BeautifulSoup\n\n\ndef ge... | [
0,
1,
2,
3
] |
from Global import *
import ShuntingYard
from Thompson import *
def check_string(automaton, word):
inicial = automata['s'].closure
for i in word:
inicial = state_list_delta(inicial, i)
return automaton['f'] in inicial
def create_AFND(re):
deltas = []
initial_node = ShuntingYard.create_tree(ShuntingYard.to_rpn... | normal | {
"blob_id": "9cf0174a8bd2bccbd8e5d0be1f0b031a1a23c9df",
"index": 4691,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef check_string(automaton, word):\n inicial = automata['s'].closure\n for i in word:\n inicial = state_list_delta(inicial, i)\n return automaton['f'] in inicial\n\n\n... | [
0,
1,
2,
3,
4
] |
"""script for subpixel experiment (not tested)
"""
import numpy as np
from tqdm import tqdm
import logging
from pathlib import Path
import paddle
import paddle.optimizer
import paddle.io
from utils.loader import dataLoader
from utils.loader import modelLoader
from utils.loader import pretrainedLoader
from utils.tools... | normal | {
"blob_id": "fc89fdf17f887ea398be5b36d4d6f0444d64b3e0",
"index": 8026,
"step-1": "<mask token>\n\n\n@paddle.no_grad()\nclass Val_model_subpixel(object):\n <mask token>\n\n def loadModel(self):\n from utils.loader import modelLoader\n self.net = modelLoader(model=self.model, **self.params)\n ... | [
3,
5,
6,
7,
8
] |
import os
from app_web import sg
from sendgrid.helpers.mail import *
import pdfkit
from models.user import User
from models.expense import Expense
from models.statement import Statement
from models.category import Category
import tempfile
import subprocess
from .aws_uploader import upload_image_to_s3
import datetime
fr... | normal | {
"blob_id": "55df8d13ddf28f7b0477329bee743471a0780f24",
"index": 3253,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef create_statement(month=None):\n\n def _get_pdfkit_config():\n if os.getenv('FLASK_ENV') == 'production':\n WKHTMLTOPDF_CMD = subprocess.Popen(['which', os.env... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class NoticiaForm(ModelForm):
class Meta:
model = Noticia
fields = ['idNoticia', 'resumen', 'titulo', 'categoria']
<|reserved_special_token_1|>
from django import forms
from django.forms import ModelForm... | flexible | {
"blob_id": "e7a283e0e0e16e9adb415b26d724b2ee84c4f4f8",
"index": 1547,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass NoticiaForm(ModelForm):\n\n\n class Meta:\n model = Noticia\n fields = ['idNoticia', 'resumen', 'titulo', 'categoria']\n",
"step-3": "from django import forms... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def recoverpix(doc, item):
x = item[0]
s = item[1]
if s == 0:
return doc.extractImage(x)
def getimage(pix):
if pix.colorspace.n != 4:
return pix
tpix = fitz.Pixmap(fitz.csRGB,... | flexible | {
"blob_id": "856afd30a2ed01a1d44bbe91a7b69998e9a51bb7",
"index": 3170,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef recoverpix(doc, item):\n x = item[0]\n s = item[1]\n if s == 0:\n return doc.extractImage(x)\n\n def getimage(pix):\n if pix.colorspace.n != 4:\n ... | [
0,
1,
3,
4,
5
] |
from django.apps import AppConfig
from django.conf import settings
import importlib
import importlib.util
class RestAdminAppConfig(AppConfig):
name = 'libraries.django_rest_admin'
verbose_name = 'Rest Admin'
loaded = False
def ready(self):
autodiscover()
def autodiscover():
"""
Auto... | normal | {
"blob_id": "a41d00c86d0bdab1bced77c275e56c3569af4f4e",
"index": 921,
"step-1": "<mask token>\n\n\nclass RestAdminAppConfig(AppConfig):\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 RestAdminAppConfig(AppConfig):\n name = 'li... | [
1,
3,
4,
5,
6
] |
import re
def read_input():
with open('../input/day12.txt') as f:
lines = f.readlines()
m = re.search(r'initial state:\s([\.#]+)', lines[0])
initial_state = m.groups()[0]
prog = re.compile(r'([\.#]{5})\s=>\s([\.#])')
rules = []
for i in range(2, len(lines)):
m = prog.search(line... | normal | {
"blob_id": "27f001f4e79291825c56642693894375fef3e66a",
"index": 1647,
"step-1": "<mask token>\n\n\ndef read_input():\n with open('../input/day12.txt') as f:\n lines = f.readlines()\n m = re.search('initial state:\\\\s([\\\\.#]+)', lines[0])\n initial_state = m.groups()[0]\n prog = re.compile(... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for x in a:
b.append(int(x))
print(b)
<|reserved_special_token_0|>
for i in range(l):
s = len(b[:i])
for j in range(s):
if b[s] < b[j]:
c = b[s]
b.pop(s)
b.insert(b.index(b[j... | flexible | {
"blob_id": "24de4f486d4e976850e94a003f8d9cbe3e518402",
"index": 33,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor x in a:\n b.append(int(x))\nprint(b)\n<mask token>\nfor i in range(l):\n s = len(b[:i])\n for j in range(s):\n if b[s] < b[j]:\n c = b[s]\n b.pop(s... | [
0,
1,
2,
3
] |
from manimlib.imports import *
class A_Scroller(Scene):
CONFIG={
"camera_config":{"background_color":"#FFFFFF"}
}
def construct(self):
text_1 = Text("3493", color="#DC3832")
text_2 = Text("3646", color="#221F20").shift(2*RIGHT)
text_3 = Text("4182", color="#2566AD").shift(4*RIGHT)
text_4 = Te... | normal | {
"blob_id": "97c97f18d1b93dc54538a0df7badafd961fdcb9c",
"index": 3588,
"step-1": "<mask token>\n\n\nclass A_Scroller(Scene):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass A_Scroller(Scene):\n <mask token>\n\n def construct(self):\n text_1 = Text('3493', color='#DC3832'... | [
1,
2,
3,
4,
5
] |
"""Defines all Rady URL."""
from django.conf.urls import url, include
from django.contrib import admin
apiv1_urls = [
url(r"^users/", include("user.urls")),
url(r"^meetings/", include("meeting.urls")),
url(r"^docs/", include("rest_framework_docs.urls")),
url(r"^auth/", include("auth.urls")),
url(... | normal | {
"blob_id": "aa00e4569aeae58e3f0ea1a8326e35c0776f7727",
"index": 4849,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napiv1_urls = [url('^users/', include('user.urls')), url('^meetings/',\n include('meeting.urls')), url('^docs/', include(\n 'rest_framework_docs.urls')), url('^auth/', include('auth.... | [
0,
1,
2,
3
] |
import unittest
import userinput
class Testing(unittest.TestCase):
def test_creation(self):
x = userinput.UserInput()
self.assertNotEqual(x, None)
def test_charset_initialization(self):
x = userinput.UserInput()
self.assertEqual(x.character_set, userinput.CHARACTERS)
def ... | normal | {
"blob_id": "4745d81558130440d35d277b586572f5d3f85c06",
"index": 7366,
"step-1": "<mask token>\n\n\nclass Testing(unittest.TestCase):\n\n def test_creation(self):\n x = userinput.UserInput()\n self.assertNotEqual(x, None)\n\n def test_charset_initialization(self):\n x = userinput.UserI... | [
4,
5,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for kk in file:
paragraph += kk[0]
f.close()
<|reserved_special_token_0|>
print('most commons below...')
print(most_common_words)
<|reserved_special_token_0|>
for i, j in most_common_words:
most_cm_1.append(i)
<|reserved_s... | flexible | {
"blob_id": "0dbdd7f7adffed850f126a2054c764b421c6ab84",
"index": 6799,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor kk in file:\n paragraph += kk[0]\nf.close()\n<mask token>\nprint('most commons below...')\nprint(most_common_words)\n<mask token>\nfor i, j in most_common_words:\n most_cm_1.app... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class QManeger(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def listening(self):
while True:
traces = self.q_trace.get(block=True)
for s, a, r in zip(traces[0], traces[1], traces[2]):
self._push_one(s, a, r... | flexible | {
"blob_id": "b693cc63e2ee4c994ef7b5e44faea99f15a021f6",
"index": 68,
"step-1": "<mask token>\n\n\nclass QManeger(object):\n <mask token>\n <mask token>\n\n def listening(self):\n while True:\n traces = self.q_trace.get(block=True)\n for s, a, r in zip(traces[0], traces[1], t... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('src/time.txt', 'w') as f:
f.write(str(int(time.time())))
<|reserved_special_token_1|>
import time
with open('src/time.txt', 'w') as f:
f.write(str(int(time.time())))
<|reserved_special_token_1|>
import tim... | flexible | {
"blob_id": "0058a6d3c9d4e600885b876614362ea4401ce2fe",
"index": 1640,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('src/time.txt', 'w') as f:\n f.write(str(int(time.time())))\n",
"step-3": "import time\nwith open('src/time.txt', 'w') as f:\n f.write(str(int(time.time())))\n",
"step... | [
0,
1,
2,
3
] |
import os
class Idea:
def __init__(self, folder):
self.folder = folder
def name(self):
return "jetbrains-idea"
def cmd(self):
return "intellij-idea-ultimate-edition %s" % self.folder
| normal | {
"blob_id": "90fc6e37e3988a2014c66913db61749509db2d53",
"index": 1036,
"step-1": "<mask token>\n\n\nclass Idea:\n <mask token>\n <mask token>\n\n def cmd(self):\n return 'intellij-idea-ultimate-edition %s' % self.folder\n",
"step-2": "<mask token>\n\n\nclass Idea:\n\n def __init__(self, fold... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class _CornerStorageBuilder:
def __init__(self, progress_indicator=None):
self._progress_indicator = progress_indicator
self._corners = dict()
def set_corners_at_frame(self, frame, corners):
self._corners[frame] = corners
if self._progress_indicat... | flexible | {
"blob_id": "0b5fb649dc421187820677ce75f3cd0e804c18a3",
"index": 7055,
"step-1": "<mask token>\n\n\nclass _CornerStorageBuilder:\n\n def __init__(self, progress_indicator=None):\n self._progress_indicator = progress_indicator\n self._corners = dict()\n\n def set_corners_at_frame(self, frame, ... | [
10,
12,
14,
15,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
app.run_server(debug=False, port=8080, host='127.0.0.1')
<|reserved_special_token_1|>
<|reserved_special_token_0|>
app = dash.Dash(__name__)
app.layout = html.H1('Hello dashboard')
if __name__ == ... | flexible | {
"blob_id": "b66f588149d160c119f9cc24af3acb9f64432d6e",
"index": 6014,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n app.run_server(debug=False, port=8080, host='127.0.0.1')\n",
"step-3": "<mask token>\napp = dash.Dash(__name__)\napp.layout = html.H1('Hello dashboard')\... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def ipfs_add_local(file_path):
"""Returns CID"""
proc = subprocess.run(['ipfs', 'add', file_path], capture_output=True,
text=True)
stdout = proc.stdout
try:
return stdout.split()[1]
except IndexError as e:
print(e)
print(stdout)
... | flexible | {
"blob_id": "7ca88d451ad702e5a8e532da3e3f5939cfaa7215",
"index": 9571,
"step-1": "<mask token>\n\n\ndef ipfs_add_local(file_path):\n \"\"\"Returns CID\"\"\"\n proc = subprocess.run(['ipfs', 'add', file_path], capture_output=True,\n text=True)\n stdout = proc.stdout\n try:\n return stdou... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
def get_heart_rate(auth2_client, date, granularity='1sec'):
"""
Query intraday time series given date
granularity: 1sec or 1min
"""
heart_rate_raw = auth2_client.intraday_time_series('activities/heart',
base_date=date, detail_level=granularity)
time_list = ... | flexible | {
"blob_id": "9f1cbc655a5d8f14fa45cf977bb2dcee4874b188",
"index": 5809,
"step-1": "<mask token>\n\n\ndef get_heart_rate(auth2_client, date, granularity='1sec'):\n \"\"\"\n Query intraday time series given date\n granularity: 1sec or 1min\n \"\"\"\n heart_rate_raw = auth2_client.intraday_time_series... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
regressor.fit(X, y)
<|reserved_special_token_0|>
plt.scatter(X, y, color='red')
plt.plot(X_grid, regressor.predict(X_grid), color='blue')
plt.scatter(6.5, y_pred, color='green')
plt.title('Salary vs Title')
plt.xlabel('Title')
plt... | flexible | {
"blob_id": "c8565e1b5659dd0908aabf91e07738a798dc3232",
"index": 1366,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nregressor.fit(X, y)\n<mask token>\nplt.scatter(X, y, color='red')\nplt.plot(X_grid, regressor.predict(X_grid), color='blue')\nplt.scatter(6.5, y_pred, color='green')\nplt.title('Salary vs... | [
0,
1,
2,
3,
4
] |
"""This module contains an algorithm to find the different
components in a graph represented as an adjacency matrix.
"""
def find_components(adjacency_matrix):
visited = set()
components = []
for node in range(len(adjacency_matrix)):
if node not in visited:
component = []
b... | normal | {
"blob_id": "e71a23ef7a065bc4210e55552e19c83c428bc194",
"index": 3187,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef find_components(adjacency_matrix):\n visited = set()\n components = []\n for node in range(len(adjacency_matrix)):\n if node not in visited:\n component... | [
0,
1,
2,
3
] |
from typing import List
"""
1. Generate an array containing the products of all elements to the left of current element
2. Similarly, start from the last element and generate an array containing the products to the right of each element
3. Multiply both arrays element-wise
"""
class Solution:
def productExceptS... | normal | {
"blob_id": "26ae44b5be1d78ed3fe9c858413ae47e163c5460",
"index": 1282,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def productExceptSelf(self, nums: List[int]) ->List[int]:\n output = []\n pro... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
df.head()
<|reserved_special_token_0|>
print(m)
<|reserved_special_token_0|>
print(mean)
for i in mean:
random.seed(1)
randomFactor = [(random.random() * 0.01 + (i - 0.005)) for _ in range(m)]
for idx, step in enumerat... | flexible | {
"blob_id": "d0adbcd60727c2c68e06dc5e796f2676f927c45a",
"index": 4593,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndf.head()\n<mask token>\nprint(m)\n<mask token>\nprint(mean)\nfor i in mean:\n random.seed(1)\n randomFactor = [(random.random() * 0.01 + (i - 0.005)) for _ in range(m)]\n for id... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def load_cifar_data(data_files):
data = []
labels = []
for file in data_files:
with open(file, 'rb') as fo:
data_dict = pickle.load(fo, encoding='bytes')
if len(data) == 0:
data = data_dict[str.encode('data')]
lab... | flexible | {
"blob_id": "66fe0a3b84773ee1d4f91d8fde60f1fc5b3d7e4c",
"index": 6454,
"step-1": "<mask token>\n\n\ndef load_cifar_data(data_files):\n data = []\n labels = []\n for file in data_files:\n with open(file, 'rb') as fo:\n data_dict = pickle.load(fo, encoding='bytes')\n if len(da... | [
8,
10,
12,
13,
14
] |
<|reserved_special_token_0|>
def k_NN(data, predict, k=3):
if len(data) >= k:
warnings.warn('K is set to a value less than total voting groups !')
distances = []
[[distances.append([np.linalg.norm(np.array(features) - np.array(
predict)), group]) for features in data[group]] for group in d... | flexible | {
"blob_id": "c6ce6ffe46be993bfe74ccb240e1ebf586c9f556",
"index": 7656,
"step-1": "<mask token>\n\n\ndef k_NN(data, predict, k=3):\n if len(data) >= k:\n warnings.warn('K is set to a value less than total voting groups !')\n distances = []\n [[distances.append([np.linalg.norm(np.array(features) - ... | [
1,
2,
3,
4,
5
] |
def primeiras_ocorrencias(str):
dic = {}
for i, letra in enumerate(str):
if letra not in dic:
dic[letra] = i
return dic
| normal | {
"blob_id": "bb1a6815649eb9e79e2ab1e110ea8acd8adce5aa",
"index": 3379,
"step-1": "<mask token>\n",
"step-2": "def primeiras_ocorrencias(str):\n dic = {}\n for i, letra in enumerate(str):\n if letra not in dic:\n dic[letra] = i\n return dic\n",
"step-3": null,
"step-4": null,
"s... | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
pickle.dump(emp1, empObj)
pickle.dump(emp2, empObj)
pickle.dump(emp3, empObj)
pickle.dump(emp4, empObj)
print('Successfully written four dictionaries')
empObj.close()
<|reserved_special_token_1|>
<|reserved_special_token_0|>
em... | flexible | {
"blob_id": "23937ae531cc95069a1319f8c77a459ba7645363",
"index": 4331,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npickle.dump(emp1, empObj)\npickle.dump(emp2, empObj)\npickle.dump(emp3, empObj)\npickle.dump(emp4, empObj)\nprint('Successfully written four dictionaries')\nempObj.close()\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
class CardHolder:
acctlen = 8
retireage = 59.5
def __init__(self, acct, name, age, addr):
self.acct = acct
self.name = name
self.age = age
self.addr = addr
def __getattribute__(self, item): # __getattribute__ intercepts calls for all
... | normal | {
"blob_id": "602a7676129721dbfd318407dd972f80d681146c",
"index": 3062,
"step-1": "class CardHolder:\n <mask token>\n <mask token>\n <mask token>\n\n def __getattribute__(self, item):\n superget = object.__getattribute__\n if item == 'acct':\n return superget(self, 'acct')[:-3... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def setPixel(strip):
for i in range(count):
if i < lightUp:
strip.setPixelColor(i, Color(0, 255, 0))
strip.show()
else:
strip.setPixelColor(i, Color(255, 0, 0))
... | flexible | {
"blob_id": "5ff7a3843314dfd3914c5e96164385d61fbe7fa5",
"index": 684,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef setPixel(strip):\n for i in range(count):\n if i < lightUp:\n strip.setPixelColor(i, Color(0, 255, 0))\n strip.show()\n else:\n st... | [
0,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class TimeInterval(object):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class TimeInterval(object):
def __init__(self, start_time, end_time):
self.start_time = start_time
self.end_time = end_time
| flexible | {
"blob_id": "9d772d5500593583907b65bc2c81490e61375e8b",
"index": 8081,
"step-1": "<mask token>\n",
"step-2": "class TimeInterval(object):\n <mask token>\n",
"step-3": "class TimeInterval(object):\n\n def __init__(self, start_time, end_time):\n self.start_time = start_time\n self.end_time ... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@client.command()
async def inviteInfo(ctx, link):
try:
await delete.byContext(ctx)
except:
pass
linkData = await client.fetch_invite(url=link)
if linkData.inviter:
inviterData = await get... | flexible | {
"blob_id": "b8f9633ab3110d00b2f0b82c78ad047fca0d3eee",
"index": 6999,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@client.command()\nasync def inviteInfo(ctx, link):\n try:\n await delete.byContext(ctx)\n except:\n pass\n linkData = await client.fetch_invite(url=link)\n ... | [
0,
1,
2,
3
] |
var blackList = []string{
// global
"document", "window", "top", "parent", "global", "this",
//func
"console", "alert", "log", "promise", "fetch", "eval", "import",
//char
"<", ">", "`", "\\*", "&", "#", "%", "\\\\",
//key
"if", "set", "get", "with", "yield", "async", "wait", "func", "for", "error", "string",
... | normal | {
"blob_id": "f502290cc8ffa9571454a214497aff1d1c5e1c9f",
"index": 8285,
"step-1": "var blackList = []string{\n\t// global\n\t\"document\", \"window\", \"top\", \"parent\", \"global\", \"this\",\n\t//func\n\t\"console\", \"alert\", \"log\", \"promise\", \"fetch\", \"eval\", \"import\",\n\t//char\n\t\"<\", \">\", \... | [
0
] |
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.urls import reverse
from gatheros_event.views.mixins import AccountMixin
from gatheros_subscription.helpers.extract import (
create_extract,
get_extract_file_name,
)
from gatheros_subscription.models import Subscrip... | normal | {
"blob_id": "431f109903e014a29aed7f125d47f327e17b9f65",
"index": 4366,
"step-1": "<mask token>\n\n\nclass ExtractSubscriptionPDFView(AccountMixin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass ExtractSubscriptionPDFView(Account... | [
1,
4,
6,
7,
8
] |
<|reserved_special_token_0|>
class TestCases(unittest.TestCase):
def test_chart_cell(self):
t = [{'country': 'US', 'quantity': 100}, {'country': 'ZA',
'quantity': 50}]
IPython.get_ipython().user_ns = {}
chart = datalab.utils.commands._chart._chart_cell({'chart': 'geo',
... | flexible | {
"blob_id": "445e91edbeb88a3e300761342b28369fd9833fbb",
"index": 5727,
"step-1": "<mask token>\n\n\nclass TestCases(unittest.TestCase):\n\n def test_chart_cell(self):\n t = [{'country': 'US', 'quantity': 100}, {'country': 'ZA',\n 'quantity': 50}]\n IPython.get_ipython().user_ns = {}\n... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Port(object):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Port(object):
def __init__(self, mac):
self.mac = mac
| flexible | {
"blob_id": "cd89c9eaea9d331288fd07f1968ef9dce89b4a4b",
"index": 7228,
"step-1": "<mask token>\n",
"step-2": "class Port(object):\n <mask token>\n",
"step-3": "class Port(object):\n\n def __init__(self, mac):\n self.mac = mac\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for n in my_list:
if new_num <= n:
i += 1
my_list.insert(i, float(new_num))
print(my_list)
<|reserved_special_token_1|>
my_list = [9, 9, 9, 8, 8, 7, 7, 6, 6, 5, 4, 4, 4, 2, 2, 1]
new_num = int(input('Enter a new num... | flexible | {
"blob_id": "be16e13c0e03952e45f98b175975795bba19cf9a",
"index": 2775,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor n in my_list:\n if new_num <= n:\n i += 1\nmy_list.insert(i, float(new_num))\nprint(my_list)\n",
"step-3": "my_list = [9, 9, 9, 8, 8, 7, 7, 6, 6, 5, 4, 4, 4, 2, 2, 1]\nnew... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class TestRollingWindow(unittest.TestCase):
<|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_spe... | flexible | {
"blob_id": "9539d2a4da87af1ff90b83bbcf72dfc8ab7b6db0",
"index": 5501,
"step-1": "<mask token>\n\n\nclass TestRollingWindow(unittest.TestCase):\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 Te... | [
1,
7,
8,
9,
11
] |
#https://www.youtube.com/watch?v=CQ5kc_j4RjA
import pandas as pd
#import quandl
import math, datetime
import time
import numpy as np
from pandas.tools.plotting import scatter_matrix
import matplotlib.pyplot as plt
from sklearn import cross_validation, preprocessing, svm
from sklearn.metrics import accuracy_s... | normal | {
"blob_id": "9c4676edbeef3748a4947f827fefa29e95674bfa",
"index": 121,
"step-1": "<mask token>\n\n\ndef Actual_Value():\n global df\n print('The Actual Closing Value is Displayed below')\n df = data.DataReader(stockTicker, 'yahoo', '2017-01-28', '2017-02-5')\n ao = df['Close']\n print(str(ao))\n ... | [
5,
12,
13,
14,
15
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 1 11:52:48 2022
@author: ccamargo
"""
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
import os
# 1. get filelist
path = "/Volumes/LaCie_NIOZ/data/steric/data/"
path_to_original_files = path + "original/"
flist = [file for ... | normal | {
"blob_id": "4fc4bb81d47a33e4669df46033033fddeca6544e",
"index": 8858,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor file in flist:\n print(file)\n name = file.split('.nc')[0]\n ds = xr.open_dataset(path_to_regrided_files + file, decode_times=False)\n timespan = [ds.timespan]\n print(... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class AdminUrlUserPermission(permissions.BasePermission):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class ReadOnly(permissions.BasePermission):
def has_permission(self, request, view):
return request.method in permissions.SAFE_METHODS
class AuthorM... | flexible | {
"blob_id": "4549f26cf8051535f9d3486d111fc7afe7514dea",
"index": 5674,
"step-1": "<mask token>\n\n\nclass AdminUrlUserPermission(permissions.BasePermission):\n <mask token>\n <mask token>\n\n\nclass ReadOnly(permissions.BasePermission):\n\n def has_permission(self, request, view):\n return reques... | [
6,
7,
8,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
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
<|reserved_special_token_1|>
<|reserved_special_to... | flexible | {
"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
] |
import json
import sqlite3
import time
import shelve
import os
from constants import *
VEC_TYPES = [
'''
CREATE TABLE "{}"
(ID TEXT PRIMARY KEY NOT NULL,
num TEXT NOT NULL);
''',
'''
CREATE TABLE "{}"
(ID INT PRIMARY KEY NOT NULL,
num TEXT NOT NULL);
''... | normal | {
"blob_id": "0a6cb6d3fad09ab7f0e19b6c79965315c0e0d634",
"index": 4793,
"step-1": "<mask token>\n\n\nclass Vector:\n\n def __init__(self, name, type, url_path):\n self._name = name\n self._conn = sqlite3.connect(url_path)\n self._cur = self._conn.cursor()\n self._cur.execute(\"SELEC... | [
3,
6,
8,
9,
10
] |
<|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": "2bf5ec4b4c0f0eed8364dcc9f1be599a804846f2",
"index": 4981,
"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 = [('ml', '0003_... | [
0,
1,
2,
3,
4
] |
import copy
from basics.binary_tree.binary_tree import TreeNode
from basics.binary_tree.traversals import level_order_traversal
def max_depth_bottom_up(root):
if not root:
return 0
max_so_far = 0
def max_depth(node, depth):
nonlocal max_so_far
if not node.left and not node.right... | normal | {
"blob_id": "555646a5d57152034b467cbce16b6c183bcfbb37",
"index": 6658,
"step-1": "<mask token>\n\n\ndef max_depth_bottom_up(root):\n if not root:\n return 0\n max_so_far = 0\n\n def max_depth(node, depth):\n nonlocal max_so_far\n if not node.left and not node.right:\n max... | [
8,
9,
12,
14,
15
] |
#! /usr/bin/env python
# -*- conding:utf-8 -*-
import MySQLdb
import os
import commands
from common import logger_init
from logging import getLogger
import re
from db import VlanInfo,Session,WafBridge
def getVlan(): # get vlan data from t_vlan
session=Session()
vlanport=[]
for info in session.query(VlanIn... | normal | {
"blob_id": "cd564ebb51cf91993d2ed1810707aead44c19a6b",
"index": 6959,
"step-1": "<mask token>\n\n\ndef getVlan():\n session = Session()\n vlanport = []\n for info in session.query(VlanInfo):\n a = []\n a.append(info.nets)\n a.append(info.vlan_id)\n vlanport.append(a)\n in... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
def numSmallerByFrequency(self, queries: List[str], words: List[str]
) ->List[int]:
words_freq = {word: word.count(min(word)) for word in wor... | flexible | {
"blob_id": "e9918f4fac2e13b36d9b20ffc28dc6508aad6f9b",
"index": 2159,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def numSmallerByFrequency(self, queries: List[str], words: List[str]\n ) ->List[int]:\n words_freq = {word: word.... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [path('', views.home, name='home'), path('ppt1', views.ppt1,
name='ppt1'), path('ppt2', views.ppt2, name='ppt2')]
<|reserved_special_token_1|>
from django.urls import path
from . import views
urlpatterns = [pa... | flexible | {
"blob_id": "9db1887c5379623687d1dea343d72122bab66303",
"index": 2143,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', views.home, name='home'), path('ppt1', views.ppt1,\n name='ppt1'), path('ppt2', views.ppt2, name='ppt2')]\n",
"step-3": "from django.urls import path\nfrom . ... | [
0,
1,
2,
3
] |
from .facebook import *
| normal | {
"blob_id": "7901a2bd4ae1070c8263d3cd97351b01ffbf7bb1",
"index": 7246,
"step-1": "<mask token>\n",
"step-2": "from .facebook import *\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
import contextlib
import logging
import os
import pwd
import sys
from typing import Iterable
from sqlalchemy import Table, exists, null, select
from sqlalchemy.engine import Engine
from sqlalchemy.exc import DBAPIError
from sqlalchemy.pool import NullPool
from hades import constants
from hades.common import db
from h... | normal | {
"blob_id": "c9df53ac06b8bb106d73825d60fa885c06385e95",
"index": 8557,
"step-1": "<mask token>\n\n\ndef check_database(engine: Engine, user_name: pwd.struct_passwd, tables:\n Iterable[Table]):\n logger.info('Checking database access as user %s', user_name)\n try:\n conn = engine.connect()\n ex... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def report_mismatch_for_module(modules_1, modules_2, index):
module_1 = modules_1[index]
module_2 = modules_2[index]
if len(module_1) != 2 or len(module_2) != 2:
raise AssertionError('Module {}, value {}, has length {}'.format(
index, module_1, len(module_1... | flexible | {
"blob_id": "329451a3d3fa95f5572dc1701d1adbf4aaa72628",
"index": 8521,
"step-1": "<mask token>\n\n\ndef report_mismatch_for_module(modules_1, modules_2, index):\n module_1 = modules_1[index]\n module_2 = modules_2[index]\n if len(module_1) != 2 or len(module_2) != 2:\n raise AssertionError('Modul... | [
3,
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_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.... | flexible | {
"blob_id": "b7a8e4105f1c1c532eaae27afae14e9a4f2ddfba",
"index": 2915,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# coding: utf-8
# # Cabecera
# In[1]:
# -*- coding: utf-8 -*-
# ------------- Cantidad de segundos que has vivido -------------
# # Definición de variables
# In[2]:
# Definición de variables
anios = 30
dias_por_anio = 365
horas_por_dia = 24
segundos_por_hora = 60
# # Operación
# In[3]... | normal | {
"blob_id": "f153da7e4537f807f6c9d9d268a00443933d8315",
"index": 4167,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(anios * dias_por_anio * horas_por_dia * segundos_por_hora)\n",
"step-3": "anios = 30\ndias_por_anio = 365\nhoras_por_dia = 24\nsegundos_por_hora = 60\nprint(anios * dias_por_anio ... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.