code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def calcula_distancia_do_projetil(v, O, y0):
g = 9.8
return v ** 2 / 2 * g * (1 + math.sqrt(1 + 2 * g * y0 / v ** 2 * math.
sin(O) ** 2)) * math.sin(2 * O)
<|reserved_special_token_1|>
import math
def calcul... | flexible | {
"blob_id": "0a459b4aeb2a16c06c1d89dafb656028b235a31e",
"index": 9415,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef calcula_distancia_do_projetil(v, O, y0):\n g = 9.8\n return v ** 2 / 2 * g * (1 + math.sqrt(1 + 2 * g * y0 / v ** 2 * math.\n sin(O) ** 2)) * math.sin(2 * O)\n",
"s... | [
0,
1,
2,
3
] |
#Kivy + Box2d test
#Not working...
from Box2D import *
from random import random
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ObjectProperty
from kivy.lang import Builder
from kivy.clock import Clock
Builder.load_string('''
<PongBall>:
canvas:
C... | normal | {
"blob_id": "fa8431ae96cd6c1133d56285d0168f43d9068bc5",
"index": 2099,
"step-1": "<mask token>\n\n\nclass PongBall(Widget):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, **kwargs):\n super(PongBall, self).__init__(**kwargs)\n sel... | [
8,
12,
13,
15,
16
] |
from tkinter import *
from get_train_set import *
from datetime import *
counter = 0
week = int(datetime.today().isocalendar()[1])
def update(a, b):
global counter
if b == 'x':
b = 0
a = week
counter = 0
else:
counter += b
a += counter
train_set = get_train_set(... | normal | {
"blob_id": "62fe29b0ac4dee8fec4908cf803dba9bd7e92fa5",
"index": 4602,
"step-1": "<mask token>\n\n\ndef update(a, b):\n global counter\n if b == 'x':\n b = 0\n a = week\n counter = 0\n else:\n counter += b\n a += counter\n train_set = get_train_set(a)\n txtLbl1.c... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
auto_duration_sec = 15
teleop_duration_sec = 135
| flexible | {
"blob_id": "5229002103379ff10969e64289d5a0f36641c0a3",
"index": 3497,
"step-1": "<mask token>\n",
"step-2": "auto_duration_sec = 15\nteleop_duration_sec = 135\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
"""
definition of a sensor
"""
import datetime
import pytz
class tlimit:
def __init__(self, name, text):
self.name = name
self.text = text
time_limit = [
tlimit("All", "All Data"),
tlimit("day", "Current day"),
tlimit("24hours", "Last 24 hours"),
tlimit("3days", "Three last days"... | normal | {
"blob_id": "cb9ea8791009a29a24a76bc2b161e7f8599fec1b",
"index": 5780,
"step-1": "<mask token>\n\n\nclass tlimit:\n\n def __init__(self, name, text):\n self.name = name\n self.text = text\n\n\n<mask token>\n\n\nclass SensorData:\n date = datetime.datetime(1970, 1, 1, 0, 0, 0)\n server_room... | [
12,
13,
14,
18,
20
] |
<|reserved_special_token_0|>
def main(argc, argv, envir):
raw_samples = np.array([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]])
deal_with_ohe(raw_samples)
ohe = sp.OneHotEncoder(sparse=False, dtype=int)
ohe_samples = ohe.fit_transform(raw_samples)
print(ohe_samples)
return 0
<|reserved_specia... | flexible | {
"blob_id": "0b0282ade565eb4031cef3a2fa8605249f104d9d",
"index": 2438,
"step-1": "<mask token>\n\n\ndef main(argc, argv, envir):\n raw_samples = np.array([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]])\n deal_with_ohe(raw_samples)\n ohe = sp.OneHotEncoder(sparse=False, dtype=int)\n ohe_samples = ohe.fi... | [
1,
2,
3,
4,
5
] |
# required !!!
# pip install selenium
# pip install webdriver-manager
from theMachine import loops
# fill the number and message
# you can fill the number with array
phoneNumber = "fill the number"
message = "fill with ur message"
loop = 1 # this how many u want to loop
loops(loop, phoneNumber, message)... | normal | {
"blob_id": "81dfdf0479fc1f136fa5153840d8c7015f9db676",
"index": 32,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nloops(loop, phoneNumber, message)\n",
"step-3": "<mask token>\nphoneNumber = 'fill the number'\nmessage = 'fill with ur message'\nloop = 1\nloops(loop, phoneNumber, message)\n",
"step-4... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def print99():
"""
打印99乘法口诀表
:return:
"""
for i in range(1, 10):
for j in range(1, i + 1):
print('%dX%d=%2s ' % (j, i, i * j))
print('\n')
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def prin... | flexible | {
"blob_id": "90f1fd45d58c7e6f275a33cd9c693ff584b2df47",
"index": 1396,
"step-1": "<mask token>\n",
"step-2": "def print99():\n \"\"\"\n 打印99乘法口诀表\n :return:\n \"\"\"\n for i in range(1, 10):\n for j in range(1, i + 1):\n print('%dX%d=%2s ' % (j, i, i * j))\n print('\\n'... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class NormalBetForm(forms.Form):
song = forms.CharField()
data = forms.ChoiceField(BET_CHOICES)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
BET_CHOICES = ('1', 'Will rise'), ('x', 'Will stay'), ('2', 'Wi... | flexible | {
"blob_id": "2f6d51d5c14ddc1f6cd60ab9f3b5d4a879d14af0",
"index": 4590,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass NormalBetForm(forms.Form):\n song = forms.CharField()\n data = forms.ChoiceField(BET_CHOICES)\n",
"step-3": "<mask token>\nBET_CHOICES = ('1', 'Will rise'), ('x', 'Will ... | [
0,
2,
3,
4,
5
] |
import numpy as np
"""
function for calculating integrals using the trapezoid method
x is a vector of independent variables
y is a vector of dependent variables
a is the initial value
b is the final value
n is the number of intervals
y_generator is the function to be integrated
"""
def tra... | normal | {
"blob_id": "8ce468460a81c7869f3abb69035a033c58e0f699",
"index": 8828,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef trapezoid_integral(**kwargs):\n a = kwargs.get('a', None)\n b = kwargs.get('b', None)\n n = kwargs.get('n', 2)\n y_generator = kwargs.get('y_generator', None)\n x =... | [
0,
1,
2,
3
] |
try:
a = int(input("Enter a:"))
b = int(input("Enter b:"))
c = a/b
except:
print("Can't divide with zero") | normal | {
"blob_id": "143f6ee38413a0713c18281e9737c09d9947a61a",
"index": 2805,
"step-1": "<mask token>\n",
"step-2": "try:\n a = int(input('Enter a:'))\n b = int(input('Enter b:'))\n c = a / b\nexcept:\n print(\"Can't divide with zero\")\n",
"step-3": "try:\n a = int(input(\"Enter a:\"))\n b = int(... | [
0,
1,
2
] |
<|reserved_special_token_0|>
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1].lower() == 'jpg'
def get_profile_img():
os.chdir('static\\img\\profile_img')
if os.access(f'{current_user.id}.jpg', os.F_OK):
filename = str(current_user.id)
elif current_user.gende... | flexible | {
"blob_id": "d373d283a622262e2da974549907bdd8f61e89ec",
"index": 2114,
"step-1": "<mask token>\n\n\ndef allowed_file(filename):\n return '.' in filename and filename.rsplit('.', 1)[1].lower() == 'jpg'\n\n\ndef get_profile_img():\n os.chdir('static\\\\img\\\\profile_img')\n if os.access(f'{current_user.i... | [
30,
35,
37,
40,
41
] |
from pathlib import Path
file = Path(__file__).parent / 'input.txt'
Y = 2000000
MAX_X = 4000000
MIN_X = 0
MAX_Y = 4000000
MIN_Y = 0
# file = Path(__file__).parent / 'test_input.txt'
# Y = 10
# MAX_X = 20
# MIN_X = 0
# MAX_Y = 20
# MIN_Y = 0
text = file.read_text().splitlines()
class Beacon():
def __init__(self, ... | normal | {
"blob_id": "f3a1a926feabcabc870f0a41ae239939c331d09d",
"index": 4106,
"step-1": "<mask token>\n\n\nclass Beacon:\n\n def __init__(self, pos, sensor) ->None:\n self.pos = pos\n self.sensor = sensor\n <mask token>\n\n def __repr__(self) ->str:\n return f'{self}'\n <mask token>\n ... | [
24,
28,
30,
34,
35
] |
# Write files
# Writing to a file within a Python program:
# In order to write to a file, we use file.write(str).
# This method writes a string to a file.
# The method write() works like Python's print() function, except it does not add a newline ("\n") character.
# File dialogs:
# Module tkinter has a submodule cal... | normal | {
"blob_id": "0372cdbae8c5b0bbcbade86a5a7de28c1ee513b1",
"index": 2486,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntkinter.filedialog.askopenfilename()\n<mask token>\nfrom_file.close()\n<mask token>\nto_file.write('Copy\\n')\nto_file.write(contents)\nto_file.close()\n",
"step-3": "<mask token>\ntkin... | [
0,
1,
2,
3,
4
] |
from pynhost.grammars import extension
from pynhost.grammars import baseutils as bu
class AtomExtensionGrammar(extension.ExtensionGrammar):
activate = '{ctrl+alt+8}'
search_chars = bu.merge_dicts(bu.OPERATORS, bu.ALPHABET, bu.CHAR_MAP)
def __init__(self):
super().__init__()
self.app_conte... | normal | {
"blob_id": "ac5c6a534d5131438d9590b070e6b392d4ebed0c",
"index": 9764,
"step-1": "<mask token>\n\n\nclass AtomExtensionGrammar(extension.ExtensionGrammar):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass AtomExtensionGrammar(extension.ExtensionGrammar):\n <mask t... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
args = docopt(__doc__, version=openmaptiles.__version__)
layer = Layer.parse(args['<layer-definition>'])
markdown = collect_documentation(layer)
print(markdown)
<|reserved_special_token... | flexible | {
"blob_id": "991b894c4c0fb9cb90aef0542227e001a3a3bb0d",
"index": 9651,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n args = docopt(__doc__, version=openmaptiles.__version__)\n layer = Layer.parse(args['<layer-definition>'])\n markdown = collect_documentation(layer)\... | [
0,
1,
2,
3
] |
'''
Created on 17.05.2018
@author: markus
'''
import Ship
import Player
import Planet
import random
from FighterShip import FighterShip
turnCounter = 0
def cleanScreen():
for i in range(0,50):
print("")
def spacePirates(player):#space prites attack, their firepower is +/-20% of player firepower
... | normal | {
"blob_id": "97611fef5faafe660c7640e4a5aec8456e52135c",
"index": 9960,
"step-1": "<mask token>\n\n\ndef spacePortMenu(player, planet):\n global turnCounter\n while True:\n cleanScreen()\n print('****W*E*L*C*O*M*E****T*O****T*H*E****S*P*A*C*E*P*O*R*T****')\n print('Enter 1 to jump to a ... | [
2,
5,
8,
9,
10
] |
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 15 19:27:59 2020
@author: Dan
"""
import numpy as np
def shift(v,i,j):
if i <= j:
return v
store = v[i]
for k in range(0, i-j-1):
v[i-k] = v[i-k-1]
v[j] = store
return v
def insertion(v):
for i in range(1, len(v)):
j = i
... | normal | {
"blob_id": "35288c9ad4d3550003e3c2f9e9034f4bce1df830",
"index": 3626,
"step-1": "<mask token>\n\n\ndef shift(v, i, j):\n if i <= j:\n return v\n store = v[i]\n for k in range(0, i - j - 1):\n v[i - k] = v[i - k - 1]\n v[j] = store\n return v\n\n\ndef insertion(v):\n for i in rang... | [
2,
3,
4,
5,
6
] |
# Copyright (c) 2018, Raul Astudillo
import numpy as np
from copy import deepcopy
class BasicModel(object):
"""
Class for handling a very simple model that only requires saving the evaluated points (along with their corresponding outputs) so far.
"""
analytical_gradient_prediction = True
def __in... | normal | {
"blob_id": "88071df9367804b1c6e2b1c80da178ab7658e7a4",
"index": 3861,
"step-1": "<mask token>\n\n\nclass BasicModel(object):\n <mask token>\n <mask token>\n <mask token>\n\n def updateModel(self, X, Y):\n \"\"\"\n Updates the model with new observations.\n \"\"\"\n self.X... | [
7,
8,
9,
10,
12
] |
#coding=utf-8
from selenium import webdriver
wd=webdriver.Firefox()
wd.get('https://www.baidu.com/')
wd.find_element_by_id('kw').send_keys(u'哈哈')
wd.quit()
| normal | {
"blob_id": "8de36400f21bfb4e24703d5a65471a961e1afddc",
"index": 9796,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwd.get('https://www.baidu.com/')\nwd.find_element_by_id('kw').send_keys(u'哈哈')\nwd.quit()\n",
"step-3": "<mask token>\nwd = webdriver.Firefox()\nwd.get('https://www.baidu.com/')\nwd.fin... | [
0,
1,
2,
3,
4
] |
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
ts=robjects.r('ts')
forecast = importr("forecast", lib_loc = "C:/Users/sand9888/Documents/sand9888/R/win-library/3.3")
import os
import pandas as pd
from rpy2.robjects import pandas2ri
pandas2ri.activate()
train = os.path.join('C:/DAT203.3x/... | normal | {
"blob_id": "e00cbe6e177ee841c6e64de842e5b8f95463b3a8",
"index": 2169,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npandas2ri.activate()\n<mask token>\n",
"step-3": "<mask token>\nts = robjects.r('ts')\nforecast = importr('forecast', lib_loc=\n 'C:/Users/sand9888/Documents/sand9888/R/win-library/3... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
import sys
OPEN_BRACES = ['{', '(', '[']
CLOSE_BRACES = ['}', ')', ']']
def match_paranthesis (s, pos):
stack = []
for i,c in enumerate(s):
if not c in OPEN_BRACES and not c in CLOSE_BRACES:
continue
if c in OPEN_BRACES:
stack.append((i, c))
... | normal | {
"blob_id": "cc6cef70381bb08247720ec32b7e8fe79ed7123d",
"index": 1014,
"step-1": "#!/usr/bin/python\n\nimport sys\n\nOPEN_BRACES = ['{', '(', '[']\nCLOSE_BRACES = ['}', ')', ']']\n\ndef match_paranthesis (s, pos):\n stack = []\n\n for i,c in enumerate(s):\n if not c in OPEN_BRACES and not c in CLOSE... | [
0
] |
<|reserved_special_token_0|>
class LocationPayload(FBObject):
coordinates: Coors
class AttachmentFallback(FBObject):
title: str
url: AnyUrl
payload: typing.Any = None
type: str = 'fallback'
class Attachment(FBObject):
type: str
payload: typing.Union[MediaPayload, Coors, None]
<|reser... | flexible | {
"blob_id": "1f6176e9285d810934ae745cf8759b5cd6f408c8",
"index": 8767,
"step-1": "<mask token>\n\n\nclass LocationPayload(FBObject):\n coordinates: Coors\n\n\nclass AttachmentFallback(FBObject):\n title: str\n url: AnyUrl\n payload: typing.Any = None\n type: str = 'fallback'\n\n\nclass Attachment(... | [
3,
4,
5,
6,
7
] |
from django.conf.urls import url
from tipz import views
urlpatterns = [
# /tipz/
url(r'^$', views.IndexView.as_view(), name='index'),
# /tipz/login
url(r'^login/$', views.LoginFormView.as_view(), name='login'),
# /tipz/logout
url(r'^logout/$', views.LogoutFormView.as_view(), name='logout'),
... | normal | {
"blob_id": "3ea123aceb72e4731afe98cf4c5beced2d424035",
"index": 3302,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('^$', views.IndexView.as_view(), name='index'), url(\n '^login/$', views.LoginFormView.as_view(), name='login'), url(\n '^logout/$', views.LogoutFormView.as_view(... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def manhat(point_one, point_two):
return abs(point_one[0] - point_two[0]) + abs(point_one[1] - point_two[1])
def find_edge(sensors, pos, dir):
x, row = pos
closer = []
for sensor in sensors.keys():
if manhat(pos, sensor) <= sensors[sensor]:
closer.app... | flexible | {
"blob_id": "c4bd55be86c1f55d89dfcbba2ccde4f3b132edcb",
"index": 9981,
"step-1": "<mask token>\n\n\ndef manhat(point_one, point_two):\n return abs(point_one[0] - point_two[0]) + abs(point_one[1] - point_two[1])\n\n\ndef find_edge(sensors, pos, dir):\n x, row = pos\n closer = []\n for sensor in sensor... | [
3,
4,
5,
7,
9
] |
<|reserved_special_token_0|>
class TestDateTime(FieldTestCase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def test_utc_processing(self):
field = DateTime(utc=True)
self.assert_processed(field, None)
self.assert_not_processed(field, 'invalid', True)
now = da... | flexible | {
"blob_id": "92b22ea23ad0cf4e16c7d19d055b7ec152ca433a",
"index": 5191,
"step-1": "<mask token>\n\n\nclass TestDateTime(FieldTestCase):\n <mask token>\n <mask token>\n\n def test_utc_processing(self):\n field = DateTime(utc=True)\n self.assert_processed(field, None)\n self.assert_not... | [
3,
7,
8,
9
] |
from import_export.admin import ImportExportMixin
from django.contrib import admin
from import_export import resources, widgets, fields
from .models import Addgroup,Addsystemname,Zhuanzhebushi,Yewuzerenbumen,czyylx,Zhuanze,Data
from import_export import fields, resources
from import_export.widgets import ForeignKeyWidg... | normal | {
"blob_id": "016b64a2eb4af3034d54272c878fb917506d330c",
"index": 648,
"step-1": "<mask token>\n\n\nclass DataResource(resources.ModelResource):\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n fields = 'groupname', 'system_name', 'I6000'\n\n\nclass DataAdmin(ImportExportMixin, ... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for testes in range(casosteste):
num_instru = int(input())
lista = []
for intru in range(num_instru):
p = input().upper()
if p == 'LEFT':
lista.append(-1)
elif p == 'RIGHT':
... | flexible | {
"blob_id": "a14a6c015ed3063015973b5376a1351a70808dc0",
"index": 8420,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor testes in range(casosteste):\n num_instru = int(input())\n lista = []\n for intru in range(num_instru):\n p = input().upper()\n if p == 'LEFT':\n lis... | [
0,
1,
2
] |
from outils import Outils
class BilanComptes(object):
"""
Classe pour la création du bilan des comptes
"""
@staticmethod
def bilan(dossier_destination, subedition, subgeneraux, lignes):
"""
création du bilan
:param dossier_destination: Une instance de la classe dossier.Dos... | normal | {
"blob_id": "53c874fbe14031c323f83db58f17990f4e60bc58",
"index": 2195,
"step-1": "<mask token>\n\n\nclass BilanComptes(object):\n <mask token>\n <mask token>\n\n @staticmethod\n def creation_lignes(subedition, subgeneraux, consolidation):\n \"\"\"\n génération des lignes de données du b... | [
2,
3,
4,
5,
6
] |
import sys
def main():
# String to format output
format_string = "%s %s %s %s %s %s %s %s %s\n"
while True:
# Read 14 lines at a time from stdin for wikipedia dataset
edit = [sys.stdin.readline() for i in range(14)]
# Break if we've reached the end of stdin
if edit[13] == "":
break
# Parse data from re... | normal | {
"blob_id": "f6b2169a4644f4f39bbdebd9bb9c7cc637b54f8b",
"index": 9920,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n format_string = '%s %s %s %s %s %s %s %s %s\\n'\n while True:\n edit = [sys.stdin.readline() for i in range(14)]\n if edit[13] == '':\n br... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
##################################
# @program synda
# @description climate models data transfer program
# @copyright Copyright "(c)2009 Centre National de la Recherche Scientifique CNRS.
# All Rights Reserved"
# @license CeCILL (https://raw.g... | normal | {
"blob_id": "0e6e84a31b626639e2aa149fd1ef89f3ef251cd7",
"index": 207,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Context(Base):\n\n def __init__(self, dataset='', capsys=None):\n super(Context, self).__init__(capsys=capsys)\n self.dataset = ''\n self.dataset = datase... | [
0,
4,
5,
6,
7
] |
from openerp import models, fields, api, _
class priority_customer(models.Model):
_inherit = 'res.partner'
is_priority = fields.Boolean("Is Priority Partner:?")
registration_date = fields.Date("Registration Date:")
liability_card_number = fields.Char("Liability Card Number:")
| normal | {
"blob_id": "f2bb00d06023ef7b3ea3dc33f7ec00d1f48d46ae",
"index": 8477,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass priority_customer(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass priority_customer(models.Model)... | [
0,
1,
2,
3,
4
] |
"""
BCXYZ company has up to
employees.
The company decides to create a unique identification number (UID) for each of its employees.
The company has assigned you the task of validating all the randomly generated UIDs.
A valid UID must follow the rules below:
It must contain at least 2 uppercase English alphabet chara... | normal | {
"blob_id": "3a5c8ee49c50820cea201c088acca32e018c1501",
"index": 3715,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(int(input())):\n imp = input()\n if bool(re.search('[a-zA-Z0-9]{10}', imp)) and bool(re.search(\n '([A-Z].*){2}', imp)) and bool(re.search('([0-9].*){3}', imp)... | [
0,
1,
2,
3
] |
import pygame
class DrawingBrush():
def __init__(self, size, color, radius):
self.drawSurface = pygame.Surface(size, pygame.SRCALPHA, 32).convert_alpha()
self.drawColor = color
self.size = radius
self.winSize = size
self.winSurface = pygame.display.get_surface()
def Dra... | normal | {
"blob_id": "45658cdfcd1529bbf803294cd7cec32d6d2c2198",
"index": 7638,
"step-1": "<mask token>\n\n\nclass DrawingBrush:\n\n def __init__(self, size, color, radius):\n self.drawSurface = pygame.Surface(size, pygame.SRCALPHA, 32\n ).convert_alpha()\n self.drawColor = color\n self... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(
f'With a total of {total}, you should tip ${int(total + total * 0.15)}. If the waiter did a really good job, you should tip ${int(total + total * 0.2)}. '
)
<|reserved_special_token_1|>
total = int(input('What wa... | flexible | {
"blob_id": "45d5c75a993ff50e1a88510bdb16e963403c5356",
"index": 8588,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(\n f'With a total of {total}, you should tip ${int(total + total * 0.15)}. If the waiter did a really good job, you should tip ${int(total + total * 0.2)}. '\n )\n",
"step-3... | [
0,
1,
2,
3
] |
from django.conf.urls import url
from django.urls import path
from . import views
app_name = 'Accounts'
urlpatterns = [
path('update_info', views.update_info, name='update_info'),
path('create_user', views.create_user, name='create_user'),
path('change_password', views.change_password, name='change_passwo... | normal | {
"blob_id": "bfb778a2ecf43a697bc0e3449e9302142b20e1f4",
"index": 4278,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp_name = 'Accounts'\nurlpatterns = [path('update_info', views.update_info, name='update_info'),\n path('create_user', views.create_user, name='create_user'), path(\n 'change_passw... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
@dataclass
class Settings:
<|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_1|>
<|reserved_special_token_0|>
load_... | flexible | {
"blob_id": "a1c5d86a3f042d9e5ba522726191c8aeb9b738ed",
"index": 8018,
"step-1": "<mask token>\n\n\n@dataclass\nclass Settings:\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>\nload_dotenv()\n\n\n@dataclass\nclass Settings:... | [
1,
3,
4,
5,
6
] |
from django.shortcuts import render, get_object_or_404, redirect
from django.utils import timezone
from django.core.paginator import Paginator
from .models import post
from django.contrib.auth.decorators import login_required
from .forms import post_fo
from django.db.models import Q
def index(request):
posts_l... | normal | {
"blob_id": "2b88bec388f3872b63d6bfe200e973635bb75054",
"index": 5418,
"step-1": "<mask token>\n\n\ndef detail(request, post_id):\n po = get_object_or_404(post, pk=post_id)\n ratelist = [1, 2, 3, 4, 5]\n return render(request, 'detail.html', {'post': po, 'ratelist': ratelist})\n\n\n@login_required(login... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('v2: {0}\tL2: {1}'.format(v2, L2))
<|reserved_special_token_0|>
print('T: {0}\te:{1}'.format(T, e))
<|reserved_special_token_1|>
L1 = float(input('Enter distance to the sun: '))
v1 = float(input('Enter velocity at perihel... | flexible | {
"blob_id": "83b65b951b06b117c2e85ba348e9b591865c1c2e",
"index": 3145,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('v2: {0}\\tL2: {1}'.format(v2, L2))\n<mask token>\nprint('T: {0}\\te:{1}'.format(T, e))\n",
"step-3": "L1 = float(input('Enter distance to the sun: '))\nv1 = float(input('Enter ve... | [
0,
1,
2,
3
] |
# -*- coding:utf-8 -*-
from odoo import api, models, fields, _
class hrsalaryRule(models.Model):
_inherit = "hr.salary.rule"
is_tax_fdfp = fields.Boolean("Est un impôt FDFP") | normal | {
"blob_id": "097a87f7f1346e5db1599e59680232912348aef7",
"index": 311,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass hrsalaryRule(models.Model):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass hrsalaryRule(models.Model):\n _inherit = 'hr.salary.rule'\n is_tax_... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class TermserviceConfig(AppConfig):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class TermserviceConfig(AppConfig):
name = 'termservice'
<|reserved_special_token_1|>
fro... | flexible | {
"blob_id": "f0168a737b9215520ce600470f9b27837dafb593",
"index": 4183,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TermserviceConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TermserviceConfig(AppConfig):\n name = 'termservice'\n",
"step-4": "from django.app... | [
0,
1,
2,
3
] |
class String:
def reverse(self, s):
return s[::-1]
s = input()
obj1 = String()
print(obj1.reverse(s))
| normal | {
"blob_id": "c27c29a5b4be9f710e4036f7f73a89c7d20acea5",
"index": 4317,
"step-1": "class String:\n <mask token>\n\n\n<mask token>\n",
"step-2": "class String:\n\n def reverse(self, s):\n return s[::-1]\n\n\n<mask token>\n",
"step-3": "class String:\n\n def reverse(self, s):\n return s[:... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class SpotEnvironmentController:
def __init__(self, debug=False):
self.debug = debug
if self.debug == True:
print('... In Controller -> __init__')
self.sem = Environment.spot_environment_model.SpotEnvironmentModel(self
.debug)
def ... | flexible | {
"blob_id": "7c19b9521dc874a1ff4bed87dae0452cc329224a",
"index": 6890,
"step-1": "<mask token>\n\n\nclass SpotEnvironmentController:\n\n def __init__(self, debug=False):\n self.debug = debug\n if self.debug == True:\n print('... In Controller -> __init__')\n self.sem = Environm... | [
17,
18,
24,
27,
28
] |
import asyncio
import json
from functools import lru_cache
from pyrogram import Client
SETTINGS_FILE = "/src/settings.json"
CONN_FILE = "/src/conn.json"
def load_setting(setting: str):
with open(SETTINGS_FILE) as f:
return json.load(f)[setting]
@lru_cache()
def get_bot_name():
return load_setting(... | normal | {
"blob_id": "14e1af3d60efef842c72bf9b55143d0e14f3a7b8",
"index": 5897,
"step-1": "<mask token>\n\n\ndef load_setting(setting: str):\n with open(SETTINGS_FILE) as f:\n return json.load(f)[setting]\n\n\n@lru_cache()\ndef get_bot_name():\n return load_setting('bot_name')\n\n\n@lru_cache()\ndef get_app_... | [
4,
5,
6,
7,
8
] |
# -*- coding: utf-8 -*-
{
'name': 'EDC Analytic Entry',
'depends': [
'stock_account',
'purchase_stock',
'account_accountant',
],
"description": """
""",
'author': "Ejaftech",
'data': [
'views/account_move_view.xml',
],
}
| normal | {
"blob_id": "797e7c1b3e8b41a167bfbedfb6a9449e6426ba22",
"index": 8570,
"step-1": "<mask token>\n",
"step-2": "{'name': 'EDC Analytic Entry', 'depends': ['stock_account',\n 'purchase_stock', 'account_accountant'], 'description': '\\n ',\n 'author': 'Ejaftech', 'data': ['views/account_move_view.xml']}\n"... | [
0,
1,
2
] |
<|reserved_special_token_0|>
def simplify_string(inp):
inp = inp.lower().strip()
inp = re.sub('[^A-Za-z0-9]', '_', inp)
return inp
def makeDirectory(path):
print('creating directory ' + path)
try:
os.mkdir(path)
except FileExistsError:
pass
def initialize(url, browser=None)... | flexible | {
"blob_id": "43b9d308bb8d2b38c5f539e8700f5c2d8fe2287d",
"index": 2157,
"step-1": "<mask token>\n\n\ndef simplify_string(inp):\n inp = inp.lower().strip()\n inp = re.sub('[^A-Za-z0-9]', '_', inp)\n return inp\n\n\ndef makeDirectory(path):\n print('creating directory ' + path)\n try:\n os.mkd... | [
7,
9,
10,
12,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class NLPPredictionModel(object):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class NLPPredictionModel(object):
def getPasswordProbabilities(self, sweetwordList):
... | flexible | {
"blob_id": "1c01fbf7eafd49ada71cb018a62ead5988dcf251",
"index": 2968,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass NLPPredictionModel(object):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass NLPPredictionModel(object):\n\n def getPasswordProbabilities(self, sweetwordList):\n ... | [
0,
1,
2,
3,
4
] |
##############################
# SConscript for OgreOpcode #
##############################
#SCons scripts maintained by:
# Van Aarde "nanocell" Krynauw.
#TODO:
# - Add commandline options to specify include dirs, defines, compiler defs, libraries, etc.
# - Add Sconscripts for the samples.
# - Add a binary SConstruc... | normal | {
"blob_id": "ed1df078ad2e8d770f3d8c41493b5537ed106e3a",
"index": 1954,
"step-1": "##############################\n# SConscript for OgreOpcode #\n##############################\n#SCons scripts maintained by:\n# Van Aarde \"nanocell\" Krynauw.\n\n#TODO:\n# - Add commandline options to specify include dirs, defin... | [
0
] |
import cv2
import numpy as np
if __name__ == "__main__":
cap = cv2.VideoCapture()
while True:
ret, frame = cap.read()
cv2.imshow(frame)
| normal | {
"blob_id": "14f309d478de6de5a0b493503176941fdfa8b702",
"index": 110,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n cap = cv2.VideoCapture()\n while True:\n ret, frame = cap.read()\n cv2.imshow(frame)\n",
"step-3": "import cv2\nimport numpy as np\nif __... | [
0,
1,
2,
3
] |
# Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... | normal | {
"blob_id": "1ea31a126417c2feb079339aa79f97ea9e38fa40",
"index": 6152,
"step-1": "<mask token>\n\n\nclass Focusv2(nn.Cell):\n\n def __init__(self, c1, c2, k=1, s=1, p=None, act=True):\n super(Focusv2, self).__init__()\n self.conv = Conv(c1 * 4, c2, k, s, p, act)\n\n def construct(self, x):\n ... | [
12,
21,
27,
28,
33
] |
from django.test import TestCase
from stack_it.models import Image
class TextPageContentModelTest(TestCase):
def test_instance(self):
file = Image.create_empty_image_file(name='hello.jpg')
image = Image.objects.create(image=file, alt="World")
self.assertEqual(Image.objects.count(), 1)
... | normal | {
"blob_id": "5287bd1847848aa527df8ce57e896bc30c70b43c",
"index": 4432,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TextPageContentModelTest(TestCase):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TextPageContentModelTest(TestCase):\n\n def test_instance(self):\n file ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def distance(row):
source = row['start_lat'], row['start_lng']
dest = row['end_lat'], row['end_lng']
return vincenty(source, dest).miles
<|reserved_special_token_0|>
def dropoff_to_MH(row):
"""find the distance between dropoff point and Manhattan center"""
dest = r... | flexible | {
"blob_id": "c1bb7b579e6b251ddce41384aef1243e411c5d0e",
"index": 1018,
"step-1": "<mask token>\n\n\ndef distance(row):\n source = row['start_lat'], row['start_lng']\n dest = row['end_lat'], row['end_lng']\n return vincenty(source, dest).miles\n\n\n<mask token>\n\n\ndef dropoff_to_MH(row):\n \"\"\"fin... | [
8,
9,
11,
12,
15
] |
<|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": "6b6b734c136f3c4ed5b2789ab384bab9a9ea7b58",
"index": 9368,
"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 = [('weatherData... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class TFRecordProducer:
def remove_list(self, list1, list2):
i, j = 0, 0
tmp_list1 = []
tmp_list2 = []
while i < len(list1) and j < len(list2):
item1 = int(list1[i].split('/')[-1].split('-')[0])
item2 = int(list2[j].split('/')[-... | flexible | {
"blob_id": "df40b0628d6a180a98cd385145ee7c65ecb78256",
"index": 270,
"step-1": "<mask token>\n\n\nclass TFRecordProducer:\n\n def remove_list(self, list1, list2):\n i, j = 0, 0\n tmp_list1 = []\n tmp_list2 = []\n while i < len(list1) and j < len(list2):\n item1 = int(li... | [
4,
5,
6,
9,
10
] |
import daemon
import time
import sys
#out = open("~/tmp/stdout", "a+")
#err = open("~/tmp/stderr", "a+")
# 如果设定为标准输出,那么关闭终端窗口,退出守护进程。
# Ctrl+c 不会退出进程
# 关闭终端窗口,退出守护进程
def do_main_program():
print("start the main program...")
while True:
time.sleep(1)
print('another second passed')
context = d... | normal | {
"blob_id": "3cb96607aaf58a7de3fa0a9cd61b7f4e3c6b061a",
"index": 4802,
"step-1": "<mask token>\n\n\ndef do_main_program():\n print('start the main program...')\n while True:\n time.sleep(1)\n print('another second passed')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef do_main_progr... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def cut_text_line(geo, scale_ratio_w, scale_ratio_h, im_array, img_path, s):
geo /= [scale_ratio_w, scale_ratio_h]
p_min = np.amin(geo, axis=0)
p_max = np.amax(geo, axis=0)
min_xy = p_min.astype(int)
max_xy = p_max.astype(int) + 2
sub_im_arr = im_array[min_xy[1]:ma... | flexible | {
"blob_id": "48cef0377087d9245aad1fb759adf8ff07d2b66f",
"index": 4464,
"step-1": "<mask token>\n\n\ndef cut_text_line(geo, scale_ratio_w, scale_ratio_h, im_array, img_path, s):\n geo /= [scale_ratio_w, scale_ratio_h]\n p_min = np.amin(geo, axis=0)\n p_max = np.amax(geo, axis=0)\n min_xy = p_min.astyp... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class TestMultiTan(object):
<|reserved_special_token_0|>
if sys.platform == 'darwin':
WTML = WTML.replace('Dec="0.7438249862258411"',
'Dec="0.743824986225841"')
<|reserved_special_token_0|>
def teardown_method(self, method):
from shutil import ... | flexible | {
"blob_id": "618b6c74133e181ce5cbaf4e969d9fc3aa44ce98",
"index": 1261,
"step-1": "<mask token>\n\n\nclass TestMultiTan(object):\n <mask token>\n if sys.platform == 'darwin':\n WTML = WTML.replace('Dec=\"0.7438249862258411\"',\n 'Dec=\"0.743824986225841\"')\n <mask token>\n\n def tea... | [
5,
6,
9,
10,
13
] |
<|reserved_special_token_0|>
def WriteToFile(f, output, condition=False, conditionID=''):
f.write(output if not condition else WrapInGuard(conditionID, output))
<|reserved_special_token_0|>
def WrapInGuard(condition, innerbody):
return TIfGuard.substitute(dict(condition=condition, innerbody=innerbody))
... | flexible | {
"blob_id": "8cba57e3552e0072720fe42fa1949534f29d71b5",
"index": 1562,
"step-1": "<mask token>\n\n\ndef WriteToFile(f, output, condition=False, conditionID=''):\n f.write(output if not condition else WrapInGuard(conditionID, output))\n\n\n<mask token>\n\n\ndef WrapInGuard(condition, innerbody):\n return TI... | [
8,
12,
15,
16,
18
] |
def twoSensorAvg(input_data, duration=1):
times = {}
for i in input_data:
data = i.split(',')
time = int(int(data[1]) / (duration * 1000))
if time not in times:
times[time] = [0, 0]
times[time][0] += int(data[2])
times[time][1] += 1
ans = []
for i, v i... | normal | {
"blob_id": "836d712c811079f190eae9c2780131a844c9dddf",
"index": 3044,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test(input, output, duration):\n results = twoSensorAvg(input, duration)\n print(results)\n if len(results) != len(output):\n return False\n for i in range(len(... | [
0,
1,
2,
3
] |
print("hello world")
print("welcome to london") | normal | {
"blob_id": "cd322f9771f1ac90931a7229ffd5effd1cae1a54",
"index": 7207,
"step-1": "<mask token>\n",
"step-2": "print('hello world')\nprint('welcome to london')\n",
"step-3": "print(\"hello world\")\nprint(\"welcome to london\")",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
<|reserved_special_token_0|>
def render():
port.render()
def setColor(panel, color):
if panels[panel]:
port.set_channel(panels[panel] - 1, color[0])
port.set_channel(panels[panel], color[1])
port.set_channel(panels[panel] + 1, color[2])
def run(func):
global port
port = pye... | flexible | {
"blob_id": "55252fc78c67e48c64e777e4c3a713c898312b81",
"index": 7166,
"step-1": "<mask token>\n\n\ndef render():\n port.render()\n\n\ndef setColor(panel, color):\n if panels[panel]:\n port.set_channel(panels[panel] - 1, color[0])\n port.set_channel(panels[panel], color[1])\n port.set_... | [
3,
4,
5,
6
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Alonso Vidales"
__email__ = "alonso.vidales@tras2.es"
__date__ = "2013-11-11"
class ConnectedSets:
"""
This is a classic percolation problem, the algorithms uses an array
of integer to represent tees, each tree will be a set of connected element... | normal | {
"blob_id": "d18c0fa29ccdabdd9e11622e8aaec91ff96117df",
"index": 6650,
"step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*- \n\n__author__ = \"Alonso Vidales\"\n__email__ = \"alonso.vidales@tras2.es\"\n__date__ = \"2013-11-11\"\n\nclass ConnectedSets:\n \"\"\"\n This is a classic percolation problem, ... | [
0
] |
from soln import Solution
import pytest
@pytest.mark.parametrize(
["inp1", "inp2", "res"],
[
("112", 1, "11"),
("11000002000304", 4, "4"),
("9119801020", 6, "20"),
("111111", 3, "111"),
("1432219", 3, "1219"),
("10200", 1, "200"),
("10", 2, "0"),
... | normal | {
"blob_id": "7eb4efb64a5a5b2e8c2dfa965411ff4c7aad6e35",
"index": 6525,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.mark.parametrize(['inp1', 'inp2', 'res'], [('112', 1, '11'), (\n '11000002000304', 4, '4'), ('9119801020', 6, '20'), ('111111', 3, '111'\n ), ('1432219', 3, '1219'), ('1... | [
0,
1,
2,
3
] |
from django.contrib import admin
from main_app.models import sites, statuses, redirects
# Register your models here.
admin.site.register(statuses)
admin.site.register(sites)
admin.site.register(redirects) | normal | {
"blob_id": "2b8ca0c8c7878536da4f31652976988cdba62d89",
"index": 491,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(statuses)\nadmin.site.register(sites)\nadmin.site.register(redirects)\n",
"step-3": "from django.contrib import admin\nfrom main_app.models import sites, statuses, re... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def calculate_returns(ticker_data):
returns_list = list()
previous_ticker_day = None
for ticker_day in ticker_data.itertuples():
if previous_ticker_day == None:
returns_list.append((ticker_day.Close - ticker_day.Open) /
ticker_day.Open)
... | flexible | {
"blob_id": "22ffda3b2d84218af22bad7835689ec3d4959ab2",
"index": 3660,
"step-1": "<mask token>\n\n\ndef calculate_returns(ticker_data):\n returns_list = list()\n previous_ticker_day = None\n for ticker_day in ticker_data.itertuples():\n if previous_ticker_day == None:\n returns_list.ap... | [
6,
8,
9,
10,
11
] |
import sys
sys.stdin = open('magnet.txt', 'r')
from collections import deque
def check(t, d, c):
if t == 1:
if m1[2] != m2[-2] and not c:
check(t + 1, d * (-1), 1)
if d == 1:
m1.appendleft(m1.pop())
else:
m1.append(m1.popleft())
elif t == 4:
... | normal | {
"blob_id": "7e3a5e1f19683b1716f3c988dcc1e65fee1cae13",
"index": 8956,
"step-1": "<mask token>\n\n\ndef check(t, d, c):\n if t == 1:\n if m1[2] != m2[-2] and not c:\n check(t + 1, d * -1, 1)\n if d == 1:\n m1.appendleft(m1.pop())\n else:\n m1.append(m1.pop... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('Programinha de controle de festinhas 1.0')
print('#' * 20)
<|reserved_special_token_0|>
while i <= numero_de_convidados:
nome_do_convidado = input('Coloque o nome do convidado #' + str(i) + ': ')
lista_de_convidados... | flexible | {
"blob_id": "426a8fb6d1adf5d4577d299083ce047c919dda67",
"index": 3525,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Programinha de controle de festinhas 1.0')\nprint('#' * 20)\n<mask token>\nwhile i <= numero_de_convidados:\n nome_do_convidado = input('Coloque o nome do convidado #' + str(i) ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def score_model(X, y, model):
train_X, test_X, train_y, test_y = train_test_split(X, y)
model.fit(train_X, train_y)
return model.score(test_X, test_y)
<|reserved_special_token_0|>
def main():
ds_names = classification_dataset_names
models = [LogisticRegression, Gra... | flexible | {
"blob_id": "4c010f9d9e7813a4ae4f592ade60130933b51958",
"index": 6125,
"step-1": "<mask token>\n\n\ndef score_model(X, y, model):\n train_X, test_X, train_y, test_y = train_test_split(X, y)\n model.fit(train_X, train_y)\n return model.score(test_X, test_y)\n\n\n<mask token>\n\n\ndef main():\n ds_name... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Query(f1hub.drivers.schema.Query, f1hub.results.schema.Query, f1hub.
constructors.schema.Query, f1hub.races.schema.Query, f1hub.status.
schema.Query, f1hub.circuits.schema.Query, f1hub.constructorresults.
schem... | flexible | {
"blob_id": "05e4bcc7323b908a7b45d766ada463ce172e25c4",
"index": 378,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Query(f1hub.drivers.schema.Query, f1hub.results.schema.Query, f1hub.\n constructors.schema.Query, f1hub.races.schema.Query, f1hub.status.\n schema.Query, f1hub.circuits.sch... | [
0,
1,
2,
3,
4
] |
from analizer_pl.abstract.instruction import Instruction
from analizer_pl import grammar
from analizer_pl.statement.expressions import code
from analizer_pl.reports.Nodo import Nodo
class If_Statement(Instruction):
def __init__(self, row, column,expBool, elseif_list,else_,stmts ) -> None:
super().__i... | normal | {
"blob_id": "bbbdb30ceef920e600c9f46fb968732b077be2d8",
"index": 4231,
"step-1": "<mask token>\n\n\nclass If_Statement(Instruction):\n\n def __init__(self, row, column, expBool, elseif_list, else_, stmts) ->None:\n super().__init__(row, column)\n self.expBool = expBool\n self.elseif_list ... | [
7,
9,
10,
11,
12
] |
<|reserved_special_token_0|>
def index(request):
return render(request, 'ALR1.html')
def search(request):
return render(request, 'ALR2.html')
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def index(request):
return render(request, 'ALR1.html')
def search... | flexible | {
"blob_id": "d9f586bbb72021ee0b37ff8660e26b50d7e6a2d3",
"index": 569,
"step-1": "<mask token>\n\n\ndef index(request):\n return render(request, 'ALR1.html')\n\n\ndef search(request):\n return render(request, 'ALR2.html')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef index(request):\n return r... | [
2,
3,
4,
5,
6
] |
"""Helpers for FormatCBFMiniPilatus..."""
from __future__ import annotations
import calendar
import time
def get_pilatus_timestamp(timestamp_string):
if "." in timestamp_string:
timestamp, milliseconds = timestamp_string.split(".")
else:
timestamp = timestamp_string
milliseconds = "... | normal | {
"blob_id": "21526dabe8456c599e4409228fa69ffd0d672c5b",
"index": 4689,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_pilatus_timestamp(timestamp_string):\n if '.' in timestamp_string:\n timestamp, milliseconds = timestamp_string.split('.')\n else:\n timestamp = timestamp_... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class EchoBot(ClientXMPP):
def __init__(self, jid, password):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler('session_start', self.session_start)
self.register_plugin('xep_0045')
<|reserved_special_token_0|>
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "3b531c5935f0be89536c95ff471f96b4249d951c",
"index": 2521,
"step-1": "<mask token>\n\n\nclass EchoBot(ClientXMPP):\n\n def __init__(self, jid, password):\n ClientXMPP.__init__(self, jid, password)\n self.add_event_handler('session_start', self.session_start)\n self.register_pl... | [
2,
3,
4,
5,
6
] |
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(X):
""" Applies the logistic function to x, element-wise. """
return 1 / (1 + np.exp(-X))
def x_strich(X):
return np.column_stack((np.ones(len(X)), X))
def feature_scaling(X):
x_mean = np.mean(X, axis=0)
x_std = np.std(X, axis=0)
... | normal | {
"blob_id": "36e7398f576aa1d298a20b4d4a27a7b93e3bd992",
"index": 5482,
"step-1": "<mask token>\n\n\ndef sigmoid(X):\n \"\"\" Applies the logistic function to x, element-wise. \"\"\"\n return 1 / (1 + np.exp(-X))\n\n\ndef x_strich(X):\n return np.column_stack((np.ones(len(X)), X))\n\n\n<mask token>\n\n\n... | [
7,
9,
10,
11,
13
] |
<|reserved_special_token_0|>
def word2features(sent, i):
word = sent[i][0]
tag = sent[i][1]
features = ['bias', 'word.lower=' + word.lower(), 'word[-3:]=' + word[-
3:], 'word[-2:]=' + word[-2:], 'word.isupper=%s' % word.isupper(),
'word.istitle=%s' % word.istitle(), 'word.isdigit=%s' % wo... | flexible | {
"blob_id": "af9b83b6e213359f5e193918b6c09c22220e5457",
"index": 607,
"step-1": "<mask token>\n\n\ndef word2features(sent, i):\n word = sent[i][0]\n tag = sent[i][1]\n features = ['bias', 'word.lower=' + word.lower(), 'word[-3:]=' + word[-\n 3:], 'word[-2:]=' + word[-2:], 'word.isupper=%s' % word... | [
4,
5,
7,
8,
9
] |
# -*- coding: utf-8 -*-
from flask import abort, flash, redirect, render_template, url_for, request
from flask_login import current_user, login_required
from . import user
from .. import db
from models import User
def check_admin():
"""
Prevent non-admins from accessing the page
"""
if not current_us... | normal | {
"blob_id": "9a6f4f0eac5d9e5b4b92fcb2d66d39df15b3b281",
"index": 6303,
"step-1": "<mask token>\n\n\n@user.route('/users/add', methods=['GET', 'POST'])\ndef add_user():\n \"\"\"\n load form page and add to the database\n \"\"\"\n if request.method == 'POST':\n user = User(username=request.form[... | [
2,
4,
5,
6,
7
] |
# Author: Omkar Sunkersett
# Purpose: To fetch SPP data and update the database
# Summer Internship at Argonne National Laboratory
import csv, datetime, ftplib, MySQLdb, os, time
class SPP():
def __init__(self, server, path, start_dt, end_dt, prog_dir):
self.files_cached = []
try:
self.ftp_handle = ... | normal | {
"blob_id": "755eeaf86ebf2560e73869084030a3bfc89594f6",
"index": 2390,
"step-1": "# Author: Omkar Sunkersett\r\n# Purpose: To fetch SPP data and update the database\r\n# Summer Internship at Argonne National Laboratory\r\n\r\nimport csv, datetime, ftplib, MySQLdb, os, time\r\n\r\nclass SPP():\r\n\tdef __init__(s... | [
0
] |
<|reserved_special_token_0|>
def test_zero_sample():
m = MeanNormalizedBias()
with pytest.raises(NotComputableError, match=
'MeanNormalizedBias must have at least one example before it can be computed'
):
m.compute()
def test_zero_gt():
a = np.random.randn(4)
ground_truth = n... | flexible | {
"blob_id": "452f35fe2ae9609949a3f92ad7768fc37094a2f1",
"index": 3786,
"step-1": "<mask token>\n\n\ndef test_zero_sample():\n m = MeanNormalizedBias()\n with pytest.raises(NotComputableError, match=\n 'MeanNormalizedBias must have at least one example before it can be computed'\n ):\n ... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def input_fn(images, labels, epochs, batch_size):
data = tf.data.Dataset.from_tensor_slices((images, labels))
data = data.repeat(epochs).batch(batch_size)
return data
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def input_fn(ima... | flexible | {
"blob_id": "ef6f91af5f500745fdcc23947a7e1764061c608c",
"index": 2368,
"step-1": "<mask token>\n\n\ndef input_fn(images, labels, epochs, batch_size):\n data = tf.data.Dataset.from_tensor_slices((images, labels))\n data = data.repeat(epochs).batch(batch_size)\n return data\n\n\n<mask token>\n",
"step-2... | [
1,
2,
3,
4,
5
] |
from django.shortcuts import get_object_or_404, render
from django.http import Http404
from django.urls import reverse
# Create your views here.
from django.template import loader
from django.http import HttpResponse, HttpResponseRedirect
from .models import Categories, News, SalesSentences
from .models_gfl import Info... | normal | {
"blob_id": "531d1cab3d0860de38f8d1fefee28f10fc018bdb",
"index": 9005,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef index(request):\n listTopNews = News.objects.filter(category__category='topside-news')\n listBottomNews = News.objects.filter(category__category='bottomside-news')\n list... | [
0,
1,
2,
3
] |
from console import Display
import time
images = ["/img/erni_l.txt", "/img/erni_s.txt", "/img/erni_logo.txt", "/img/github_logo.txt",
"/img/upython_logo.txt", "/img/python_logo.txt", "/img/upython_logo_s.txt",
"/img/MSC_logo.txt"]
def show():
oled = Display()
for image in images:
... | normal | {
"blob_id": "1930aa258ac4fbcdb2972e19bdb2625d2dae4114",
"index": 9403,
"step-1": "<mask token>\n\n\ndef show():\n oled = Display()\n for image in images:\n oled.clear(0, 1)\n oled.draw_graphic(image, 35, 2)\n time.sleep(5)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef show()... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test_random_genome(race_basic):
genome = random_genome(race_basic)
assert genome
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test_create_population(race_example):... | flexible | {
"blob_id": "0802aac57cd28104cdb6ff45d993aa224f80b830",
"index": 2877,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_random_genome(race_basic):\n genome = random_genome(race_basic)\n assert genome\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef test_create_population(race_exa... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class GF_IPMPX_Data(Structure):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class GF_IPMPX_Data(Structure):
_fields_ = [('tag', c_char), ('Version', c_char), ('dataID', c_c... | flexible | {
"blob_id": "b3f4815495c781fe6cc15f77b4ee601680117419",
"index": 8592,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass GF_IPMPX_Data(Structure):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass GF_IPMPX_Data(Structure):\n _fields_ = [('tag', c_char), ('Version', c_char), ('dataID', ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
from .factories import *
| flexible | {
"blob_id": "c036e6a0a9f06b08ee3eb43655dd833b46fd1e76",
"index": 3690,
"step-1": "<mask token>\n",
"step-2": "from .factories import *\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def test_corr_callable_method(self, datetime_series):
my_corr = lambda a, b: 1.0 if (a == b).all() else 0.0
s1 = Series([1, 2, 3, 4, 5])
s2 = Series([5, 4, 3, 2, 1])
expected = 0
tm.assert_almost_equal(s1.corr(s2, method=my_corr), expected... | flexible | {
"blob_id": "5e68233fde741c0d2a94bf099afb6a91c08e2a29",
"index": 6071,
"step-1": "<mask token>\n",
"step-2": "def test_corr_callable_method(self, datetime_series):\n my_corr = lambda a, b: 1.0 if (a == b).all() else 0.0\n s1 = Series([1, 2, 3, 4, 5])\n s2 = Series([5, 4, 3, 2, 1])\n expected = 0\n ... | [
0,
1,
2
] |
#!/usr/bin/python
import os
def main():
os.system("notify-send 'Backup' 'NAS Backup Starting...' -i /usr/share/pixmaps/xarchiver/xarchiver-extract.png ")
os.system("sudo mount -o username='emre' //192.168.1.2/Samba /media/NAS")
os.system("sudo rsync -av --include='.profile' --include='.bash*' --exclude='.... | normal | {
"blob_id": "b6dd04219de1d4526d175254da539107362772d6",
"index": 9229,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n os.system(\n \"notify-send 'Backup' 'NAS Backup Starting...' -i /usr/share/pixmaps/xarchiver/xarchiver-extract.png \"\n )\n os.system(\"sudo mount -o... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class ClassMKB(models.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "8753996c90ecea685e6312020dfd31fabb366138",
"index": 5270,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ClassMKB(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n db_table = 'cla... | [
0,
2,
3,
4,
5
] |
from django.db import models
from colorfield.fields import ColorField
from api import settings
from os.path import splitext
from datetime import datetime, timedelta
from PIL import Image
def saveTaskPhoto(instance,filename):
taskId = instance.id
name,ext = splitext(filename)
return f'tasks/task_{taskId}{e... | normal | {
"blob_id": "e59bd92a94399d4a81687fc5e52e9ae04b9de768",
"index": 7472,
"step-1": "<mask token>\n\n\nclass Task(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <m... | [
7,
8,
9,
10,
11
] |
import nltk
tw_dict = {'created_at':[],
'id':[],
'id_str':[],
'full_text':[],
'entities':[],
'source':[],
'user':[],
'lang':[]}
def Preprocessing(instancia):
# Remove caracteres indesejados.
instancia = re... | normal | {
"blob_id": "bffd211a2d2dc3dd9b596f69909be7f0437ab0c8",
"index": 9322,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef Preprocessing(instancia):\n instancia = re.sub('#\\\\S+', '', instancia)\n instancia = re.sub('@\\\\S+', '', instancia).lower().replace('.', ''\n ).replace(';', '').r... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
img_rows = 200
img_cols = 200
img_channels = 1
nb_classes = 3
nb_test_images = 1
<|reserved_special_token_1|>
#for declaring the variables used in program
img_rows=200
img_cols=200
img_channels=1
nb_classes=3
nb_test_images=1
| flexible | {
"blob_id": "c41388043295280f9354e661a8d38ae46cae2d65",
"index": 9590,
"step-1": "<mask token>\n",
"step-2": "img_rows = 200\nimg_cols = 200\nimg_channels = 1\nnb_classes = 3\nnb_test_images = 1\n",
"step-3": "#for declaring the variables used in program\nimg_rows=200\nimg_cols=200\nimg_channels=1\nnb_classe... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class TestResumeParser(TestCase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def generate_counter(self, resume_name):
json_file = self.load_resume(resume_name)
return self.convert_to_counter(json_file)
<|reserved_special_token_0|>
def g... | flexible | {
"blob_id": "4bbfb35e4b03e2bfd46dd0fe5bfd54fb01ba11df",
"index": 1996,
"step-1": "<mask token>\n\n\nclass TestResumeParser(TestCase):\n <mask token>\n <mask token>\n\n def generate_counter(self, resume_name):\n json_file = self.load_resume(resume_name)\n return self.convert_to_counter(json... | [
10,
22,
24,
25,
26
] |
import glob
import json
import pickle
import gzip
import os
import hashlib
import re
import bs4, lxml
import concurrent.futures
URL = 'http://mangamura.org'
def _map(arg):
key, names = arg
size = len(names)
urls = set()
for index, name in enumerate(names):
html = gzip.decompress(open('htmls/' + name... | normal | {
"blob_id": "3acd592594ae4f12b9b694aed1aa0d48ebf485f5",
"index": 5787,
"step-1": "<mask token>\n\n\ndef _map(arg):\n key, names = arg\n size = len(names)\n urls = set()\n for index, name in enumerate(names):\n html = gzip.decompress(open('htmls/' + name, 'rb').read()).decode()\n soup = ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class PageRankReader(Reader):
def read_num_of_vertices(self):
line = self.config_fp.readline()
return int(line)
def read_vertex(self):
line = self.graph_fp.readline()
if not line:
return None
line = line.strip().split(':')
... | flexible | {
"blob_id": "6db7189d26c63ca9f9667045b780ec11994bac28",
"index": 788,
"step-1": "<mask token>\n\n\nclass PageRankReader(Reader):\n\n def read_num_of_vertices(self):\n line = self.config_fp.readline()\n return int(line)\n\n def read_vertex(self):\n line = self.graph_fp.readline()\n ... | [
7,
9,
10,
12,
13
] |
# Generated by Django 3.1.6 on 2021-05-06 10:29
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0028_auto_20210506_1020'),
]
operations = [
migrations.AlterField(
model_name='user',
... | normal | {
"blob_id": "39ac4e0d543048ea02123baa39b6c8ce7618d16b",
"index": 6802,
"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 = [('core', '002... | [
0,
1,
2,
3,
4
] |
from omt.gui.abstract_panel import AbstractPanel
class SourcePanel(AbstractPanel):
def __init__(self):
super(SourcePanel, self).__init__()
def packagePath(self):
"""
This file holds the link to the active panels.
The structure is a dictionary, the key is the class name
... | normal | {
"blob_id": "aa0a69e3286934fcfdf31bd713eca1e8dd90aeaa",
"index": 6914,
"step-1": "<mask token>\n\n\nclass SourcePanel(AbstractPanel):\n\n def __init__(self):\n super(SourcePanel, self).__init__()\n\n def packagePath(self):\n \"\"\"\n This file holds the link to the active panels.\n ... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def generate_provider_specific_cmd_list(script, driver, output, error):
"""Method to compile the BigQuery specific script execution command.
Arguments:
script: SQL script which contains the query.
driver: Driver that contains the BigQuery specific script executor.
outpu... | flexible | {
"blob_id": "5e14eeaa3c79bfdd564f3bfd1575c9bbf1a3773d",
"index": 7881,
"step-1": "<mask token>\n\n\ndef generate_provider_specific_cmd_list(script, driver, output, error):\n \"\"\"Method to compile the BigQuery specific script execution command.\n\n Arguments:\n script: SQL script which contains the query... | [
1,
2,
3,
4,
5
] |
import hashlib
from ast import literal_eval
# import requests
# from rest_framework import generics
from rest_framework.views import APIView
from rest_framework.response import Response
from django.shortcuts import render, redirect, HttpResponse,get_object_or_404
from django.views.decorators.csrf import csrf_exempt
fro... | normal | {
"blob_id": "a84920821982f04b9835391eb267707971f8f7c1",
"index": 3929,
"step-1": "import hashlib\nfrom ast import literal_eval\n# import requests\n# from rest_framework import generics\nfrom rest_framework.views import APIView\nfrom rest_framework.response import Response\nfrom django.shortcuts import render, re... | [
0
] |
print('Boolean Exercise')
print(False or False)
print(False and False)
print(not True or not False)
| normal | {
"blob_id": "2385882f040ef4bd0a3611bebfbb2ae5b3cd1dc6",
"index": 4204,
"step-1": "<mask token>\n",
"step-2": "print('Boolean Exercise')\nprint(False or False)\nprint(False and False)\nprint(not True or not False)\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
import Environment.spot_environment_model
"""This is basically the control center. All actions here are being condensed and brought in from
spot_market_model...... the BRAIN of the simulator"""
class SpotEnvironmentController():
def __init__(self, debug=False): # debug builds an error trap
self.debug = ... | normal | {
"blob_id": "7c19b9521dc874a1ff4bed87dae0452cc329224a",
"index": 6890,
"step-1": "<mask token>\n\n\nclass SpotEnvironmentController:\n\n def __init__(self, debug=False):\n self.debug = debug\n if self.debug == True:\n print('... In Controller -> __init__')\n self.sem = Environm... | [
17,
18,
24,
27,
28
] |
<|reserved_special_token_0|>
class QuantidadeForm(forms.Form):
class Meta:
fields = 'quantidade', 'produto_id'
produto_id = forms.CharField(widget=forms.HiddenInput())
quantidade = forms.IntegerField(min_value=1, max_value=1000,
error_messages={'required': 'Campo obrigatório.'}, widget=f... | flexible | {
"blob_id": "fd5fca0e9abbb669ddff4d676147acc4344cdd1c",
"index": 509,
"step-1": "<mask token>\n\n\nclass QuantidadeForm(forms.Form):\n\n\n class Meta:\n fields = 'quantidade', 'produto_id'\n produto_id = forms.CharField(widget=forms.HiddenInput())\n quantidade = forms.IntegerField(min_value=1, ma... | [
2,
3,
4,
5,
6
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.