code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
#library import pandas as pd import numpy as np import sys from tqdm import tqdm # appear the precess of running situation. import time from scipy.spatial.distance import pdist, squareform #0. Data Load data = pd.read_csv(sys.argv[1], delimiter='\t') # Load train (input text file) #1. Data Preprocessing all_element...
normal
{ "blob_id": "267695555e876dc2fe5820dc194490aad9e5e344", "index": 1361, "step-1": "<mask token>\n\n\ndef avg_dissim_within_group_element(node, element_list):\n max_diameter = -np.inf\n sum_dissm = 0\n for i in element_list:\n sum_dissm += dissimilarity_matrix[node][i]\n if dissimilarity_mat...
[ 4, 5, 6, 8, 9 ]
from typing import Callable, List, Optional import numpy as np import lab1.src.grad.grad_step_strategy as st import lab1.src.grad.stop_criteria as sc DEFAULT_EPSILON = 1e-9 DEFAULT_MAX_ITERATIONS = 1e5 def gradient_descent(f: Callable[[np.ndarray], float], f_grad: Callable[[np.ndarray], np.nda...
normal
{ "blob_id": "919e1f8a4b021d75496f3bcff369261a09362a65", "index": 3645, "step-1": "<mask token>\n\n\ndef gradient_descent(f: Callable[[np.ndarray], float], f_grad: Callable[[np\n .ndarray], np.ndarray], start: np.ndarray, step_strategy: st.\n StepStrategy, stop_criteria: sc.StopCriteria, eps_strategy: float...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> f.close() <|reserved_special_token_0|> for c, cl in jsonObject.items(): for d in cl: d.update({'player': c}) l.append(d) <|reserved_special_token_0|> ax.set_xticks(labels) ax.set_xticklabels(labels, rotation=45...
flexible
{ "blob_id": "33e9e45fbe0e3143d75d34c1db283c01e2693f68", "index": 4967, "step-1": "<mask token>\n", "step-2": "<mask token>\nf.close()\n<mask token>\nfor c, cl in jsonObject.items():\n for d in cl:\n d.update({'player': c})\n l.append(d)\n<mask token>\nax.set_xticks(labels)\nax.set_xticklabels(...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.2.13 on 2021-08-11 15:38 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("notifications", "0011_auto_20171229_1747"), ] operations = [ migrations.AlterField( model_name="notification", name...
normal
{ "blob_id": "fa045ccd4e54332f6c05bf64e3318e05b8123a10", "index": 3317, "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 = [('notificatio...
[ 0, 1, 2, 3, 4 ]
# encoding: utf-8 """ File: demo.py Author: Rock Johnson Description: 此文件为案例文件 """ import sys sys.path.append('../') try: from panicbuying.panic import Panic except: from panicbuying.panicbuying.panic import Panic def main(): ''' 公共参数: store: 商城或书店名称(小米|文泉), browser: 浏览器(目前只支持Chrome), versio...
normal
{ "blob_id": "2f8dff78f5bc5ed18df97e2574b47f0a7711d372", "index": 547, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n \"\"\"\n 公共参数:\n store: 商城或书店名称(小米|文泉), browser: 浏览器(目前只支持Chrome),\n version: 浏览器版本号, quit: 运行完后是否退出浏览器(默认不退出),\n hidden: 是否启用界面(默认启用),\n\n 商城抢购:\n u...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(parsed['var1']) <|reserved_special_token_1|> <|reserved_special_token_0|> data = '{"var1": "harry", "var2":56}' parsed = json.loads(data) print(parsed['var1']) <|reserved_special_token_1|> import json data = '{"var1": ...
flexible
{ "blob_id": "f0f9541eba29b4488c429c889f3b346d53d0239d", "index": 7193, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(parsed['var1'])\n", "step-3": "<mask token>\ndata = '{\"var1\": \"harry\", \"var2\":56}'\nparsed = json.loads(data)\nprint(parsed['var1'])\n", "step-4": "import json\ndata = '{\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def test_point3d_wkt(): p = GeometryPoint3D(10, 20, 30) assert p.wkt == 'POINT Z (10 20 30)' def test_point2d_to_shapely(): p = GeometryPoint2D(10, 20) sp = p.to_shapely() assert sp.x == 10 assert sp.y == 20 assert sp.wkt == p.wkt <|reserved_special_token_0...
flexible
{ "blob_id": "ae45a4967a8ee63c27124d345ad4dc0c01033c0e", "index": 6749, "step-1": "<mask token>\n\n\ndef test_point3d_wkt():\n p = GeometryPoint3D(10, 20, 30)\n assert p.wkt == 'POINT Z (10 20 30)'\n\n\ndef test_point2d_to_shapely():\n p = GeometryPoint2D(10, 20)\n sp = p.to_shapely()\n assert sp.x...
[ 2, 3, 4, 5, 6 ]
from django.contrib import admin # Register your models here. from .models import HuyenQuan admin.site.register(HuyenQuan)
normal
{ "blob_id": "16e5a44cb4fbe71eaa9c1f5b00505578de0d2cea", "index": 6403, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(HuyenQuan)\n", "step-3": "from django.contrib import admin\nfrom .models import HuyenQuan\nadmin.site.register(HuyenQuan)\n", "step-4": "from django.contrib import...
[ 0, 1, 2, 3 ]
from convert_data2 import array_rule from convert_data2 import array_packet import tensorflow as tf import numpy as np train_x, train_y = array_packet() x_input, input_ip = array_rule() n_nodes_hl1 = 210 n_nodes_hl2 = 210 n_nodes_hl3 = 210 n_classes = 2 batch_size = 500 hm_epochs = 20 x = tf.placeholder('float') y ...
normal
{ "blob_id": "1446268583bf9fa3375319eae3c21cf47f47faca", "index": 7279, "step-1": "<mask token>\n\n\ndef neural_network_model(data):\n l1 = tf.add(tf.matmul(data, hidden_1_layer['weight']), hidden_1_layer[\n 'bias'])\n l1 = tf.nn.relu(l1)\n l2 = tf.add(tf.matmul(l1, hidden_2_layer['weight']), hidd...
[ 2, 3, 4, 5, 6 ]
import sys import sucessor import expande from collections import deque def busca_caminho(nodo_final, nodo_inicial): pilha_acoes = deque() # iremos empilhar as acoes já que a estaremos com a ordem reversa a priori v = nodo_final while v != nodo_inicial: pilha_acoes.append(v.acao) v = v.pai return pilha_acoes ...
normal
{ "blob_id": "a85a7ad6ffb2b9aa5f5326d11c75ddbee680fac4", "index": 673, "step-1": "<mask token>\n\n\ndef busca_dfs(nodo_inicial, custo_maximo_atual):\n objetivo = '12345678_'\n custo_maximo_absoluto = 100\n explorados = set()\n fronteira = deque()\n fronteira.append(nodo_inicial)\n if custo_maxim...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def visualize_data(positive_images, negative_images): figure = plt.figure() count = 0 for i in range(positive_images.shape[0]): count += 1 figure.add_subplot(2, positive_images.shape[0], count) ...
flexible
{ "blob_id": "ebe79cf1b54870055ce8502430f5fae833f3d96d", "index": 3121, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef visualize_data(positive_images, negative_images):\n figure = plt.figure()\n count = 0\n for i in range(positive_images.shape[0]):\n count += 1\n figure.add_...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def linear_combination_plus_error(X, num_dependent_cols=5, parameter_mean=0, parameter_std=1, error_mean=0, error_std=1): """ Generate a column that is a random linear combination of X1, X2 and X3 plus some random error """ length = X.shape[0] param = np.random...
flexible
{ "blob_id": "48f2cc5b6d53c7317ad882947cabbc367cda0fb7", "index": 905, "step-1": "<mask token>\n\n\ndef linear_combination_plus_error(X, num_dependent_cols=5, parameter_mean=0,\n parameter_std=1, error_mean=0, error_std=1):\n \"\"\"\n Generate a column that is a random linear combination of\n X1, X2 a...
[ 1, 2, 3, 4, 5 ]
def descending_order(num): return int(''.join(sorted(str(num), reverse=True))) import unittest class TestIsBalanced(unittest.TestCase): def test_is_balanced(self): self.assertEquals(descending_order(0), 0) self.assertEquals(descending_order(15), 51) self.assertEquals(descending_orde...
normal
{ "blob_id": "fc5d0dd16b87ab073bf4b054bd2641bdec88e019", "index": 6594, "step-1": "<mask token>\n\n\nclass TestIsBalanced(unittest.TestCase):\n\n def test_is_balanced(self):\n self.assertEquals(descending_order(0), 0)\n self.assertEquals(descending_order(15), 51)\n self.assertEquals(descen...
[ 2, 3, 4, 5 ]
<|reserved_special_token_0|> def switch_y_z(inter, liq_cutoff, vap_cutoff, liq_in, vap_in, int_in): triangles = inter.triangulated_surface[0][inter.triangulated_surface[1]] interface1 = np.zeros_like(triangles) interface2 = np.zeros_like(triangles) xlim, zlim, ylim = inter.universe.dimensions[0], inte...
flexible
{ "blob_id": "086c74669b6762a6b35e8a46f816db2f4f172caa", "index": 1437, "step-1": "<mask token>\n\n\ndef switch_y_z(inter, liq_cutoff, vap_cutoff, liq_in, vap_in, int_in):\n triangles = inter.triangulated_surface[0][inter.triangulated_surface[1]]\n interface1 = np.zeros_like(triangles)\n interface2 = np....
[ 2, 3, 4, 5, 6 ]
from enum import IntEnum class DaqListType(IntEnum): """ This class describes a daq list type. """ DAQ = 0x01 STIM = 0x02 DAQ_STIM = 0x03
normal
{ "blob_id": "71e0137fc02b4f56bdf87cc15c275f5cca1588c4", "index": 8925, "step-1": "<mask token>\n\n\nclass DaqListType(IntEnum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass DaqListType(IntEnum):\n <mask token>\n DAQ = 1\n STIM = 2\n ...
[ 1, 2, 3, 4, 5 ]
# Generated by Django 2.2.2 on 2019-07-17 10:02 from django.db import migrations, models import django.db.models.deletion import modelcluster.fields class Migration(migrations.Migration): dependencies = [ ('users', '0003_delete_userprofile'), ] operations = [ migrations.CreateModel( ...
normal
{ "blob_id": "cf2c57dbb2c1160321bcd6de98691db48634d5d6", "index": 5388, "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 = [('users', '00...
[ 0, 1, 2, 3, 4 ]
import os import numpy as np from argparse import ArgumentParser from collections import Counter from typing import Iterable, Dict, Any, Tuple from utils.constants import TRAIN, VALID, TEST, SAMPLE_ID, INPUTS, OUTPUT from utils.file_utils import make_dir from utils.data_writer import DataWriter WINDOW = 50 STRIDE = ...
normal
{ "blob_id": "e82dd2792ecbb8ed5a33012239102d2c6a02202b", "index": 1749, "step-1": "<mask token>\n\n\ndef get_partition(subject_id: int) ->str:\n if subject_id <= 10:\n return TEST\n elif subject_id <= 15:\n return VALID\n else:\n return TRAIN\n\n\ndef data_generator(input_folder: str...
[ 3, 4, 5, 6, 7 ]
import sqlite3 class DatabaseHands(object): def __init__(self, database): self.conn = sqlite3.connect(database) self.cur = self.conn.cursor() self.cur.execute("CREATE TABLE IF NOT EXISTS hands" + "(id INTEGER PRIMARY KEY, first INTEGER," + ...
normal
{ "blob_id": "f8c85f34fb55ee1c3b3020bcec87b60ae80e4ed2", "index": 3126, "step-1": "<mask token>\n\n\nclass DatabaseHands(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass DatabaseProbability(object):\n\n def __init__(self, database):\n self.con...
[ 13, 16, 17, 19, 20 ]
"""tables Revision ID: 35f6815c3112 Revises: None Create Date: 2013-07-28 21:15:38.385006 """ # revision identifiers, used by Alembic. revision = '35f6815c3112' down_revision = None from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op...
normal
{ "blob_id": "9989d31dfe13809d67f629cc283cd02ce354a74e", "index": 115, "step-1": "<mask token>\n\n\ndef upgrade():\n op.create_table('users', sa.Column('id', sa.Integer(), nullable=False),\n sa.Column('firstname', sa.String(length=64), nullable=True), sa.\n Column('lastname', sa.String(length=64)...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): lemonpie.debug = True lemonpie.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False toolbar = DebugToolbarExtension(lemonpie) lemonpie.run('0.0.0.0') <|reserved_special_token_0|> <|reserved_special_toke...
flexible
{ "blob_id": "328c483bf59c6b84090e6bef8814e829398c5a56", "index": 6954, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n lemonpie.debug = True\n lemonpie.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False\n toolbar = DebugToolbarExtension(lemonpie)\n lemonpie.run('0.0.0.0')\n\n\n<m...
[ 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": "d6e06a78c9a5d8184e5adf9b99cc6030c3434558", "index": 8464, "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 = [('blog', '001...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def missing_philippine_hokkien_words_generator(synonyms: ZhTopolectSynonyms, hokprons: ZhTopolectPronunciations): all_hokkien = set() for word, syn_data in synonyms.all_words(): minnan = set(syn_data['Philippine-MN']) minnan.update(syn_data['Quanzhou']) ...
flexible
{ "blob_id": "18366633489d905c96b0c30d65442bc2e2b188ea", "index": 4703, "step-1": "<mask token>\n\n\ndef missing_philippine_hokkien_words_generator(synonyms: ZhTopolectSynonyms,\n hokprons: ZhTopolectPronunciations):\n all_hokkien = set()\n for word, syn_data in synonyms.all_words():\n minnan = se...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Modell(Resource): <|reserved_special_token_0|> <|reserved_special_token_0|> def put(self, name): item = StoreModel.find_by_name(name) item.save_to_db() return item.json() <|reserved_special_token_0|> class Storelist(Resource): def get(...
flexible
{ "blob_id": "5616ec135a2233e742ff3b2b1f378ec12298b935", "index": 9578, "step-1": "<mask token>\n\n\nclass Modell(Resource):\n <mask token>\n <mask token>\n\n def put(self, name):\n item = StoreModel.find_by_name(name)\n item.save_to_db()\n return item.json()\n <mask token>\n\n\nc...
[ 4, 5, 6, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> e.showWindow() <|reserved_special_token_1|> <|reserved_special_token_0|> e = Editor() e.showWindow() <|reserved_special_token_1|> from editor.editor import Editor e = Editor() e.showWindow()
flexible
{ "blob_id": "46d6771fd9f589e2498cd019ba72232cbda06e5a", "index": 3108, "step-1": "<mask token>\n", "step-2": "<mask token>\ne.showWindow()\n", "step-3": "<mask token>\ne = Editor()\ne.showWindow()\n", "step-4": "from editor.editor import Editor\ne = Editor()\ne.showWindow()\n", "step-5": null, "step-id...
[ 0, 1, 2, 3 ]
def login(): usernameInput = input("Username : ") passwordInput = input("Password : ") if usernameInput == "admin" and passwordInput == "1234": return (showMenu()) else: print("User or Password Wrong.") return login() def showMenu(): print("---Please Choose Menu---") prin...
normal
{ "blob_id": "34dd6966a971e3d32e82a17cd08c3b66bb88163b", "index": 1277, "step-1": "<mask token>\n\n\ndef showMenu():\n print('---Please Choose Menu---')\n print('1. Vat7')\n print('2. Calculation')\n print('3. Vat Calulation')\n return menuSelect()\n\n\n<mask token>\n\n\ndef priceResult():\n pri...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('Welcome to the Guessing Game 2.0\n') print('1 = Easy\t(1 - 10)') print('2 = Medium\t(1 - 50)') print('3 = Hard\t(1 - 100)') <|reserved_special_token_1|> print ("Welcome to the Guessing Game 2.0\n") print ("1 = Easy\t(1 - 10)") print ("2 = Medium\t(...
flexible
{ "blob_id": "7f2489aa440441568af153b231420aa2736716ca", "index": 4052, "step-1": "<mask token>\n", "step-2": "print('Welcome to the Guessing Game 2.0\\n')\nprint('1 = Easy\\t(1 - 10)')\nprint('2 = Medium\\t(1 - 50)')\nprint('3 = Hard\\t(1 - 100)')\n", "step-3": "print (\"Welcome to the Guessing Game 2.0\\n\"...
[ 0, 1, 2 ]
import json import requests from pyyoutube import Api def get_data(YOUTUBE_API_KEY, videoId, maxResults, nextPageToken): """ Получение информации со страницы с видео по video id """ YOUTUBE_URI = 'https://www.googleapis.com/youtube/v3/commentThreads?key={KEY}&textFormat=plainText&' + \ ...
normal
{ "blob_id": "4ed5ceb784fb1e3046ab9f10c4b556f2e94274db", "index": 7054, "step-1": "<mask token>\n\n\ndef get_data(YOUTUBE_API_KEY, videoId, maxResults, nextPageToken):\n \"\"\"\n Получение информации со страницы с видео по video id\n \"\"\"\n YOUTUBE_URI = (\n 'https://www.googleapis.com/youtub...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def line(start, end): """Draw line from start to end.""" up() goto(start.x, start.y) down() goto(end.x, end.y) def square(start, end): """Draw square from start to end.""" up() goto(start.x, start.y) down() begin_fill() for count in range(4): ...
flexible
{ "blob_id": "803283c9dac78c821373fa1025008b04919df72c", "index": 5404, "step-1": "<mask token>\n\n\ndef line(start, end):\n \"\"\"Draw line from start to end.\"\"\"\n up()\n goto(start.x, start.y)\n down()\n goto(end.x, end.y)\n\n\ndef square(start, end):\n \"\"\"Draw square from start to end.\...
[ 7, 8, 9, 10, 11 ]
#!/usr/bin/env python """ maskAOI.py Dan Fitch 20150618 """ from __future__ import print_function import sys, os, glob, shutil, fnmatch, math, re, numpy, csv from PIL import Image, ImageFile, ImageDraw, ImageColor, ImageOps, ImageStat ImageFile.MAXBLOCK = 1048576 DEBUG = False AOI_DIR='/study/reference/public/IAP...
normal
{ "blob_id": "833053a5a75636267feaad5ddaa21dce1de34038", "index": 5319, "step-1": "<mask token>\n\n\ndef RepresentsInt(s):\n try:\n int(s)\n return True\n except ValueError:\n return False\n\n\n<mask token>\n\n\ndef drawOneEllipse(aoi, img, draw):\n if DEBUG:\n print('Ellipse ...
[ 6, 8, 12, 13, 17 ]
'''This class contains a custom made format for printing complex numbers''' class ComplexCustom(complex): ''' This class contains function for a custom made printing format for complex numbers ''' def __format__(self, fmt): '''This function creates a custom made format for printing complex n...
normal
{ "blob_id": "c62647b0b226d97926d1f53975a7aac7c39949d8", "index": 7959, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ComplexCustom(complex):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ComplexCustom(complex):\n <mask token>\n\n def __format__(self, fmt):\...
[ 0, 1, 2, 3, 4 ]
from math import * def heron(a, b, c): tmp = [a, b, c] tmp.sort() if tmp[0] + tmp[1] <= tmp[-1]: raise ValueError ("Warunek trojkata jest nie spelniony") halfPerimeter = (a + b + c)/2 return sqrt(halfPerimeter * (halfPerimeter - a)*(halfPerimeter-b)*(halfPerimeter-c)) print heron...
normal
{ "blob_id": "bbd421d39894af163b56e7104c3b29a45635d5a3", "index": 5425, "step-1": "from math import *\r\n\r\ndef heron(a, b, c):\r\n tmp = [a, b, c]\r\n tmp.sort()\r\n if tmp[0] + tmp[1] <= tmp[-1]:\r\n raise ValueError (\"Warunek trojkata jest nie spelniony\")\r\n halfPerimeter = (a + b + c)/2...
[ 0 ]
import warnings warnings.filterwarnings('ignore', category=FutureWarning) from cv2 import cv2 from tqdm import tqdm import os import pickle import numpy as np import csv import sys from collections import defaultdict from dataset_utils import * sys.path.append("../training") from dataset_tools import enclosing_square...
normal
{ "blob_id": "0b7d1564ecbd78086d59629a2058716f41b4b8c8", "index": 9686, "step-1": "<mask token>\n\n\ndef get_emotion_label(emotion):\n return LABELS['emotion'][emotion]\n\n\ndef _load_meta_from_csv(csv_meta, output_dict):\n data = readcsv(csv_meta)\n for row in data:\n output_dict[row[0]]['gender'...
[ 9, 12, 13, 18, 19 ]
from torch import nn class MNIST3dModel(nn.Module): def __init__(self, input_c=3, num_filters=8, num_classes=10): super().__init__() self.conv1 = nn.Conv3d(in_channels=input_c, out_channels= num_filters, kernel_size=3, stride=1, padding=1) self.conv2 = nn.Conv3d(in_channels=nu...
normal
{ "blob_id": "f6838906c961a9ca7d91d2ab02fd2af72797b880", "index": 4628, "step-1": "<mask token>\n\n\nclass MNIST3dModel(nn.Module):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass MNIST3dModel(nn.Module):\n <mask token>\n\n def forward(self, x):\n x = self.conv1(x)\n ...
[ 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- from django import forms from django.utils.translation import ugettext_lazy as _ # import models from apps.qa.models.coupon import Coupon from apps.qa.models.coupon_type import CouponType COUPONTYPE_CHOICES = ( ('text', _("text")), ('url', _("url")), ('questionnaire', ...
normal
{ "blob_id": "a0f83f0a2c6ddaa2fc641bd4fa48a6f50fd1d978", "index": 1755, "step-1": "<mask token>\n\n\nclass CouponForm(forms.ModelForm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def clean(self):\n cleaned_type = self.cleaned_data.get(...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/python3 import os import netifaces # nicList = netifaces.interfaces() NICList = [i for i in netifaces.interfaces() if i != "lo"] for i in NICList: os.system("sudo ifconfig " + i + " promisc") os.system("sudo python ./src/top.py")
normal
{ "blob_id": "b38d23a7de3c805ddde4ed2d236e3c6e7bb5e2d0", "index": 118, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in NICList:\n os.system('sudo ifconfig ' + i + ' promisc')\nos.system('sudo python ./src/top.py')\n", "step-3": "<mask token>\nNICList = [i for i in netifaces.interfaces() if i ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class spotinst(terrascript.Provider): pass <|reserved_special_token_1|> import terrascript class spotinst(terrascript.Provider): pass <|reserved_special_token_1|> # terrascript/spotinst/__init__.py import terras...
flexible
{ "blob_id": "0ae626df5a471af77f7361bb765b46b861ee8a2c", "index": 7142, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass spotinst(terrascript.Provider):\n pass\n", "step-3": "import terrascript\n\n\nclass spotinst(terrascript.Provider):\n pass\n", "step-4": "# terrascript/spotinst/__init...
[ 0, 1, 2, 3 ]
import pandas as pd import matplotlib.pyplot as plt from netCDF4 import Dataset from cftime import num2date import os import numpy as np from datetime import datetime, timedelta, date def plot_temperatures_by_country(values, country, start, end): """ Returns a plot for temperature values for a coun...
normal
{ "blob_id": "2b579c3def4c2d02d365f019518e8e0b25664460", "index": 7436, "step-1": "<mask token>\n\n\ndef plot_temperatures_by_country(values, country, start, end):\n \"\"\"\n Returns a plot for temperature values for a country\n from a start point to an end point\n \"\"\"\n filtered = values.loc[(v...
[ 7, 8, 9, 10, 11 ]
from os import wait import cv2 import numpy as np import math import sys import types import operator ## orb 및 bf matcher 선언 orb = cv2.cv2.ORB_create( nfeatures=5000, scaleFactor=1.2, nlevels=8, edgeThreshold=31, ...
normal
{ "blob_id": "73e7e43e9cfb3c0884480809bc03ade687d641d6", "index": 733, "step-1": "<mask token>\n\n\ndef getScale(NumFrame, t_gt, seq_num):\n txt_file = open('/media/cordin/새 볼륨/rosbag/dataset/poses/{0:02d}.txt'.\n format(seq_num))\n x_prev = float(t_gt[0])\n y_prev = float(t_gt[1])\n z_prev = f...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class GpsDataBlockIndex(object): def __init__(self, position: int, size: int): if position <= 0: raise ValueError(f"An invalid position: `{position}'.") if size <= 0: raise ValueError(f"An invalid size: `{size}'.") self._position = posi...
flexible
{ "blob_id": "fbb1254c7166fa2aa9cd8a0b9c6525dbe5b652a0", "index": 2625, "step-1": "<mask token>\n\n\nclass GpsDataBlockIndex(object):\n\n def __init__(self, position: int, size: int):\n if position <= 0:\n raise ValueError(f\"An invalid position: `{position}'.\")\n if size <= 0:\n ...
[ 47, 55, 64, 81, 82 ]
from __future__ import annotations from typing import Generator, Optional from collections import Counter from itertools import zip_longest from re import finditer codon_table = """UUU F CUU L AUU I GUU V UUC F CUC L AUC I GUC V UUA L CUA L AUA I GUA V UUG L CUG L ...
normal
{ "blob_id": "3d742505d480493fbc729e7a0febdcab3a7dc041", "index": 9386, "step-1": "<mask token>\n\n\nclass Seq:\n <mask token>\n\n def __init__(self, sequence: str, id: str=None, codons: dict=codons):\n self.sequence = sequence\n self.id = id\n self.codons = codons\n\n def __repr__(s...
[ 20, 24, 31, 33, 35 ]
<|reserved_special_token_0|> def enter(): global Start_menu Start_menu = Menu() menu_world.add_object(Start_menu, 0) <|reserved_special_token_0|> def handle_events(): global Start_menu, menu_time events = get_events() for event in events: if event.type == SDL_QUIT: game...
flexible
{ "blob_id": "fee2ddca5888c9db00d2d7a4fe11ba20c4e31685", "index": 1909, "step-1": "<mask token>\n\n\ndef enter():\n global Start_menu\n Start_menu = Menu()\n menu_world.add_object(Start_menu, 0)\n\n\n<mask token>\n\n\ndef handle_events():\n global Start_menu, menu_time\n events = get_events()\n ...
[ 4, 6, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> tkinter.filedialog.askopenfilename() <|reserved_special_token_0|> from_file.close() <|reserved_special_token_0|> to_file.write('Copy\n') to_file.write(contents) to_file.close() <|reserved_special_token_1|> <|reserved_special_to...
flexible
{ "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 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class userSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['username', 'password', 'email'] <|reserved_special_token_1|> <|reserved_special_token_0|> class dataSerializer(ser...
flexible
{ "blob_id": "972c479ea40232e14fbf678ca2ccf9716e473fe8", "index": 9736, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass userSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = User\n fields = ['username', 'password', 'email']\n", "step-3": "<mask token>\n\n\ncl...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def shuffle(): l_digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] random.shuffle(l_digits) return ''.join(l_digits) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0...
flexible
{ "blob_id": "b0468e58c4d0387a92ba96e8fb8a876ece256c78", "index": 6507, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef shuffle():\n l_digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\n random.shuffle(l_digits)\n return ''.join(l_digits)\n\n\n<mask token>\n", "step-3": "<mask ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class RegisterView(View): <|reserved_special_token_0|> <|reserved_special_token_0|> class HomeView(View): def get(self, request): return HttpResponse(f'Home Page | Logged in as - {request.user}') <|reserved_special_token_1|> <|reserved_special_token_0|> class R...
flexible
{ "blob_id": "c9191df0fc04818b4df9c93a9479f75a60688aa9", "index": 6372, "step-1": "<mask token>\n\n\nclass RegisterView(View):\n <mask token>\n <mask token>\n\n\nclass HomeView(View):\n\n def get(self, request):\n return HttpResponse(f'Home Page | Logged in as - {request.user}')\n", "step-2": "<...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class Point(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class Rect(object): """A rectangle identified by its lower left and upper right corners. ...
flexible
{ "blob_id": "7b9660bba6fcb8c725251971f3733a1cc915c0e7", "index": 760, "step-1": "<mask token>\n\n\nclass Point(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Rect(object):\n \"\"\"A rectangle identified by its lower left\n and upper right corne...
[ 9, 12, 16, 17, 18 ]
import pickle import torch data = pickle.load(open('dd0eb7901523d494d4aa324f474c782063e9e231.p', 'rb')) torch.nn.functional.adaptive_avg_pool3d(**data)
normal
{ "blob_id": "20d09a616133295a6162a7ab1d7970ccbaf6de95", "index": 1331, "step-1": "<mask token>\n", "step-2": "<mask token>\ntorch.nn.functional.adaptive_avg_pool3d(**data)\n", "step-3": "<mask token>\ndata = pickle.load(open('dd0eb7901523d494d4aa324f474c782063e9e231.p', 'rb'))\ntorch.nn.functional.adaptive_a...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Article: <|reserved_special_token_0|> title: str target: str g: float f: float parent: typing.Union[Article, Type(None)] heuristic: Callable[[str, str], float] def __init__(self, title: str, target: str, parent: typing.Union[ Article, Type(No...
flexible
{ "blob_id": "1fad591fde707c73bd52aa8518828c8b8be9cd32", "index": 2283, "step-1": "<mask token>\n\n\nclass Article:\n <mask token>\n title: str\n target: str\n g: float\n f: float\n parent: typing.Union[Article, Type(None)]\n heuristic: Callable[[str, str], float]\n\n def __init__(self, ti...
[ 12, 15, 17, 18, 23 ]
import random from datetime import datetime from slackbot.bot import respond_to from .term_model import Term, Response from ..botmessage import botsend, botwebapi # すでに存在するコマンドは無視する RESERVED = ( 'drive', 'manual', 'jira', 'wikipedia', 'plusplus', 'translate', '翻訳', 'weather', '天気', 'term', 'shuff...
normal
{ "blob_id": "86e97e7eaf0d23ccf4154b5ffc853c5aee966326", "index": 5769, "step-1": "<mask token>\n\n\n@respond_to('^term\\\\s+([\\\\w-]+)$')\n@respond_to('^term\\\\s+create\\\\s+([\\\\w-]+)$')\n@respond_to('^term\\\\s+add\\\\s+([\\\\w-]+)$')\ndef term_create(message, command):\n \"\"\"\n 指定されたコマンドを生成する\n ...
[ 7, 9, 12, 15, 19 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(art.guess) print(art.the) print(art.number) print("I'm thinking of a number between 1 and 100") <|reserved_special_token_0|> if difficulty == 'easy': turns += 10 else: turns += 5 <|reserved_special_token_0|> while no...
flexible
{ "blob_id": "f2bf4f5b057af1d2362ec8d1472aa76e774be1c7", "index": 2736, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(art.guess)\nprint(art.the)\nprint(art.number)\nprint(\"I'm thinking of a number between 1 and 100\")\n<mask token>\nif difficulty == 'easy':\n turns += 10\nelse:\n turns += 5\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def valid_anagram(filename): f = open(filename, 'r') lines = f.readlines() f.close() result = len(lines) for line in lines: split = line.rstrip().split(' ') split = [sorted(s) for s in split] ...
flexible
{ "blob_id": "7dce240a891e807b1f5251a09a69368f4e513973", "index": 4472, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef valid_anagram(filename):\n f = open(filename, 'r')\n lines = f.readlines()\n f.close()\n result = len(lines)\n for line in lines:\n split = line.rstrip().spl...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class LinkedList: <|reserved_special_token_0|> <|reserved_special_token_0|> def atEnd(self, data): NewNode = Node(data) NewNode.nextVal = None if self.headVal is None: self.headVal = NewNode return NewNode last = self.he...
flexible
{ "blob_id": "00260e23614a7b0a11ff3649e71392e4892de423", "index": 4511, "step-1": "<mask token>\n\n\nclass LinkedList:\n <mask token>\n <mask token>\n\n def atEnd(self, data):\n NewNode = Node(data)\n NewNode.nextVal = None\n if self.headVal is None:\n self.headVal = NewNo...
[ 6, 9, 12, 15, 17 ]
import pandas import os from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException import json CONFIG_FILE_NAME = os.path.join(os.path.dirname(__file__), 'input_info.json') def create_ne...
normal
{ "blob_id": "14cb702054b8caaa8899a2a3d8b65aae9b063cb6", "index": 5600, "step-1": "<mask token>\n\n\ndef create_new_report(chrome_driver_inner, report_info_inner):\n add_new_report = chrome_driver_inner.find_element_by_id(\n 'MainContent_MainActionCreate')\n add_new_report.click()\n next_button = ...
[ 2, 3, 4, 5, 6 ]
import json def main(): with open('./src/test/predictions.json', 'r') as f: data = json.load(f) total = len(data['label']) google = 0 sphinx = 0 for i in range(len(data['label'])): label = data['label'][i] google_entry = data['google'][i] sphinx_entry = data['p...
normal
{ "blob_id": "9fc184fe3aa498138138403bef719c59b85b3a80", "index": 4392, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n with open('./src/test/predictions.json', 'r') as f:\n data = json.load(f)\n total = len(data['label'])\n google = 0\n sphinx = 0\n for i in range(l...
[ 0, 1, 2, 3, 4 ]
#coding=UTF-8 import random import random list=[] s=0 for i in range(1,5): for j in range(1,5): for k in range(1,5): if i!=j and j<>k: list.append(str(i)+str(j)+str(k)) s=s+1 print len(list) print s if len(list)==s: print "是相等的!" else: print "不相等!" print l...
normal
{ "blob_id": "fa07553477e3bb2ecbeb87bd1383a2194282579c", "index": 4081, "step-1": "#coding=UTF-8\nimport random\nimport random\nlist=[]\ns=0\nfor i in range(1,5):\n for j in range(1,5):\n for k in range(1,5):\n if i!=j and j<>k:\n list.append(str(i)+str(j)+str(k))\n ...
[ 0 ]
<|reserved_special_token_0|> class ICrawlerLog: <|reserved_special_token_0|> def __init__(self, name, logger=None): self.logger = logger self.name = name @property def save(self, *args, **kwargs): """ 指定保存日志的文件路径,日志级别,以及调用文件 将日志存入到指定的文件中 """ ...
flexible
{ "blob_id": "63001128d9cb934d6f9d57db668a43ba58f4ece3", "index": 1679, "step-1": "<mask token>\n\n\nclass ICrawlerLog:\n <mask token>\n\n def __init__(self, name, logger=None):\n self.logger = logger\n self.name = name\n\n @property\n def save(self, *args, **kwargs):\n \"\"\"\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def all_subsets(ss, i): return chain(*map(lambda x: combinations(ss, x), range(i, i + 1))) <|reserved_special_token_0|> def f1(i): return wi[i[0] - 1] * max(0, pi[i[0] - 1] - di[i[0] - 1]) def f2(i): ci = 0 for j in range(len(i)): ci += pi[int(i[j]) - 1] ...
flexible
{ "blob_id": "ddab4d014c000dd96bad932adac75e4eec065483", "index": 9644, "step-1": "<mask token>\n\n\ndef all_subsets(ss, i):\n return chain(*map(lambda x: combinations(ss, x), range(i, i + 1)))\n\n\n<mask token>\n\n\ndef f1(i):\n return wi[i[0] - 1] * max(0, pi[i[0] - 1] - di[i[0] - 1])\n\n\ndef f2(i):\n ...
[ 3, 5, 6, 7, 8 ]
# Get Facebook's bAbi dataset from utils import maybe_download from shutil import rmtree import os import tarfile def get_babi_en(get_10k=False): data_dir = "datasets/tasks_1-20_v1-2/en/" if get_10k == True: data_dir = "datasets/tasks_1-20_v1-2/en-10k/" maybe_download('https://s3.amazonaws...
normal
{ "blob_id": "7a4d04bd60b5f5555982af372145f9f4bcd83ca2", "index": 8194, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_babi_en(get_10k=False):\n data_dir = 'datasets/tasks_1-20_v1-2/en/'\n if get_10k == True:\n data_dir = 'datasets/tasks_1-20_v1-2/en-10k/'\n maybe_download(\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def create_user(open_ldap, smtp, entries): """ If the 'ldap_insert' returns True, then the email will be send with the account info. """ try: if open_ldap.ldap_insert(entries): smtp.send_email(entries) return True else: ...
flexible
{ "blob_id": "4f0a0089ad128edca3052da58a4c71f935592e25", "index": 4499, "step-1": "<mask token>\n\n\ndef create_user(open_ldap, smtp, entries):\n \"\"\"\n If the 'ldap_insert' returns True, then\n the email will be send with the account info.\n \"\"\"\n try:\n if open_ldap.ldap_insert(entrie...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def process_all(folder): exclude = ['OpenITI.github.io', 'Annotation', '_maintenance', 'i.mech'] for root, dirs, files in os.walk(folder): dirs[:] = [d for d in dirs if d not in exclude] for file in files: if re.search('^\\d{4}\\w+\\.\\w+\\.\\w+-ara\\d$...
flexible
{ "blob_id": "5c001303962315afe2512eb307376f6f7a883cf9", "index": 6831, "step-1": "<mask token>\n\n\ndef process_all(folder):\n exclude = ['OpenITI.github.io', 'Annotation', '_maintenance', 'i.mech']\n for root, dirs, files in os.walk(folder):\n dirs[:] = [d for d in dirs if d not in exclude]\n ...
[ 1, 3, 4, 5, 6 ]
from helper import * async def main(URL, buy_time): browser, page = await get_window() # 30s登陆时间 await page.goto('https://account.xiaomi.com/pass/serviceLogin?callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252F%26sign%3DNzY3MDk1YzczNmUwMGM4ODAxOWE0NjRiNTU...
normal
{ "blob_id": "1e87f625fb7bd9f9bf4233229332c909702954a5", "index": 4334, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nasync def main(URL, buy_time):\n browser, page = await get_window()\n await page.goto(\n 'https://account.xiaomi.com/pass/serviceLogin?callback=http%3A%2F%2Forder.mi.com%...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def test_index_with_url(): with Client(app.app) as client: response = client.http.get('/?url=https://google.com') assert response.status_code == HTTPStatus.MOVED_PERMANENTLY assert response.headers['Location'] is not None <|reserved_special_token_0|> <|rese...
flexible
{ "blob_id": "e7e9a53d4c41448521b324d51641a46827faa692", "index": 2607, "step-1": "<mask token>\n\n\ndef test_index_with_url():\n with Client(app.app) as client:\n response = client.http.get('/?url=https://google.com')\n assert response.status_code == HTTPStatus.MOVED_PERMANENTLY\n assert ...
[ 1, 2, 3, 4, 5 ]
import re def detectPeriod(data): numWord = "[0-9,一二三四五六七八九十兩半]" hourWord = "小時鐘頭" minWord = "分鐘" secWord = "秒鐘" timePat = "["+numWord+"]+點?\.?["+numWord+"]*個?半?["+hourWord+"]*半?又?["+numWord+"]*["+minWord+"]*又?["+numWord+"]*["+secWord+"]*" def main(): detectPeriod("我要去游泳一個小時") if _...
normal
{ "blob_id": "397686964acbf640a5463a3a7095d85832545d9e", "index": 6462, "step-1": "<mask token>\n\n\ndef main():\n detectPeriod('我要去游泳一個小時')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef detectPeriod(data):\n numWord = '[0-9,一二三四五六七八九十兩半]'\n hourWord = '小時鐘頭'\n minWord = '分鐘'\n secWord =...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(1, n + 1): for j in range(1, n + 1): if i == j: graph[i][j] = 0 for _ in range(m): a, b = map(int, Read().split()) graph[a][b] = 1 for k in range(1, n + 1): for i in range(1, n + ...
flexible
{ "blob_id": "6ec39aa712c8abe610418e410883ff168d73126d", "index": 3292, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n if i == j:\n graph[i][j] = 0\nfor _ in range(m):\n a, b = map(int, Read().split())\n graph[a][b] = 1\nfo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class LoginPageTests(RegistrationBaseTestCase): def test_can_open_whatsapp_login_page(self): self.assertTrue(self.login_page.is_title_matches()) self.assertTrue(self.login_page.is_instruction_title_matches()) def test_checkbox_remember_me_is_checked_by_default(se...
flexible
{ "blob_id": "380a28958fc6d1b403b29ede229860bf5f709572", "index": 2550, "step-1": "<mask token>\n\n\nclass LoginPageTests(RegistrationBaseTestCase):\n\n def test_can_open_whatsapp_login_page(self):\n self.assertTrue(self.login_page.is_title_matches())\n self.assertTrue(self.login_page.is_instruct...
[ 8, 10, 12, 13, 14 ]
import src.integralimage as II import src.adaboost as AB import src.utils as UT import numpy as np if __name__ == "__main__": pos_training_path = 'dataset-1/trainset/faces' neg_training_path = 'dataset-1/trainset/non-faces' pos_testing_path = 'dataset-1/testset/faces' neg_testing_path = 'dataset-1/tes...
normal
{ "blob_id": "3f4f60ff315c8e7e4637a84629894012ed13280e", "index": 3163, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n pos_training_path = 'dataset-1/trainset/faces'\n neg_training_path = 'dataset-1/trainset/non-faces'\n pos_testing_path = 'dataset-1/testset/faces'\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def training(dict): model = {} model['µ'] = {} model['sigma'] = {} for x in dict: model['µ'][x] = {} model['sigma'][x] = {} for y in dict[x]: model['µ'][x][y] = {} ...
flexible
{ "blob_id": "6726c8f1b3ef9a0df74c25c1921203af3aaacb12", "index": 8758, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef training(dict):\n model = {}\n model['µ'] = {}\n model['sigma'] = {}\n for x in dict:\n model['µ'][x] = {}\n model['sigma'][x] = {}\n for y in dic...
[ 0, 1, 2, 3, 4 ]
import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:, 1:-1].values y = dataset.iloc[:, dataset.shape[1]-1].values #Fitting the Decision Tree Regression from sklearn.tree import DecisionTreeRegressor regressor = DecisionTreeRegressor(r...
normal
{ "blob_id": "c8565e1b5659dd0908aabf91e07738a798dc3232", "index": 1366, "step-1": "<mask token>\n", "step-2": "<mask token>\nregressor.fit(X, y)\n<mask token>\nplt.scatter(X, y, color='red')\nplt.plot(X_grid, regressor.predict(X_grid), color='blue')\nplt.scatter(6.5, y_pred, color='green')\nplt.title('Salary vs...
[ 0, 1, 2, 3, 4 ]
from setuptools import setup, find_packages setup( name="champ", version="0.0.1", description='Channel modeling in Python', url='https://github.com/sgherbst/champ', author='Steven Herbst', author_email='sherbst@stanford.edu', packages=['champ'], include_package_data=True, zip_safe=F...
normal
{ "blob_id": "885fd32c9520dfdc2becd6b1a3d0c0f5f5397112", "index": 7449, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='champ', version='0.0.1', description=\n 'Channel modeling in Python', url='https://github.com/sgherbst/champ',\n author='Steven Herbst', author_email='sherbst@stanford.e...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from .lasot import Lasot from .got10k import Got10k from .tracking_net import TrackingNet from .imagenetvid import ImagenetVID from .imagenetdet import ImagenetDET from .coco_seq import MSCOCOSeq from .vot import VOT from .youtube_vos import YoutubeVOS from ....
flexible
{ "blob_id": "e12ca2c4592a629ce78cae7211fedaf02352a603", "index": 4700, "step-1": "<mask token>\n", "step-2": "from .lasot import Lasot\nfrom .got10k import Got10k\nfrom .tracking_net import TrackingNet\nfrom .imagenetvid import ImagenetVID\nfrom .imagenetdet import ImagenetDET\nfrom .coco_seq import MSCOCOSeq\...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def loudness_zwst(signal, fs=None, field_type='free', is_sdt_output=False): """Zwicker-loudness calculation for stationary signals Calculates the acoustic loudness according to Zwicker method for stationary signals....
flexible
{ "blob_id": "75716aaaca63f8ca6d32c885021c1dc0f9a12dac", "index": 793, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef loudness_zwst(signal, fs=None, field_type='free', is_sdt_output=False):\n \"\"\"Zwicker-loudness calculation for stationary signals\n\n Calculates the acoustic loudness accor...
[ 0, 1, 2, 3, 4 ]
import time import json import pygame from pygame.locals import * import urllib.request from pygame.color import THECOLORS pygame.init() Brack=[0,0,0] White=[255,255,255] Green=[0,255,0] Red=[255,0,0] Gray=[169,169,169] button_text=["开 始","开 始","开 始","开 始","开 始"] line=['http://localhost:5050/mixer/000','http://localhos...
normal
{ "blob_id": "609071fc3af1b526fbd4555ced2376f56ae0f3c3", "index": 2174, "step-1": "<mask token>\n\n\ndef Process(num, x, y, button_text, color):\n text_fmt1 = text_1.render(text[num], 1, Brack)\n screen.blit(text_fmt1, (x - 127, y))\n pygame.draw.rect(screen, Brack, [x, y, 60, 25], 2)\n pygame.draw.re...
[ 2, 3, 4, 5, 6 ]
import iris import numpy as np import matplotlib.pyplot as plt import glob import iris.analysis.cartography import iris.coord_categorisation import iris.analysis import time def my_callback(cube, field, filename): cube.remove_coord('forecast_reference_time') cube.remove_coord('forecast_period') ...
normal
{ "blob_id": "6ea651e27620d0f26f7364e6d9d57e733b158d77", "index": 6466, "step-1": "import iris\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport glob\nimport iris.analysis.cartography\nimport iris.coord_categorisation\nimport iris.analysis\nimport time\n\ndef my_callback(cube, field, filename):\n ...
[ 0 ]
#!/usr/bin/env python # -*- coding:utf-8 _*- """ :Author :weijinlong :Time: :2020/1/10 17:22 :File :graph.py :content: """ import tensorflow as tf from .base import TFLayer class TFModel(TFLayer): def build_model(self): raise NotImplementedError def add_outputs(self, *a...
normal
{ "blob_id": "cdabb4a118cb0ef55c271a446fa190a457ebe142", "index": 7383, "step-1": "<mask token>\n\n\nclass TFCompile(TFLayer):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass TFComModel(TFModel, TFCompile):\n \"\"\"\n 基于TensorFlow的复合模型,即使用一个算子构建模型的和模型的编译\n \"\"\"\n\n def build_model(s...
[ 5, 8, 10, 11, 13 ]
import pulumi import pulumi_aws as aws bar = aws.elasticache.get_replication_group(replication_group_id="example")
normal
{ "blob_id": "4bf140ae01f2eaa0c67f667766c3ec921d552066", "index": 6073, "step-1": "<mask token>\n", "step-2": "<mask token>\nbar = aws.elasticache.get_replication_group(replication_group_id='example')\n", "step-3": "import pulumi\nimport pulumi_aws as aws\nbar = aws.elasticache.get_replication_group(replicati...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SlidingDoorIllustration(Scene): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SlidingDoorIllustration(Scene): def construct(self): waiting_room = Rectang...
flexible
{ "blob_id": "e93d5461a2604d3b8015489397c68e16d1cb222e", "index": 3695, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SlidingDoorIllustration(Scene):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass SlidingDoorIllustration(Scene):\n\n def construct(self):\n waiting_room = Re...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> assert ec.scale(4, ec.order) == 0 <|reserved_special_token_0|> print('Factoring...') <|reserved_special_token_0|> for i in range(2, 2 ** 24): if x % i == 0: if x % (i * i) != 0: factors.append(i) x ...
flexible
{ "blob_id": "b5275fc068526063fd8baf13210052971b05503f", "index": 585, "step-1": "<mask token>\n", "step-2": "<mask token>\nassert ec.scale(4, ec.order) == 0\n<mask token>\nprint('Factoring...')\n<mask token>\nfor i in range(2, 2 ** 24):\n if x % i == 0:\n if x % (i * i) != 0:\n factors.app...
[ 0, 1, 2, 3, 4 ]
from utils import * import math class State: "This class represents the search state that will be used for ARA* search" def __init__(self, x, y, theta, parent=None, parent_action=None, g=float('inf'), h=float('inf')): self.x = x self.y = y self.theta = theta % (2*math.pi) self.g...
normal
{ "blob_id": "c8f899958ce19e7e2bf1307a685e65873695f140", "index": 9028, "step-1": "<mask token>\n\n\nclass State:\n <mask token>\n\n def __init__(self, x, y, theta, parent=None, parent_action=None, g=\n float('inf'), h=float('inf')):\n self.x = x\n self.y = y\n self.theta = theta...
[ 8, 9, 10, 11, 12 ]
class MyClass: <|reserved_special_token_0|> def set_name(self, name): self.name = name def get_name(self): return self.name def say_hello(self): self.greet = 'Hello' def say_hi(self): print('HI~~~~~') <|reserved_special_token_0|> <|reserved_special_token_1|> ...
flexible
{ "blob_id": "babb5ac680c74e19db5c86c2c3323e8285d169ff", "index": 9939, "step-1": "class MyClass:\n <mask token>\n\n def set_name(self, name):\n self.name = name\n\n def get_name(self):\n return self.name\n\n def say_hello(self):\n self.greet = 'Hello'\n\n def say_hi(self):\n ...
[ 5, 6, 7, 8, 9 ]
#!/usr/bin/env python3 """Initiates connection to AWSIoT and provides helper functions deviceshadowhandler.py by Darren Dunford """ import json import logging import queue from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTShadowClient LOGGER = logging.getLogger(__name__) class DeviceShadowHandler: def status_pos...
normal
{ "blob_id": "a6d409b806dbd1e174cac65a26c5e8106a8b93ea", "index": 3760, "step-1": "<mask token>\n\n\nclass DeviceShadowHandler:\n\n def status_post(self, status, state=None):\n \"\"\"Post status message and device state to AWSIoT and LOGGER\n\n :param status: status string\n :param state: ...
[ 6, 8, 9, 10, 12 ]
<|reserved_special_token_0|> def write_fasta_file(pdb_names, pdb_sequences, filename, dump_dir=''): """ Use a list of <pdb_names> and their corresponding <pdb_sequences> to write out a FASTA formatted file Need a <filename> to work with. Include a path to a dump directory, if desired :param pdb_names:...
flexible
{ "blob_id": "876e9f03c908338a247b6bf1f23011e609bbc2a5", "index": 8739, "step-1": "<mask token>\n\n\ndef write_fasta_file(pdb_names, pdb_sequences, filename, dump_dir=''):\n \"\"\"\n Use a list of <pdb_names> and their corresponding <pdb_sequences> to write out a FASTA formatted file\n Need a <filename> ...
[ 1, 2, 3, 4, 5 ]
import re import z3 digit_search = re.compile('\-?\d+') def get_sensor_beacon(data_in): sensors = {} beacons = set() for line in data_in: s_x, s_y, b_x, b_y = list(map(int, digit_search.findall(line))) sensors[(s_x, s_y)] = abs(s_x - b_x) + abs(s_y - b_y) beacons.add((b_x, b_y)) ...
normal
{ "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 ]
import sys, os sys.path.append(os.pardir) # 親ディレクトリのファイルをインポートするための設定 import numpy as np from dataset.mnist import load_mnist from controller import Controller # データの読み込み (x_train, t_train), (x_test, t_test) = load_mnist(normalize=True, one_hot_label=True) # instance controller = Controller() # accuracy trycount = ...
normal
{ "blob_id": "c2d8e34ab0b449a971c920fc86f259f093f16cc5", "index": 7156, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.pardir)\n<mask token>\nfor i in range(len(x_test)):\n p = controller.accuracy(x_test[i])\n a = np.argmax(t_test[i])\n result[p][a] += 1\n if p == a:\n ...
[ 0, 1, 2, 3, 4 ]
# --------------------------------------------------------------------- # Iskratel.ESCOM.get_version # --------------------------------------------------------------------- # Copyright (C) 2007-2018 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # Pyth...
normal
{ "blob_id": "40b3c403f99044eb61740d62eda15ddd08b0f739", "index": 1980, "step-1": "<mask token>\n\n\nclass Script(BaseScript):\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...
[ 1, 2, 3, 4, 5 ]
... ... model = Sequential() model.add(Conv2D(32, kernel_size=3, input_shape=(256, 256, 3)) ... ...
normal
{ "blob_id": "ad054febac3a04c625653a2f3864506eeb672d9e", "index": 6273, "step-1": "...\n...\nmodel = Sequential()\nmodel.add(Conv2D(32, kernel_size=3, input_shape=(256, 256, 3))\n...\n...\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
<|reserved_special_token_0|> class Cellule: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def basculer(self): """mutateur qui change l'état actuel de la ...
flexible
{ "blob_id": "cef904b70eb9a997c3c48884ee34665a77e18897", "index": 8465, "step-1": "<mask token>\n\n\nclass Cellule:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def basculer(self):\n \"\"\"mutateur qui change l'état actuel de la cellule ...
[ 20, 23, 24, 28, 32 ]
#coding=utf-8 from selenium import webdriver from selenium.webdriver import ActionChains # 常用鼠标操作 driver = webdriver.Chrome() driver.get('https://www.baidu.com') driver.maximize_window() element = driver.find_element_by_link_text(u"新闻") #˫ 双击 ‘新闻’ 这个超链接 ActionChains(driver).double_click(element).perform() import time ...
normal
{ "blob_id": "e3f180d4309ade39ac42a895f7f73469fd20724f", "index": 4538, "step-1": "<mask token>\n", "step-2": "<mask token>\ndriver.get('https://www.baidu.com')\ndriver.maximize_window()\n<mask token>\nActionChains(driver).double_click(element).perform()\n<mask token>\ntime.sleep(2)\ndriver.quit()\n<mask token>...
[ 0, 1, 2, 3, 4 ]
import vk_loader.vk_api as vk from config import config import uuid import requests from models import session, Meme import os PHOTO_URL_FIELDS = [ 'photo_75', 'photo_130', 'photo_604', 'photo_807', 'photo_1280', 'photo_2560' ] conf = config('loader', default={ 'access_token': 'Enter VK a...
normal
{ "blob_id": "cb742701094a8060e524ba22a0af2f969bdbf3d9", "index": 2365, "step-1": "<mask token>\n\n\ndef get_random_id():\n return uuid.uuid4().hex\n\n\n<mask token>\n\n\ndef get_last_loaded_ids(source_id):\n try:\n with open('vk_loader/loaded_ids/' + str(source_id), 'r') as file:\n return...
[ 5, 7, 10, 11, 12 ]
from flask import Flask, request, g from flask_restful import Resource, Api from sqlalchemy import create_engine from flask import jsonify import json import eth_account import algosdk from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import scoped_session from sqlalchemy.orm import load_only from datetime im...
normal
{ "blob_id": "d9bdf466abecb50c399556b99b41896eead0cb4b", "index": 2959, "step-1": "<mask token>\n\n\n@app.before_request\ndef create_session():\n g.session = scoped_session(DBSession)\n\n\n<mask token>\n\n\ndef check_sig(payload, sig):\n pk = payload['sender_pk']\n platform = payload['platform']\n pay...
[ 7, 8, 11, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from . import * from module import * from transfer import * from dataset import *
flexible
{ "blob_id": "94d992ef4b9015aa8f42071bb1409703d509c313", "index": 9810, "step-1": "<mask token>\n", "step-2": "from . import *\nfrom module import *\nfrom transfer import *\nfrom dataset 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|> <|reserved_special_token_0|> def main(): """Restaurant""" moeny = int(input()) service = moeny * 0.1 vat = moeny * 0.07 print('Service Charge : %.2f Baht' % service) print('VAT : %.2f Baht' % vat) print('Total : %.2f Baht' % (moe...
flexible
{ "blob_id": "ae6cbb181e024b8c0b222d14120b910919f8cc81", "index": 3811, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n \"\"\"Restaurant\"\"\"\n moeny = int(input())\n service = moeny * 0.1\n vat = moeny * 0.07\n print('Service Charge : %.2f Baht' % service)\n print('VAT...
[ 0, 1, 2, 3 ]
# https://daphne-dev.github.io/2020/09/24/algo-022/ def solution(n): arr = [[0 for _ in range(i+1)] for i in range(n)] # 경우의수 는 3가지 # 1. y축이 증가하면서 수가 증가 # 2. x축이 증가하면서 수가 증가 # 3. y,x축이 감소하면서 수가 증가 size = n num = 0 x = 0 y = -1 while True: # 1번 for _ in range(size)...
normal
{ "blob_id": "3c029adb59cd6db1e3d4a22e6561f5e2ae827d60", "index": 2465, "step-1": "<mask token>\n", "step-2": "def solution(n):\n arr = [[(0) for _ in range(i + 1)] for i in range(n)]\n size = n\n num = 0\n x = 0\n y = -1\n while True:\n for _ in range(size):\n num += 1\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(effort) <|reserved_special_token_1|> <|reserved_special_token_0|> size, k = map(int, input().split()) parcel = list(map(int, input().split())) effort = 2 * parcel[k - 1] * min(parcel) + max(parcel) * min(parcel) print(eff...
flexible
{ "blob_id": "92dea316889192824c353002670cdcf03dfbcd4c", "index": 1457, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(effort)\n", "step-3": "<mask token>\nsize, k = map(int, input().split())\nparcel = list(map(int, input().split()))\neffort = 2 * parcel[k - 1] * min(parcel) + max(parcel) * min(pa...
[ 0, 1, 2, 3 ]
def max_product(n): lst, lstnums, res, num = [], [], [], 1 for i in range(0, n+1): lstnums.append(i) for j in str(i): num *= int(j) lst.append(num) num = 1 ​ maxlst = max(lst) for i in range(len(lst)): if lst[i] == maxlst: res.append(lstnu...
normal
{ "blob_id": "c804391cc199a242d1b54ece8487ef74065a40ad", "index": 840, "step-1": "\ndef max_product(n):\n lst, lstnums, res, num = [], [], [], 1\n for i in range(0, n+1):\n lstnums.append(i)\n for j in str(i):\n num *= int(j)\n lst.append(num)\n num = 1\n​\n maxlst ...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> file_handle.write(contents) file_handle.close() print(contents) <|reserved_special_token_1|> fileName = str(input( 'Please write the name of the file you would like to open: ')) file_handle = open(fileName, 'w') contents = ...
flexible
{ "blob_id": "aed09a3c04f284fa0b8844a47c5bc9d1621a9b5f", "index": 2034, "step-1": "<mask token>\n", "step-2": "<mask token>\nfile_handle.write(contents)\nfile_handle.close()\nprint(contents)\n", "step-3": "fileName = str(input(\n 'Please write the name of the file you would like to open: '))\nfile_handle =...
[ 0, 1, 2, 3 ]
"""This module will serve the api request.""" import json from bson.json_util import dumps from flask import abort, request, Response, jsonify from api import app, collection @app.route("/api/v1/users", methods=['POST']) def create_user(): """ Function to create new users. """ try: # Creat...
normal
{ "blob_id": "0f4bb65b93df997ca1a9b7945ebcec53a2f43822", "index": 3636, "step-1": "<mask token>\n\n\n@app.route('/api/v1/users', methods=['POST'])\ndef create_user():\n \"\"\"\n Function to create new users.\n \"\"\"\n try:\n try:\n body = request.get_json()\n except:\n ...
[ 3, 4, 5, 6, 7 ]
import giraffe.configuration.common_testing_artifactrs as commons from giraffe.business_logic.ingestion_manger import IngestionManager from redis import Redis def test_parse_redis_key(config_helper, ingestion_manager): im = ingestion_manager job_name = config_helper.nodes_ingestion_operation operation = c...
normal
{ "blob_id": "13451352e8dcdfe64771f9fc188b13a31b8109f5", "index": 4555, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_parse_redis_key(config_helper, ingestion_manager):\n im = ingestion_manager\n job_name = config_helper.nodes_ingestion_operation\n operation = config_helper.nodes_in...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class LoggingMiddleware(object): <|reserved_special_token_0|> <|reserved_special_token_0|> class ScriptNameEdit(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): url = environ['SCRIPT_NAME'] environ['w...
flexible
{ "blob_id": "a2aa615ac660f13727a97cdd2feaca8f6e457da4", "index": 4830, "step-1": "<mask token>\n\n\nclass LoggingMiddleware(object):\n <mask token>\n <mask token>\n\n\nclass ScriptNameEdit(object):\n\n def __init__(self, app):\n self.app = app\n\n def __call__(self, environ, start_response):\n...
[ 4, 5, 6, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from .interface import AudioInterface from .config import AudioConfig from .buffer import CustomBuffer
flexible
{ "blob_id": "cc33d0cf1b922a6b48fb83be07acb35a62372f2e", "index": 8260, "step-1": "<mask token>\n", "step-2": "from .interface import AudioInterface\nfrom .config import AudioConfig\nfrom .buffer import CustomBuffer\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open(hfilename, 'r') as file: for line in file: tweetSplitter = TweetTokenizer(strip_handles=True, reduce_len=True) WordList = tweetSplitter.tokenize(line) regex1 = re.compile('^#.+') regex...
flexible
{ "blob_id": "fd04f6f4a03fdbe40e400d04e5759ef9ef30f974", "index": 6634, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(hfilename, 'r') as file:\n for line in file:\n tweetSplitter = TweetTokenizer(strip_handles=True, reduce_len=True)\n WordList = tweetSplitter.tokenize(line)\n ...
[ 0, 1, 2, 3, 4 ]