code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.12
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path impo... | normal | {
"blob_id": "a6670d0d09f02b674bc31b770f42d4d8a01a4a4e",
"index": 9884,
"step-1": "<mask token>\n\n\nclass SoapySDRSizeList(_object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def iterator(self):\n return _SoapySDR.SoapySDRSizeList_iterator(self)\n\n ... | [
177,
316,
400,
419,
427
] |
from flask import Flask, render_template
serious12 = Flask(__name__)
@serious12.route("/")
def home():
return "HOME"
@serious12.route("/user/<username>")
def user(username):
user = {
"trung": {
"name": "Trung",
"age": 19,
"birthplace": "Hanoi"
},
"n... | normal | {
"blob_id": "db1b6c545555116a334061440614e83e62994838",
"index": 4440,
"step-1": "<mask token>\n\n\n@serious12.route('/')\ndef home():\n return 'HOME'\n\n\n@serious12.route('/user/<username>')\ndef user(username):\n user = {'trung': {'name': 'Trung', 'age': 19, 'birthplace': 'Hanoi'},\n 'nguyenvana'... | [
2,
3,
4,
5,
6
] |
import pandas as pd
df1 = pd.read_csv('Tweets1.csv', names=['tweet'])
df2 = pd.read_csv('Tweets2.csv', names=['tweet'])
df3 = pd.read_csv('Tweets3.csv', names=['tweet'])
df = pd.concat([df1, df2, df3], axis=0, join='outer', ignore_index=False,
keys=None, levels=None, names=None, verify_integrity=False, copy=True)
d... | normal | {
"blob_id": "7d6196268b85861e76efaa53e14976f2eae09405",
"index": 3226,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndf.to_csv('Tweets.csv', index=None, header=None)\n",
"step-3": "<mask token>\ndf1 = pd.read_csv('Tweets1.csv', names=['tweet'])\ndf2 = pd.read_csv('Tweets2.csv', names=['tweet'])\ndf3 =... | [
0,
1,
2,
3
] |
print(sum([int(d) for d in str(pow(2, 1000))]))
| normal | {
"blob_id": "fc0c8deb3a5a57934c9e707911c352af55100c3c",
"index": 3533,
"step-1": "<mask token>\n",
"step-2": "print(sum([int(d) for d in str(pow(2, 1000))]))\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""
# fmt: off
"""
Every template contains an ordered list of TemplateObjects.
TemplateObject is defined in template_objects.py
GetMemory templates are written for filters and have an answer_type
They represent the action of fetching from the memory using the filte... | normal | {
"blob_id": "ceb714e949a72f621aec8b8728fbd1201e22afd1",
"index": 8705,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nANSWER_WITH_CORRECTION = [[[Human, What, Is, BlockObjectThis], [\n HumanReplace, The, AbstractDescription, BlockObjectLocation]], [[Human,\n What, Is, BlockObjectThis, AbstractDescr... | [
0,
1,
2,
3
] |
import unittest
from reactivex import interval
from reactivex import operators as ops
from reactivex.testing import ReactiveTest, TestScheduler
from reactivex.testing.marbles import marbles_testing
from reactivex.testing.subscription import Subscription
on_next = ReactiveTest.on_next
on_completed = ReactiveTest.on_co... | normal | {
"blob_id": "03dd37346ed12bbd66cbebc46fadc37be319b986",
"index": 548,
"step-1": "<mask token>\n\n\nclass TestSwitchMapIndex(unittest.TestCase):\n\n def test_switch_map_indexed_uses_index(self):\n scheduler = TestScheduler()\n xs = scheduler.create_hot_observable(on_next(300, 'a'), on_next(400,\n... | [
5,
7,
8,
9,
10
] |
import sys, os
sys.path.insert(0, os.path.abspath("adjust_schedule_function"))
| normal | {
"blob_id": "19126e5041841ab1320730ae82d66c6900cf31bd",
"index": 9145,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.insert(0, os.path.abspath('adjust_schedule_function'))\n",
"step-3": "import sys, os\nsys.path.insert(0, os.path.abspath('adjust_schedule_function'))\n",
"step-4": "import sy... | [
0,
1,
2,
3
] |
import os
class User(object):
def __init__(self, meta):
meta.update({
'groups': meta.get('groups', []) + [meta['username']]
})
self.meta = meta
@property
def username(self):
return self.meta['username']
@property
def groups(self):
return self.... | normal | {
"blob_id": "aa47b7c74b9b6b8a7f014de4bd58236edeba485d",
"index": 5971,
"step-1": "<mask token>\n\n\nclass User(object):\n\n def __init__(self, meta):\n meta.update({'groups': meta.get('groups', []) + [meta['username']]})\n self.meta = meta\n\n @property\n def username(self):\n retur... | [
9,
11,
12,
13,
16
] |
def long_alpha(str1):
list1 = []
list2 = ""
maxi = 0
j = 0
for i in range(len(str1)):
if i == 0:
list2 += str1[i]
elif ord(str1[i - 1]) <= ord(str1[i]):
list2 += str1[i]
else:
list1.append(list2)
list2 = ""
... | normal | {
"blob_id": "e7c18fa99c801fd959c868954f020d8c55babe0d",
"index": 7543,
"step-1": "<mask token>\n",
"step-2": "def long_alpha(str1):\n list1 = []\n list2 = ''\n maxi = 0\n j = 0\n for i in range(len(str1)):\n if i == 0:\n list2 += str1[i]\n elif ord(str1[i - 1]) <= ord(st... | [
0,
1,
2,
3,
4
] |
import sys
if sys.hexversion < 0x03000000:
from .foo import foo
| normal | {
"blob_id": "485729398b51bebd16f38800c6100289b7b0b347",
"index": 9023,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif sys.hexversion < 50331648:\n from .foo import foo\n",
"step-3": "import sys\nif sys.hexversion < 50331648:\n from .foo import foo\n",
"step-4": "\nimport sys\n\nif sys.hexver... | [
0,
1,
2,
3
] |
# import draw as p
# ако няма __init__.py
# from draw.point import Point
from draw import Rectangle
from draw import Point
from draw import ShapeUtils
if __name__ == '__main__':
pn1 = Point(9,8)
pn2 = Point(6,4)
print(f'dist: {pn1} and {pn1} = {ShapeUtils.distance(pn1,pn2)}')
rc1 = Rectangle(4... | normal | {
"blob_id": "b984dc052201748a88fa51d25c3bd3c22404fa96",
"index": 6571,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n pn1 = Point(9, 8)\n pn2 = Point(6, 4)\n print(f'dist: {pn1} and {pn1} = {ShapeUtils.distance(pn1, pn2)}')\n rc1 = Rectangle(40, 20, 120, 300)\n ... | [
0,
1,
2,
3
] |
from sklearn import cluster
from sklearn.metrics import adjusted_rand_score
import matplotlib.pyplot as plt
def test_Kmeans(*data):
x,labels_true = data
clst = cluster.KMeans()
clst.fit(x)
predicted_labels = clst.predict(x)
print("ARI: %s" % adjusted_rand_score(labels_true, predicted_labels))
p... | normal | {
"blob_id": "bd419d0a197a5e5a99a370e45cdb53a276ac5507",
"index": 5633,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_Kmeans(*data):\n x, labels_true = data\n clst = cluster.KMeans()\n clst.fit(x)\n predicted_labels = clst.predict(x)\n print('ARI: %s' % adjusted_rand_score(lab... | [
0,
2,
3,
4,
5
] |
from aspose.email.storage.pst import *
from aspose.email.mapi import MapiCalendar
from aspose.email.mapi import MapiRecipientType
from aspose.email.mapi import MapiRecipientCollection
from aspose.email.mapi import MapiRecipient
import datetime as dt
from datetime import timedelta
import os
def run():
dataDir = "Dat... | normal | {
"blob_id": "8a6028aa477f697946ab75411b667f559e87141c",
"index": 7072,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef run():\n dataDir = 'Data/'\n personalStorage = PersonalStorage.from_file(dataDir + 'Outlook.pst')\n for folder in personalStorage.root_folder.get_sub_folders():\n ... | [
0,
1,
2,
3,
4
] |
# Generated by Django 2.1.7 on 2019-04-01 14:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('submissions', '0004_auto_20190401_1834'),
]
operations = [
migrations.AlterField(
model_name='mainsubmission',
name=... | normal | {
"blob_id": "3fed8723d215bce3cf391752e07ca85b2d6701a3",
"index": 3410,
"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 = [('submissions... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
from random import *
prob = "change"
cases = [
10,
10,
10,
100,
100,
100000,
100000,
100000,
100000,
100000
]
cur = 0
st = [1,2,5,10,20,50,100,200,500,1000,2000,5000,10000]
for (n) in cases :
cout = ""
... | normal | {
"blob_id": "2cef5311a9ff9497ad6611fe7b47e4f7c5b1b3c7",
"index": 7581,
"step-1": "#!/usr/bin/python\n\nfrom random import *\n\nprob = \"change\"\n\ncases = [ \n 10,\n 10,\n 10,\n 100,\n 100,\n 100000,\n 100000,\n 100000,\n 100000,\n 100000\n... | [
0
] |
#!/bin/env python
# coding: utf-8
"""
Dakara Online protocol generator, by Alejandro Santos
"""
from genpackets import *
from gendefs_js import *
BUILDERS = []
HANDLERS = []
DECODE_DISPATCH = []
ARGS_HANDLER = []
def write_packets_from(f, fph, base_name, namespace, P):
# Enum with IDs
if base_name != "Serv... | normal | {
"blob_id": "22dccf6bb76dab735f373089d0772f475b2d5a5d",
"index": 6849,
"step-1": "<mask token>\n\n\ndef write_packets_from(f, fph, base_name, namespace, P):\n if base_name != 'ServerPacket':\n f.write('var {base_name}ID = {{ \\n'.format(base_name=base_name))\n for i, x in enumerate(P):\n ... | [
4,
5,
6,
7,
8
] |
fahrenheit = float(input("Enter a fahrenheit degree: "))
celcius = ((fahrenheit - 32) * 5) / 9
print("From fahrenheit to celcius", celcius) | normal | {
"blob_id": "2f2030107f3a23c0d2f404a838eaccc8b35ac410",
"index": 1086,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('From fahrenheit to celcius', celcius)\n",
"step-3": "fahrenheit = float(input('Enter a fahrenheit degree: '))\ncelcius = (fahrenheit - 32) * 5 / 9\nprint('From fahrenheit to celc... | [
0,
1,
2,
3
] |
#This version assumes domains = train/test set
import numpy as np
from ..utils import Dataset
import math
import random
from .interface import TopicModel
from .man_model.models import *
from .man_model import utils
from .man_model.options import opt
import torch.utils.data as data_utils
from tqdm import tqdm
from colle... | normal | {
"blob_id": "8f01934472805b5ad6dca328483a7ac79ae7748a",
"index": 6474,
"step-1": "<mask token>\n\n\nclass MultinomialAdversarialNetwork(TopicModel):\n <mask token>\n\n def prepare_data(self, d):\n \"\"\"\n Assume d is a dictionary of dataset where d[domain] = another dataset class\n As... | [
4,
5,
6,
8,
9
] |
# Copyright 2018 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | normal | {
"blob_id": "fc5b9117ecf56401a888e2b6a5e244f9ab115e41",
"index": 3999,
"step-1": "<mask token>\n\n\nclass SyncTestCase(tests.unittest.HomeserverTestCase):\n <mask token>\n servlets = [admin.register_servlets, knock.register_servlets, login.\n register_servlets, room.register_servlets]\n\n def pre... | [
6,
8,
9,
10,
11
] |
import sqlite3
connection = sqlite3.connect('database.db')
cursor = connection.cursor()
# cursor.execute('CREATE TABLE users (id int, username text, password text)')
cursor.execute('INSERT INTO users VALUES(?,?,?)',(1,'ilia','qwerty'))
users = [(2,'nika','asdf'),(3,'nino','sdfg')]
cursor.executemany('INSERT INTO ... | normal | {
"blob_id": "d6b49533573dfefba6286ac2bffc2bd7a4075063",
"index": 1731,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncursor.execute('INSERT INTO users VALUES(?,?,?)', (1, 'ilia', 'qwerty'))\n<mask token>\ncursor.executemany('INSERT INTO users VALUES(?,?,?)', users)\nfor row in cursor.execute('SELECT * F... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Phase transition module
"""
import utils
import datetime
import itertools
import numpy as np
import recovery as rec
import sampling as smp
import graphs_signals as gs
import pathos.multiprocessing as mp
from tqdm import tqdm
## MAIN FUNCTIONS ##
def grid_evalua... | normal | {
"blob_id": "d65f858c3ad06226b83d2627f6d38e03eae5b36c",
"index": 266,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef line_evaluation(param_list, param_eval, file_name='line evaluation', **\n kwargs):\n \"\"\"\n Evaluates a list of parameter pairs across repeated trials and aggregates the... | [
0,
1,
2,
3,
4
] |
class Person:
country = "INDIA"
def __init__(self):
print("its base constructor")
def takeBreath(self):
print("Yes Iam breathing.")
class Emp(Person): # inherits person
def takeBreath(self):
print("Yes Iam EMP and Iam also breathing.")
class Prog(Emp):
def ... | normal | {
"blob_id": "cb2e2ef70935a22854c70fedf4f4a6715b089291",
"index": 1990,
"step-1": "<mask token>\n\n\nclass Prog(Emp):\n\n def __init__(self):\n super().__init__()\n print('its child constructor')\n\n def takeBreath(self):\n super().takeBreath()\n print('Iam a programmer and breat... | [
4,
6,
8,
11,
13
] |
'''
IplNorm.py
Description:
Normalizing 0 - 255 initial fingerprint to a normalized image.
Using energy normalization.
Input:
-image
Output:
-norm_im
@author: Edoardo Foco
'''
import cv2
import numpy as np
def normalise(image):
dbl_image = image.astype(float)
#... | normal | {
"blob_id": "f51d85ff352d9c84a8ded29ad94b24ca6dda46ad",
"index": 7593,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef normalise(image):\n dbl_image = image.astype(float)\n mean = np.mean(dbl_image)\n iplImage = cv2.cv.CreateImageHeader((image.shape[1], image.shape[0]),\n cv2.cv.IP... | [
0,
1,
2,
3
] |
# Generated by Django 2.2.6 on 2020-05-27 19:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pancar', '0006_auto_20200526_1058'),
]
operations = [
migrations.AlterField(
model_name='process',
name='price',
... | normal | {
"blob_id": "316a34bbc2b3e3c818ef837f51bc1f86863ea59a",
"index": 2473,
"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 = [('pancar', '0... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: MIT
"""
The main service module
MIT License
Copyright (c) 2017-2020, Leo Moll
"""
# -- Imports ------------------------------------------------
from resources.lib.service import MediathekViewService
# -- Main Code ----------------------------------------------
if... | normal | {
"blob_id": "e769e930ab8f0356116679bc38a09b83886eb8f6",
"index": 4003,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n SERVICE = MediathekViewService()\n SERVICE.init()\n SERVICE.run()\n SERVICE.exit()\n del SERVICE\n",
"step-3": "<mask token>\nfrom resources.... | [
0,
1,
2,
3
] |
# Exercise 3: Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message.
# If the score is between 0.0 and 1.0, print a grade using the following table:
# Score Grade
# >= 0.9 A
# >= 0.8 B
# >= 0.7 C
# >= 0.6 D
# < 0.6 F
# Vinayak Nayak
# 27... | normal | {
"blob_id": "6f253da5dc1caa504a3a8aadae7bce6537b5c8c6",
"index": 6237,
"step-1": "<mask token>\n",
"step-2": "try:\n i = float(input('Enter the score : '))\n if i > 1 or i < 0:\n print(\"Entered score isn't valid.\")\n elif i < 0.6:\n print('Grade: F')\n elif i < 0.7:\n print('... | [
0,
1,
2
] |
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
def paragraph_spacing():
doc = SimpleDocTemplate("paragraph_spacing.pdf", pagesize=letter)
styles = getSampleStyleSheet()
#Mengahasilkan spasi antar ... | normal | {
"blob_id": "d79e65b7aa09066230dec1a472f4535dff4123b5",
"index": 4217,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef paragraph_spacing():\n doc = SimpleDocTemplate('paragraph_spacing.pdf', pagesize=letter)\n styles = getSampleStyleSheet()\n styles['Normal'].spaceBefore = 10\n styles[... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def calcLuckyNumber(x):
resultSet = set()
for i in range(30):
for j in range(30):
for k in range(30):
number = pow(3, i) * pow(5, j) * pow(7, k)
if number > 1 and number <= x:
resultSet.add(nu... | normal | {
"blob_id": "49a9fb43f3651d28d3ffac5e33d10c428afd08fd",
"index": 6072,
"step-1": "<mask token>\n",
"step-2": "def calcLuckyNumber(x):\n resultSet = set()\n for i in range(30):\n for j in range(30):\n for k in range(30):\n number = pow(3, i) * pow(5, j) * pow(7, k)\n ... | [
0,
1,
2,
3,
4
] |
import socket
import json
import numpy as np
"""TCP client used to communicate with the Unity Application"""
class TCP:
def __init__(self, sock = None):
# Create a TCP socket
if sock is None:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
else:
self.s... | normal | {
"blob_id": "cc66dcd34115e72479953ca24f4b2eaeb52cf313",
"index": 7747,
"step-1": "<mask token>\n\n\nclass TCP:\n <mask token>\n\n def connect(self, host, port):\n server_address = host, port\n print('connecting to {} port {}'.format(*server_address))\n self.sock.connect(server_address)... | [
5,
6,
7,
8,
9
] |
__author__ = 'samar'
import mv_details
import product
| normal | {
"blob_id": "7ac53779a98b6e4b236b1e81742163d2c610a274",
"index": 4556,
"step-1": "<mask token>\n",
"step-2": "__author__ = 'samar'\n<mask token>\n",
"step-3": "__author__ = 'samar'\nimport mv_details\nimport product\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
import http.cookies
import json
import os
import itertools
import types
from framework import helpers
from framework import security
class Model:
"""Manages the information received by the client"""
def __init__(self):
"""Puth the os.environ dict into the namespace"""
self.__dict__.update(
... | normal | {
"blob_id": "7f21ab8d332d169226ef17276abbdd373e3a62c2",
"index": 8544,
"step-1": "<mask token>\n\n\nclass Model:\n <mask token>\n <mask token>\n\n @property\n def form(self):\n \"\"\"Contains the data send from the client.\"\"\"\n return security.get_field_storage()\n\n @property\n ... | [
7,
8,
9,
10,
11
] |
import json
import math
import rospy
import sys
import RPi.GPIO as GPIO
from std_msgs.msg import Float32
from geometry_msgs.msg import Point32
from time import sleep
#pulse width of difference rotations
d_45 = 1.0
d_90 = 1.5
d_180 = 2.5
frequency = 50.0
t_per_cycle = (1.0 / frequency) * 1000.0
#convert to duty cycle... | normal | {
"blob_id": "95845aeb47e0d2c579739767ece35f4134564d98",
"index": 7717,
"step-1": "<mask token>\n\n\nclass Servo_node:\n\n def __init__(self):\n rospy.init_node('servo_node', anonymous=False)\n GPIO.setwarnings(False)\n GPIO.setmode(GPIO.BCM)\n motor_x = 13\n motor_y = 12\n ... | [
7,
8,
10,
11,
12
] |
from django.db import models
from django.utils.translation import ugettext_lazy as _
from apps.sources.models.mixins.page_numbers import PageNumbersMixin
from apps.sources.models.source import Source
PIECE_TYPES = (('essay', 'Essay'),)
TYPE_MAX_LENGTH: int = 10
class Piece(Source, PageNumbersMixin):
"""A piece ... | normal | {
"blob_id": "30c24b9a4738c1952fc5d36a4bc36d8d3576ed3b",
"index": 7201,
"step-1": "<mask token>\n\n\nclass Piece(Source, PageNumbersMixin):\n \"\"\"A piece (e.g., essay).\"\"\"\n type = models.CharField(verbose_name=_('piece type'), max_length=\n TYPE_MAX_LENGTH, choices=PIECE_TYPES, default=PIECE_TY... | [
4,
5,
6,
7,
8
] |
class Solution(object):
def exist(self, board, word):
"""
:type board: List[List[str]]
:type word: str
:rtype: bool
"""
if not board or not board[0]: return not word
self.length = len(word)
def hasPathCore(row, col, depth=0):
if self.length... | normal | {
"blob_id": "9b8db3407313a3e39d429b7c10897fc447fcdc27",
"index": 1337,
"step-1": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution(object):\n\n def exist(self, board, word):\n \"\"\"\n :type board: List[List[str]]\n :type word: ... | [
1,
2,
3,
4,
5
] |
# Generated by Django 2.2.3 on 2019-07-18 06:05
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('juchu', '0003_auto_20190718_1500'),
]
operations = [
migrations.RemoveField(
mode... | normal | {
"blob_id": "b0174b6f6c33434ff9b5cdb59531502899d8348a",
"index": 4262,
"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 = [('juchu', '00... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
##!/work/local/bin/python
##!/work/local/CDAT/bin/python
import sys,getopt
import matplotlib.pyplot as plt
def read():
x = []
y = []
for line in sys.stdin:
v1,v2 = line.split()[:2]
x.append(float(v1))
y.append(float(v2))
return x,y
#def plot(x,y):
def ... | normal | {
"blob_id": "b16ad4bae079159da7ef88b61081d7763d4ae9a0",
"index": 8312,
"step-1": "#!/usr/bin/env python\n##!/work/local/bin/python\n##!/work/local/CDAT/bin/python\n\nimport sys,getopt\nimport matplotlib.pyplot as plt\n\n\ndef read():\n\n x = []\n y = []\n for line in sys.stdin:\n v1,v2 = line.spl... | [
0
] |
# coding: utf-8
"""
Styled object
=============
A :class:`~benker.styled.Styled` object contains a dictionary of styles.
It is mainly used for :class:`~benker.table.Table`, :class:`~benker.table.RowView`,
:class:`~benker.table.ColView`, and :class:`~benker.cell.Cell`.
"""
import pprint
class Styled(object):
""... | normal | {
"blob_id": "8fa58791aae1352109b3bf7410d68bf5ae1d8cb7",
"index": 9559,
"step-1": "<mask token>\n\n\nclass Styled(object):\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return str(self._styles)\n\n def __repr__(self):\n cls = self.__class__.__name__\n it... | [
5,
6,
8,
9,
10
] |
def solution(a, b):
answer = 0;
for i in range(0,len(a)):
answer+=a[i]*b[i];
print(answer);
return answer
solution([1,2,3,4],[-3,-1,0,2]); | normal | {
"blob_id": "5fd34c698c2060d5399ba43f6746527961aa574b",
"index": 9239,
"step-1": "<mask token>\n",
"step-2": "def solution(a, b):\n answer = 0\n for i in range(0, len(a)):\n answer += a[i] * b[i]\n print(answer)\n return answer\n\n\n<mask token>\n",
"step-3": "def solution(a, b):\n answ... | [
0,
1,
2,
3
] |
#day11
n = int(input("Enter a number: "))
c = 0
a,b = 0, 1
list = [a, b]
for i in range(2,n+1):
c = a+b
list.append(c)
a,b = b, c
print(n,"th fibonacci number is ",list[n])
| normal | {
"blob_id": "255cdbce1f9f7709165b1a29362026ad92ba4712",
"index": 2303,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(2, n + 1):\n c = a + b\n list.append(c)\n a, b = b, c\nprint(n, 'th fibonacci number is ', list[n])\n",
"step-3": "n = int(input('Enter a number: '))\nc = 0\na, ... | [
0,
1,
2,
3
] |
# Copyright 2021 Yegor Bitensky
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, ... | normal | {
"blob_id": "5750fd4b59f75ea63b4214ee66b23602ed4d314d",
"index": 8909,
"step-1": "<mask token>\n\n\nclass DiceWrongFacesItemsTypeError(Exception):\n\n def __init__(self):\n super().__init__('Dice \"faces_items\" argsument need to be iterable.')\n\n\nclass DiceWrongFacesItemsCountError(Exception):\n\n ... | [
6,
7,
9,
12,
13
] |
#!/usr/bin/env python3
import numpy as np
from DMP.PIDMP import RLDMPs
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
np.random.seed(50)
dmp_y0 = np.array([-1.52017496, 0.04908739, 1.41433029])
dmp_goal = np.array([-1.50848603, 0.0591503 , 1.44347592])
load_file_name = "w_0_2_right_3... | normal | {
"blob_id": "5e6bbb10ec82e566c749dd4d794eabd2e8f7a648",
"index": 4488,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnp.random.seed(50)\n<mask token>\nrl.load_weight(load_file_name)\n<mask token>\nprint(rl.w)\n<mask token>\nplt.scatter(x, track.y[0][:, 0], c='b', label='random')\nplt.scatter(x, track.y[... | [
0,
1,
2,
3,
4
] |
import unittest
from Spreadsheet.HTML import Table
class TestColGroup(unittest.TestCase):
def test_colgroup(self):
return
data = [
['a','b','c'],
[1,2,3],
[4,5,6],
]
gen = Table( { 'data': data, 'colgroup': { 'span': 3, 'width': 100 }, 'attr_so... | normal | {
"blob_id": "24f87bd6aab0ff65cf2153e27df31122818ad0ac",
"index": 766,
"step-1": "<mask token>\n\n\nclass TestColGroup(unittest.TestCase):\n <mask token>\n\n def test_col(self):\n return\n data = [['a', 'b', 'c'], [1, 2, 3], [4, 5, 6]]\n gen = Table({'data': data, 'colgroup': {'span': 3... | [
2,
3,
4,
5,
6
] |
import input_data
import tensorflow as tf
from infogan import InfoGAN
if __name__ == '__main__':
# get input data
mnist_data = input_data.load_mnist_dataset('../../dataset/mnist_data', one_hot=True)
num_sample = mnist_data.train.num_examples
dataset = 'mnist'
if dataset == 'mnist':
input_di... | normal | {
"blob_id": "02a28b61ad9d664c89829df019f4887c2c869f91",
"index": 6046,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n mnist_data = input_data.load_mnist_dataset('../../dataset/mnist_data',\n one_hot=True)\n num_sample = mnist_data.train.num_examples\n dataset ... | [
0,
1,
2,
3
] |
import optparse
from camera import apogee_U2000
if __name__ == "__main__":
parser = optparse.OptionParser()
group1 = optparse.OptionGroup(parser, "General")
group1.add_option('--s', action='store', default=1, dest='mode', help='set cooler on/off')
args = parser.parse_args()
options, args = parser.par... | normal | {
"blob_id": "60c849d213f6266aeb0660fde06254dfa635f10f",
"index": 3383,
"step-1": "import optparse\n\nfrom camera import apogee_U2000\t\t\t\n\nif __name__ == \"__main__\":\n parser = optparse.OptionParser()\n group1 = optparse.OptionGroup(parser, \"General\") \n group1.add_option('--s', action='store', defau... | [
0
] |
# Inspiration: [Fake Album Covers](https://fakealbumcovers.com/)
from IPython.display import Image as IPythonImage
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import requests
from xml.etree import ElementTree as ET
def display_cover(top,bottom ):
name='album_art_raw.png'
alb... | normal | {
"blob_id": "07215403750be53994ae36727b6f790202b88697",
"index": 253,
"step-1": "# Inspiration: [Fake Album Covers](https://fakealbumcovers.com/)\nfrom IPython.display import Image as IPythonImage\nfrom PIL import Image\nfrom PIL import ImageFont\nfrom PIL import ImageDraw\n\nimport requests\nfrom xml.etree impo... | [
0
] |
# -*- coding: utf-8 -*-
__author__ = 'virtual'
statuses = {
None: {'name': 'None', },
-1: { 'name': 'unknown', },
0: { 'name': '',},
1: { 'name': 'Новый',},
2: { 'name': '',},
3: { 'name': 'Активный', },
4: { 'name': 'Приостановленный',},
5: { 'name': 'Заблокированный', },
6: { 'n... | normal | {
"blob_id": "a847fc32af2602db3b5545c15186c0209eb8ae8d",
"index": 4008,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_status_name(status):\n return '[%d]%s' % (status, statuses[status]['name'])\n",
"step-3": "__author__ = 'virtual'\nstatuses = {None: {'name': 'None'}, (-1): {'name': 'unk... | [
0,
1,
2,
3
] |
#!/usr/bin/python
import platform
from numpy import ctypeslib,empty,array,exp,ascontiguousarray,zeros,asfortranarray
from ctypes import c_float,c_double,c_int
from time import time
def resize(img,scale):
"""
downsample img to scale
"""
sdims=img.shape
datatype=c_double
if img.dtype!=data... | normal | {
"blob_id": "816f4cfe98f5e5b23f2c8f9f42c5f3ed8458042f",
"index": 3700,
"step-1": "#!/usr/bin/python \n\nimport platform\nfrom numpy import ctypeslib,empty,array,exp,ascontiguousarray,zeros,asfortranarray\nfrom ctypes import c_float,c_double,c_int\nfrom time import time\n\ndef resize(img,scale):\n \"\"\"\n ... | [
0
] |
import time
class Solution(object):
def __init__(self):
self.n = None
self.memory = dict()
def dfs(self, bottom, energy):
# optimize for memory, save search time for duplicate results
if (bottom,energy) in self.memory:
return self.memory[(bottom,energy)]
... | normal | {
"blob_id": "d52b6dda7111aefb7f9a7b10ad606cda615389d9",
"index": 7123,
"step-1": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n\n def dfs(self, bottom, energy):\n if (bottom, energy) in self.memory:\n return self.memory[bottom, energy]\n if energy == 1:\n re... | [
3,
5,
7,
8,
10
] |
from __future__ import annotations
import ibis
from ibis import _
def test_format_sql_query_result(con, snapshot):
t = con.table("airlines")
query = """
SELECT carrier, mean(arrdelay) AS avg_arrdelay
FROM airlines
GROUP BY 1
ORDER BY 2 DESC
"""
schema = ibis.schema({"... | normal | {
"blob_id": "97ff8dae060475b0efbc8d39e9fc251be8ac091b",
"index": 6264,
"step-1": "<mask token>\n\n\ndef test_memoize_insert_sort_key(con, snapshot):\n table = con.table('airlines')\n t = table['arrdelay', 'dest']\n expr = t.group_by('dest').mutate(dest_avg=t.arrdelay.mean(), dev=t.\n arrdelay - t... | [
1,
2,
3,
4,
5
] |
import math
# 计算像素点属于哪个中心点
from utils.util import distance
def attenuation(color, last_mean):
return 1 - math.exp(((distance(color, last_mean) / 80) ** 2) * -1)
def get_Count_By_distance(centers, pixel_use,d):
# d_min设置过低会产生多的中心点,许多很相似但是没有归到一类中
# d_min设置过高产生少的中心点,不相似的归到一类中
d_min = 1;
d_b = d;
... | normal | {
"blob_id": "918db455fc50b49ca2b40dd78cecdec4ba08dcb8",
"index": 6013,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_Count_By_distance(centers, pixel_use, d):\n d_min = 1\n d_b = d\n count_use = 0\n for i in range(len(centers)):\n d = attenuation(centers[i], pixel_use)\n ... | [
0,
1,
2,
3,
4
] |
from fixate.reporting.csv import register_csv, unregister_csv
| normal | {
"blob_id": "c70db0fc9d98657e318ecab7eb8af60cc2b19a2c",
"index": 4145,
"step-1": "<mask token>\n",
"step-2": "from fixate.reporting.csv import register_csv, unregister_csv\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
from flask import Flask,request,Response
from spamapp.spam import SpamIdentify
from json import dumps,loads
app = Flask(__name__)
spam = SpamIdentify()
@app.route("/",methods=['GET'])
def home():
return Response(response=dumps({"msg":"App successfull"}), status=200, mimetype='application/json')
@app.route("/spam... | normal | {
"blob_id": "1552d862d3b9df45eda8c08256e8b4437ab08740",
"index": 2641,
"step-1": "<mask token>\n\n\n@app.route('/', methods=['GET'])\ndef home():\n return Response(response=dumps({'msg': 'App successfull'}), status=200,\n mimetype='application/json')\n\n\n@app.route('/spamapi/', methods=['GET', 'POST']... | [
2,
3,
4,
5,
6
] |
N = int(input())
K = int(input())
xs = list(map(int, input().split()))
dist = 0
for x in xs:
dist += min(x, K - x)
print(dist * 2)
| normal | {
"blob_id": "a65ab0faf08c13f007a132fb92f358a35834fdb7",
"index": 2556,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor x in xs:\n dist += min(x, K - x)\nprint(dist * 2)\n",
"step-3": "N = int(input())\nK = int(input())\nxs = list(map(int, input().split()))\ndist = 0\nfor x in xs:\n dist += min... | [
0,
1,
2
] |
def test(d_iter):
from cqlengine import columns
from cqlengine.models import Model
from cqlengine.query import ModelQuerySet
from cqlengine import connection
from cqlengine.management import sync_table
from urllib2 import urlopen, Request
from pyspark.sql import S... | normal | {
"blob_id": "11f29508d52e856f4751a5dc8911a1f1c9832374",
"index": 944,
"step-1": "<mask token>\n",
"step-2": "def test(d_iter):\n from cqlengine import columns\n from cqlengine.models import Model\n from cqlengine.query import ModelQuerySet\n from cqlengine import connection\n from cqlengine.mana... | [
0,
1,
2,
3,
4
] |
import os
from sklearn import metrics
import pandas as pd
import numpy as np
from submission import submission
import argparse
import glob
def calc_auc(subm):
preds=subm['target'].values
labels=subm['labels'].values
if len(set(labels))==1:
print('warning calc_auc with single label dataset, return... | normal | {
"blob_id": "fe0b21deb2e48ad74449b264265729cb328090ea",
"index": 6380,
"step-1": "<mask token>\n\n\ndef calc_auc(subm):\n preds = subm['target'].values\n labels = subm['labels'].values\n if len(set(labels)) == 1:\n print('warning calc_auc with single label dataset, return 0')\n return 0\n ... | [
3,
4,
5,
6,
7
] |
from .dla import get_network as get_dla
from lib.utils.tless import tless_config
_network_factory = {'dla': get_dla}
def get_network(cfg):
arch = cfg.network
heads = cfg.heads
head_conv = cfg.head_conv
num_layers = int(arch[arch.find('_') + 1:]) if '_' in arch else 0
arch = arch[:arch.find('_')] i... | normal | {
"blob_id": "7df94c86ff837acf0f2a78fe1f99919c31bdcb9b",
"index": 4881,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_network(cfg):\n arch = cfg.network\n heads = cfg.heads\n head_conv = cfg.head_conv\n num_layers = int(arch[arch.find('_') + 1:]) if '_' in arch else 0\n arch = ... | [
0,
1,
2,
3
] |
"""Secret Garden tests."""
from secret_garden import Decoder, SecretGarden
import random
filename = "pr08_example_data.txt"
key = "Fat Chocobo"
d = Decoder(filename, key)
s = SecretGarden(filename, key)
def test_read_from_file():
"""
Test of function of reading data from file.
:return:
"""
readi... | normal | {
"blob_id": "8cfab525ab3a86dd6964475d5621fdc7c6413e38",
"index": 8019,
"step-1": "<mask token>\n\n\ndef test_read_from_file():\n \"\"\"\n Test of function of reading data from file.\n\n :return:\n \"\"\"\n reading_file = d.read_code_from_file()\n assert type(reading_file) == list\n assert le... | [
5,
6,
7,
8,
9
] |
import math
import pendulum
from none import *
@on_command('yearprogress')
async def year_progress(session: CommandSession):
await session.send(get_year_progress())
def get_year_progress():
dt = pendulum.now()
percent = year_progress(dt)
year = dt.year
return f'你的 {year} 使用进度:{percent}%\n' \
... | normal | {
"blob_id": "f54d0eeffa140af9c16a1fedb8dcd7d06ced29f2",
"index": 2395,
"step-1": "<mask token>\n\n\ndef get_year_progress():\n dt = pendulum.now()\n percent = year_progress(dt)\n year = dt.year\n return f'你的 {year} 使用进度:{percent}%\\n\\n\\n{make_progress_string(percent)}'\n\n\ndef year_progress(dt):\n... | [
2,
3,
4,
5,
6
] |
import json
import glob
import sys
searchAreaName = sys.argv[1]
# searchAreaName = "slovenia_177sqkm_shards/20161220-162010-c9e0/slovenia_177sqkm_predicted/predict_slovenia_177sqkm_shard"
print('./{0}_??.txt'.format(searchAreaName))
all_predicts = glob.glob('./{0}_??.txt'.format(searchAreaName))
def getBboxes(bboxes):... | normal | {
"blob_id": "8f9d823785d42d02a0a3d901d66b46a5cd59cdd7",
"index": 7465,
"step-1": "<mask token>\n\n\ndef getBboxes(bboxes):\n return [bb for bb in bboxes if sum(bb) > 0.0]\n\n\n<mask token>\n",
"step-2": "<mask token>\nprint('./{0}_??.txt'.format(searchAreaName))\n<mask token>\n\n\ndef getBboxes(bboxes):\n ... | [
1,
2,
3,
4,
5
] |
"""
Constants to be used throughout this program
stored here.
"""
ROOT_URL = "https://api.twitter.com"
UPLOAD_URL = "https://upload.twitter.com"
REQUEST_TOKEN_URL = f'{ROOT_URL}/oauth/request_token'
AUTHENTICATE_URL = f'{ROOT_URL}/oauth/authenticate'
ACCESS_TOKEN_URL = f'{ROOT_URL}/oauth/access_token'
VERSION = '1.1'... | normal | {
"blob_id": "c907f6b954aa3eae21a54eba9d54c116576bd40a",
"index": 5848,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nROOT_URL = 'https://api.twitter.com'\nUPLOAD_URL = 'https://upload.twitter.com'\nREQUEST_TOKEN_URL = f'{ROOT_URL}/oauth/request_token'\nAUTHENTICATE_URL = f'{ROOT_URL}/oauth/authenticate'... | [
0,
1,
2
] |
# Unsolved:Didn't try coz of this warning:
# If you use Python, then submit solutions on PyPy. Try to write an efficient solution.
from sys import stdin
from collections import defaultdict
t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, stdin.readline().strip().split()))
d... | normal | {
"blob_id": "789f098fe9186d2fbda5417e9938930c44761b83",
"index": 6760,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(t):\n n = int(input())\n arr = list(map(int, stdin.readline().strip().split()))\n d = defaultdict(int)\n maxnum = 0\n for num in arr:\n d[num] += 1\n ... | [
0,
1,
2,
3,
4
] |
ALPHABET = 'abcdefghijklmnopqrstuvwxyz'
# Convert the ALPHABET to list
ALPHABET = [i for i in ALPHABET]
output_string = ''
input_string = input('Enter a String : ')
key = int(input('Enter the key: '))
for letter in input_string:
if letter in input_string:
# ALPHABET.index(letter) returns the index of that... | normal | {
"blob_id": "b2db622596d0dff970e44759d25360a62f5fea83",
"index": 4725,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor letter in input_string:\n if letter in input_string:\n output_string += ALPHABET[(ALPHABET.index(letter) + key) % 26]\n else:\n output_string += letter\nprint(f'En... | [
0,
1,
2,
3
] |
"""
Solution to Codeforces problem 50A
Copyright (c) GeneralMing. All rights reserved.
https://github.com/GeneralMing/codeforces
"""
n = input().split()
n[0] = int(n[0])
n[1] = int(n[1])
print((n[0]*n[1])//2) | normal | {
"blob_id": "41a80feeb1fdc8ad783706ad261f5fc1124371d6",
"index": 8216,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(n[0] * n[1] // 2)\n",
"step-3": "<mask token>\nn = input().split()\nn[0] = int(n[0])\nn[1] = int(n[1])\nprint(n[0] * n[1] // 2)\n",
"step-4": "\"\"\"\n\tSolution to Codeforces p... | [
0,
1,
2,
3
] |
from setuptools import setup, find_packages
import sys, os
version = '0.1'
setup(
name='ckanext-MYEXTENSION',
version=version,
description="description",
long_description="""\
""",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='',
author='ldhspace',
author... | normal | {
"blob_id": "9d2c0d59b0b2b4e4fca942e648059738053c53d0",
"index": 9376,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='ckanext-MYEXTENSION', version=version, description=\n 'description', long_description='\\t', classifiers=[], keywords='',\n author='ldhspace', author_email='ldhspace@yah... | [
0,
1,
2,
3,
4
] |
#coding: utf-8
"""
1) Encontre em um texto os nomes próprios e os retorne em uma lista. Utilize o Regex (‘import re’) e a função findall(). Na versão básica, retorne todas as palavras que iniciam com maiúscula.
2) Apresente um plot de alguns segundos dos dados de acelerômetro do dataset:
https://archive.ics.uci.edu/... | normal | {
"blob_id": "d95d899c6eae5a90c90d3d920ee40b38bf304805",
"index": 532,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n pass\n",
"step-3": "#coding: utf-8\n\"\"\" \n1) Encontre em um texto os nomes próprios e os retorne em uma lista. Utilize o Regex (‘import re’) e a função... | [
0,
1,
2
] |
def Merge (left,right,merged):
#Ф-ция объединения и сравнения элементов массивов
left_cursor,right_cursor=0,0
while left_cursor<len(left) and right_cursor<len(right):
if left[left_cursor]<=right[right_cursor]:
merged[left_cursor+right_cursor]=left[left_cursor]
left_cursor+=1... | normal | {
"blob_id": "c64c542b57107c06de2ce0751075a81fcb195b61",
"index": 4293,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef MergeSort(array):\n if len(array) <= 1:\n return array\n mid = len(array) // 2\n left, right = MergeSort(array[:mid]), MergeSort(array[mid:])\n return Merge(lef... | [
0,
1,
2,
3
] |
import thread
import time
import ctypes
lib = ctypes.CDLL('/home/ubuntu/workspace/35SmartPy/CAN/brain/CANlib.so')
init = lib.init
read = lib.readGun
read.restype = ctypes.POINTER(ctypes.c_ubyte * 8)
send = lib.sendBrake
init()
| normal | {
"blob_id": "866571341a587c8b1b25437f5815429875bbe5ad",
"index": 9285,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ninit()\n",
"step-3": "<mask token>\nlib = ctypes.CDLL('/home/ubuntu/workspace/35SmartPy/CAN/brain/CANlib.so')\ninit = lib.init\nread = lib.readGun\nread.restype = ctypes.POINTER(ctypes.... | [
0,
1,
2,
3
] |
def countdown(n):
def next():
nonlocal n
r = n
n -= 1
return r
return next
a = countdown(12)
while True:
v = a()
if not v:
break
| normal | {
"blob_id": "01eef391f6d37d1e74cb032c5b27e1d8fc4395da",
"index": 6122,
"step-1": "<mask token>\n",
"step-2": "def countdown(n):\n\n def next():\n nonlocal n\n r = n\n n -= 1\n return r\n return next\n\n\n<mask token>\n",
"step-3": "def countdown(n):\n\n def next():\n ... | [
0,
1,
2,
3
] |
# Generated by Django 3.1.5 on 2021-05-30 14:27
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('fuser', '0009_movement_type'),
]
operations = [
migrations.AlterField(
model_name='movementpass... | normal | {
"blob_id": "848374ea7d706bbd2ef5a76489cabeff998acb82",
"index": 6040,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('fuser', '00... | [
0,
1,
2,
3,
4
] |
import struct
from coapthon import defines
from coapthon.utils import byte_len, bit_len, parse_blockwise
__author__ = 'Giacomo Tanganelli'
__version__ = "2.0"
class BlockwiseLayer(object):
"""
Handles the Blockwise feature.
"""
def __init__(self, parent):
"""
Initialize a Blockwise L... | normal | {
"blob_id": "70d740a7003ca3f2d2cde039b2fc470ef2165e77",
"index": 7078,
"step-1": "<mask token>\n\n\nclass BlockwiseLayer(object):\n <mask token>\n\n def __init__(self, parent):\n \"\"\"\n Initialize a Blockwise Layer.\n\n :type parent: coapserver.CoAP\n :param parent: the CoAP s... | [
5,
6,
7,
8,
9
] |
from mikeio.spatial import GeometryPoint2D, GeometryPoint3D
# https://www.ogc.org/standard/sfa/
def test_point2d_wkt():
p = GeometryPoint2D(10, 20)
assert p.wkt == "POINT (10 20)"
p = GeometryPoint2D(x=-5642.5, y=120.1)
assert p.wkt == "POINT (-5642.5 120.1)"
def test_point3d_wkt():
p = Geomet... | normal | {
"blob_id": "ae45a4967a8ee63c27124d345ad4dc0c01033c0e",
"index": 6749,
"step-1": "<mask token>\n\n\ndef test_point3d_wkt():\n p = GeometryPoint3D(10, 20, 30)\n assert p.wkt == 'POINT Z (10 20 30)'\n\n\ndef test_point2d_to_shapely():\n p = GeometryPoint2D(10, 20)\n sp = p.to_shapely()\n assert sp.x... | [
2,
3,
4,
5,
6
] |
number = int(input("Enter a number, and I'll tell you if it's even or odd: "))
if number % 2 == 0:
print(f"{number} is an even number.")
else:
print(f"{number} is an odd number.") | normal | {
"blob_id": "b147a22d6bd12a954c0d85c11e578a67f0a51332",
"index": 3025,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif number % 2 == 0:\n print(f'{number} is an even number.')\nelse:\n print(f'{number} is an odd number.')\n",
"step-3": "number = int(input(\"Enter a number, and I'll tell you if ... | [
0,
1,
2,
3
] |
something1
x = session.query(x).filter(y).count()
something2
y = session.query(
models.User, models.X,
).filter(
models.User.time > start_time,
models.User.id == user_id,
).count()
def something3():
x = session.query(
models.Review,
).filter(
models.Review.time < end_time,
).coun... | normal | {
"blob_id": "5b91b7025b0e574d45f95a0585128018d83c17ea",
"index": 563,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef something3():\n x = session.query(models.Review).filter(models.Review.time < end_time\n ).count()\n\n\n<mask token>\n",
"step-3": "something1\n<mask token>\nsomething2\... | [
0,
1,
2,
3,
4
] |
from odoo import models, fields, api, _
class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv"
date_start_invoice_timesheet = fields.Date(
string='Start Date',
help="Only timesheets not yet invoiced (and validated, if applicable) from this period will be inv... | normal | {
"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
] |
#Created by Jake Hansen for Zebra interview take home assessment, July 2020.
import csv, os, sys, pickle
from datetime import date
#Class For storing information about each file generally. Helpful for future
#use cases to remember the indicies from a file, if file has thousands of fields
#Also can be used as a log to ... | normal | {
"blob_id": "38c1b82a29a5ad0b4581e63fb083ca2487a79817",
"index": 9544,
"step-1": "<mask token>\n\n\nclass DataSource:\n\n def __init__(self, name, usableRows, errorRows, indices):\n self.name = name\n self.usableRows = usableRows\n self.errorRows = errorRows\n self.indices = indice... | [
5,
6,
8,
9,
10
] |
from unittest import TestCase
# auto-test toggled test class to monitor changes to is_palindrome function
class Test_is_palindrome(TestCase):
def test_is_palindrome(self):
from identify_a_palindrome import is_palindrome
self.assertTrue(is_palindrome("Asdfdsa"))
self.assertTrue(is_palindrome... | normal | {
"blob_id": "785b54dce76d6906df513a8bde0110ab6fd63357",
"index": 7083,
"step-1": "<mask token>\n\n\nclass Test_is_palindrome(TestCase):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Test_is_palindrome(TestCase):\n\n def test_is_palindrome(self):\n from i... | [
1,
3,
4,
5,
6
] |
"""
Copyright (C) 2014, Jill Huchital
"""
# test comment
from flask import Flask
from flask import render_template
from flask import jsonify
from flask import request
from playlists import get_all_playlists, create_playlists, get_all_categories, add_new_category, add_new_topic, get_all_topics
from db import connect_... | normal | {
"blob_id": "5193de15052f81460a23d993cfa039fa90c9de5e",
"index": 897,
"step-1": "<mask token>\n\n\n@app.route('/hello/')\ndef hello():\n return render_template('index.html', greeting='here we are')\n\n\n<mask token>\n\n\n@app.route('/api/1.0/create_playlists', methods=['POST'])\ndef do_create_playlists():\n ... | [
6,
9,
11,
13,
14
] |
from typing import Optional,List
from fastapi import FastAPI
from pydantic import BaseModel, Field
from redisqueue import RedisQueue,MyRedis
import random
class Award(BaseModel):
name: str
count: int
class Item(BaseModel):
luckname: str = Field(...,title="抽奖规则名称",max_lenght = 300)
total: int = Field... | normal | {
"blob_id": "4550ed971eef36badf46a44adcc593324a5292cf",
"index": 2637,
"step-1": "<mask token>\n\n\nclass Award(BaseModel):\n name: str\n count: int\n\n\nclass Item(BaseModel):\n luckname: str = Field(..., title='抽奖规则名称', max_lenght=300)\n total: int = Field(..., title='抽奖总人数', gt=0)\n award: Opti... | [
7,
8,
10,
11,
12
] |
#
# Copyright (c) 2018-2020 by Kristoffer Paulsson <kristoffer.paulsson@talenten.se>.
#
# This software is available under the terms of the MIT license. Parts are licensed under
# different terms if stated. The legal terms are attached to the LICENSE file and are
# made available on:
#
# https://opensource.org/lice... | normal | {
"blob_id": "f494dc99febfad99b371d72f542556a9024bc27d",
"index": 5333,
"step-1": "<mask token>\n\n\nclass TestVerified(TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass TestTrusted(TestCase):\n\n def setUp(self):\n self.instance = Trusted()\n\n def tearDown(self):\n ... | [
9,
13,
14,
17,
18
] |
from mininet.cli import CLI
from mininet.term import makeTerms
from mininet.util import irange
from log import log
from utils import (UITextStyle, display)
from dijkstra import (get_routing_decision, get_route_cost)
# Check if route directly connects two switches
def isDirect(route):
return (len(route) == 2)
# ... | normal | {
"blob_id": "7636925982434b12307383ba7b01f931f7ea6e24",
"index": 5927,
"step-1": "<mask token>\n\n\nclass DongPhamTestCli(CLI):\n <mask token>\n\n def __init__(self, _mininet, _env):\n self.env = _env\n self.net = _mininet\n self._testCLI = {}\n CLI.__init__(self, _mininet)\n ... | [
10,
18,
21,
26,
27
] |
num = 15850
base = 16
# Primera división
residuo = num % base
cociente = num // base
bit1 = str(residuo)
bit1 = bit1.replace("10","a")
bit1 = bit1.replace("11","b")
bit1 = bit1.replace("12","c")
bit1 = bit1.replace("13","d")
bit1 = bit1.replace("14","e")
bit1 = bit1.replace("15","f")
# Segunda división
residuo = co... | normal | {
"blob_id": "2d72f063362aaefdc236e1240020c71bacaf51cf",
"index": 8057,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('{} = {}{}{}{}'.format(num, bit4, bit3, bit2, bit1))\n",
"step-3": "num = 15850\nbase = 16\nresiduo = num % base\ncociente = num // base\nbit1 = str(residuo)\nbit1 = bit1.replace(... | [
0,
1,
2,
3
] |
positivo = float(1.0000001)
negativo = float(-1.000001)
print(negativo, positivo)
b_pos = bin(positivo)
b_neg = bin(negativo)
print(b_neg, b_pos)
| normal | {
"blob_id": "5c908697000247056bb63a443f837eef88b4c957",
"index": 9196,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(negativo, positivo)\n<mask token>\nprint(b_neg, b_pos)\n",
"step-3": "positivo = float(1.0000001)\nnegativo = float(-1.000001)\nprint(negativo, positivo)\nb_pos = bin(positivo)\nb... | [
0,
1,
2
] |
import sys, os
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.p... | normal | {
"blob_id": "5fb3905abf958f0a8be41cd6ad07efb2a0cf6c66",
"index": 7542,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef resource_path(relative_path):\n \"\"\" Get absolute path to resource, works for dev and for PyInstaller \"\"\"\n try:\n base_path = sys._MEIPASS\n except Exception... | [
0,
1,
2,
3,
4
] |
import datastructure
import wordUri
class Question:
def __init__(self, nlp, otter, nounArray, verbArray):
self.nlp = nlp
self.nounArray = nounArray
self.verbArray = verbArray
self.file = otter
def findFirst(self, sentence):
sentenceDoc = self.nlp(sentence)
for... | normal | {
"blob_id": "4d63a5f09164b78faa731af6dce41969edc2c4f5",
"index": 848,
"step-1": "<mask token>\n\n\nclass Question:\n <mask token>\n <mask token>\n\n def findSecond(self, sentenceDoc, verb, children):\n for child in children:\n if child.dep_ == 'attr' or child.dep_ == 'nsubj':\n ... | [
3,
4,
6,
7,
8
] |
# boj, 9237 : 이장님 초대, python3
# 그리디 알고리즘
import sys
def tree(l):
return max([i+j+2 for i,j in enumerate(l)])
N = int(sys.stdin.readline())
t = sorted(list(map(int, sys.stdin.readline().split())), reverse = True)
print(tree(t)) | normal | {
"blob_id": "e79cdd32977eb357c3f6709887b671c50eb1fa45",
"index": 7071,
"step-1": "<mask token>\n\n\ndef tree(l):\n return max([(i + j + 2) for i, j in enumerate(l)])\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef tree(l):\n return max([(i + j + 2) for i, j in enumerate(l)])\n\n\n<mask token>\npri... | [
1,
2,
3,
4,
5
] |
'''
Please Note:
Note: It is intended for some problems to be ambiguous. You should gather all requirements up front before implementing one.
Please think of all the corner cases and clarifications yourself.
Validate if a given string is numeric.
Examples:
1."0" => true
2." 0.1 " => true
3."abc" => false
4."1 a" =>... | normal | {
"blob_id": "50be2cbdaec6ed76e5d9367c6a83222f9153db82",
"index": 7426,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def isNumber(self, A):\n while len(A) > 0 and A[0] == ' ':\n ... | [
0,
1,
2,
3,
4
] |
import random
import time
import unittest
from old import dict_groupby
class TestDictGroupBy(unittest.TestCase):
def setUp(self):
random.seed(0)
self.sut = dict_groupby
def generate_transaction(self):
return {
'transaction_type': random.choice(['a', 'b', 'c']),
... | normal | {
"blob_id": "f8e6f6e1be6c4ea306b7770c918b97808a0765b2",
"index": 6580,
"step-1": "<mask token>\n\n\nclass TestDictGroupBy(unittest.TestCase):\n\n def setUp(self):\n random.seed(0)\n self.sut = dict_groupby\n <mask token>\n\n def generate_facility(self):\n num_transactions = random.r... | [
4,
7,
8,
9,
10
] |
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
#led = 21
pins = [21, 25, 18]
# 0 1 2 3 4
names = ["First", "Second", "Third"]
for x in range(len(pins)):
GPIO.setup(pins[x], GPIO.IN, pull_up_down=GPIO.PUD_UP)
#GPIO.setup(led, GPIO.OUT)
while True:
input_state = 0
for i in ran... | normal | {
"blob_id": "d292de887c427e3a1b95d13cef17de1804f8f9ee",
"index": 6535,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nGPIO.setmode(GPIO.BCM)\n<mask token>\nfor x in range(len(pins)):\n GPIO.setup(pins[x], GPIO.IN, pull_up_down=GPIO.PUD_UP)\nwhile True:\n input_state = 0\n for i in range(len(pins... | [
0,
1,
2,
3,
4
] |
import tcod as libtcod
import color
from input_handlers import consts
from input_handlers.ask_user_event_handler import AskUserEventHandler
class SelectIndexHandler(AskUserEventHandler):
"""
Handles asking the user for an index on the map.
"""
def __init__(self, engine):
super().__init__(eng... | normal | {
"blob_id": "8c7dcff80eeb8d7d425cfb25da8a30fc15daf5f9",
"index": 4872,
"step-1": "<mask token>\n\n\nclass SelectIndexHandler(AskUserEventHandler):\n <mask token>\n <mask token>\n\n def on_render(self, console):\n \"\"\"\n Highlight the tile under the cursor.\n \"\"\"\n super(... | [
3,
6,
7,
8,
9
] |
__version__ = '18.07.0'
| normal | {
"blob_id": "3cac7829cf0c07ddc704a25ec3c781c9510a8e0c",
"index": 3613,
"step-1": "<mask token>\n",
"step-2": "__version__ = '18.07.0'\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
# Mostra entre as 7 pessoas, quantas pessoas são maiores de idade.
num1 = 0
for c in range(0,7):
pe1 = int(input('Digite o ano de nascimento: '))
pe1 = 2019 - pe1
if pe1 >= 21:
num1 = num1 + 1
print(f'Entre as 7 pessoas, {num1} pessoas são maiores de idade.') | normal | {
"blob_id": "251d589a5815d77d2bc375d8d4a7d41e79a2a5cd",
"index": 5303,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor c in range(0, 7):\n pe1 = int(input('Digite o ano de nascimento: '))\n pe1 = 2019 - pe1\n if pe1 >= 21:\n num1 = num1 + 1\nprint(f'Entre as 7 pessoas, {num1} pessoas s... | [
0,
1,
2,
3
] |
from Eutils.pathmagic import context
with context():
import argparse
import numpy as np
from model.hourglass_yolo_net_multi_gpu import HOURGLASSYOLONet
from evaluator.Eutils.pascal_val import PASCAL_VAL
# from evaluator.Eutils.coco_val import COCO_VAL
from evaluator.Eutils.detector import Detect... | normal | {
"blob_id": "3bb6305ceb1491db57c7f8b03e438398644c8f90",
"index": 8124,
"step-1": "<mask token>\n\n\nclass EVALUATOR(object):\n\n def __init__(self, detector, data):\n self.detector = detector\n self.data = data\n self.gt = self.data.gt\n self.image_ids, self.bboxes, self.prob, self... | [
5,
6,
7,
8,
9
] |
import os
import zipfile
import cv2
import numpy as np
from sklearn import svm
from sklearn import cross_validation
from sklearn.externals import joblib
import matplotlib.pyplot as plt
""" Global constants """
data_zip = "data.zip" # The zip archive
clean_files = [".csv", ".jpg"] # File extensions ... | normal | {
"blob_id": "d2da95f44e814accd3a91c5e8497ceff85c98711",
"index": 2848,
"step-1": "import os\nimport zipfile\nimport cv2\nimport numpy as np\nfrom sklearn import svm\nfrom sklearn import cross_validation\nfrom sklearn.externals import joblib\nimport matplotlib.pyplot as plt\n\n\n\"\"\" Global constants \"\"\"\nda... | [
0
] |
#!/usr/bin/python3
import os
import sys
import subprocess
path = sys.argv[1]
name, ext = os.path.splitext(path)
options = ['g++',
'-O3',
'src/' + path,
'-o', f'./bin/{name}',
'-std=c++11',
'-lgmp']
subprocess.call(options)
subprocess.call([f'./bin/{name}'])
| normal | {
"blob_id": "5dd79f8ebd74099871d4367cafd83359c4f24e26",
"index": 5385,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsubprocess.call(options)\nsubprocess.call([f'./bin/{name}'])\n",
"step-3": "<mask token>\npath = sys.argv[1]\nname, ext = os.path.splitext(path)\noptions = ['g++', '-O3', 'src/' + path,... | [
0,
1,
2,
3,
4
] |
# ------------------------------------------------------------
# calclex.py
#
# tokenizer for a simple expression evaluator for
# numbers and +,-,*,/
# ------------------------------------------------------------
import ply.lex as lex
# Regular expression rules for simple tokens
t_PLUS = r'\+'
t_MINUS = r'-'... | normal | {
"blob_id": "1530f1711be6313b07df680721daf4cb0a84edc0",
"index": 5502,
"step-1": "# ------------------------------------------------------------\n# calclex.py\n#\n# tokenizer for a simple expression evaluator for\n# numbers and +,-,*,/\n# ------------------------------------------------------------\nimport ply.l... | [
0
] |
def digital_sum(n):
if n < 10:
return n
return n % 10 + digital_sum(n // 10)
def digital_root(n):
if n < 10:
return n
return digital_root(digital_sum(n))
| normal | {
"blob_id": "e3e6f1b6580a223558791cebfcb1a92d45553162",
"index": 1823,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef digital_root(n):\n if n < 10:\n return n\n return digital_root(digital_sum(n))\n",
"step-3": "def digital_sum(n):\n if n < 10:\n return n\n return n % ... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
"""
Project Euler - Problem XX
...
"""
# Imports
import time
# Global variables
# Lamda functions
# Functions
# Main functions
def main():
print('Output')
# Execute code
start = time.time()
if __name__ == "__main__":
main()
end = time.time()
print('Run time: {}'.format(end - start... | normal | {
"blob_id": "cdb07241e08f8ac85a427c5b2bc3effca3917c85",
"index": 2188,
"step-1": "<mask token>\n\n\ndef main():\n print('Output')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n print('Output')\n\n\n<mask token>\nif __name__ == '__main__':\n main()\n<mask token>\nprint('Run time: {}'.... | [
1,
2,
3,
4,
5
] |
from bacalhau.tei_document import TEIDocument
import nltk
import unittest
class TestDocument(unittest.TestCase):
def setUp(self):
self.filepath = 'tests/corpus/a.xml'
self.doc = TEIDocument(self.filepath, nltk.tokenize.regexp.
WordPunctTokenizer(), nltk.corpus.stopwords.words('english... | normal | {
"blob_id": "f86d01c4b980ac44dcdb1b0008493e1dbda25971",
"index": 4544,
"step-1": "<mask token>\n\n\nclass TestDocument(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_get_texts(self):\n texts = self.doc.get_texts()\n self.assertEqual(2, len(texts))\n\n def test_get_term_d... | [
3,
5,
6,
7
] |
import sys
sys.stdin = open('10989.txt', 'r')
counting_list = [0 for _ in range(10001)]
N = int(sys.stdin.readline())
for n in range(N):
counting_list[int(sys.stdin.readline())] += 1
for i, v in enumerate(counting_list):
if v:
sys.stdout.write((str(i) + '\n') * v)
| normal | {
"blob_id": "efca954e1977a6f6ac9a966b3c84ba80f5b7a663",
"index": 690,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor n in range(N):\n counting_list[int(sys.stdin.readline())] += 1\nfor i, v in enumerate(counting_list):\n if v:\n sys.stdout.write((str(i) + '\\n') * v)\n",
"step-3": "<ma... | [
0,
1,
2,
3,
4
] |
#classes that store values related to levels
from mg_cus_struct import *
from mg_movement import *
import copy
class BulletTemplate(object) :
def __init__(self, animationName, initialVelocity, hitbox) :
self._spawningCycle = 0
self._animationName = animationName
self._initialVelocity = init... | normal | {
"blob_id": "519746450826d02230a492a99e0b518602d53fcb",
"index": 9932,
"step-1": "<mask token>\n\n\nclass BulletSpawnerTemplate(object):\n <mask token>\n <mask token>\n\n def setRounds(self, rounds):\n self._rounds = rounds\n <mask token>\n\n def setInBetweenTimer(self, delay):\n sel... | [
16,
19,
22,
25,
26
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.