code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> 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": "7a1be5c9c48413ba1969631e99ecb45cf15ef613", "index": 559, "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 = [('Registration...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding:UTF-8 -*- ''' @Description: 数据库迁移 @Author: Zpp @Date: 2020-03-30 11:01:56 @LastEditors: Zpp @LastEditTime: 2020-04-28 09:55:26 ''' import sys import os curPath = os.path.abspath(os.path.dirname(__file__)) rootPath = os.path.split(curPath)[0] sys.path.append(rootPath) from flask impor...
normal
{ "blob_id": "69ebdab4cd1f0b5154305410381db252205ff97d", "index": 9768, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(rootPath)\n<mask token>\nmanager.add_command('db', MigrateCommand)\nif __name__ == '__main__':\n manager.run()\n", "step-3": "<mask token>\ncurPath = os.path.abspath(...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class HashTable: <|reserved_special_token_0|> def __init__(self, capacity): self.capacity = capacity self.storage = [None] * capacity self.numberOfItems = 0 def fnv1(self, key): """ FNV-1 64-bit hash function Implement this, a...
flexible
{ "blob_id": "7e58fe636e6d835d7857a49900bbc127b52f63d9", "index": 6112, "step-1": "<mask token>\n\n\nclass HashTable:\n <mask token>\n\n def __init__(self, capacity):\n self.capacity = capacity\n self.storage = [None] * capacity\n self.numberOfItems = 0\n\n def fnv1(self, key):\n ...
[ 6, 11, 13, 15, 16 ]
<|reserved_special_token_0|> class PositionalEncoding(nn.Module): def __init__(self, d_model, max_len, dropout=0.1): super(PositionalEncoding, self).__init__() self.dropout = nn.Dropout(p=dropout) pe = torch.zeros(max_len, d_model) position = torch.arange(0, max_len, dtype=torch.f...
flexible
{ "blob_id": "79522db1316e4a25ab5a598ee035cf9b9a9a9411", "index": 3511, "step-1": "<mask token>\n\n\nclass PositionalEncoding(nn.Module):\n\n def __init__(self, d_model, max_len, dropout=0.1):\n super(PositionalEncoding, self).__init__()\n self.dropout = nn.Dropout(p=dropout)\n pe = torch....
[ 12, 18, 21, 23, 24 ]
<|reserved_special_token_0|> @app.route('/api/v1/users', methods=['POST']) def create_user(): """ Function to create new users. """ try: try: body = request.get_json() except: return abort(400) record_id = collection.insert(body) return jsonif...
flexible
{ "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 ]
<|reserved_special_token_0|> def remove_duplicate_legal_reasons(apps, purpose_slug, source_object_content_type, source_object_id): LegalReason = apps.get_model(u'gdpr', u'LegalReason') duplicate_legal_reason_qs = LegalReason.objects.filter(purpose_slug= purpose_slug, source_object_content_type=sou...
flexible
{ "blob_id": "6c86b4823756853bb502b34492ac8ad0a75daf7e", "index": 7036, "step-1": "<mask token>\n\n\ndef remove_duplicate_legal_reasons(apps, purpose_slug,\n source_object_content_type, source_object_id):\n LegalReason = apps.get_model(u'gdpr', u'LegalReason')\n duplicate_legal_reason_qs = LegalReason.ob...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class UserNotification(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) notification_content = models.CharField(max_length=100) notification_link = models.CharField(max_length=100) created_at = models.DateTimeField(auto_now_add=True) class Post(Abs...
flexible
{ "blob_id": "1e81e0f3cb2fb25fdef08a913aa1ff77d0c2a562", "index": 9204, "step-1": "<mask token>\n\n\nclass UserNotification(models.Model):\n user = models.ForeignKey(User, on_delete=models.CASCADE)\n notification_content = models.CharField(max_length=100)\n notification_link = models.CharField(max_length...
[ 10, 11, 12, 13, 14 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals import re import arabic_reshaper from scrapy import Spider, Request from bidi.algorithm import get_display from websites.items import ArticleItem from operator import add from scrapy_splash import SplashRequest class Blogsaljazeera2Spider(Spider): na...
normal
{ "blob_id": "17058b323c0a0974dfa8f124ccd6cb5bf29dd849", "index": 2065, "step-1": "<mask token>\n\n\nclass Blogsaljazeera2Spider(Spider):\n <mask token>\n <mask token>\n <mask token>\n\n @staticmethod\n def cleanhtml(raw_html):\n cleanr = re.compile('<.*?>')\n cleantext = re.sub(clean...
[ 6, 7, 8, 9, 10 ]
# Generated by Django 3.1.1 on 2020-10-07 04:04 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('articals', '0001_initial'), ] operations = [ migrations.AddField( model_name='artical', name='thumb', fi...
normal
{ "blob_id": "d69bffb85d81ab3969bfe7dfe2759fa809890208", "index": 503, "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 = [('articals', '...
[ 0, 1, 2, 3, 4 ]
# Greedy Algorithm solves a problem by building a solution incrementally # The algorithm is greedy because it chooses the next step that gives the most benefit # Can save a lot of time when used correctly since they don't have to look at the entire problem space # It's either the most optimal solution or it doesn't wor...
normal
{ "blob_id": "f6974c0e5908710031bc3c3bb75c277be426632c", "index": 2789, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution:\n\n def canJump(self, nums):\n best_index = 0\n for i in range(len(nums)):\n if i > best...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> comms_socket1.bind(('120.79.26.97', 55000)) comms_socket2.bind(('120.79.26.97', 55001)) comms_socket1.listen() <|reserved_special_token_0|> comms_socket2.listen() <|reserved_special_token_0|> while True: send_date = user1.recv...
flexible
{ "blob_id": "8981d53641d22430efb2dd43401fab562b8a95ed", "index": 3262, "step-1": "<mask token>\n", "step-2": "<mask token>\ncomms_socket1.bind(('120.79.26.97', 55000))\ncomms_socket2.bind(('120.79.26.97', 55001))\ncomms_socket1.listen()\n<mask token>\ncomms_socket2.listen()\n<mask token>\nwhile True:\n send...
[ 0, 1, 2, 3, 4 ]
#!C:/Users/Tarang/AppData/Local/Programs/Python/Python37-32/python.exe -u print("Content-Type: text/html") print() import cgi,cgitb cgitb.enable() #for debugging form = cgi.FieldStorage() name = form.getvalue('fname') print("Name of the user is:",name) import pymysql db = pymysql.connect("localhost","roo...
normal
{ "blob_id": "cb28e8bb98cbeed0b703fbfcf7cf30ebca52aa25", "index": 4247, "step-1": "<mask token>\n", "step-2": "print('Content-Type: text/html')\nprint()\n<mask token>\ncgitb.enable()\n<mask token>\nprint('Name of the user is:', name)\n<mask token>\ncursor.execute(name)\n<mask token>\nprint(name)\ndb.close()\n",...
[ 0, 1, 2, 3, 4 ]
""" binary_adder.py: Takes two arrays representing binary numbers, adds them together. """ __author__ = "David Vaillant" __credits__ = "CLRS, Chapter 2.1" def binary_add(x, y): """ Adds two binary arrays together. """ # Makes sure that the arrays have the same length. # Could be chang...
normal
{ "blob_id": "40aa9e7cf0aaca24054297ca80aaf468ba485966", "index": 5621, "step-1": "<mask token>\n\n\ndef binary_add(x, y):\n \"\"\" Adds two binary arrays together. \"\"\"\n assert len(x) == len(y)\n z = [0] * (len(x) + 1)\n for a, (i, j) in enumerate(zip(x[::-1], y[::-1])):\n if i not in [0, 1...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> setup(name='google-drive-helpers', version='0.1', description= 'Helper functions for google drive', url= 'https://github.com/jdoepfert/google-drive-helpers', license='MIT', packages=['gdrive_helpers'], install_requires...
flexible
{ "blob_id": "c0218acadb9e03359ac898cf3bb4898f516400e5", "index": 5361, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='google-drive-helpers', version='0.1', description=\n 'Helper functions for google drive', url=\n 'https://github.com/jdoepfert/google-drive-helpers', license='MIT',\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> IEX_CLOUD_API_TOKEN = 'Tpk_5d9dc536610243cda2c8ef4787d729b6'
flexible
{ "blob_id": "86849d0e63cdb93a16497ca56ff9c64c15a60fa7", "index": 4891, "step-1": "<mask token>\n", "step-2": "IEX_CLOUD_API_TOKEN = 'Tpk_5d9dc536610243cda2c8ef4787d729b6'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> def test_fancy_exception_base(): exc = _FancyExceptionBase('message') assert str(exc) == 'message' exc = _FancyExceptionBase(message='message') assert str(exc) == 'message' cause = Exception('cause') exc = _FancyExceptionBase('message') exc.__cause__ = cause ...
flexible
{ "blob_id": "6fd4df7370de2343fe7723a2d8f5aacffa333835", "index": 3105, "step-1": "<mask token>\n\n\ndef test_fancy_exception_base():\n exc = _FancyExceptionBase('message')\n assert str(exc) == 'message'\n exc = _FancyExceptionBase(message='message')\n assert str(exc) == 'message'\n cause = Excepti...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def fact(n): c = 1 for i in range(1, n + 1): c *= i return c <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def fact(n): c = 1 for i in range(1, n + 1): ...
flexible
{ "blob_id": "1f4d9f5406b91fd687c0ace8ed29e3c4dfb4d3d2", "index": 8748, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fact(n):\n c = 1\n for i in range(1, n + 1):\n c *= i\n return c\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef fact(n):\n c = 1\n for i in range(1...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: Dang Kai # @Date: 2018-10-30 15:52:57 # @Last Modified time: 2018-11-10 09:09:21 # @E-mail: 1370465454@qq.com # @Description: from time import sleep import sys sys.path.append('../') from common.encapsulation import BasePage class IndexPage: def login(self...
normal
{ "blob_id": "463f50567c9dd4b7b47a84eea715541cec5d3cb5", "index": 2110, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass IndexPage:\n\n def login(self, username, password):\n BasePage.open_url(self, self.base_url)\n BasePage.send_key(self, 'css', '#username', username)\n Ba...
[ 0, 2, 3, 4, 5 ]
def solve(bt): if len(bt) == n: print(*bt, sep="") exit() for i in [1, 2, 3]: if is_good(bt + [i]): solve(bt + [i]) def is_good(arr): for i in range(1, len(arr)//2+1): if arr[-i:] == arr[-(i*2):-i]: return False return True if __name__ == "__main__": n = int(input()) sol...
normal
{ "blob_id": "65d5cee6899b0b75474e3898459bf2cfa8b3635b", "index": 1042, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef is_good(arr):\n for i in range(1, len(arr) // 2 + 1):\n if arr[-i:] == arr[-(i * 2):-i]:\n return False\n return True\n\n\n<mask token>\n", "step-3": "de...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> admin.site.register(Profile) admin.site.register(Category) admin.site.register(Post) <|reserved_special_token_1|> from django.contrib import admin from blog.models import Post, Category, Profile admin.site.register(Profile) adm...
flexible
{ "blob_id": "20f0de097fdd8f2a435c06a73c6a90cc7ebc69ad", "index": 4014, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Profile)\nadmin.site.register(Category)\nadmin.site.register(Post)\n", "step-3": "from django.contrib import admin\nfrom blog.models import Post, Category, Profile\n...
[ 0, 1, 2, 3 ]
# coding: utf-8 # 2021/5/29 @ tongshiwei import logging def get_logger(): _logger = logging.getLogger("EduNLP") _logger.setLevel(logging.INFO) _logger.propagate = False ch = logging.StreamHandler() ch.setFormatter(logging.Formatter('[%(name)s, %(levelname)s] %(message)s')) ch.setLevel(logging....
normal
{ "blob_id": "41f71589d3fb9f5df218d8ffa0f608a890c73ad2", "index": 8486, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_logger():\n _logger = logging.getLogger('EduNLP')\n _logger.setLevel(logging.INFO)\n _logger.propagate = False\n ch = logging.StreamHandler()\n ch.setFormatter(...
[ 0, 1, 2, 3, 4 ]
""" Test the OOD-detection capabilities of models by scaling a random feature for all sample in the data set. """ # STD import os import pickle from copy import deepcopy from collections import defaultdict import argparse from typing import Tuple, Dict, List # EXT import numpy as np from tqdm import tqdm import torch...
normal
{ "blob_id": "bf3e7f1aa9fd20b69e751da9ac8970c88b1144eb", "index": 9363, "step-1": "<mask token>\n\n\ndef run_perturbation_experiment(nov_an: NoveltyAnalyzer, X_test: np.ndarray,\n scoring_func: str=None) ->Tuple[Dict[str, List[float]], Dict[str, List[\n float]]]:\n \"\"\"Runs the perturbation experiment ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class SpatialAttention(nn.Module): def __init__(self, kernel_size=7): super(SpatialAttention, self).__init__() self.conv1 = nn.Conv2d(2, 1, kernel_size, padding=kernel_size // 2, bias=False) self.sigmoid = nn.Sigmoid() <|reserved_special_token_...
flexible
{ "blob_id": "c9de51ee5a9955f36ecd9f5d92813821fb68fb3d", "index": 4308, "step-1": "<mask token>\n\n\nclass SpatialAttention(nn.Module):\n\n def __init__(self, kernel_size=7):\n super(SpatialAttention, self).__init__()\n self.conv1 = nn.Conv2d(2, 1, kernel_size, padding=kernel_size // 2,\n ...
[ 8, 10, 11, 13, 14 ]
#!/usr/bin/env python # -*- coding:utf-8 -*- """ Module test_measured_model - Contains the unit tests for the classes in the datamodels.miri_measured_model module. :History: 15 Jan 2013: Created. 21 Jan 2013: Warning messages controlled with Python warnings module. 05 Feb 2013: File closing problem solved by using ...
normal
{ "blob_id": "644b4a2f0e8ce95e669c9c01df111c943e0c4af2", "index": 3417, "step-1": "<mask token>\n\n\nclass TestMiriMeasuredModel(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_creation(self):\n dq_def_names = list(MiriMeasuredModel.dq_def_names)\n schema_names = list(self.da...
[ 19, 23, 27, 28, 31 ]
<|reserved_special_token_0|> def e(d): """Encode the given string instance using UTF-8.""" return d.encode('UTF-8') <|reserved_special_token_0|> def u32(d): """Return the number represented by d when interpreted as a 32-bit unsigned integer (little endian).""" return unpack('<I', d)[0] <|reserve...
flexible
{ "blob_id": "e4a05cbfd0959402eacf21959c68e449d15b1e74", "index": 7651, "step-1": "<mask token>\n\n\ndef e(d):\n \"\"\"Encode the given string instance using UTF-8.\"\"\"\n return d.encode('UTF-8')\n\n\n<mask token>\n\n\ndef u32(d):\n \"\"\"Return the number represented by d when interpreted as a 32-bit ...
[ 30, 44, 58, 59, 63 ]
#!python # -*- coding: utf-8 -*- from PyQt4.QtCore import * from PyQt4.QtGui import * from window.window import * import sys app = QtGui.QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_())
normal
{ "blob_id": "9e2af13a15a98702981e9ee369c3a132f61eac86", "index": 5174, "step-1": "<mask token>\n", "step-2": "<mask token>\nwindow.show()\nsys.exit(app.exec_())\n", "step-3": "<mask token>\napp = QtGui.QApplication(sys.argv)\nwindow = MainWindow()\nwindow.show()\nsys.exit(app.exec_())\n", "step-4": "from P...
[ 0, 1, 2, 3, 4 ]
from pyramid.request import Request from pyramid.response import Response from pyramid.view import view_config from svc1_first_auto_service.data.repository import Repository @view_config(route_name='autos_api', request_method='GET', renderer='json') def all_autos(_): cars = Repository.a...
normal
{ "blob_id": "cb903f3f7fd3c4f3ba5f8ff2ce12aac9c680aa15", "index": 6116, "step-1": "<mask token>\n\n\n@view_config(route_name='auto_api', request_method='GET', renderer='json')\ndef single_auto(request: Request):\n car_id = request.matchdict.get('car_id')\n car = Repository.car_by_id(car_id)\n if not car:...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class base_controller: <|reserved_special_token_0|> def move(self, xy: list): """ 移动 """ m.move(xy[0] * w, xy[1] * h) def click(self, xy: list): """ 点击 """ m.click(xy[0] * w, xy[1] * h) <|reserved_special_tok...
flexible
{ "blob_id": "b2f2f1e4b7070ac867b71e538f759e527eb1ffb9", "index": 416, "step-1": "<mask token>\n\n\nclass base_controller:\n <mask token>\n\n def move(self, xy: list):\n \"\"\"\n 移动\n \"\"\"\n m.move(xy[0] * w, xy[1] * h)\n\n def click(self, xy: list):\n \"\"\"\n ...
[ 6, 8, 10, 11, 12 ]
from datetime import datetime import xarray import matplotlib.pyplot as plt import pandas as pd from matplotlib.dates import date2num import numpy as np from matplotlib.gridspec import GridSpec def test_plot_area_avg(target_nc_folder="", source_nc_path=""): # target_nc_folder = "/HOME/huziy/skynet3_rech1/Netbea...
normal
{ "blob_id": "2d5e147b081283047cd044746d73d91ee2e59052", "index": 4139, "step-1": "<mask token>\n\n\ndef __print_field_stats(tfield, field, label):\n good_mask = ~field.mask\n if not np.any(good_mask):\n print(f'{label}: no meaningful data')\n return\n good_data = field[good_mask]\n prin...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python3 """ brightness an image""" import tensorflow as tf def change_brightness(image, max_delta): """brightness an image""" img = tf.image.adjust_brightness(image, max_delta) return img
normal
{ "blob_id": "07e068dbc1ba1bcb85121ee49f2f9337cae188ba", "index": 9388, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef change_brightness(image, max_delta):\n \"\"\"brightness an image\"\"\"\n img = tf.image.adjust_brightness(image, max_delta)\n return img\n", "step-3": "<mask token>\nim...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def send_answer(question_id, answer_owner, receiver_tel_id, short): answer = cur.execute( 'SELECT answer FROM Answers WHERE question_id = (%s) AND tel_id = (%s)' , (question_id, answer_owner)).fetchone() ...
flexible
{ "blob_id": "464fc2c193769eee86a639f73b933d5413be2b87", "index": 3396, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef send_answer(question_id, answer_owner, receiver_tel_id, short):\n answer = cur.execute(\n 'SELECT answer FROM Answers WHERE question_id = (%s) AND tel_id = (%s)'\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def getFiturEkstraksi(): connection = mysql.connector.connect(host='localhost', database= 'cad_ultrasound', user='root', password='') cursor = connection.cursor() sql_select_Query = 'SELECT id_pasien,nama,pathdata FROM datasets' cursor.execute(sql_select_Query) ...
flexible
{ "blob_id": "4d7696c832f9255fbc68040b61fde12e057c06fa", "index": 3899, "step-1": "<mask token>\n\n\ndef getFiturEkstraksi():\n connection = mysql.connector.connect(host='localhost', database=\n 'cad_ultrasound', user='root', password='')\n cursor = connection.cursor()\n sql_select_Query = 'SELECT...
[ 2, 3, 4, 5, 6 ]
""" Prog: helloworld.py Name: Samuel doyle Date: 18/04/18 Desc: My first program! """ print('Hello, world!')
normal
{ "blob_id": "513a2bbcf7a63baf900b73b18cf25618937dc7d0", "index": 1054, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Hello, world!')\n", "step-3": "\"\"\"\nProg: helloworld.py\nName: Samuel doyle\nDate: 18/04/18\nDesc: My first program!\n\"\"\"\n\nprint('Hello, world!')\n", "step-4": ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(weights) <|reserved_special_token_0|> print(hidden_layer_vals) <|reserved_special_token_0|> print(output_val) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> input_data = np.array([2...
flexible
{ "blob_id": "6a09311b5b3b876fd94ed0a9cce30e070528f22c", "index": 2993, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(weights)\n<mask token>\nprint(hidden_layer_vals)\n<mask token>\nprint(output_val)\n<mask token>\n", "step-3": "<mask token>\ninput_data = np.array([2, 3])\nweights = {'node_0': np...
[ 0, 1, 2, 3, 4 ]
import numpy as np from scipy import stats from statarray import statdat #a2a1 = np.loadtxt('a2a1_130707_2300.dat') #a2a1 = np.concatenate( (a2a1, np.loadtxt('a2a1_130708_1223.dat')), axis=0 ) #a2a1 = np.loadtxt('a2a1_130708_1654.dat') #a2a1 = np.loadtxt('a2a1_130709_0030.dat') import matplotlib.pyplot as plt impo...
normal
{ "blob_id": "feac1092d1aaf70eb4d4df919e434cdc1aa9c826", "index": 9171, "step-1": "<mask token>\n", "step-2": "<mask token>\nrc('font', **{'family': 'serif'})\n<mask token>\nfor i, nafm in enumerate(nafms):\n detuning = 6.44\n a1, a2 = fetchdata.fetch_data_A1A2({'afmsize': nafm, 'ai': 0.0}, 'det',\n ...
[ 0, 1, 2, 3, 4 ]
import glob import csv import math import pandas # this is used to train the model, try different model, generate the csv file of the result import pandas import pandas as pd import pickle from sklearn.linear_model import LogisticRegression from sklearn import metrics from sklearn import datasets from sklearn.prepro...
normal
{ "blob_id": "a92384a6abee9e231092ee0e4dbdb60bafcc9979", "index": 8782, "step-1": "<mask token>\n\n\ndef naiveBayes(X_train, y_train):\n model = GaussianNB()\n model = model.fit(X_train, y_train)\n return model\n\n\ndef knn(X_train, y_train):\n model = KNeighborsClassifier()\n model = model.fit(X_t...
[ 13, 14, 16, 17, 21 ]
#!/usr/bin/env python3 ''' towerdev - Ansible Tower Testing Framework MIT License Copyright © 2021 falcon78921 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including wit...
normal
{ "blob_id": "63e28e6a1ea5db1d1c41bbc755b9c33905e066bb", "index": 9832, "step-1": "<mask token>\n\n\ndef runTowerContainer(towerVersion, externalPort, osVersion, containerName,\n debug=False, **kwargs):\n \"\"\"Runs Tower container from pre-existing image\"\"\"\n allowedMemory = None\n if debug == Tru...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def preprocess_image(image_path, desired_size=SIZE): """ Resize the picture to the desired size :param image_path: the path of image folder :param desired_size: the size that image will be cropped as. The default size is 224*224 :return: the cropped image """ i...
flexible
{ "blob_id": "c2b3594d25e2d1670d9b99e0d3484c680f59421f", "index": 9465, "step-1": "<mask token>\n\n\ndef preprocess_image(image_path, desired_size=SIZE):\n \"\"\"\n Resize the picture to the desired size\n :param image_path: the path of image folder\n :param desired_size: the size that image will be c...
[ 9, 10, 12, 13, 14 ]
from django.db import models from django.utils.translation import ugettext_lazy as _ class Especialidade(models.Model): def __str__(self): return self.nome # add unique=True? nome = models.CharField(max_length=200, verbose_name=_('Especialidade'), unique=True, blank=False, null=False)
normal
{ "blob_id": "9cc672702d960088f0230cbd1694b295216d8b5a", "index": 4617, "step-1": "<mask token>\n\n\nclass Especialidade(models.Model):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Especialidade(models.Model):\n\n def __str__(self):\n return self.nome\n <mask token>\n"...
[ 1, 2, 3, 4, 5 ]
# 2019/10/08 2019년10월8일 ss = input('날짜: 년/월/일 입력-> ') sslist = ss.split('/') print(sslist) print('입력하신 날짜의 10년 후 -> ', end='') year = int(sslist[0]) + 10 print(str(year) + "년", end='') print(sslist[1] + "월", end='') print(sslist[2] + "일")
normal
{ "blob_id": "fb2ef5a90b6e2582450726905868dd1b78e36166", "index": 5008, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(sslist)\nprint('입력하신 날짜의 10년 후 -> ', end='')\n<mask token>\nprint(str(year) + '년', end='')\nprint(sslist[1] + '월', end='')\nprint(sslist[2] + '일')\n", "step-3": "ss = input('날짜: 년...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class MySQL(object): def __init__(self, app=None): self.app = app if app is not None: self.init_app(app) <|reserved_special_token_0|> @property def connect(self): kwargs = {} if current_app.config['MYSQL_HOST']: kwa...
flexible
{ "blob_id": "db8c2f6f5da0b52c268634043e1132984f610eed", "index": 8405, "step-1": "<mask token>\n\n\nclass MySQL(object):\n\n def __init__(self, app=None):\n self.app = app\n if app is not None:\n self.init_app(app)\n <mask token>\n\n @property\n def connect(self):\n kw...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class Bounds(object): """Required for acceptance testing in scipy.optimize.basinhopping""" def __init__(self, xmin, xmax, costs): self.xmax = xmax self.xmin = xmin self.costs = costs def is_valid(self, x): tmax = bool(np.all(x <= self.xmax)) ...
flexible
{ "blob_id": "0f4bdaecef356e01cbef527d4886564d9ef840fa", "index": 5573, "step-1": "<mask token>\n\n\nclass Bounds(object):\n \"\"\"Required for acceptance testing in scipy.optimize.basinhopping\"\"\"\n\n def __init__(self, xmin, xmax, costs):\n self.xmax = xmax\n self.xmin = xmin\n self...
[ 16, 17, 22, 23, 24 ]
<|reserved_special_token_0|> class Controlador(object): def __init__(self, vista, modelo, vista2): self._mi_vista = vista self._mi_modelo = modelo self._mi2_ventana = vista2 def recibirruta(self, r): self._mi_modelo.recibirruta(r) def recibirtipodearchivo(self, tipefile)...
flexible
{ "blob_id": "3329db63552592aabb751348efc5d983f2cc3f36", "index": 1828, "step-1": "<mask token>\n\n\nclass Controlador(object):\n\n def __init__(self, vista, modelo, vista2):\n self._mi_vista = vista\n self._mi_modelo = modelo\n self._mi2_ventana = vista2\n\n def recibirruta(self, r):\n...
[ 7, 8, 9, 10, 12 ]
''' 给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。 返回被除数 dividend 除以除数 divisor 得到的商 链接:https://leetcode-cn.com/problems/divide-two-integers ''' # 该题看起来也不难,但是其中坑很多,想要写出健壮的代码并不容易 # 我个人思考可以考虑使用上下界,不断缩小范围来确定 def division(dividend, divisor): temp = 0 for i in range(dividend + 1): temp += abs(...
normal
{ "blob_id": "edb80652de641a1a6cbb37a60cc236cd7828a96e", "index": 8151, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef division_v2(dividend, divisor):\n\n def get_add_num(num, times):\n sum = 0\n for i in range(times):\n sum += num\n return sum\n low = 0\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> parser.add_argument('--in_n_estimator', type=int, default=8) parser.add_argument('--in_criterion', type=str, default='gini') parser.add_argument('--in_max_depth', type=int, default=2) <|reserved_special_token_0|> model.fit(x_train...
flexible
{ "blob_id": "66c2d73c100f7fc802e66f2762c92664e4b93fcd", "index": 5736, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('--in_n_estimator', type=int, default=8)\nparser.add_argument('--in_criterion', type=str, default='gini')\nparser.add_argument('--in_max_depth', type=int, default=2)\n...
[ 0, 1, 2, 3, 4 ]
class BaseException(object): <|reserved_special_token_0|> def with_traceback(self, tb): """ Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self. """ pass def __delattr__(self, *args, **kwargs): """ Implement delattr(self, name). ...
flexible
{ "blob_id": "3d01910ae1c163067f4a23b3cca109a7d9e193d5", "index": 5251, "step-1": "class BaseException(object):\n <mask token>\n\n def with_traceback(self, tb):\n \"\"\"\n Exception.with_traceback(tb) --\n set self.__traceback__ to tb and return self.\n \"\"\"\n pass\n...
[ 9, 10, 11, 12, 15 ]
<|reserved_special_token_0|> @utility.init() def init(): if utility.is_test(): return api.init() time.sleep(3) def wait(): global g_threads for t in g_threads: t.join() g_threads.clear() @utility.fini() def fini(): if utility.is_test(): return api.fini() ...
flexible
{ "blob_id": "e2feb12b88babbbfa4cc8447c91e8a5b6c30f78b", "index": 1466, "step-1": "<mask token>\n\n\n@utility.init()\ndef init():\n if utility.is_test():\n return\n api.init()\n time.sleep(3)\n\n\ndef wait():\n global g_threads\n for t in g_threads:\n t.join()\n g_threads.clear()\n...
[ 26, 29, 30, 34, 38 ]
# -*- coding: utf-8 -*- # @Time : 2020/6/12 20:19 # @Author : damon # @Site : # @File : work0612 # @Software: PyCharm import math """ 1、给定n=10,计算1! + 2! + 3! + ... + n!的值 """ # 解法1: n = 10 factorial = 1 sum = 0 for i in range(1, n+1): factorial = i * factorial sum += factorial print(f"阶乘之和{sum}")...
normal
{ "blob_id": "af9adc0faad4fc1426a2bd75c1c77e23e37b60bf", "index": 2431, "step-1": "<mask token>\n\n\ndef fa(x):\n dict2 = {(1): 'one', (2): 'two', (3): 'three', (4): 'four', (5): 'five',\n (6): 'six', (7): 'seven', (8): 'eight', (9): 'nine', (0): 'zero'}\n return dict2[int(x)]\n\n\n<mask token>\n", ...
[ 1, 3, 4, 5, 6 ]
import itertools import numpy import math import psycopg2 import podatki baza = podatki.baza dom = podatki.preberi_lokacijo() seznam_trgovin =["spar", "mercator", "tus", "hofer", "lidl"] id_in_opis = podatki.id_izdelka_v_opis() seznam_izdelkov = [el[0] for el in id_in_opis] #['cokolada', 'sladoled', ...] mnozica_izdel...
normal
{ "blob_id": "5a0702dd869862ebc27c83d10e0b1f0575de68a7", "index": 2944, "step-1": "<mask token>\n\n\ndef kombinacije_trgovin_f(mnozica_izdelkov_v_kosarici, seznam_trgovin,\n trgovine_z_izdelki):\n generator_kombinacij = (set(itertools.compress(seznam_trgovin, el)) for\n el in itertools.product(*([[0,...
[ 4, 5, 6, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> from compas.geometry import Frame
flexible
{ "blob_id": "d4e3751b2d4796c72be497007fe4c7d8ca67e18e", "index": 6874, "step-1": "<mask token>\n", "step-2": "from compas.geometry import Frame\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|> for i in a: b *= i print(b) <|reserved_special_token_1|> a = range(1, 11) b = 1 for i in a: b *= i print(b) <|reserved_special_token_1|> a=range(1,11) #1~10숫자를 에이에 저장 b=1 for i in a: #a에있는 원소를 b에 곱하고 비에 저장 b*=i...
flexible
{ "blob_id": "8cb7290792f9390dd350e0c79711e0dd72d6063b", "index": 9508, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in a:\n b *= i\nprint(b)\n", "step-3": "a = range(1, 11)\nb = 1\nfor i in a:\n b *= i\nprint(b)\n", "step-4": "a=range(1,11) #1~10숫자를 에이에 저장\nb=1\nfor i in a: #a에있는 원소를 ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> setup(name='pytpm', packages=['pytpm'], package_dir={'pytpm': 'pytpm'}, package_data={'pytpm': ['*.pxd', '*.pyx', '*.pxi']}, ext_modules= cythonize(ext_modules)) <|reserved_special_token_1|> <|reserved_special_token_0|>...
flexible
{ "blob_id": "3875d85bef37900f9066c108dc720b364cbafffa", "index": 8476, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='pytpm', packages=['pytpm'], package_dir={'pytpm': 'pytpm'},\n package_data={'pytpm': ['*.pxd', '*.pyx', '*.pxi']}, ext_modules=\n cythonize(ext_modules))\n", "step-3":...
[ 0, 1, 2, 3, 4 ]
""" Implements a Neural Network """ from vectorflux import VectorFlux from mnist import read, show, normalize from vectorflux.layers import Dense from vectorflux.layers.Dropout import Dropout train = list(read('train')) test = list(read('test')) print("Train size: {}".format(len(train))) print("Test size: {}".forma...
normal
{ "blob_id": "94d296b5a13bfa59dba5812da31707f9db9080af", "index": 1292, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Train size: {}'.format(len(train)))\nprint('Test size: {}'.format(len(test)))\n<mask token>\nvf.add(Dense(800, activation='sigmoid', input_shape=784, optimizer='Momentum'))\nvf.add...
[ 0, 1, 2, 3, 4 ]
import enter import loginout import roleinfo import zhanyi import package #import matrix
normal
{ "blob_id": "de665735f02c7569ab382fdc3e910d5d3ac05bb5", "index": 9088, "step-1": "<mask token>\n", "step-2": "import enter\nimport loginout\nimport roleinfo\nimport zhanyi\nimport package\n", "step-3": "import enter\nimport loginout\nimport roleinfo\nimport zhanyi\nimport package\n#import matrix", "step-4"...
[ 0, 1, 2 ]
# uploadops.py # CS304-Final Project # Created by: Megan Shum, Maxine Hood, Mina Hattori #!/usr/local/bin/python2.7 # This file handles all the SQL calls for the upload page. import sys import MySQLdb import dbconn2 def uploadPost(conn, username, description, location, time_stamp, pathname): '''Inserts post in Po...
normal
{ "blob_id": "f0deb8ccaf50ea0abb9e1632eaa4354a4f21dece", "index": 5794, "step-1": "# uploadops.py\n# CS304-Final Project\n# Created by: Megan Shum, Maxine Hood, Mina Hattori\n#!/usr/local/bin/python2.7\n# This file handles all the SQL calls for the upload page.\n\nimport sys\nimport MySQLdb\nimport dbconn2\n\ndef...
[ 0 ]
import spacy nlp = spacy.load("en_core_web_lg") def find_entities(corpus): doc = nlp(corpus) entities = {} for ent in doc.ents: entity_type = ent.label_ entity_name = ent.text values = entities.get(entity_type, set()) values.add(entity_name) entities[entity_type]...
normal
{ "blob_id": "3a0bf031b76d2df03cdb5b37861cb8942307709c", "index": 7601, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_entities(corpus):\n doc = nlp(corpus)\n entities = {}\n for ent in doc.ents:\n entity_type = ent.label_\n entity_name = ent.text\n values = enti...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @api.route(f'/{COLLECTION}/<collection_id>', endpoint=f'{COLLECTION}_by_id') @api.param('collection_id', f'Unique id, used to distinguish {COLLECTION}.') class CollectionsById(Resource): @api.doc(description='[Q2] Deleting a collection with the data service.') @api.response(200, ...
flexible
{ "blob_id": "75958b48a3372b56e072a0caa468171ab6b99eb6", "index": 8917, "step-1": "<mask token>\n\n\n@api.route(f'/{COLLECTION}/<collection_id>', endpoint=f'{COLLECTION}_by_id')\n@api.param('collection_id', f'Unique id, used to distinguish {COLLECTION}.')\nclass CollectionsById(Resource):\n\n @api.doc(descript...
[ 7, 11, 15, 16, 19 ]
from django.conf.urls import url from . import consumers websocket_urlpatterns = [ url(r'^account/home', consumers.NotificationConsumer), url(r'^fund/(?P<fund>[\w-]+)', consumers.NotificationConsumer), url(r'^websockets', consumers.StreamConsumer), ]
normal
{ "blob_id": "7ab9c530035185ee2250f3f6ce8cde87bdfd9803", "index": 5295, "step-1": "<mask token>\n", "step-2": "<mask token>\nwebsocket_urlpatterns = [url('^account/home', consumers.\n NotificationConsumer), url('^fund/(?P<fund>[\\\\w-]+)', consumers.\n NotificationConsumer), url('^websockets', consumers.S...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def get_common_logger(name='common', logfile=None): """ args: name (str): logger name logfile (str): log file, use stream handler (stdout) as default. return: logger obj """ my_logger = logging.getLogger(name) my_logger.setLevel(config.LOG_LEVEL) ...
flexible
{ "blob_id": "1754bce54a47cb78dce3b545d3dce835a4e0e69f", "index": 947, "step-1": "<mask token>\n\n\ndef get_common_logger(name='common', logfile=None):\n \"\"\"\n args: name (str): logger name\n logfile (str): log file, use stream handler (stdout) as default.\n return:\n logger obj\n \"\...
[ 1, 2, 3, 4, 5 ]
from tilBackend.celery import app import smtplib import email import ssl #librerias pruebas from celery.task.schedules import crontab from celery.decorators import periodic_task from celery.utils.log import get_task_logger from celery import Celery @app.task def correo(): try: port = 587 smtp_serve...
normal
{ "blob_id": "d0a6bfb729a150863303621a136ae80e96ae32d0", "index": 3250, "step-1": "<mask token>\n\n\ndef task_correo():\n \"\"\"\n envia correo\n \"\"\"\n correo()\n logger.info('se envio el correo')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.task\ndef correo():\n try:\n po...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(f'Текст:{x}') print(f'Число:{y}') <|reserved_special_token_0|> print(f'Вы ввели числа: {a1}/{a2}') print(f'Вы ввели строки: {b1} / {b2}') <|reserved_special_token_1|> y = 10 x = 'Тишь да гладь' print(f'Текст:{x}') print(f...
flexible
{ "blob_id": "2fabb03f0f6b0b297245354782e650380509424b", "index": 8054, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f'Текст:{x}')\nprint(f'Число:{y}')\n<mask token>\nprint(f'Вы ввели числа: {a1}/{a2}')\nprint(f'Вы ввели строки: {b1} / {b2}')\n", "step-3": "y = 10\nx = 'Тишь да гладь'\nprint(f'Т...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class SearchSuggest(View): <|reserved_special_token_0|> class SearchDetail(View): def get(self, request): key_words = request.GET.get('q', '') data = {} if key_words: es = Elasticsearch(hosts=['127.0.0.1']) s = Search(index='zntg_...
flexible
{ "blob_id": "e5e7856d752f14e0671bae8d8b7997207c667ae1", "index": 6602, "step-1": "<mask token>\n\n\nclass SearchSuggest(View):\n <mask token>\n\n\nclass SearchDetail(View):\n\n def get(self, request):\n key_words = request.GET.get('q', '')\n data = {}\n if key_words:\n es = ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('Select an operation to perform: ') print('1.ADD') print('2.SUBTRACT') print('3.MULTIPLY') print('4.DIVIDE') print('5.SQUARE ROOT') <|reserved_special_token_0|> if operation == '1': a = input('Enter first number: ') b = input('Enter second numbe...
flexible
{ "blob_id": "ea35180daecb8ca4b9bd351a949a4757b97322ec", "index": 2819, "step-1": "<mask token>\n", "step-2": "print('Select an operation to perform: ')\nprint('1.ADD')\nprint('2.SUBTRACT')\nprint('3.MULTIPLY')\nprint('4.DIVIDE')\nprint('5.SQUARE ROOT')\n<mask token>\nif operation == '1':\n a = input('Enter ...
[ 0, 1, 2, 3 ]
# coding=utf-8 class HtmlDownload(object): """docstring for HtmlDownload""" def html_download(city, keyWords, pages): # root URL paras = { 'jl': city, 'kw': keyWords, 'pages': pages, 'isadv': 0 } url = "http://sou.zhaopin.com/jobs/searchresult.ashx?" + urlencode...
normal
{ "blob_id": "e33aca56e4c9f82779278e836308c2e22d3356e2", "index": 3770, "step-1": "<mask token>\n", "step-2": "class HtmlDownload(object):\n <mask token>\n <mask token>\n", "step-3": "class HtmlDownload(object):\n <mask token>\n\n def html_download(city, keyWords, pages):\n paras = {'jl': c...
[ 0, 1, 2, 3, 4 ]
import re from mapa import graficar_lista, graficar_matriz class nodo: def __init__(self, x, y, n, c): self.columna = x self.fila = y self.nombre = n self.color = c pattern_matriz = r"[M|m][A|a][T|t][R|r][I|i][Z|z]\s*\(.*,.*,.*,.*,.*\)\{" pattern_fila = r"[F|f][I|i][L|l][A|a]\s*\(...
normal
{ "blob_id": "70373c74e459efb2a310d94ae906910423e8bfd4", "index": 6631, "step-1": "<mask token>\n\n\nclass nodo:\n\n def __init__(self, x, y, n, c):\n self.columna = x\n self.fila = y\n self.nombre = n\n self.color = c\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass nodo:...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('product', views.ProductCreateAndList.as_view()), path( 'product/<int:pk>', views.ProductRetrieve.as_view())] <|reserved_special_token_1|> from django.urls import path from . import views urlpatterns = [...
flexible
{ "blob_id": "d21b89285d4b4c73a08bda746cea31b5a13d1050", "index": 1967, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('product', views.ProductCreateAndList.as_view()), path(\n 'product/<int:pk>', views.ProductRetrieve.as_view())]\n", "step-3": "from django.urls import path\nfrom ...
[ 0, 1, 2, 3 ]
import time import os, os.path import random import cv2 import glob import keras import matplotlib import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.cluster import KMeans from sklearn.mixture import GaussianMixture from sklearn.decomposition import PCA import pandas as ...
normal
{ "blob_id": "9c8a213fc8a7397662eebb74d6ee1ad34cb884d9", "index": 1420, "step-1": "<mask token>\n\n\ndef create_train_kmeans(data, number_of_clusters):\n k = KMeans(n_clusters=number_of_clusters, n_jobs=-1, random_state=728)\n start = time.time()\n k.fit(data)\n end = time.time()\n print('Training ...
[ 1, 3, 4, 6, 7 ]
from difflib import SequenceMatcher import csv naam = "straat" def similar(a, b): return SequenceMatcher(None, a, b).ratio() f = open("straten.txt", "r") f.readline() names = f.readlines() for name in names: if similar(name[:-1].lower(),naam.lower()) > 0.7: sim = similar(name[:-1].lower(),naam.lower(...
normal
{ "blob_id": "2f1193e3ab5e0527ab5f89141613eddb18b5f61d", "index": 2787, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef similar(a, b):\n return SequenceMatcher(None, a, b).ratio()\n\n\n<mask token>\nf.readline()\n<mask token>\nfor name in names:\n if similar(name[:-1].lower(), naam.lower()) >...
[ 0, 2, 3, 4, 5 ]
import ctypes import win32con import request_spider from selenium_tickets_spider import * from threading import Thread from PyQt5.QtWidgets import * from PyQt5 import QtCore, QtWidgets from PyQt5.QtCore import Qt, QThread, pyqtSignal import sys, time, re import datetime SESSION_DATA = False SHOW_S_P = False class Wor...
normal
{ "blob_id": "bc0846397a5ad73b1c4b85e12864b27ef4fd08d7", "index": 5358, "step-1": "<mask token>\n\n\nclass Ui_MainWindow(QMainWindow):\n threads = []\n keywordJudge = ''\n\n def __init__(self):\n super(Ui_MainWindow, self).__init__()\n self.buy_succeed_count = 0\n for func in [self.o...
[ 25, 26, 30, 32, 33 ]
<|reserved_special_token_0|> class Add_Buttons(object): <|reserved_special_token_0|> def validate_inputs(self): try: self.button_labels = list(self.button_labels) for it in self.button_labels: if type(it) != str: raise TypeError() ex...
flexible
{ "blob_id": "1576693264a334153c2752ab6b3b4b65daa7c37c", "index": 8928, "step-1": "<mask token>\n\n\nclass Add_Buttons(object):\n <mask token>\n\n def validate_inputs(self):\n try:\n self.button_labels = list(self.button_labels)\n for it in self.button_labels:\n i...
[ 6, 8, 9, 10, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> ap.add_argument('-o', '--output', required=True, help='Path to save the images' ) ap.add_argument('-n', '--number', required=False, default=500, help= 'number of images to download') <|reserved_special_token_0|> for j in r...
flexible
{ "blob_id": "6990b5f34af654b4e1a39c3d73b6822fa48e4835", "index": 9159, "step-1": "<mask token>\n", "step-2": "<mask token>\nap.add_argument('-o', '--output', required=True, help='Path to save the images'\n )\nap.add_argument('-n', '--number', required=False, default=500, help=\n 'number of images to down...
[ 0, 1, 2, 3, 4 ]
import logging import os from os.path import exists, abspath, join, dirname from os import mkdir os.environ["MKL_NUM_THREADS"] = "1" os.environ["MP_NUM_THREADS"] = "1" from smallab.runner_implementations.multiprocessing_runner import MultiprocessingRunner from plannin_experiment import PlanningExperiment mpl_logger ...
normal
{ "blob_id": "88d8d04dd7117daed0e976f3abc52c5d7bf18434", "index": 9334, "step-1": "<mask token>\n", "step-2": "<mask token>\nmpl_logger.setLevel(logging.WARNING)\n<mask token>\nif __name__ == '__main__':\n if 'experiments' in os.getcwd():\n os.chdir('../..')\n this_dir = dirname(abspath(__file__))\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def similar(a, b): return SequenceMatcher(None, a, b).ratio() <|reserved_special_token_0|> f.readline() <|reserved_special_token_0|> for name in names: if similar(name[:-1].lower(), naam.lower()) > 0.7: sim = s...
flexible
{ "blob_id": "2f1193e3ab5e0527ab5f89141613eddb18b5f61d", "index": 2787, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef similar(a, b):\n return SequenceMatcher(None, a, b).ratio()\n\n\n<mask token>\nf.readline()\n<mask token>\nfor name in names:\n if similar(name[:-1].lower(), naam.lower()) >...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def conv1d(x, w, p=0, s=1): w_rot = np.array(w[::-1]) x_padded = np.array(x) if p > 0: zero_pad = np.zeros(shape=p) x_padded = np.concatenate([zero_pad, x_padded, zero_pad]) res = [] for i in range(0, int((len(x) + 2 * p - len(w)) / s) + 1): j =...
flexible
{ "blob_id": "a336434abc526357db0536955885cf076ee60f59", "index": 7220, "step-1": "<mask token>\n\n\ndef conv1d(x, w, p=0, s=1):\n w_rot = np.array(w[::-1])\n x_padded = np.array(x)\n if p > 0:\n zero_pad = np.zeros(shape=p)\n x_padded = np.concatenate([zero_pad, x_padded, zero_pad])\n r...
[ 1, 2, 3, 4, 5 ]
import sys from .csvtable import * from .utils import * from .reporter import Reporter class ColumnKeyVerifier: def __init__(self): self.keys = {} def prologue(self, table_name, header): if 0 == len(header): return False # 키는 첫번째 컬럼에만 설정 가능하다. return header[0].is_...
normal
{ "blob_id": "eca4abf706fd094a40fdfc8ea483d71b0a018ce9", "index": 4378, "step-1": "<mask token>\n\n\nclass ColumnKeyVerifier:\n <mask token>\n <mask token>\n\n def epilogue(self):\n pass\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ColumnKeyVerifier:\n\n def __init__(self):\n ...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class GeventExecutor(BaseExecutor): <|reserved_special_token_0|> def _do_submit_job(self, job, run_times): def callback(greenlet): try: events = greenlet.get() except BaseException: self._run_job_error(job.id, *sys....
flexible
{ "blob_id": "afcadc11d23fb921eb6f8038a908de02ee763ca4", "index": 693, "step-1": "<mask token>\n\n\nclass GeventExecutor(BaseExecutor):\n <mask token>\n\n def _do_submit_job(self, job, run_times):\n\n def callback(greenlet):\n try:\n events = greenlet.get()\n exce...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if sys.argv[1] == '1': for x in range(5): print(str(x)) <|reserved_special_token_0|> if sys.argv[1] == '2': for x in range(5): print(str(4 - x)) <|reserved_special_token_0|> if sys.argv[1] == '3': for x...
flexible
{ "blob_id": "eda8bde048f3d4c4af4bd1c296e4cc02b92eaa17", "index": 4727, "step-1": "<mask token>\n", "step-2": "<mask token>\nif sys.argv[1] == '1':\n for x in range(5):\n print(str(x))\n<mask token>\nif sys.argv[1] == '2':\n for x in range(5):\n print(str(4 - x))\n<mask token>\nif sys.argv[1...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def solution(tickets): routes = defaultdict(list) for t in tickets: routes[t[0]].append(t[1]) for r in routes: routes[r].sort(reverse=True) stack = ['ICN'] path = [] while stack: t...
flexible
{ "blob_id": "15c6841052882406d7c7b6cd05c0186c6a4a5924", "index": 2021, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solution(tickets):\n routes = defaultdict(list)\n for t in tickets:\n routes[t[0]].append(t[1])\n for r in routes:\n routes[r].sort(reverse=True)\n stack...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> traditional_investor_stage1 = ( "SELECT investor, investor_id, invest_amount, invest_change, security_id, isin, issue_date, maturity_date FROM (SELECT report_date, investor_holdings.investor_name AS investor,investor_id,AVG(investor_holdings.amount_held) ...
flexible
{ "blob_id": "1e168cf6ba785a08244f47eb490b54605a09e4b0", "index": 9433, "step-1": "<mask token>\n", "step-2": "traditional_investor_stage1 = (\n \"SELECT investor, investor_id, invest_amount, invest_change, security_id, isin, issue_date, maturity_date FROM (SELECT report_date, investor_holdings.investor_name...
[ 0, 1, 2 ]
import torch import torch.nn as nn class MLPNet(nn.Module): def __init__(self, num_classes): super(MLPNet, self).__init__() self.fc1 = nn.Linear(32 * 32 * 3, 512) self.fc2 = nn.Linear(512, num_classes) def forward(self, x): x = x.view(x.size(0), -1) x = self.fc1(x) ...
normal
{ "blob_id": "eff8b6a282ac73a116587e7ed04f386927c9f826", "index": 9089, "step-1": "<mask token>\n\n\nclass MLPNet(nn.Module):\n <mask token>\n\n def forward(self, x):\n x = x.view(x.size(0), -1)\n x = self.fc1(x)\n x = torch.sigmoid(x)\n x = self.fc2(x)\n return x\n <ma...
[ 2, 3, 4, 5 ]
# Generated by Django 2.1.4 on 2019-01-11 11:58 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('devisa', '0021_auto_20190110_1256'), ] operations = [ migrations.RemoveField( model_name='entidade', name='bairro', ...
normal
{ "blob_id": "34f79fa3de68b53f19220697815e5bae5270d056", "index": 9274, "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 = [('devisa', '0...
[ 0, 1, 2, 3, 4 ]
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. from awscrt import http, io from awsiot import mqtt_connection_builder from utils.command_line_utils import CommandLineUtils # This sample shows how to create a MQTT connection using a certificate file and key ...
normal
{ "blob_id": "2ff398e38b49d95fdc8a36a08eeb5950aaea1bc9", "index": 2279, "step-1": "<mask token>\n\n\ndef on_connection_resumed(connection, return_code, session_present, **kwargs):\n print('Connection resumed. return_code: {} session_present: {}'.format(\n return_code, session_present))\n\n\n<mask token>...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> @app.route('/') def hello(): return 'Hello word' @app.route('/analyze', methods=['POST']) def analyze(): if request.method == 'POST': image_file = request.files['image'] file_name = secure_filename(image_file.filename) image_file.save(os.path.join(app.con...
flexible
{ "blob_id": "b9c8689dbdf451e6a981f1abdae55771266fe231", "index": 9129, "step-1": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return 'Hello word'\n\n\n@app.route('/analyze', methods=['POST'])\ndef analyze():\n if request.method == 'POST':\n image_file = request.files['image']\n file_nam...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ import argparse from glob import glob import os import cv2 import numpy as np import matplotlib.pyplot as plt import torch import torch.nn.functional as F from src.args import ArgumentParserRGBDSegmentation from src.build_...
normal
{ "blob_id": "559e46aa4e9b55f8c01acf30fa01e106ab914116", "index": 5687, "step-1": "<mask token>\n\n\ndef _load_img(fp):\n img = cv2.imread(fp, cv2.IMREAD_UNCHANGED)\n if img.ndim == 3:\n img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n return img\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nde...
[ 1, 2, 3, 4, 5 ]
import os import re import logging import time from string import replace from settings import * import wsgiref.handlers from google.appengine.ext import webapp from google.appengine.ext.webapp import template from modules.xml2dict import * from modules import kayak from modules.messaging import * from modules.cron im...
normal
{ "blob_id": "08568c31e5a404957c11eca9cbc9472c71cf088b", "index": 9546, "step-1": "<mask token>\n\n\nclass KayakHandler(webapp.RequestHandler):\n <mask token>\n\n\nclass ClearTripHandler(webapp.RequestHandler):\n\n def get(self):\n file = open('result.xml', 'r')\n content = file.read()\n ...
[ 5, 8, 9, 11, 17 ]
#%% ### 날짜 데이터 분리 # 연-월-일 날짜 데이터에서 일부 분리 추출 import pandas as pd df = pd.read_csv('../../datasets/part5/stock-data.csv') # 문자열인 날짜 데이터를 판다스 Timestamp로 변환 df['new_Date'] = pd.to_datetime(df['Date']) # df에 새로운 열로 추가 print(df.head()) print() # dt 속성을 이용하여 new_Data 열의 연-월-일 정보를 년, 월, 일로 구분 df['Year'] = df['new_...
normal
{ "blob_id": "d89e1d653c6db322feb6edba93cbfc622bf47aa2", "index": 2781, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(df.head())\nprint()\n<mask token>\nprint(df.head())\nprint('------------------')\n<mask token>\nprint(df.head())\nprint('------------------')\ndf.set_index('Date_m', inplace=True)\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Carteiro: if os.environ.get('REDIS_URL') != None: redis_pool = redis.ConnectionPool.from_url(os.environ.get('REDIS_URL')) else: redis_pool = '' def __init__(self, id, pacote): if os.environ.get('REDIS_URL') != None: self.redis_bd = re...
flexible
{ "blob_id": "dd95d14f35b6a92b3363d99a616678da18733a61", "index": 7839, "step-1": "<mask token>\n\n\nclass Carteiro:\n if os.environ.get('REDIS_URL') != None:\n redis_pool = redis.ConnectionPool.from_url(os.environ.get('REDIS_URL'))\n else:\n redis_pool = ''\n\n def __init__(self, id, pacot...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def main(): n_joints = 10 parameter_set = [SimulationParameters(simulation_duration=15, drive=4.0, amplitudes=None, phase_lag=None, turn=None, amplitude_gradient=[ Rhead, Rtail], backward=None, frequency=1) for Rhead in np.linspace (0.2, 0.5, 10) for Rtail ...
flexible
{ "blob_id": "a0284eba1a0e6c498f240068c586e7f8b79cd86c", "index": 5782, "step-1": "<mask token>\n\n\ndef main():\n n_joints = 10\n parameter_set = [SimulationParameters(simulation_duration=15, drive=4.0,\n amplitudes=None, phase_lag=None, turn=None, amplitude_gradient=[\n Rhead, Rtail], backwa...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(n): inp = int(input()) lista.append(inp) lista.sort(reverse=True) print(lista[0]) print(lista[1]) <|reserved_special_token_1|> n = int(input()) lista = [] for i in range(n): inp = int(input()) lis...
flexible
{ "blob_id": "b03960999fa30a55932ada7fbf731a3861b840ae", "index": 3496, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n inp = int(input())\n lista.append(inp)\nlista.sort(reverse=True)\nprint(lista[0])\nprint(lista[1])\n", "step-3": "n = int(input())\nlista = []\nfor i in range...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> while True: if fib[counter] > 4000000: flag = 0 break else: fib.append(fib[counter] + fib[counter - 1]) counter += 1 <|reserved_special_token_0|> print(total) <|reserved_special_token_1|> ...
flexible
{ "blob_id": "e2572b48f7183353ba2aab0500130dc8a71a0b22", "index": 5286, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n if fib[counter] > 4000000:\n flag = 0\n break\n else:\n fib.append(fib[counter] + fib[counter - 1])\n counter += 1\n<mask token>\nprint(tot...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> setup(name='testcov-plugin', version='1.0', packages=['testcov'], namespace_packages=['testcov'], entry_points={'plugins': [ 'testp = testcov.plugin:testp']}, description='Test for coverage bug') <|reserved_special_token...
flexible
{ "blob_id": "88f5aa56eca6b61ba2b428bff0efdf4ec7f5f5d9", "index": 1913, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='testcov-plugin', version='1.0', packages=['testcov'],\n namespace_packages=['testcov'], entry_points={'plugins': [\n 'testp = testcov.plugin:testp']}, description='Test ...
[ 0, 1, 2, 3 ]
from django.contrib import admin from apps.cart.models import * # Register your models here. class CartAdmin(admin.ModelAdmin): list_display = ('user_id', 'goods_id', 'goods_num') search_fields = ('user_id', 'goods_id', 'goods_num') list_filter = ['user_id', 'goods_id', 'goods_num'] admin.sit...
normal
{ "blob_id": "222948fb0a991bb6d7faa186c7442a303b88290b", "index": 7184, "step-1": "<mask token>\n\n\nclass CartAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass CartAdmin(admin.ModelAdmin):\n list_display = 'user_id', 'good...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python import argparse import requests import sys import os import xml.dom.minidom __author__ = 'Tighe Schlottog || tschlottog@paloaltonetworks.com' ''' wf.py is a script to interact with the WildFire API to upload files or pull back reports on specific hashes. You need to have the argparse a...
normal
{ "blob_id": "e8e78610df4461a96f7d9858870de0e3482801fd", "index": 5083, "step-1": "#!/usr/bin/env python\n\nimport argparse\nimport requests\nimport sys\nimport os\nimport xml.dom.minidom\n\n__author__ = 'Tighe Schlottog || tschlottog@paloaltonetworks.com'\n\n'''\n wf.py is a script to interact with the WildFi...
[ 0 ]
<|reserved_special_token_0|> class MainWindow: <|reserved_special_token_0|> <|reserved_special_token_0|> def search_wikipedia(self): """Safely browse wikipedia articles.""" self.summary.delete('1.0', tk.END) possibilities = wk.search(self.search_box.get('1.0', tk.END). ...
flexible
{ "blob_id": "874fa927a1c0f1beeb31ca7b0de7fd2b16218ea4", "index": 2756, "step-1": "<mask token>\n\n\nclass MainWindow:\n <mask token>\n <mask token>\n\n def search_wikipedia(self):\n \"\"\"Safely browse wikipedia articles.\"\"\"\n self.summary.delete('1.0', tk.END)\n possibilities = ...
[ 8, 9, 11, 12, 13 ]
from pycat.base.color import Color from pycat.sprite import Sprite from pycat.window import Window from pyglet.gl.glext_arb import GL_FONT_HEIGHT_NV from random import randint window=Window() class Chick(Sprite): def on_create(self): self.image = 'chick-a.png' self.goto_random_position() ...
normal
{ "blob_id": "cc7942c406e9bcb5af43f131fdf0a6441f81c16a", "index": 4260, "step-1": "<mask token>\n\n\nclass Chick(Sprite):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Chick(Sprite):\n\n def on_create(self):\n self.image = 'chick-a.png'\n self.goto_random_position()...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for key, value in response.items(): Emoji = Emojis(name=key, url=value) session.add(Emoji) session.commit() <|reserved_special_token_1|> <|reserved_special_token_0|> engine = create_engine('postgresql://myuser:mypas...
flexible
{ "blob_id": "0aa95b6a72472e8e260c07f4c42a327384ca0da4", "index": 9173, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor key, value in response.items():\n Emoji = Emojis(name=key, url=value)\n session.add(Emoji)\n session.commit()\n", "step-3": "<mask token>\nengine = create_engine('postgresq...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class RecognizeListsTestCase(unittest.TestCase): def test_simple(self): self.assertListEqual(_recognize_lists({(0): 'a', (1): {'b': -1, 'c': {(0): 'd', (1): -2}}}), ['a', {'b': -1, 'c': ['d', -2]}]) def test_again(self): self.assertDictEqual(unflatten...
flexible
{ "blob_id": "5119b1b6817e002c870b4d6a19fe9aee661fff7e", "index": 8425, "step-1": "<mask token>\n\n\nclass RecognizeListsTestCase(unittest.TestCase):\n\n def test_simple(self):\n self.assertListEqual(_recognize_lists({(0): 'a', (1): {'b': -1, 'c':\n {(0): 'd', (1): -2}}}), ['a', {'b': -1, 'c'...
[ 13, 17, 20, 21, 22 ]
def merge_the_tools(string, k): if(len(string)%k != 0): exit() else: L = [] for i in range(0, len(string), k): L.append(''.join(list(dict.fromkeys(string[i:i+k])))) print('\n'.join(L)) if __name__ == '__main__': string, k = input(), int(input()) merge_the_to...
normal
{ "blob_id": "0004e90622f8b13ec7ce0c1f49e8c8df7ea07269", "index": 7098, "step-1": "<mask token>\n", "step-2": "def merge_the_tools(string, k):\n if len(string) % k != 0:\n exit()\n else:\n L = []\n for i in range(0, len(string), k):\n L.append(''.join(list(dict.fromkeys(str...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> context(arch='amd64', os='windows', log_level='debug') <|reserved_special_token_0|> log.info('Enviando estágio 1') <|reserved_special_token_0|> payload1 += 'ÿ\x00\x00\x00' payload1 += 'A' * 255 payload1 += '\n' <|reserved_special_...
flexible
{ "blob_id": "4fff64a62776a9d1b06cc11d5e55fc00f6787338", "index": 8128, "step-1": "<mask token>\n", "step-2": "<mask token>\ncontext(arch='amd64', os='windows', log_level='debug')\n<mask token>\nlog.info('Enviando estágio 1')\n<mask token>\npayload1 += 'ÿ\\x00\\x00\\x00'\npayload1 += 'A' * 255\npayload1 += '\\n...
[ 0, 1, 2, 3, 4 ]
import numpy d1 = numpy.array([1.,0.,0.]) d2 = numpy.array([0.,1.,0.]) d3 = numpy.array([0.,0.,1.]) s0 = numpy.array([0.,0.,1.]) m2 = numpy.array([1.,0.,0.]) print "x y zeta" for x in xrange(-100, 101): for y in xrange(-100, 101): s = x*d1 + y*d2 + 100*d3 e1 = numpy.cross(s, s0) e1 /= numpy.linalg.norm(...
normal
{ "blob_id": "3d16f2da03c067d410bec7bfe96d874322533d30", "index": 6693, "step-1": "import numpy\n\nd1 = numpy.array([1.,0.,0.])\nd2 = numpy.array([0.,1.,0.])\nd3 = numpy.array([0.,0.,1.])\ns0 = numpy.array([0.,0.,1.])\nm2 = numpy.array([1.,0.,0.])\n\nprint \"x y zeta\"\nfor x in xrange(-100, 101):\n for y in xra...
[ 0 ]