code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import json
import requests
import time
class TRY():
rates = list()
def __init__(self, r):
# if(TRY.rates[-1] != r):
TRY.rates.append(r)
def ls(self):
# print("TRY: "+TRY.rates[e] for e in range(1, len(TRY.rates)))
print(f"TRY: {TRY.rates}")
class USD():
rates = lis... | normal | {
"blob_id": "d56aa0f0b7c420e4021736cf8f80923121856d1c",
"index": 1286,
"step-1": "<mask token>\n\n\nclass RUB:\n rates = list()\n\n def __init__(self, r):\n RUB.rates.append(r)\n\n def ls(self):\n print(f'RUB: {RUB.rates}')\n\n\nclass INR:\n rates = list()\n\n def __init__(self, r):\... | [
10,
14,
16,
19,
22
] |
"""Utils module."""
import click
import os.path
import pandas as pd
from tensorflow.keras.models import load_model
from tensorflow.keras.regularizers import l1_l2
from tensorflow.keras.callbacks import CSVLogger, ModelCheckpoint, TensorBoard
from zalando_classification.models import build_model
def get_basename(na... | normal | {
"blob_id": "6553312c9655c821444ff5f60e4d68c7fc08bd08",
"index": 1118,
"step-1": "<mask token>\n\n\ndef get_basename(name, split_num):\n return f'{name}.split{split_num:d}'\n\n\n<mask token>\n\n\ndef maybe_load_model(name, split_num, checkpoint_dir, resume_from_epoch,\n batch_norm, l1_factor, l2_factor, op... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class PairMatcherTestCase(TestCase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class PairMatcherTestCase(TestCase):
<|reserved_special_token_0|>
def test_simple(self):
employees = Emplo... | flexible | {
"blob_id": "0c68bd65cac3c8b9fd080900a00991b2d19260ee",
"index": 534,
"step-1": "<mask token>\n\n\nclass PairMatcherTestCase(TestCase):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass PairMatcherTestCase(TestCase):\n <mask token>\n\n def test_simple(self):\n employees = ... | [
1,
2,
3,
4
] |
import tornado
import copy
class DjangoHandler(tornado.web.RequestHandler):
async def reroute(self):
http = tornado.httpclient.AsyncHTTPClient()
new_request = copy.deepcopy(self.request)
url_obj = copy.urlparse(new_request.url)
new_request.url = f"{url_obj.scheme}://localhost:9000... | normal | {
"blob_id": "6960fc6d949512ffc783b085041f86cb791160a3",
"index": 1500,
"step-1": "<mask token>\n\n\nclass DjangoHandler(tornado.web.RequestHandler):\n\n async def reroute(self):\n http = tornado.httpclient.AsyncHTTPClient()\n new_request = copy.deepcopy(self.request)\n url_obj = copy.urlp... | [
1,
3,
4,
5,
6
] |
#!/usr/bin/env python3
import datetime
import time
import board
from busio import I2C
import adafruit_bme680
# Create library object using our Bus I2C port
i2c = I2C(board.SCL, board.SDA)
bme680 = adafruit_bme680.Adafruit_BME680_I2C(i2c, debug=False)
# change this to match the location's pressure (hPa) at sea level
b... | normal | {
"blob_id": "ae7fc034249b7dde6d6bca33e2e6c8f464284cfc",
"index": 9718,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n ts = time.time()\n st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')\n file.write('\\ntimestamp: %s ' % st)\n print('\\ntimestamp: %s ' % st... | [
0,
1,
2,
3,
4
] |
from random import randint
class Game(object):
def __init__(self, players):
if len(players) < 2:
raise ValueError('Number of player must be at least 2')
self.play_order = players
self.player_data = {}
for player in self.play_order:
# ... | normal | {
"blob_id": "52f3000514fd39083daa6316d551f1685c7cea23",
"index": 6792,
"step-1": "<mask token>\n\n\nclass Game(object):\n <mask token>\n\n def game_loop(self):\n while not self.won():\n hunches = []\n for player, data in self.player_data.items():\n print('Jogador... | [
7,
10,
11,
12,
13
] |
from time import time
import threading
import os
#hh:mm:ss
movie1Time = "00:00:00"
movie2Time = "00:00:00"
movie3Time = "00:00:00"
movie4Time = "00:00:00"
movie5Time = "00:00:00"
timer1Start = None
timer1Time = "00:00:00"
timer1Running = False
timer2Start = None
timer2Time = "00:00:00"
timer2Running = False
timer3Star... | normal | {
"blob_id": "cef4568b4568bceeedca6d57c0ccacfaae67c061",
"index": 147,
"step-1": "<mask token>\n\n\nclass Ui_Form1(QtGui.QWidget):\n\n def __init__(self):\n QtGui.QWidget.__init__(self)\n self.setupUi(self)\n if os.path.exists(os.getcwd() + '\\\\settings.ini') and os.path.getsize(\n ... | [
15,
20,
21,
22,
28
] |
from collections import deque
def solution(people, limit):
people.sort()
cnt = 0
left_idx = 0
right_idx = len(people) - 1
while left_idx <= right_idx:
if people[left_idx] + people[right_idx] <= limit:
cnt += 1
left_idx += 1
right_idx -= 1
else:
... | normal | {
"blob_id": "b0dbc4e8a2ce41dc9d2040890e3df4d078680fa1",
"index": 5444,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef solution(people, limit):\n people.sort()\n cnt = 0\n left_idx = 0\n right_idx = len(people) - 1\n while left_idx <= right_idx:\n if people[left_idx] + people... | [
0,
1,
2
] |
import requests
from urllib.parse import urlparse
from bs4 import BeautifulSoup
import re
import datetime
import random
pages = set()
# Retrieve a list of all Internal links foound on a page.
def getInternalLinks(bs, includeUrl):
includeUrl = f'{urlparse(includeUrl).scheme}://{urlparse(includeUrl).netloc}'
in... | normal | {
"blob_id": "5ddfeb49c16a7452c99126f1a837f3c0bed0ec10",
"index": 300,
"step-1": "<mask token>\n\n\ndef getExternalLinks(bs, excludeUrl):\n externalLinks = []\n for link in bs.find_all('a', href=re.compile('^(http|www)((?!' +\n excludeUrl + ').)*$')):\n if link.attrs['href'] is not None:\n ... | [
2,
3,
4,
5,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
np.random.seed(1)
<|reserved_special_token_0|>
K.set_image_dim_ordering('th')
<|reserved_special_token_0|>
model.add(ZeroPadding2D((1, 1), input_shape=(3, img_width, img_height)))
model.add(Convolution2D(64, 3, 3, activation='relu... | flexible | {
"blob_id": "96210942b01c510300120913bed1bc6d497a39a9",
"index": 1945,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnp.random.seed(1)\n<mask token>\nK.set_image_dim_ordering('th')\n<mask token>\nmodel.add(ZeroPadding2D((1, 1), input_shape=(3, img_width, img_height)))\nmodel.add(Convolution2D(64, 3, 3, ... | [
0,
1,
2,
3,
4
] |
from django.shortcuts import render, redirect, get_object_or_404
from .models import Article, Comment
# from IPython import embed
# Create your views here.
def article_list(request):
articles = Article.objects.all()
return render(request, 'board/list.html', {
'articles': articles,
})
def articl... | normal | {
"blob_id": "6946601050802aaaa559d25612d0d4f5116559eb",
"index": 1845,
"step-1": "<mask token>\n\n\ndef article_list(request):\n articles = Article.objects.all()\n return render(request, 'board/list.html', {'articles': articles})\n\n\ndef article_detail(request, article_id):\n article = get_object_or_40... | [
5,
6,
7,
8,
9
] |
from django.db import models
# Create your models here.
class UserInfo(models.Model):
uname = models.CharField('用户名', max_length=50, null=False)
upassword = models.CharField('密码', max_length=200, null=False)
email = models.CharField('邮箱', max_length=50, null=True)
phone = models.CharField('手机号', max_le... | normal | {
"blob_id": "dbec74ecf488ca98f3f441e252f79bc2bc0959c1",
"index": 4068,
"step-1": "<mask token>\n\n\nclass UserInfo(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\n\n class Meta:\n verbose_n... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
ap = argparse.ArgumentParser()
ap.add_argument('-sd', '--startdate', help=
'Date to start scheduling trials, format is MM/DD.', required=True)
ap.add_argument('-r', '--round', help='A... | flexible | {
"blob_id": "e4767d8a4991a1180cc185c4c2d77104d63f9c7a",
"index": 6858,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n ap = argparse.ArgumentParser()\n ap.add_argument('-sd', '--startdate', help=\n 'Date to start scheduling trials, format is MM/DD.', required=True... | [
0,
1,
2,
3
] |
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def getIntersectionNode(self, headA, headB):
"""
:type head1, head1: ListNode
:rtype: ListNode
"""
if not hea... | normal | {
"blob_id": "66f60eb86137203a74656be13b631384eba30c84",
"index": 1681,
"step-1": "class Solution(object):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class Solution(object):\n\n def getIntersectionNode(self, headA, headB):\n \"\"\"\n :type head1, head1: ListNode\n ... | [
1,
2,
3,
4,
5
] |
# Copyright 2017 Google Inc.
# 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, softwa... | normal | {
"blob_id": "c2f6fa4d9a6e2ee5f0593bef775ce8f811225613",
"index": 2047,
"step-1": "<mask token>\n\n\n@gapit_test('vkCmdCopyQueryPoolResults_test')\nclass FifthToEighthQueryResultsIn64BitWithWaitBitCopyWithZeroOffsets(GapitTest\n ):\n <mask token>\n\n\n@gapit_test('vkCmdCopyQueryPoolResults_test')\nclass All... | [
3,
5,
6,
7,
8
] |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 4 13:04:32 2018
@author: andrew
"""
import os
import glob
import initialize
import psf
from astropy.io import fits
import filters
import numpy as np
import sys
import MR
from tqdm import tqdm
def sextractor_MR(location, MR_method='swarp', use_con... | normal | {
"blob_id": "6f5eda426daf5db84dc205f36ec31e9076acb8ee",
"index": 8971,
"step-1": "<mask token>\n\n\ndef sextractor(location):\n \"\"\"\n runs SExtractor on all residual images\n \"\"\"\n x = 0\n sources = location + '/sources'\n residuals = location + '/residuals'\n check = os.path.exists(so... | [
8,
9,
10,
11,
12
] |
<|reserved_special_token_0|>
class Mov_ZigZag(AbstractMoviment):
<|reserved_special_token_0|>
def move(self, coordinates, speed, startcoordinate, dt):
ZigZageamento = 100
coordinates[1] = round(coordinates[1] + speed * dt)
if startcoordinate[0] + ZigZageamento >= coordinates[0
... | flexible | {
"blob_id": "57935b560108ef0db59de9eee59aa0c908c58b8f",
"index": 2348,
"step-1": "<mask token>\n\n\nclass Mov_ZigZag(AbstractMoviment):\n <mask token>\n\n def move(self, coordinates, speed, startcoordinate, dt):\n ZigZageamento = 100\n coordinates[1] = round(coordinates[1] + speed * dt)\n ... | [
8,
9,
11,
12,
15
] |
<|reserved_special_token_0|>
class CastingAgencyTestCase(unittest.TestCase):
<|reserved_special_token_0|>
def setUp(self):
"""Define test variables and initialize app."""
self.app = create_app()
self.client = self.app.test_client
self.database_name = os.environ.get('TEST_DATAB... | flexible | {
"blob_id": "bae4eb94d561f7aa810718840ff7c2de52cb0d6f",
"index": 3228,
"step-1": "<mask token>\n\n\nclass CastingAgencyTestCase(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n \"\"\"Define test variables and initialize app.\"\"\"\n self.app = create_app()\n self.client = self... | [
21,
30,
31,
35,
39
] |
<|reserved_special_token_0|>
def home_view(request):
if request.user.is_authenticated:
return HttpResponseRedirect('afterlogin')
return render(request, 'library/index.html')
<|reserved_special_token_0|>
def studentsignup_view(request):
form1 = forms.StudentUserForm()
form2 = forms.StudentE... | flexible | {
"blob_id": "ce9e1ac0f1596ba4db904289f91f5ab95c2de4b8",
"index": 7642,
"step-1": "<mask token>\n\n\ndef home_view(request):\n if request.user.is_authenticated:\n return HttpResponseRedirect('afterlogin')\n return render(request, 'library/index.html')\n\n\n<mask token>\n\n\ndef studentsignup_view(req... | [
8,
11,
15,
18,
19
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class ItemInfo(Command):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class ItemInfo(Command):
@is_command
def item_info(self, player, *args):
if len(args) == 0... | flexible | {
"blob_id": "6b2bd6954f188626fa857ffc37611d3f971d22e2",
"index": 5259,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ItemInfo(Command):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ItemInfo(Command):\n\n @is_command\n def item_info(self, player, *args):\n if len(args... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def check_database(engine: Engine, user_name: pwd.struct_passwd, tables:
Iterable[Table]):
logger.info('Checking database access as user %s', user_name)
try:
conn = engine.connect()
except DBAPIError as e:
logger.critical('Could not connect to database as %... | flexible | {
"blob_id": "c9df53ac06b8bb106d73825d60fa885c06385e95",
"index": 8557,
"step-1": "<mask token>\n\n\ndef check_database(engine: Engine, user_name: pwd.struct_passwd, tables:\n Iterable[Table]):\n logger.info('Checking database access as user %s', user_name)\n try:\n conn = engine.connect()\n ex... | [
3,
4,
5,
6,
7
] |
from django.apps import AppConfig
class AccountsnConfig(AppConfig):
name = 'accounts'
| normal | {
"blob_id": "a3fc624d6d101667ab11842eac96ed1b34d4317e",
"index": 3369,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass AccountsnConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass AccountsnConfig(AppConfig):\n name = 'accounts'\n",
"step-4": "from django.apps impor... | [
0,
1,
2,
3
] |
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf.urls import include
# from rest_framework import routers
from rest_framework.authtoken import views
# from adventure.api import PlayerViewSet, RoomViewSet
# from adventure.api import move
# router = routers.DefaultRoute... | normal | {
"blob_id": "a14114f9bb677601e6d75a72b84ec128fc9bbe61",
"index": 71,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('admin/', admin.site.urls), path('api/', include(\n 'api.urls')), path('api/adv/', include('adventure.urls'))]\n",
"step-3": "from django.contrib import admin\nfrom... | [
0,
1,
2,
3
] |
import tkinter as tk
import random
from tkinter import messagebox as mb
n = 16
class Application(tk.Frame):
playButtons = [0] * n
def __init__(self, master=None):
tk.Frame.__init__(self, master)
self.grid(sticky='NEWS')
self.createWidgets()
def show_win(self):
msg = "YOU ... | normal | {
"blob_id": "f29bc0263f8bb1d59ab2442347727d9d3233ec77",
"index": 9893,
"step-1": "<mask token>\n\n\nclass Application(tk.Frame):\n <mask token>\n <mask token>\n\n def show_win(self):\n msg = 'YOU WIN!'\n mb.showinfo('Information', msg)\n self.makePlayButtons()\n\n def move(self, ... | [
5,
7,
8,
9,
11
] |
# Generated by Django 3.1 on 2020-09-26 03:46
import datetime
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('bcs', '0002_auto_20200915_2245'),
]
operations = [
migrations.AddField(
model_name='s... | normal | {
"blob_id": "61484d9a08f2e3fcd15573ce89be4118a442dc2e",
"index": 6062,
"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 = [('bcs', '0002... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class _CORPORALS(_CORPORAL):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class _CORPORALS(_CORPORAL):
def __init__(self):
_CORPORAL.__init__(self)
self.nam... | flexible | {
"blob_id": "d2787f17a46cf0db9aeea82f1b97ee8d630fd28a",
"index": 8932,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass _CORPORALS(_CORPORAL):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass _CORPORALS(_CORPORAL):\n\n def __init__(self):\n _CORPORAL.__init__(self)\n se... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
conf = open('../conf/linked.data.gov.au-vocabularies.conf')
new = ['anzsrc-for', 'anzsrc-seo', 'ausplots-cv',
'australian-phone-area-codes', 'care', 'corveg-cv', 'nrm',
'reg-roles... | flexible | {
"blob_id": "4a620957b2cd1e5945d98e49a5eae5d5592ef5a2",
"index": 3911,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n conf = open('../conf/linked.data.gov.au-vocabularies.conf')\n new = ['anzsrc-for', 'anzsrc-seo', 'ausplots-cv',\n 'australian-phone-area-codes', ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def convert_type(data_value):
try:
return int(data_value)
except ValueError:
try:
return float(data_value)
except ValueError:
return data_value
<|reserved_special_token_0|>
def get_delim(sourcefile1):
print('> executing get_d... | flexible | {
"blob_id": "594479c22cada665dcdc76737085ce342d7d5faf",
"index": 1480,
"step-1": "<mask token>\n\n\ndef convert_type(data_value):\n try:\n return int(data_value)\n except ValueError:\n try:\n return float(data_value)\n except ValueError:\n return data_value\n\n\n<... | [
5,
6,
7,
8,
9
] |
import string
#takes file as input, outputs a dictionary of keys from the file
#file should be in format (apiName, key/id)
#dictionary key = apiName, value = key/id
def getKeys(f):
keys = {}
f = open(f, 'r')
for line in f:
apiInfo = line.split(',')
keys[apiInfo[0]] = apiInfo[1].strip(string... | normal | {
"blob_id": "3653c6fce33467600a3eea72578ed995606bfc03",
"index": 4100,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef getKeys(f):\n keys = {}\n f = open(f, 'r')\n for line in f:\n apiInfo = line.split(',')\n keys[apiInfo[0]] = apiInfo[1].strip(string.whitespace)\n keys.p... | [
0,
1,
2,
3
] |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: xurongzhong#126.com 技术支持qq群:6089740
# CreateDate: 2018-3-27
# pillow_rotate.py
import glob
import os
from PIL import Image
def rotate(files, dst, value=90):
for file_ in files:
img = Image.open(file_)
img = img.rotate(value)
name = "{... | normal | {
"blob_id": "cd104eec21be8a59e8fb3bd8ab061dd357fc126a",
"index": 667,
"step-1": "<mask token>\n\n\ndef rotate(files, dst, value=90):\n for file_ in files:\n img = Image.open(file_)\n img = img.rotate(value)\n name = '{}{}{}'.format(dst, os.sep, os.path.basename(file_))\n img.save(n... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class QuoteModel(db.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def __init__(self, author, quote, rating=1):
self.author = author
self.quote = quote
self.rate = rat... | flexible | {
"blob_id": "38f41fa87230ddc0b3a8c411b4c569f59f0ea065",
"index": 2509,
"step-1": "<mask token>\n\n\nclass QuoteModel(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, author, quote, rating=1):\n self.author = author\n self.quote = quote\n ... | [
3,
4,
5,
7,
8
] |
<|reserved_special_token_0|>
class Formation(db):
<|reserved_special_token_0|>
query: Query
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
@staticmethod
def create(filiere: str, lieu: str, niveau: str):
retur... | flexible | {
"blob_id": "fff70312fa7c3259cf4c3d9e7ebd8ca5b9a56887",
"index": 2714,
"step-1": "<mask token>\n\n\nclass Formation(db):\n <mask token>\n query: Query\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def create(filiere: str, lieu: str, niveau: str):\n ... | [
2,
3,
4,
5,
6
] |
import requests, shutil, os, glob
from zipfile import ZipFile
import pandas as pd
from xlrd import open_workbook
import csv
# zipfilename = 'desiya_hotels'
# try:
# # downloading zip file
# r = requests.get('http://staticstore.travelguru.com/testdump/1300001176/Excel.zip', auth=('testdump', 'testdump'), veri... | normal | {
"blob_id": "1ef9df43725196904ec6c0c881f4a1204174b176",
"index": 375,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(os.path.join(os.path.dirname(__file__), 'storage/robot_list.csv'),\n 'w') as file:\n writer = csv.writer(file, delimiter=',')\n headers = [cell.value for cell in sheet.r... | [
0,
1,
2,
3,
4
] |
# Generated by Django 3.2.2 on 2021-05-07 08:01
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='teams',
fields=[
('id', models.AutoField(pr... | normal | {
"blob_id": "e72962b644fab148741eb1c528d48ada45a43e51",
"index": 3978,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... | normal | {
"blob_id": "4989db28db0f823a54ff0942fbc40fc4640da38f",
"index": 3224,
"step-1": "<mask token>\n\n\nclass FlatbuffersConversionData(object):\n \"\"\"Holds data needed to convert a set of json files to flatbuffer binaries.\n\n Attributes:\n schema: The path to the flatbuffer schema file.\n input_files: ... | [
15,
18,
20,
22,
25
] |
'''
@name: ros_env_img.py
@brief: This (abstract) class is a simulation environment wrapper for
the X-Image Representation.
@author: Ronja Gueldenring
@version: 3.5
@date: 2019/04/05
'''
# python relevant
import numpy as np
# custom classes
from rl_agent.env_wra... | normal | {
"blob_id": "1a979933eb02e9d12dc034021448cbade59abc48",
"index": 2585,
"step-1": "<mask token>\n\n\nclass RosEnvImg(RosEnvAbs):\n <mask token>\n <mask token>\n\n def get_observation_(self):\n \"\"\"\n Function returns state that will be fed to the rl-agent\n It includes\n the... | [
2,
3,
4,
5,
6
] |
from rest_framework import serializers
from .models import *
class MovieSerializer(serializers.Serializer):
movie_name = serializers.ListField(child=serializers.CharField())
class FilmSerializer(serializers.ModelSerializer):
class Meta:
model = Movie
fields = '__all__'
| normal | {
"blob_id": "0509afdce0d28cc04f4452472881fe9c5e4fbcc4",
"index": 7825,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass MovieSerializer(serializers.Serializer):\n <mask token>\n\n\nclass FilmSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Movie\n fields = ... | [
0,
2,
3,
4
] |
from wtforms import StringField, PasswordField
from wtforms.validators import DataRequired
from flask_wtf import FlaskForm
# ...
class LoginForm(FlaskForm):
"""登录表单类"""
username = StringField('用户名', validators=[DataRequired()])
password = PasswordField('密码', validators=[DataRequired()]) | normal | {
"blob_id": "6ad2014191215dac97ad6fc6a026512c3d1866dc",
"index": 8244,
"step-1": "<mask token>\n\n\nclass LoginForm(FlaskForm):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass LoginForm(FlaskForm):\n <mask token>\n username = StringField('用户名', validators=[Dat... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class MigrationVisitor(semtk.DefaultSemTKVisitor):
def __init__(self, data: RemoveIsATypeOf):
self.data = data
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@dataclass
class RemoveIsATypeOf(OntologyChange):
<|reserved_special_token_0|>
name_space: Nam... | flexible | {
"blob_id": "41294c803cf42611fa003f21b74a49dd5576a8e8",
"index": 5973,
"step-1": "<mask token>\n\n\nclass MigrationVisitor(semtk.DefaultSemTKVisitor):\n\n def __init__(self, data: RemoveIsATypeOf):\n self.data = data\n",
"step-2": "<mask token>\n\n\n@dataclass\nclass RemoveIsATypeOf(OntologyChange):\... | [
2,
5,
6,
7,
8
] |
# Generated by Django 2.0.2 on 2018-06-10 18:24
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Expression',
fields=[
... | normal | {
"blob_id": "87e0b9dc518d439f71e261d5c5047153324919ba",
"index": 9547,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
from django.apps import AppConfig
class CheckoutConfig(AppConfig):
name = "checkout"
# Override the ready method and import the signals module
# so that update_on_save and update_on_delete will be called
# after an OrderLineItem model instance is saved or deleted
def ready(self):
import c... | normal | {
"blob_id": "74e3f4cd7b09d9b96feb3f927a509b113481eaed",
"index": 7575,
"step-1": "<mask token>\n\n\nclass CheckoutConfig(AppConfig):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass CheckoutConfig(AppConfig):\n <mask token>\n\n def ready(self):\n import checkout.signals\n... | [
1,
2,
3,
4,
5
] |
# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 2.7.5 (default, Jul 13 2018, 13:06:57)
# [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
# Embedded file name: ./authx/migrations/0001_initial.py
# Compiled at: 2018-08-23 19:33:14
# Size of source mod 2**32: 2715 bytes
from __future__ import un... | normal | {
"blob_id": "1073845131afb2446ca68ee10092eeb00feef800",
"index": 3585,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
t_dim_2 = [[1, 2], [3, 4]]
def z(i, j, dim):
t = dim ** 2
if dim == 2:
return t_dim_2[i-1][j-1]
d = dim//2
if i <= d: # I or II
if j <= d:
return z(i, j, d) #I
else:
j -= d
return t//4 + z(i, j, d) # II
else: # III or IV
if j <=d... | normal | {
"blob_id": "07ed8c12e8e5c568c897b6b632c48831267eba51",
"index": 1815,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef z(i, j, dim):\n t = dim ** 2\n if dim == 2:\n return t_dim_2[i - 1][j - 1]\n d = dim // 2\n if i <= d:\n if j <= d:\n return z(i, j, d)\n ... | [
0,
1,
2,
3,
4
] |
from apps.mastermind.core.domain.domain import Color, Game
from apps.mastermind.infrastructure.mongo_persistence.uow import MongoUnitOfWork
from composite_root.container import provide
class GameMother:
async def a_game(
self,
num_slots: int,
num_colors: int,
max_guesses: int,
... | normal | {
"blob_id": "8457cdde8f8ad069505c7729b8217e5d272be41e",
"index": 957,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass GameMother:\n\n async def a_game(self, num_slots: int, num_colors: int, max_guesses:\n int, secret_code: list[Color], reference: (str | None)=None) ->Game:\n asy... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
CHROME_WEBDRIVER = 'c:/users/username/project/chromedriver.exe'
WEBSITE_PDF_CONVERTER = 'https://www.ilovepdf.com/merge_pdf'
PDF_FILES = 'c:/users/username/project'
<|reserved_special_token_1|>
"""
If you are using MultiScript ... | flexible | {
"blob_id": "0fdbdfe98496ebedb112c85b79836292ffa3a5a9",
"index": 9076,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nCHROME_WEBDRIVER = 'c:/users/username/project/chromedriver.exe'\nWEBSITE_PDF_CONVERTER = 'https://www.ilovepdf.com/merge_pdf'\nPDF_FILES = 'c:/users/username/project'\n",
"step-3": "\"\... | [
0,
1,
2
] |
import cv2 as cv
import numpy as np
img = np.zeros((512, 512, 3), np.uint8)
cv.line(img, (0, 0), (511, 511), (255, 255, 255), 10)
cv.rectangle(img, (384, 0), (510, 128), (255, 0, 0), 3)
cv.circle(img, (200, 60), 20, (0, 100, 255), 3)
cv.ellipse(img, (250, 250), (100, 50), 90, 0, 180, (255, 0, 255), 3)
font = cv.FONT_HE... | normal | {
"blob_id": "08c5f5ac568b7575d8082976336a5893951b53c2",
"index": 9269,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncv.line(img, (0, 0), (511, 511), (255, 255, 255), 10)\ncv.rectangle(img, (384, 0), (510, 128), (255, 0, 0), 3)\ncv.circle(img, (200, 60), 20, (0, 100, 255), 3)\ncv.ellipse(img, (250, 250)... | [
0,
1,
2,
3
] |
class Fail(Exception):
def __init__(self, message):
super().__init__(message)
class Student:
def __init__(self, rollNo, name, marks):
self.rollNo = rollNo
self.name = name
self.marks = marks
def displayDetails(self):
print('{} \t {} \t {}'.format(self.name, self.... | normal | {
"blob_id": "ddf074e400551d2c147d898fe876a31d13a72699",
"index": 5324,
"step-1": "<mask token>\n\n\nclass Student:\n <mask token>\n\n def displayDetails(self):\n print('{} \\t {} \\t {}'.format(self.name, self.rollNo, self.marks))\n try:\n if self.marks < 40:\n raise... | [
2,
5,
6,
7
] |
#
# o o
# 8
# .oPYo. .oPYo. odYo. o8P o8 .oPYo. odYo. .oPYo. .oPYo.
# Yb.. 8oooo8 8' `8 8 8 8oooo8 8' `8 8 ' 8oooo8
# 'Yb. 8. 8 8 8 8 8. 8 8 8 . 8.
# `YooP' `Yooo' 8 8 8 ... | normal | {
"blob_id": "c6357e6e0656388fc3fd849879aa6000e0bee1ee",
"index": 1553,
"step-1": "#\n# o o \n# 8 \n# .oPYo. .oPYo. odYo. o8P o8 .oPYo. odYo. .oPYo. .oPYo. \n# Yb.. 8oooo8 8' `8 8 8 8oooo8 8' `8 8 ' 8... | [
0
] |
from sklearn import datasets, svm
import matplotlib.pyplot as plt
digits = datasets.load_digits()
X, y = digits.data[:-1], digits.target[:-1]
clf = svm.SVC(gamma=0.1, C=100)
clf.fit(X, y)
prediction = clf.predict(digits.data[-1:])
actual = digits.target[-1:]
print("prediction = " + str(prediction) + ", actual = " + ... | normal | {
"blob_id": "0d98472d1c04bfc52378aa6401a47d96582696a2",
"index": 4046,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nclf.fit(X, y)\n<mask token>\nprint('prediction = ' + str(prediction) + ', actual = ' + str(actual))\nplt.matshow(digits.images[-1])\nplt.show()\n",
"step-3": "<mask token>\ndigits = dat... | [
0,
1,
2,
3,
4
] |
# Default imports
from sklearn.feature_selection import SelectFromModel
from sklearn.ensemble import RandomForestClassifier
import pandas as pd
import numpy as np
data = pd.read_csv('data/house_prices_multivariate.csv')
# Your solution code here
def select_from_model(dataframe):
X = dataframe.iloc[:, :-1]
y... | normal | {
"blob_id": "d6791c8122129a46631582e7d9339ea08bd2e92b",
"index": 3183,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef select_from_model(dataframe):\n X = dataframe.iloc[:, :-1]\n y = dataframe.iloc[:, -1]\n np.random.seed(9)\n model = RandomForestClassifier()\n sfm = SelectFromMode... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# encoding=utf-8
import MySQLdb
import re
# 打开数据库连接
db = MySQLdb.connect(host='wonderfulloffline.mysql.rds.aliyuncs.com',port=3306,user='wonderfull_ai',password='868wxRHrPaTKkjvC', db='wonderfull_ai_online', charset='utf8' )
def load_stop_word():
stop_word=set()
with open("data... | normal | {
"blob_id": "4942b20a8e4f58c52b82800fb4c59db169cd8048",
"index": 3562,
"step-1": "<mask token>\n\n\ndef load_stop_word():\n stop_word = set()\n with open('data/stop_word.txt', 'r', encoding='utf-8') as file:\n for line in file.readlines():\n stop_word.add(line.strip())\n return stop_wo... | [
2,
3,
4,
5,
7
] |
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name = 'index'),
path('about/', views.about, name='about'),
path('contact/', views.contact, name= 'contact'),
path('category/', views.category, name='category'),
path('product/<str:id>/<slug:slug>',views.product... | normal | {
"blob_id": "0588aad1536a81d047a2a2b91f83fdde4d1be974",
"index": 3869,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', views.index, name='index'), path('about/', views.\n about, name='about'), path('contact/', views.contact, name='contact'),\n path('category/', views.category... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Ui_MainWindow(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName('MainWindow')
self.centra... | flexible | {
"blob_id": "65264f52f641b67c707b6a827ecfe1bf417748e8",
"index": 2379,
"step-1": "<mask token>\n\n\nclass Ui_MainWindow(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Ui_MainWindow(object):\n\n def setupUi(self, MainWindow):\n MainWindow.setObjectName('MainWindow'... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def preprocess_image(img):
img = img.astype(np.uint8)
channel_b, channel_g, channel_r = cv2.split(img)
result = ndimage.maximum_filter(channel_g, size=5)
ret, result = cv2.threshold(channel_g, 120, 255, cv2.THRES... | flexible | {
"blob_id": "586d39556d2922a288a2bef3bcffbc6f9e3dc39d",
"index": 6707,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef preprocess_image(img):\n img = img.astype(np.uint8)\n channel_b, channel_g, channel_r = cv2.split(img)\n result = ndimage.maximum_filter(channel_g, size=5)\n ret, resu... | [
0,
1,
2,
3,
4
] |
<|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": "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
] |
<|reserved_special_token_0|>
@dataclass
class Book:
id: int
title: str
author: str
genre: str
published: date
status: str = 'Available'
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@dataclass
class Book:
id... | flexible | {
"blob_id": "dc13ca17bff8e2a5254c7758bd7274926bafd454",
"index": 5312,
"step-1": "<mask token>\n\n\n@dataclass\nclass Book:\n id: int\n title: str\n author: str\n genre: str\n published: date\n status: str = 'Available'\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\n@dat... | [
1,
2,
3,
4,
5
] |
from django.shortcuts import render_to_response
from mousedb.animal.models import Animal, Strain
from django.contrib.auth.decorators import login_required
from django.template import RequestContext
from django.db import connection
import datetime
@login_required
def todo(request):
eartag_list = Animal.objects.filter(... | normal | {
"blob_id": "89518f43934710ef2e7471a91128e20d2306d6f6",
"index": 9291,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@login_required\ndef todo(request):\n eartag_list = Animal.objects.filter(MouseID__isnull=True, Alive=True\n ).order_by('Strain', 'Background', 'Rack', 'Cage')\n genotype... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-07-21 12:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('user', '0001_initial'),
]
operations = [
migrations.CreateModel(
... | normal | {
"blob_id": "722739086d2777085fdbfdbddef205aaf025580d",
"index": 4291,
"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 = [('user', '000... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if ratio <= 2:
print('😊')
else:
print('⚠️')
print('Ratio is', ratio)
<|reserved_special_token_1|>
debt = 100
equity = 50
ratio = debt / equity
if ratio <= 2:
print('😊')
else:
print('⚠️')
print('Ratio is', rati... | flexible | {
"blob_id": "40b1fac14aaa81039aec8e80ce1c91bb881cfe78",
"index": 3474,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif ratio <= 2:\n print('😊')\nelse:\n print('⚠️')\nprint('Ratio is', ratio)\n",
"step-3": "debt = 100\nequity = 50\nratio = debt / equity\nif ratio <= 2:\n print('😊')\nelse:\n... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class Message(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|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "7159b447ed6fcb2005f63c7b7359970defbc9d43",
"index": 1496,
"step-1": "<mask token>\n\n\nclass Message(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Message(models.Model):\n <mask t... | [
1,
2,
3,
4,
5
] |
# -*- coding: UTF-8 -*-
# File Name: ll.py
# Author: Sam
# mail: samyunwei@163.com
# Created Time: 2016年03月09日 星期三 19时18分02秒
#########################################################################
#!/usr/bin/env python
def checkmark(marks):
if not isinstance(marks,list):
return 'marks Error'
else:
... | normal | {
"blob_id": "f98d6dd9ac4714c24ce070a1a81dc4610d04b97e",
"index": 6017,
"step-1": "# -*- coding: UTF-8 -*- \n# File Name: ll.py\n# Author: Sam\n# mail: samyunwei@163.com\n# Created Time: 2016年03月09日 星期三 19时18分02秒\n#########################################################################\n#!/usr/bin/env python\nde... | [
0
] |
"""
Test /cohort/:id/user/:id
"""
import re
from unittest.mock import patch
from django.urls.base import reverse_lazy
from rest_framework import status
from breathecode.tests.mocks import (
GOOGLE_CLOUD_PATH,
apply_google_cloud_client_mock,
apply_google_cloud_bucket_mock,
apply_google_cloud_blob_mock,
)... | normal | {
"blob_id": "937711546271c145d0f0df2981bdd7d1e9297e3a",
"index": 3788,
"step-1": "<mask token>\n\n\nclass CohortIdUserIdTestSuite(AdmissionsTestCase):\n <mask token>\n\n @patch(GOOGLE_CLOUD_PATH['client'], apply_google_cloud_client_mock())\n @patch(GOOGLE_CLOUD_PATH['bucket'], apply_google_cloud_bucket_... | [
9,
13,
14,
15,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
while i != -1:
i = s.find(st, j)
if k != i and i != -1:
k = i
sch1 += 1
j += 1
<|reserved_special_token_0|>
while i != -1:
i = s.find(st2, j)
if k != i and i != -1:
k = i
sch2 +=... | flexible | {
"blob_id": "c18e452592d53f22858f2307c60aa997b809c3c3",
"index": 4356,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile i != -1:\n i = s.find(st, j)\n if k != i and i != -1:\n k = i\n sch1 += 1\n j += 1\n<mask token>\nwhile i != -1:\n i = s.find(st2, j)\n if k != i and i ... | [
0,
1,
2,
3
] |
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.models import User
from .models import Museo, Distrito, Comentario, Favorito, Like, Titulo, Letra, Color
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth import authenticate, login
from django.... | normal | {
"blob_id": "8b2911586e21162bec074732216c410c591f18a8",
"index": 6018,
"step-1": "<mask token>\n\n\ndef getMuseums():\n museos = Museo.objects.all()\n allMuseums = {}\n for museo in museos:\n allMuseums[museo.ID_ENTIDAD] = museo.comentario_set.count()\n return allMuseums\n\n\ndef getAccessible... | [
10,
11,
14,
17,
18
] |
# Copyright 2010 Google Inc. All Rights Reserved.
#
import copy
import logging
import threading
from automation.common import command as cmd
from automation.common import logger
from automation.common.command_executer import CommandExecuter
from automation.common import job
from automation.common import job_group
fro... | normal | {
"blob_id": "720ec6c222659a13d4a0f3cf9096b70ce6e2b2b3",
"index": 175,
"step-1": "<mask token>\n\n\nclass JobGroupManager(object):\n <mask token>\n\n def GetJobGroup(self, group_id):\n with self._lock:\n for group in self.all_job_groups:\n if group.id == group_id:\n ... | [
3,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
def make_scatter(df):
plt.figure(figsize=(8, 6))
plt.plot(df['Start station number'], df['Counts'], 'o')
plt.xlabel('Station')
plt.ylabel('Counts')
plt.show()
return
def train_predict_1d(df, test):
regressor = DecisionTreeRegressor(max_depth=2)
regressor.... | flexible | {
"blob_id": "e35dbcdef8779ffabc34b5e5c543e35b29523971",
"index": 7989,
"step-1": "<mask token>\n\n\ndef make_scatter(df):\n plt.figure(figsize=(8, 6))\n plt.plot(df['Start station number'], df['Counts'], 'o')\n plt.xlabel('Station')\n plt.ylabel('Counts')\n plt.show()\n return\n\n\ndef train_pr... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class model:
def __init__(self):
self.number_to_label = {(1): 'Bot', (2): 'DoS attack', (3):
'Brute Force', (5): 'DDoS attacks', (4): 0}
try:
self.model = load('./decision_tree_model.joblib')
self.attack_model = load('./attack_model... | flexible | {
"blob_id": "c0f3a957613a4f4e04aeb3eb2e3fa4053bd0122c",
"index": 8438,
"step-1": "<mask token>\n\n\nclass model:\n\n def __init__(self):\n self.number_to_label = {(1): 'Bot', (2): 'DoS attack', (3):\n 'Brute Force', (5): 'DDoS attacks', (4): 0}\n try:\n self.model = load('.... | [
4,
5,
6,
8,
10
] |
<|reserved_special_token_0|>
class Solution:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Solution:
def minimumOperations(self, nums: List[int], start: int, goal: int) ->int:
que = deque([(start, 0)])
visited ... | flexible | {
"blob_id": "50b2b9d1edc8eaa44050e2b3b2375e966f16e10c",
"index": 6997,
"step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n\n def minimumOperations(self, nums: List[int], start: int, goal: int) ->int:\n que = deque([(start... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class ModelSelection:
def __init__(self, user_data, movie_data, aggregated_data, train_data,
output_train):
self.train = train_data
self.users = user_data
self.aggregated = aggregated_data
self.movies = movie_data
self.output_train = ou... | flexible | {
"blob_id": "5172819da135600d0764033a85a4175098274806",
"index": 7388,
"step-1": "<mask token>\n\n\nclass ModelSelection:\n\n def __init__(self, user_data, movie_data, aggregated_data, train_data,\n output_train):\n self.train = train_data\n self.users = user_data\n self.aggregated... | [
5,
7,
8,
9,
10
] |
import messages
import os
import requests
from bs4 import BeautifulSoup
URL = "https://mailman.kcl.ac.uk/mailman/"
ADMIN = "admin/"
ROSTER = "roster/"
OUTPUT_FOLDER = "../output/"
def makeoutput(path):
if os.path.exists(path):
pass
else:
os.mkdir(path)
def mailinglist_cookies(mailinglist, password): # this o... | normal | {
"blob_id": "0e337ce21450e0fdb7688183d0542ebf902a9614",
"index": 1293,
"step-1": "<mask token>\n\n\ndef makeoutput(path):\n if os.path.exists(path):\n pass\n else:\n os.mkdir(path)\n\n\ndef mailinglist_cookies(mailinglist, password):\n try:\n cookie_request = requests.post(URL + ADM... | [
4,
5,
6,
7,
8
] |
"""This module contains a class supporting composition of AugraphyPipelines"""
class ComposePipelines:
"""The composition of multiple AugraphyPipelines.
Define AugraphyPipelines elsewhere, then use this to compose them.
ComposePipelines objects are callable on images (as numpy.ndarrays).
:param pipel... | normal | {
"blob_id": "13c55c313c740edce48fc979e8956fdd018e8aab",
"index": 9716,
"step-1": "<mask token>\n\n\nclass ComposePipelines:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass ComposePipelines:\n <mask token>\n <mask token>\n\n def __call__(self, image):\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
@synchronized
def start():
startService(command='/opt/icecream/sbin/iceccd', args=
'-d -m 5 > /dev/null', pidfile='/var/run/iceccd.pid', donotify=True)
<|reserved_special_token_0|>
def status():
return isServiceRunning('/var/run/iceccd.pid')
<|reserved_special_token_... | flexible | {
"blob_id": "e3603d90bd5aa5de40baa27b62acf6f71eff9f6c",
"index": 6827,
"step-1": "<mask token>\n\n\n@synchronized\ndef start():\n startService(command='/opt/icecream/sbin/iceccd', args=\n '-d -m 5 > /dev/null', pidfile='/var/run/iceccd.pid', donotify=True)\n\n\n<mask token>\n\n\ndef status():\n retu... | [
2,
3,
4,
5,
6
] |
import numpy as np
import pandas as pd
from unrar import rarfile
import numpy as np
import pandas as pd
import tushare as ts
import os
year_month='201911'
contract_kind='NI'
rar_data_file_path='C:/Users/lenovo/Documents/WeChat Files/yiranli13/FileStorage/File/2020-01/'
main_code_path='C:/Users/lenovo/Documents/WeCha... | normal | {
"blob_id": "1c2967c26c845281ceb46cc1d8c06768298ef6b6",
"index": 9407,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef renew_commodity_future(year_month: str, contract_kind: str,\n main_code_path: str, rar_data_file_path: str, clean_data_path: str,\n time_range_path: str, end_date: str, comm... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
'''
Задание 12.3
Создать функцию print_ip_table, которая отображает таблицу доступных и недоступных IP-адресов.
Функция ожидает как аргументы два списка:
* список доступных IP-адресов
* список недоступных IP-адресов
Результат работы функции - вывод на стандартный поток вывода таблицы вида:
... | normal | {
"blob_id": "dd7e8556405f07172ce2b1e9f486c2cd2f4bad58",
"index": 7613,
"step-1": "<mask token>\n\n\ndef ping_ip_addresses(ip_addresses):\n result1 = []\n result2 = []\n for ip_address in ip_addresses:\n reply = subprocess.run(['ping', '-c', '3', '-n', ip_address],\n stdout=subprocess.P... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class StockType(Base, BaseModel):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def __json__(self, _):
return {'id': self.id, 'name': self.name}
<|reserved... | flexible | {
"blob_id": "7251d32918b16166e9b7c9613726e6dc51d6fea4",
"index": 3834,
"step-1": "<mask token>\n\n\nclass StockType(Base, BaseModel):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __json__(self, _):\n return {'id': self.id, 'name': self.name}\n",
"s... | [
2,
3,
5,
6,
8
] |
<|reserved_special_token_0|>
def compute_target_weights(context, data):
"""
Compute ordering weights.
"""
weights = {}
if context.longs:
long_weight = 0.5 / len(context.longs)
if context.shorts:
short_weight = -0.5 / len(context.shorts)
for security in context.portfolio.pos... | flexible | {
"blob_id": "c447d1fe38a4af43de39e05d46dacbe88249d427",
"index": 3654,
"step-1": "<mask token>\n\n\ndef compute_target_weights(context, data):\n \"\"\"\n Compute ordering weights.\n \"\"\"\n weights = {}\n if context.longs:\n long_weight = 0.5 / len(context.longs)\n if context.shorts:\n ... | [
1,
2,
4,
6,
7
] |
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# tail -2 hightemp.txt
import sys
with open(sys.argv[1]) as f:
lines = f.readlines();
n = sys.argv[2];
print "".join(lines[len(lines)-int(n):]) | normal | {
"blob_id": "a1710ee228a432db92c9586ddff0bfcad1f434a8",
"index": 2088,
"step-1": "# !/usr/bin/env python\n# -*- coding: utf-8 -*-\n# tail -2 hightemp.txt\n\n\nimport sys\n\nwith open(sys.argv[1]) as f:\n lines = f.readlines();\n\nn = sys.argv[2];\n\nprint \"\".join(lines[len(lines)-int(n):])",
"step-2": nul... | [
0
] |
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.initializers import RandomUniform
class Critic:
def __init__(self, obs_dim, action_dim, learning_rate=0.001):
self.obs_dim = obs_dim
self.action_dim = action_dim
self.model = self.make_network()
... | normal | {
"blob_id": "535fdee8f74b1984c5d1a5ec929310473b01239d",
"index": 1617,
"step-1": "<mask token>\n\n\nclass Critic:\n\n def __init__(self, obs_dim, action_dim, learning_rate=0.001):\n self.obs_dim = obs_dim\n self.action_dim = action_dim\n self.model = self.make_network()\n self.opti... | [
7,
8,
9,
10,
11
] |
# 5. Усовершенствовать программу «Банковский депозит». Третьим аргументом в функцию должна
# передаваться фиксированная ежемесячная сумма пополнения вклада. Необходимо в главной
# функции реализовать вложенную функцию подсчета процентов для пополняемой суммы.
# Примем, что клиент вносит средства в последний день каж... | normal | {
"blob_id": "bf9e83591f737caec3060b72d86d56faec9bb23b",
"index": 8079,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef chargeable_deposit(amount, months, charge=0):\n percent = get_percent(amount, months)\n if not percent:\n print('Нет подходящего тарифа')\n total = amount\n for... | [
0,
1,
2,
3,
4
] |
class player:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class player:
def __init__(self, name: str, symbol: str):
self._name = name
self._symbol = symbol
<|reserved_special_token_0|>
<|reserved_special_... | flexible | {
"blob_id": "3cc894570189fe545f5db3150d0b69c16dc211dc",
"index": 981,
"step-1": "class player:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class player:\n\n def __init__(self, name: str, symbol: str):\n self._name = name\n self._symbol = symbol\n <mask token>\n <... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def test_logsources_model(self):
"""
Comprobacion de que el modelo de la fuente de seguridad coincide con su asociado
Returns:
"""
log_source = LogSources.objects.get(Model='iptables v1.4.21')
self.assertEqual(log_source.get_model(), ... | flexible | {
"blob_id": "c645461effe288a1959b783473d62ff99ca29547",
"index": 8746,
"step-1": "<mask token>\n",
"step-2": "def test_logsources_model(self):\n \"\"\"\n Comprobacion de que el modelo de la fuente de seguridad coincide con su asociado\n Returns:\n\n \"\"\"\n log_source = LogSources.objects.get(M... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(32), index=True)
password_hash = db.Column(db.String(128))
def hash_password(self, password):
self.password_hash = pwd_context.encrypt(pas... | flexible | {
"blob_id": "e976f7e423d75f7fc8a3d5cd597bdd9358ae317e",
"index": 5243,
"step-1": "<mask token>\n\n\nclass User(db.Model):\n __tablename__ = 'users'\n id = db.Column(db.Integer, primary_key=True)\n username = db.Column(db.String(32), index=True)\n password_hash = db.Column(db.String(128))\n\n def h... | [
11,
13,
15,
16,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
__version__ = '0.6.1'
<|reserved_special_token_1|>
# Global version information
__version__ = "0.6.1"
| flexible | {
"blob_id": "8aeb7786984f27fabdcaffa54f52eb868c277fdb",
"index": 7707,
"step-1": "<mask token>\n",
"step-2": "__version__ = '0.6.1'\n",
"step-3": "# Global version information\n__version__ = \"0.6.1\"\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
<|reserved_special_token_0|>
def test(config, base, loaders, brief):
compute_and_save_features(base, loaders)
results = evalutate(config, base, brief)
return results
def evalutate(config, base, brief=False):
results = {}
for mode in config.modes:
print(mode)
for number_shot in co... | flexible | {
"blob_id": "b21796a9e10314f80cac3151d1fdbb139966303f",
"index": 5555,
"step-1": "<mask token>\n\n\ndef test(config, base, loaders, brief):\n compute_and_save_features(base, loaders)\n results = evalutate(config, base, brief)\n return results\n\n\ndef evalutate(config, base, brief=False):\n results =... | [
2,
3,
4,
5,
6
] |
# LCP 74. 最强祝福力场-离散化+二维差分
# https://leetcode.cn/problems/xepqZ5/
# forceField[i] = [x,y,side] 表示第 i 片力场将覆盖以坐标 (x,y) 为中心,边长为 side 的正方形区域。
# !若任意一点的 力场强度 等于覆盖该点的力场数量,请求出在这片地带中 力场强度 最强处的 力场强度。
# !统计所有左下和右上坐标,由于会出现 0.5可以将坐标乘 2。
# O(n^2)
from typing import List
from 二维差分模板 import DiffMatrix
class Solution:... | normal | {
"blob_id": "0212382b5c8cc1e98142a784fd26efd577ebceaf",
"index": 1656,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def fieldOfGreatestBlessing(self, forceField: List[List[int]]) ->int:\n allX, allY =... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
app.config.from_object('config.DevelopmentConfig')
<|reserved_special_token_0|>
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
manager.run()
<|reserved_special_token_1|>
<|reserved_special_token_0|>
ap... | flexible | {
"blob_id": "d7b91b0476a1f2e00408ce1f1501bf98d4c06e4e",
"index": 9540,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp.config.from_object('config.DevelopmentConfig')\n<mask token>\nmanager.add_command('db', MigrateCommand)\nif __name__ == '__main__':\n manager.run()\n",
"step-3": "<mask token>\na... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def lcs(X, Y, m, n):
dp = [([0] * (n + 1)) for i in range(m + 1)]
for i in range(1, m + 1):
for j in range(1, n + 1):
if X[i - 1] == Y[j - 1]:
dp[i][j] = 1 + dp[i - 1][j - 1]
else:
dp[i][... | flexible | {
"blob_id": "247e352b7772a1da74a26f007228355f5af8d3b3",
"index": 191,
"step-1": "<mask token>\n",
"step-2": "def lcs(X, Y, m, n):\n dp = [([0] * (n + 1)) for i in range(m + 1)]\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if X[i - 1] == Y[j - 1]:\n dp[i][j] =... | [
0,
1,
2,
3,
4
] |
from typing import Any, Optional
from aiogram import types
from aiogram.dispatcher.middlewares import BaseMiddleware
from scene_manager.loader.loader import Loader
from scene_manager.utils import content_type_checker
class ScenesMiddleware(BaseMiddleware):
def __init__(self, *, loader: Optional[Loader] = None, ... | normal | {
"blob_id": "11db76cba3dd76cad0d660a0e189d3e4c465071b",
"index": 8836,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ScenesMiddleware(BaseMiddleware):\n <mask token>\n\n async def on_post_process_message(self, message: types.Message, results:\n tuple, data: dict):\n if data... | [
0,
1,
2,
3,
4
] |
import requests
rsp = requests.get(
'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s'
% ('wx27c0e6ef6a7f0716', '6e29e232daf462652f66ee8acc11838b'))
print(rsp.text)
| normal | {
"blob_id": "d86fe165e378e56650e3b76bf3d0f72e2a50a023",
"index": 5082,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(rsp.text)\n",
"step-3": "<mask token>\nrsp = requests.get(\n 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s'\n % ('wx27c0e6ef6a7f0... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class ZipTools:
<|reserved_special_token_0|>
@staticmethod
def descomprimir(archivo, dir_extraer):
try:
zip_ref = zipfile.ZipFile(archivo, 'r')
zip_list = zip_ref.infolist()
for contenido in zip_list:
log.registrar_l... | flexible | {
"blob_id": "1190e802fde6c2c6f48bd2720688bd9231b622e0",
"index": 6564,
"step-1": "<mask token>\n\n\nclass ZipTools:\n <mask token>\n\n @staticmethod\n def descomprimir(archivo, dir_extraer):\n try:\n zip_ref = zipfile.ZipFile(archivo, 'r')\n zip_list = zip_ref.infolist()\n ... | [
2,
3,
4,
5,
6
] |
from flask import escape
import pandas as pd
import json
import requests
with open('result.csv', newline='') as f:
df = pd.read_csv(f)
def get_level_diff(word, only_common=False):
if only_common:
word_df = df[(df['word']==word) & (df['common']==1)]
else:
word_df = df[df['word']==word]
... | normal | {
"blob_id": "2f489a87e40bea979000dd429cc4cb0150ff4c3b",
"index": 908,
"step-1": "<mask token>\n\n\ndef get_level_diff(word, only_common=False):\n if only_common:\n word_df = df[(df['word'] == word) & (df['common'] == 1)]\n else:\n word_df = df[df['word'] == word]\n return (word_df.values[0... | [
3,
4,
5,
6,
7
] |
import matplotlib.pyplot as plt
import numpy as np
from sklearn.utils import shuffle
import math
import vis_utils
class FLAGS(object):
image_height = 100
image_width = 100
image_channel = 1
CORRECT_ORIENTATION = True
class PrepareData():
def __init__(self):
... | normal | {
"blob_id": "315fe68f4adf39ded46fa9ad059fd2e962e46437",
"index": 8533,
"step-1": "<mask token>\n\n\nclass PrepareData:\n\n def __init__(self):\n return\n\n def sparse_tuple_from_label(self, sequences, dtype=np.int32):\n \"\"\"Create a sparse representention of x.\n Args:\n s... | [
7,
8,
9,
12,
13
] |
<|reserved_special_token_0|>
class Ninja:
def __init__(self, first_name, last_name, treats, pet_food, pet):
self.first_name = first_name
self.last_name = last_name
self.treats = treats
self.pet_food = pet_food
self.pet = pet
<|reserved_special_token_0|>
<|reserved_... | flexible | {
"blob_id": "b210784a198eaa3e57b5a65ec182a746aecc0e2b",
"index": 1695,
"step-1": "<mask token>\n\n\nclass Ninja:\n\n def __init__(self, first_name, last_name, treats, pet_food, pet):\n self.first_name = first_name\n self.last_name = last_name\n self.treats = treats\n self.pet_food ... | [
3,
5,
6,
7,
9
] |
import basevcstest
class TestVCSBoxfill(basevcstest.VCSBaseTest):
def testRobinsonBoxfill(self):
# This tests if extending the longitude to more than 360 decrees is handled correctly by
# proj4. See https://github.com/UV-CDAT/uvcdat/issues/1728 for more
# information.
clt3 = self.c... | normal | {
"blob_id": "c1475209d9c9a98d72d7f703e0516aceaeb13163",
"index": 6820,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TestVCSBoxfill(basevcstest.VCSBaseTest):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TestVCSBoxfill(basevcstest.VCSBaseTest):\n\n def testRobinsonBoxfill(self)... | [
0,
1,
2,
3,
4
] |
start = input()
user_list = start.split()
if user_list[-1] == 'wolf':
print('Please go away and stop eating my sheep')
else:
user_list.reverse()
print(f'Oi! Sheep number {user_list.index("wolf,") }! You are about to be eaten by a wolf!')
| normal | {
"blob_id": "16850d931eec0356f71317cc24461e006fbcd59c",
"index": 6192,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif user_list[-1] == 'wolf':\n print('Please go away and stop eating my sheep')\nelse:\n user_list.reverse()\n print(\n f\"Oi! Sheep number {user_list.index('wolf,')}! You ... | [
0,
1,
2,
3
] |
<|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": "72c1226d40b3cdce29ef28493344c3cf68892149",
"index": 6001,
"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 = [('index', '00... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
dataset_path = 'data/output/dataset{toReplace}.csv'
dataset_path_final = 'data/output/final/datasetFinal.csv'
log_path = 'data/logs/output_append.log'
numberOfThreads = 45
inputFileMalign = 'data/input/malign/all.log'
outputFileMalign = 'data/output/fileMalig... | flexible | {
"blob_id": "305133d4840741bd5c318a99a96660d8988dd61a",
"index": 7772,
"step-1": "<mask token>\n",
"step-2": "dataset_path = 'data/output/dataset{toReplace}.csv'\ndataset_path_final = 'data/output/final/datasetFinal.csv'\nlog_path = 'data/logs/output_append.log'\nnumberOfThreads = 45\ninputFileMalign = 'data/i... | [
0,
1,
2
] |
km=float(input())
cg=float(input())
print(round(km/cg,3),"km/l") | normal | {
"blob_id": "db33f7386d1eacbfbfd29aa367df310c557ae864",
"index": 8520,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(round(km / cg, 3), 'km/l')\n",
"step-3": "km = float(input())\ncg = float(input())\nprint(round(km / cg, 3), 'km/l')\n",
"step-4": "km=float(input())\ncg=float(input())\nprint(r... | [
0,
1,
2,
3
] |
import setuptools
setuptools.setup(name='cppersist', install_requires=['Eve'])
| normal | {
"blob_id": "4f1956b34ac3b55b2d40220b79816c139b4a2f5c",
"index": 9574,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetuptools.setup(name='cppersist', install_requires=['Eve'])\n",
"step-3": "import setuptools\nsetuptools.setup(name='cppersist', install_requires=['Eve'])\n",
"step-4": null,
"step... | [
0,
1,
2
] |
from angrytux.model.game_objects.obstacle_states.HittedState import HittedState
from angrytux.model.game_objects.obstacle_states.ObstacleState import ObstacleState
class NewState(ObstacleState):
@property
def delete(self) ->bool:
"""
Don't delete this obstacle
:return: False
"... | normal | {
"blob_id": "7d21e76383b80e8a4433fb11cb3b64efee7a6d3b",
"index": 7008,
"step-1": "<mask token>\n\n\nclass NewState(ObstacleState):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass NewState(ObstacleState):\n <mask token>\n\n def hit(self) ->None:\n \"\"\"\n Just rem... | [
1,
2,
3,
4
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.