code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def process_review(review): review = re.sub('[^a-zA-Z]', ' ', review) review = review.lower() texts = [wnl.lemmatize(word) for word in review.lower().split() if word not in stoplist] return texts <|res...
flexible
{ "blob_id": "658532e1b81b025b8295bbf468dc01ecf12b922a", "index": 6463, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef process_review(review):\n review = re.sub('[^a-zA-Z]', ' ', review)\n review = review.lower()\n texts = [wnl.lemmatize(word) for word in review.lower().split() if word\n ...
[ 0, 2, 3, 4, 5 ]
from channels.db import database_sync_to_async from django.db.models import Q from rest_framework.generics import get_object_or_404 from main.models import UserClient from main.services import MainService from .models import Message, RoomGroup, UsersRoomGroup class AsyncChatService: @staticmethod @database_s...
normal
{ "blob_id": "d71ffd022d87aa547b2a379f4c92d767b91212fd", "index": 3827, "step-1": "<mask token>\n\n\nclass ChatService:\n\n @staticmethod\n def is_room_exists(room_id: int) ->bool:\n return RoomGroup.objects.filter(id=room_id).exists()\n\n @staticmethod\n def create_users_room(**data) ->RoomGro...
[ 6, 9, 11, 12, 13 ]
import numpy as np import pandas as pd from scipy import sparse, io import cPickle as pickle import sys sys.path.append('code') import models import split from itertools import chain def test_simple_instance(items, item_numbers, negative_items, user): model = models.Word2VecRecommender(size=200, window=max(item_nu...
normal
{ "blob_id": "04dc4d46a645a23913e33606c500037d37418cd7", "index": 8114, "step-1": "import numpy as np\nimport pandas as pd\nfrom scipy import sparse, io\nimport cPickle as pickle\nimport sys\nsys.path.append('code')\nimport models\nimport split\nfrom itertools import chain\n\ndef test_simple_instance(items, item_...
[ 0 ]
import socket comms_socket1 = socket.socket() comms_socket2 = socket.socket() comms_socket1.bind(("120.79.26.97",55000)) comms_socket2.bind(("120.79.26.97",55001)) comms_socket1.listen() user1,address1 = comms_socket1.accept() comms_socket2.listen() user2,address2 = comms_socket2.accept() while True: send_date = ...
normal
{ "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 ]
# This source code is part of the Biotite package and is distributed # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further # information. import warnings from tempfile import TemporaryFile import glob from os.path import join import pytest import numpy as np import biotite.structure as struc import bi...
normal
{ "blob_id": "cc637d14ce2106fcc3b8bbb54e497691e72a3f65", "index": 2858, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.mark.parametrize('path', glob.glob(join(data_dir('structure'),\n '*.cif')))\ndef test_array_conversion(path):\n pdbx_file = pdbx.PDBxFile.read(path)\n ref_structure =...
[ 0, 1, 2, 3 ]
from collections import OrderedDict as odict from vent.gui import styles MONITOR = odict({ 'oxygen': { 'name': 'O2 Concentration', 'units': '%', 'abs_range': (0, 100), 'safe_range': (60, 100), 'decimals' : 1 }, 'temperature': { ...
normal
{ "blob_id": "941dac77fe60081ffa113c437a356d59837f5883", "index": 5304, "step-1": "<mask token>\n", "step-2": "<mask token>\nMONITOR = odict({'oxygen': {'name': 'O2 Concentration', 'units': '%',\n 'abs_range': (0, 100), 'safe_range': (60, 100), 'decimals': 1},\n 'temperature': {'name': 'Temperature', 'uni...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def run(config, testing, tickers, filename): events_queue = queue.Queue() csv_dir = config.CSV_DATA_DIR initial_equity = PriceParser.parse(500000.0) price_handler = YahooDailyCsvBarPriceHandler(csv_dir, events_queue, tickers ) strategy = CustomStrategy(tickers,...
flexible
{ "blob_id": "0cec92bbfad87020baf5ef1bd005e64bc9a6ed01", "index": 5232, "step-1": "<mask token>\n\n\ndef run(config, testing, tickers, filename):\n events_queue = queue.Queue()\n csv_dir = config.CSV_DATA_DIR\n initial_equity = PriceParser.parse(500000.0)\n price_handler = YahooDailyCsvBarPriceHandler...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def calc(*numbers): sum = 0 for n in numbers: sum = sum + n * n return sum <|reserved_special_token_0|> <|reserved_special_token_1|> def calc(*numbers): sum = 0 for n in numbers: sum = sum + n * n return sum prin...
flexible
{ "blob_id": "a9ea3db019435733b5782d69450942373bb828e5", "index": 9304, "step-1": "<mask token>\n", "step-2": "def calc(*numbers):\n sum = 0\n for n in numbers:\n sum = sum + n * n\n return sum\n\n\n<mask token>\n", "step-3": "def calc(*numbers):\n sum = 0\n for n in numbers:\n su...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class TestXLUtility: <|reserved_special_token_0|> def getRowCount(file, sheetname): workbook = openpyxl.load_workbook(file) sheet = workbook[sheetname] return sheet.max_row <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_sp...
flexible
{ "blob_id": "adae4f9ebcbbb775fc40278ceec9a0cc30c0a503", "index": 1541, "step-1": "<mask token>\n\n\nclass TestXLUtility:\n <mask token>\n\n def getRowCount(file, sheetname):\n workbook = openpyxl.load_workbook(file)\n sheet = workbook[sheetname]\n return sheet.max_row\n <mask token>...
[ 2, 4, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(100): value = sess.run(next_element) assert i == value <|reserved_special_token_0|> sess.run(iterator.initializer, feed_dict={max_value: 10}) for i in range(10): value = sess.run(next_element) assert...
flexible
{ "blob_id": "4d4dd451d83d8d602c6264e77f52e5e143aef307", "index": 6239, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(100):\n value = sess.run(next_element)\n assert i == value\n<mask token>\nsess.run(iterator.initializer, feed_dict={max_value: 10})\nfor i in range(10):\n value = ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class KMeans(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class KMeans(object): def __init__(self, data, option): self.data = data self.member...
flexible
{ "blob_id": "5cf73e003b744b438c0db67ab39fb10a3f879f2f", "index": 8556, "step-1": "<mask token>\n\n\nclass KMeans(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass KMeans(object):\n\n def __init__(self, data, option):\n self.data = data\n self...
[ 1, 2, 4, 5, 6 ]
<|reserved_special_token_0|> class SlugStampMixin(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SlugStampMixin(object): <|reserved_special_token_0|> def save(self, *args, **kwarg...
flexible
{ "blob_id": "c30f11e9bac54771df5198971c312624f68d0a33", "index": 4259, "step-1": "<mask token>\n\n\nclass SlugStampMixin(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass SlugStampMixin(object):\n <mask token>\n\n def save(self, *args, **kwargs):\n ...
[ 1, 3, 4, 5, 6 ]
user_schema = { 'id': { 'type': 'string', 'required': True, 'coerce': (str, lambda x: x.lower()) }, 'latitude':{ 'type': 'float', 'required': True, 'min': -60.0, 'max': 10, 'coerce': (float, lambda x: round(x, 5)) }, 'longitude':{ ...
normal
{ "blob_id": "bf41ab20b9fae9f19efdc58852e48d9b735f34c3", "index": 1645, "step-1": "<mask token>\n", "step-2": "user_schema = {'id': {'type': 'string', 'required': True, 'coerce': (str, \n lambda x: x.lower())}, 'latitude': {'type': 'float', 'required': True,\n 'min': -60.0, 'max': 10, 'coerce': (float, la...
[ 0, 1, 2 ]
import pymysql conn = None cur = None try: conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='root', db='test') cur = conn.cursor() cur.execute("SELECT user_id, user_name FROM cap_user") row_count = cur.rowcount # row_number = cur.rownumber for r in cur.fetchall(): ...
normal
{ "blob_id": "e5b5874f060bdf93ac4fadaf556aa4182619d077", "index": 2033, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd\n ='root', db='test')\n cur = conn.cursor()\n cur.execute('SELECT user_id, user_name FROM ca...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python -tt # snmp3_test # Claudia # PyCharm __author__ = "Claudia de Luna (claudia@indigowire.net)" __version__ = ": 1.0 $" __date__ = "10/23/16 11:25 AM" __copyright__ = "Copyright (c) 2015 Claudia de Luna" __license__ = "Python" #from __future__ import print_function import sys import snmp_helper # P...
normal
{ "blob_id": "ccdae522983ddc7c02e221ab5c1bc32683358a7b", "index": 2883, "step-1": "#!/usr/bin/python -tt\n# snmp3_test\n# Claudia\n# PyCharm\n__author__ = \"Claudia de Luna (claudia@indigowire.net)\"\n__version__ = \": 1.0 $\"\n__date__ = \"10/23/16 11:25 AM\"\n__copyright__ = \"Copyright (c) 2015 Claudia de Lun...
[ 0 ]
<|reserved_special_token_0|> def model(input_shape): X_input = Input(input_shape) X = Conv2D(8, (4, 4), strides=(1, 1), name='conv0', kernel_regularizer= regularizers.l2(0.001), padding='same')(X_input) X = BatchNormalization(axis=3, name='bn0')(X) X = Activation('relu')(X) X = MaxPooling2...
flexible
{ "blob_id": "5c315a49ead80e8d8ce057bd774f97bce098de59", "index": 5443, "step-1": "<mask token>\n\n\ndef model(input_shape):\n X_input = Input(input_shape)\n X = Conv2D(8, (4, 4), strides=(1, 1), name='conv0', kernel_regularizer=\n regularizers.l2(0.001), padding='same')(X_input)\n X = BatchNormal...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class MicroBotDataUpdateCoordinator(PassiveBluetoothDataUpdateCoordinator): <|reserved_special_token_0|> def __init__(self, hass: HomeAssistant, client: MicroBotApiClient, ble_device: BLEDevice) ->None: """Initialize.""" self.api: MicroBotApiClient = clien...
flexible
{ "blob_id": "5509880c30c2e03ca6eb42ad32018c39fb5939ed", "index": 9955, "step-1": "<mask token>\n\n\nclass MicroBotDataUpdateCoordinator(PassiveBluetoothDataUpdateCoordinator):\n <mask token>\n\n def __init__(self, hass: HomeAssistant, client: MicroBotApiClient,\n ble_device: BLEDevice) ->None:\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('calificacion de los alumnos') <|reserved_special_token_0|> for i in range(0, 5): lista2_calificaciones.append(int(input( f'ingrese la calificacion corresponfiente al alumno'))) print(lista2_calificaciones) for n in range(0, len(lista2_c...
flexible
{ "blob_id": "1cc9c89182f69a5f1eb9a0e7f3433dc30c8d7035", "index": 2938, "step-1": "<mask token>\n", "step-2": "print('calificacion de los alumnos')\n<mask token>\nfor i in range(0, 5):\n lista2_calificaciones.append(int(input(\n f'ingrese la calificacion corresponfiente al alumno')))\n print(lista2...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def extract_feature(file_name, mfcc, chroma, mel): with soundfile.SoundFile(file_name) as file: X = file.read(dtype='float32') sample_rate = file.samplerate if chroma: stft = np.abs(librosa.stft(X)) result = np.array([]) if mfcc: ...
flexible
{ "blob_id": "8cd54362680aa3a96babe100b9231f6f16b3f577", "index": 6670, "step-1": "<mask token>\n\n\ndef extract_feature(file_name, mfcc, chroma, mel):\n with soundfile.SoundFile(file_name) as file:\n X = file.read(dtype='float32')\n sample_rate = file.samplerate\n if chroma:\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> class ModelManagerTests(unittest.TestCase): def test_model_manager_will_return_same_instance_when_instantiated_many_times( self): """Testing that the ModelManager will return the same instance of an MLModel class from several different references of ModelManag...
flexible
{ "blob_id": "8355faf7c0d3742be34a56ddc982cb389c80d0a9", "index": 1063, "step-1": "<mask token>\n\n\nclass ModelManagerTests(unittest.TestCase):\n\n def test_model_manager_will_return_same_instance_when_instantiated_many_times(\n self):\n \"\"\"Testing that the ModelManager will return the same i...
[ 9, 13, 14, 15, 16 ]
<|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": "11ad3e1ab4ffd491e27998a7235b7e18857632ed", "index": 3141, "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 = [('portfolio_a...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def plot_scatter(x, y, texts, adjust=False): fig, ax = plt.subplots() ax.plot(x, y, 'bo') texts = [plt.text(x[i], y[i], texts[i]) for i in range(len(x))] if adjust: plt.title(str(adjust_text(texts, x, y, arrowprops=dict(arrowstyle= '->', color='red'))) ...
flexible
{ "blob_id": "31996699bec6507d941eb8a7aaacffbd6248d79c", "index": 7112, "step-1": "<mask token>\n\n\ndef plot_scatter(x, y, texts, adjust=False):\n fig, ax = plt.subplots()\n ax.plot(x, y, 'bo')\n texts = [plt.text(x[i], y[i], texts[i]) for i in range(len(x))]\n if adjust:\n plt.title(str(adjus...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class IntegrityConstraintViolationError(_base.EdgeDBError): <|reserved_special_token_0|> class MissingRequiredPointerError(IntegrityConstraintViolationError): code = '23502' def __init__(self, msg, *, source_name=None, pointer_name=None): super().__init__(msg) ...
flexible
{ "blob_id": "b694c834555843cc31617c944fa873f15be2b9c5", "index": 9598, "step-1": "<mask token>\n\n\nclass IntegrityConstraintViolationError(_base.EdgeDBError):\n <mask token>\n\n\nclass MissingRequiredPointerError(IntegrityConstraintViolationError):\n code = '23502'\n\n def __init__(self, msg, *, source...
[ 17, 18, 19, 23, 24 ]
<|reserved_special_token_0|> class Queue: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def front(self): return self.list.get_tail() def rear(self): return self.list.get_head() <|reserved_special_token_1|> <|reserved_special_token_0|> ...
flexible
{ "blob_id": "4830da6bee6b19a5e5a82a73d2f3b220ca59d28b", "index": 9025, "step-1": "<mask token>\n\n\nclass Queue:\n <mask token>\n <mask token>\n <mask token>\n\n def front(self):\n return self.list.get_tail()\n\n def rear(self):\n return self.list.get_head()\n", "step-2": "<mask to...
[ 3, 5, 6, 7 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models from django.contrib.auth.models import User class Tweet(models.Model): owner = models.ForeignKey(User, related_name='tweets') content = models.CharField(max_length=255) when_created = models.DateTimeField(auto_no...
normal
{ "blob_id": "28978bc75cb8c5585fd0d145fe0d0c0c5456ad2e", "index": 6955, "step-1": "<mask token>\n\n\nclass Tweet(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Tweet(models.Model):\n <mask token>\n <mask token>\n <mask token...
[ 1, 2, 3, 4, 5 ]
from scrapy import cmdline cmdline.execute("scrapy crawl rapo.com".split())
normal
{ "blob_id": "326f1b5bee8f488382a76fcc5559f4ea13734f21", "index": 6551, "step-1": "<mask token>\n", "step-2": "<mask token>\ncmdline.execute('scrapy crawl rapo.com'.split())\n", "step-3": "from scrapy import cmdline\ncmdline.execute('scrapy crawl rapo.com'.split())\n", "step-4": "from scrapy import cmdline\...
[ 0, 1, 2, 3 ]
import time # Decorator def measure_time_of_func(func): def wrapper_func(n): start_time = time.time() fib_seq = func(n) end_time = time.time() return (fib_seq, end_time - start_time) return wrapper_func # Returns a list with first n numbers of fibonacci sequence. @measure_ti...
normal
{ "blob_id": "2c39660da8fe839c4634cd73ce069acc7b1b29b4", "index": 51, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@measure_time_of_func\ndef fib(n):\n sequence = [1, 1]\n for i in range(2, n, 1):\n sequence.append(sequence[i - 1] + sequence[i - 2])\n return sequence\n", "step-3": ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def get_list(user): """ Each item in the list has: name, url, description, forks, watchers, homepage, open_issues """ return [g for g in github_api.repos.list(user) if not g.fork] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_to...
flexible
{ "blob_id": "ee2cf6c472fa955ba3718bf3a3f60b66811b4907", "index": 4705, "step-1": "<mask token>\n\n\ndef get_list(user):\n \"\"\"\n Each item in the list has:\n name, url, description, forks, watchers, homepage, open_issues\n\n \"\"\"\n return [g for g in github_api.repos.list(user) if not g.fo...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 # -*- coding: ascii -*- """ A script removing animations from SVG graphics. """ import sys, os, re # etree fails utterly at producing nice-looking XML from xml.dom import minidom def process(inpt, outp): def traverse(node): for child in node.childNodes: if child.nodeTy...
normal
{ "blob_id": "f819d1b1f2f6f3052247cda592007eac40aca37a", "index": 7927, "step-1": "<mask token>\n\n\ndef main():\n if len(sys.argv) != 3:\n sys.stderr.write('USAGE: %s input output\\n' % sys.argv[0])\n sys.stderr.flush()\n sys.exit(0)\n with open(sys.argv[1]) as inpt, open(sys.argv[2], ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class BlogBuilder(object): <|reserved_special_token_0|> def _generate_output(self): """Generate output that belongs in the destination file. Subclasses must implement this method. """ raise NotImplementedError() def write_to(self, filepath): ...
flexible
{ "blob_id": "c3d9ad49b62c56dfbd9674cb1ac5c206e6401a27", "index": 830, "step-1": "<mask token>\n\n\nclass BlogBuilder(object):\n <mask token>\n\n def _generate_output(self):\n \"\"\"Generate output that belongs in the destination file.\n\n Subclasses must implement this method.\n \"\"\"...
[ 13, 24, 28, 32, 38 ]
<|reserved_special_token_0|> def crawl_urls(u): response = requests.get(u, headers=HEADER) body = etree.HTML(response.content) content_urls = body.xpath('//div[@class="box_con"]/div/dl//dd/a/@href') for pk_id, u in enumerate(content_urls): content_url = 'http://www.xxbiquge.com' + u yi...
flexible
{ "blob_id": "7539042b92a5188a11f625cdfc0f341941f751f0", "index": 6937, "step-1": "<mask token>\n\n\ndef crawl_urls(u):\n response = requests.get(u, headers=HEADER)\n body = etree.HTML(response.content)\n content_urls = body.xpath('//div[@class=\"box_con\"]/div/dl//dd/a/@href')\n for pk_id, u in enume...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class AndroidGccToolChain(GccToolChain): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class AndroidGccToolChain(GccToolChain): def __init__(self, name, ndkDir, gccVersionSt...
flexible
{ "blob_id": "d6574cacea693517f3eaa92b4b929c2ee73da2e4", "index": 4421, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AndroidGccToolChain(GccToolChain):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AndroidGccToolChain(GccToolChain):\n\n def __init__(self, name, ndkDir, gccVersi...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> clientsocket.connect(('localhost', 9999)) clientsocket.send('hallooooo') <|reserved_special_token_1|> <|reserved_special_token_0|> clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) clientsocket.connect(('localhos...
flexible
{ "blob_id": "7d3d4476343579a7704c4c2b92fafd9fa5da5bfe", "index": 9294, "step-1": "<mask token>\n", "step-2": "<mask token>\nclientsocket.connect(('localhost', 9999))\nclientsocket.send('hallooooo')\n", "step-3": "<mask token>\nclientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\nclientsocket.con...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def getSnapshot(historyData, id): data = historyData.split('\n') lines = len(data) if lines < 2: return 'Input is too short!' index = 0 curid = '' idlist = dict() recordtime = '' animal_po...
flexible
{ "blob_id": "ddbcc8e768f93a0b4f8776b19e752c57feb5bbf9", "index": 6362, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getSnapshot(historyData, id):\n data = historyData.split('\\n')\n lines = len(data)\n if lines < 2:\n return 'Input is too short!'\n index = 0\n curid = ''\n...
[ 0, 1, 2, 3 ]
from authtools.models import AbstractNamedUser class User(AbstractNamedUser): USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['name']
normal
{ "blob_id": "e7d7a002547047a9bcae830be96dd35db80a86e8", "index": 7001, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass User(AbstractNamedUser):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass User(AbstractNamedUser):\n USERNAME_FIELD = 'email'\n REQUIRED_FIELDS...
[ 0, 1, 2, 3 ]
from matplotlib import pyplot as plt import pandas as pd import numpy as np from sklearn.cluster import KMeans cols = ['Clump Thickness', 'Uniformity of Cell Size', 'Uniformity of Cell Shape', 'Marginal Adhesion', 'Single Epithelial Cell Size', 'Bare Nuclei', 'Bland Chromatin', ...
normal
{ "blob_id": "ff331dc0c72378222db9195cce7c794f93799401", "index": 5833, "step-1": "<mask token>\n", "step-2": "<mask token>\ndata.replace(to_replace='?', value=np.nan, inplace=True)\ndata.dropna(inplace=True)\n<mask token>\nkms.fit(data_train)\nprint(kms.predict(data_test))\nplt.figure()\n", "step-3": "<mask ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class PasswordChangeFormExt(PasswordChangeForm): """Form for changing user's password.""" def clean(self): user = self.user new_password = self.cleaned_data.get('new_password1') old_password = self.cleaned_data.get('old_password') validate_password...
flexible
{ "blob_id": "af442d4a78930a0ebcd85a1cdfe4aa86461be5c1", "index": 1274, "step-1": "<mask token>\n\n\nclass PasswordChangeFormExt(PasswordChangeForm):\n \"\"\"Form for changing user's password.\"\"\"\n\n def clean(self):\n user = self.user\n new_password = self.cleaned_data.get('new_password1')...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def get_file_vocabs(file): file_vocabs = Counter() for sent in file.readlines(): voc = Counter() for word in sent.split(): voc[word] += 1 file_vocabs.update(voc) return file_vocabs <|reserved_special_token_0|> <|reserved_special_token_1|...
flexible
{ "blob_id": "d30e2fa4d5b0a0965dad7d69b672b8f4ad137ff4", "index": 1359, "step-1": "<mask token>\n\n\ndef get_file_vocabs(file):\n file_vocabs = Counter()\n for sent in file.readlines():\n voc = Counter()\n for word in sent.split():\n voc[word] += 1\n file_vocabs.update(voc)\n...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class TrieNode(object): def __init__(self, char: str): self.char = char self.children = [] self.word_finished = False self.counter = 1 self.OccurrenceList = {} <|reserved_special_token_0|> def find_prefix(root, prefix: str) ->Tuple[bool, in...
flexible
{ "blob_id": "dcda8f26a06145579a9be6e5fbfdaed83d4908da", "index": 2459, "step-1": "<mask token>\n\n\nclass TrieNode(object):\n\n def __init__(self, char: str):\n self.char = char\n self.children = []\n self.word_finished = False\n self.counter = 1\n self.OccurrenceList = {}\n...
[ 3, 5, 6, 7, 8 ]
import tensorflow as tf import gensim import string import numpy as np import random ##### prepare data path = 'stanfordSentimentTreebank/output_50d.txt' # model_path = 'stanfordSentimentTreebank/output' # model = gensim.models.Word2Vec.load(model_path) model = gensim.models.KeyedVectors.load_word2vec_format('/Users/i...
normal
{ "blob_id": "7e461e212d9944c229d1473ea16283d3d036bf55", "index": 9933, "step-1": "import tensorflow as tf\nimport gensim\nimport string\nimport numpy as np\nimport random\n\n##### prepare data\npath = 'stanfordSentimentTreebank/output_50d.txt'\n# model_path = 'stanfordSentimentTreebank/output'\n# model = gensim....
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for directory_path, directory_names, file_names in walk('data'): for file_name in file_names: package_data.append('{}/{}'.format(directory_path, file_name)) setup(name='ccal', version=VERSION, description= 'Computa...
flexible
{ "blob_id": "11d0e84767f7e9e4687962a3a5c58dc882cc4dd2", "index": 1934, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor directory_path, directory_names, file_names in walk('data'):\n for file_name in file_names:\n package_data.append('{}/{}'.format(directory_path, file_name))\nsetup(name='cca...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(n[0] * n[1] // 2) <|reserved_special_token_1|> <|reserved_special_token_0|> n = input().split() n[0] = int(n[0]) n[1] = int(n[1]) print(n[0] * n[1] // 2) <|reserved_special_token_1|> """ Solution to Codeforces problem...
flexible
{ "blob_id": "41a80feeb1fdc8ad783706ad261f5fc1124371d6", "index": 8216, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(n[0] * n[1] // 2)\n", "step-3": "<mask token>\nn = input().split()\nn[0] = int(n[0])\nn[1] = int(n[1])\nprint(n[0] * n[1] // 2)\n", "step-4": "\"\"\"\n\tSolution to Codeforces p...
[ 0, 1, 2, 3 ]
from access.ssh.session import Client from access.ssh.datachannel import DataChannel
normal
{ "blob_id": "967c8348352c805b926643617b88b03a62df2d16", "index": 2271, "step-1": "<mask token>\n", "step-2": "from access.ssh.session import Client\nfrom access.ssh.datachannel import DataChannel\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#part-handler # vi: syntax=python ts=4 # # Copyright (C) 2012 Silpion IT-Solutions GmbH # # Author: Malte Stretz <stretz@silpion.de> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3, as # published by the Free Softwa...
normal
{ "blob_id": "98b27c268fe1f47a899269e988ddf798faf827df", "index": 8401, "step-1": "<mask token>\n\n\ndef list_types():\n return ['application/tar']\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef list_types():\n return ['application/tar']\n\n\ndef handle_part(data, ctype, filename, payload):\n i...
[ 1, 2, 3, 4, 5 ]
def check_integer(a): if type(a) != int: print("please input an integer") exit() def is_even(a): check_integer(a) if a % 2 == 0: print("true") return True else: print("false") return False is_even(2) is_even(3) is_even("cat")
normal
{ "blob_id": "92391f17380b2e09cc9b3913f15ce35189d9893d", "index": 8241, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef is_even(a):\n check_integer(a)\n if a % 2 == 0:\n print('true')\n return True\n else:\n print('false')\n return False\n\n\n<mask token>\n", ...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- ''' Created on 2014-03-25 @author: ZhaoJianning Modified by WangHairui on 2014-09-12 ''' import unittest import Stability import time import os,sys import runtests import re import android import datetime class TestCamera(unittest.TestCase): def setUp(self): ...
normal
{ "blob_id": "a520a93ed2dcd26b9470ed56e96b65a1b3550176", "index": 6260, "step-1": "# -*- coding: utf-8 -*-\r\n'''\r\nCreated on 2014-03-25\r\n\r\n@author: ZhaoJianning\r\nModified by WangHairui on 2014-09-12\r\n'''\r\n\r\nimport unittest\r\nimport Stability\r\nimport time\r\nimport os,sys\r\nimport runtests\r\nim...
[ 0 ]
#! /usr/bin/env python def get_case(str_arg): first_life_and_work(str_arg) print('small_hand') def first_life_and_work(str_arg): print(str_arg) if __name__ == '__main__': get_case('thing')
normal
{ "blob_id": "7a2ac3a3a2bbd7349e8cc62b4d357394d9600cc8", "index": 6326, "step-1": "<mask token>\n", "step-2": "def get_case(str_arg):\n first_life_and_work(str_arg)\n print('small_hand')\n\n\n<mask token>\n", "step-3": "def get_case(str_arg):\n first_life_and_work(str_arg)\n print('small_hand')\n\...
[ 0, 1, 2, 3, 4 ]
from mayan.apps.testing.tests.base import BaseTestCase from .mixins import AssetTestMixin class AssetModelTestCase(AssetTestMixin, BaseTestCase): def test_asset_get_absolute_url_method(self): self._create_test_asset() self.test_asset.get_absolute_url()
normal
{ "blob_id": "42c9e5039e2d5f784bf6405ea8bcaf7d6973ddcb", "index": 6456, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AssetModelTestCase(AssetTestMixin, BaseTestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AssetModelTestCase(AssetTestMixin, BaseTestCase):\n\n def test_as...
[ 0, 1, 2, 3 ]
from turtle import * from freegames import vector 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() ...
normal
{ "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 ]
import time import pigpio class Car: def __init__(self, STBY, PWMA, AIN2, AIN1, BIN1, BIN2, PWMB, sensorTrig=0, sensors=[]): self.pi = pigpio.pi() if not self.pi.connected: print("Pi not connected to pigpio.") return # GPIO Drive Pin locations ...
normal
{ "blob_id": "5b9f1b3ca4b50a4e9e8bd6715e73c62b4f778929", "index": 1594, "step-1": "<mask token>\n\n\nclass Car:\n <mask token>\n\n def activate(self):\n self.deactivate()\n self.pi.write(self.STBY, 1)\n <mask token>\n\n def setDrive(self, direction, dutycycle=100):\n dc = int(255....
[ 4, 6, 7, 8, 10 ]
from .tc_gcc import * class AndroidGccToolChain(GccToolChain): def __init__(self, name, ndkDir, gccVersionStr, platformVer, archStr, prefix = "", suffix = ""): # TODO: non-windows host platform hostPlatform = 'windows' installDir = os.path.join(ndkDir, 'toolchains', prefix + gccVersionStr,...
normal
{ "blob_id": "d6574cacea693517f3eaa92b4b929c2ee73da2e4", "index": 4421, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AndroidGccToolChain(GccToolChain):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AndroidGccToolChain(GccToolChain):\n\n def __init__(self, name, ndkDir, gccVersi...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def main(): N = int(input()) num = 1 for i in range(N + 1): if i > 0: print('%d %d %d' % (i, i ** 2, i ** 3)) num += 1 <|reserved_special_token_0|> <|reserved_special_token_1|> def main(): N = int(input()) ...
flexible
{ "blob_id": "b55984da73d3cfb3109a52990a0d4d05a27d51a5", "index": 1794, "step-1": "<mask token>\n", "step-2": "def main():\n N = int(input())\n num = 1\n for i in range(N + 1):\n if i > 0:\n print('%d %d %d' % (i, i ** 2, i ** 3))\n num += 1\n\n\n<mask token>\n", "step-3"...
[ 0, 1, 2, 3 ]
# Generated by Django 3.1.7 on 2021-03-20 14:31 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('restapp', '0021_auto_20210320_1421'), ] operations = [ migrations.AddField( model_name='order', name='phone', ...
normal
{ "blob_id": "bf160bd2fc924a11d340bd466b4a879d1cdcd86e", "index": 7639, "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 = [('restapp', '...
[ 0, 1, 2, 3, 4 ]
from django.db import models class IssueManager(models.Manager): def open(self): return self.filter(status__is_closed=False) def closed(self): return self.filter(status__is_closed=True)
normal
{ "blob_id": "4c54cfefbaf90c1dd0648485e62bff1f2787ccfe", "index": 2784, "step-1": "<mask token>\n\n\nclass IssueManager(models.Manager):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass IssueManager(models.Manager):\n\n def open(self):\n return self.filter(status__is_closed=F...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> def normal_pdfs_visualization(): xs = [(x / 10.0) for x in range(-50, 50)] plt.plot(xs, [ds_probability.normal_pdf(x, sigma=1) for x in xs], '-', label='mu=0-sigma=1') plt.plot(xs, [ds_probability.normal_pdf(x, sigma=2) for x in xs], '--', label='mu=0-sigma=2')...
flexible
{ "blob_id": "c0adc0032a2647a19d3540c057fa9762906e5f62", "index": 4439, "step-1": "<mask token>\n\n\ndef normal_pdfs_visualization():\n xs = [(x / 10.0) for x in range(-50, 50)]\n plt.plot(xs, [ds_probability.normal_pdf(x, sigma=1) for x in xs], '-',\n label='mu=0-sigma=1')\n plt.plot(xs, [ds_prob...
[ 3, 4, 6, 7, 8 ]
import torch import typing __all__ = ['NoOp'] class Null(torch.optim.Optimizer): def __init__(self, parameters: typing.Iterator[torch.nn.Parameter], ): super(Null, self).__init__(parameters, {"lr": 0.0, "eps": 1e-8}) def step(self, closure=None): if closure is not None: closure() return N...
normal
{ "blob_id": "3c7237e5770dd5552c327dbf53451a2889ea8c6b", "index": 7198, "step-1": "<mask token>\n\n\nclass Null(torch.optim.Optimizer):\n <mask token>\n <mask token>\n\n\nclass NoOp(object):\n\n def __init__(self, parameters: typing.Iterator[torch.nn.Parameter]):\n self.optimizers = [Null(paramete...
[ 4, 6, 7, 8, 9 ]
from django.db import models from django.utils import timezone from django.db.models.signals import post_save from django.urls import reverse # Create your models here. class Purchase(models.Model): invoice = models.SmallIntegerField(primary_key=True,blank=False) ch_no = models.SmallIntegerField(blank=True,nul...
normal
{ "blob_id": "bb3c42c9f87a463b9f18601c9e3897b6d21351d5", "index": 7356, "step-1": "<mask token>\n\n\nclass PurchaseDetail(models.Model):\n PRODUCT_CHOICES = ('WOOD', 'Wood'), ('GLASS', 'Glass'), ('PLASTIC',\n 'Plastic'), ('LEATHER', 'Leather'), ('FABRIC', 'Fabric'), ('STEEL',\n 'Steel')\n purc...
[ 4, 6, 7, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Cmd(object): pass <|reserved_special_token_1|> __author__ = 'zhaobin022' class Cmd(object): pass
flexible
{ "blob_id": "0eca1693caffcd9fe32a8a54ca3a33687763e5ce", "index": 6809, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Cmd(object):\n pass\n", "step-3": "__author__ = 'zhaobin022'\n\n\nclass Cmd(object):\n pass\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ...
[ 0, 1, 2 ]
import datetime interval_length_minutes = 10 # 10 minutes per interval tek_rolling_period = 144 # 24*60//10 - 24 hours per day, 60 minutes per hour, 10 minutes per interval def get_timestamp_from_interval(interval_number): return interval_number * interval_length_minutes * 60 # 60 seconds per minute def get...
normal
{ "blob_id": "f3bfa30f51c4a91844457c72fbf2b2b8368d8476", "index": 1874, "step-1": "<mask token>\n\n\ndef get_timestamp_from_interval(interval_number):\n return interval_number * interval_length_minutes * 60\n\n\ndef get_datetime_from_utc_timestamp(utc_timestamp):\n return datetime.datetime.utcfromtimestamp(...
[ 2, 3, 4, 5, 7 ]
<|reserved_special_token_0|> class SvnUtilTests(TestCase): def setUp(self): r1 = Release() r1.name = 'BETA1.1.0' r1.type = 'BETA' r1.version = '1.1.0' r1.date = time.strptime('2009-04-21 23:22:03', '%Y-%m-%d %H:%M:%S') r2 = Release() r2.name = 'STABLE0.4.9'...
flexible
{ "blob_id": "9c320db85ca1a9df6b91f6bb062e4d5c3d94ee91", "index": 9516, "step-1": "<mask token>\n\n\nclass SvnUtilTests(TestCase):\n\n def setUp(self):\n r1 = Release()\n r1.name = 'BETA1.1.0'\n r1.type = 'BETA'\n r1.version = '1.1.0'\n r1.date = time.strptime('2009-04-21 23:...
[ 2, 3, 4, 5, 6 ]
class Donkey(object): def manzou(self): print('走路慢……') def jiao(self): print('驴在欢叫%……') class Horse(object): def naili(self): print('马力足,持久强……') def jiao(self): print('马在嘶鸣') class Mule(Donkey,Horse): pass def jiao(self): print('骡子在唱歌') 骡子一号 = Mule() 骡...
normal
{ "blob_id": "5d4ef436c4ee5c31496977a5ae9b55db9ff34e79", "index": 4082, "step-1": "<mask token>\n\n\nclass Horse(object):\n\n def naili(self):\n print('马力足,持久强……')\n <mask token>\n\n\nclass Mule(Donkey, Horse):\n pass\n\n def jiao(self):\n print('骡子在唱歌')\n\n\n<mask token>\n", "step-2":...
[ 4, 7, 8, 9, 11 ]
print("This program calculates whether the year is a leap year or not") year = input("Please enter the Year: ") if year.isdecimal(): year=int(year) if year%4==0 and year%100!=0 or year%400==0: print("{0} is a leap year".format(year)) else: print("{0} is not a leap year".format(year)) else: ...
normal
{ "blob_id": "fdea48b6012b67327aea90e40eacbea5a1930d07", "index": 9688, "step-1": "<mask token>\n", "step-2": "print('This program calculates whether the year is a leap year or not')\n<mask token>\nif year.isdecimal():\n year = int(year)\n if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:\n ...
[ 0, 1, 2, 3 ]
class Thing3: def __init__(self): self.letters = 'xyz' # print(Thing3.letters) th = Thing3() print(th.letters)
normal
{ "blob_id": "22bf65a20f7398b82f528112d2ba50f1dccd465c", "index": 6487, "step-1": "class Thing3:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Thing3:\n\n def __init__(self):\n self.letters = 'xyz'\n\n\n<mask token>\n", "step-3": "class Thing3:\n\n def __init__(self):\n self.let...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def get_data_from_database_cns(connection, query_string, delimiter=';'): with connection.cursor() as cur: cur.execute(query_string) [print(x[0], end=delimiter) for x in cur.description] print() for result in cur: for w in result: ...
flexible
{ "blob_id": "39f1595374147c71bc2d4c945a0f1149891f1883", "index": 5300, "step-1": "<mask token>\n\n\ndef get_data_from_database_cns(connection, query_string, delimiter=';'):\n with connection.cursor() as cur:\n cur.execute(query_string)\n [print(x[0], end=delimiter) for x in cur.description]\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def make_knowledge_header(name: str, version: Optional[str]=None, description: Optional[str]=None, authors: Optional[str]=None, contact: Optional[str]=None, copyright: Optional[str]=None, licenses: Optional[ str]=None, disclaimer: Optional[str]=None, namespace_url: Optional[ ...
flexible
{ "blob_id": "46b8d0ba58d4bf17021b05fc03bd480802f65adf", "index": 6132, "step-1": "<mask token>\n\n\ndef make_knowledge_header(name: str, version: Optional[str]=None,\n description: Optional[str]=None, authors: Optional[str]=None, contact:\n Optional[str]=None, copyright: Optional[str]=None, licenses: Optio...
[ 3, 4, 5, 6, 7 ]
############################################################################## # Copyright by The HDF Group. # # All rights reserved. # # # # Th...
normal
{ "blob_id": "e15ea7d167aad470d0a2d95a8a328b35181e4dc3", "index": 7832, "step-1": "<mask token>\n\n\ndef info(msg):\n if config['log_level'] not in ('ERROR', 'WARNING', 'WARN'):\n print(config['prefix'] + 'INFO> ' + msg)\n log_count['INFO'] += 1\n\n\n<mask token>\n\n\ndef warning(msg):\n if co...
[ 2, 4, 8, 9, 10 ]
<|reserved_special_token_0|> class SubscriptionHandler(object): <|reserved_special_token_0|> <|reserved_special_token_0|> def handle_subscribe(self, request): if not request.xpath('//m:StreamingSubscriptionRequest', namespaces =NAMESPACES): return emails = request....
flexible
{ "blob_id": "e4bfa0a55fe0dbb547bc5f65554ef96be654ec7a", "index": 2176, "step-1": "<mask token>\n\n\nclass SubscriptionHandler(object):\n <mask token>\n <mask token>\n\n def handle_subscribe(self, request):\n if not request.xpath('//m:StreamingSubscriptionRequest', namespaces\n =NAMESPA...
[ 4, 7, 8, 9, 10 ]
<|reserved_special_token_0|> class EnigmaRotor: <|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 getEntrata(self): return self.entrata <|reserved_sp...
flexible
{ "blob_id": "c14673b56cb31efb5d79859dd0f6f3c6806e1056", "index": 3576, "step-1": "<mask token>\n\n\nclass EnigmaRotor:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def getEntrata(self):\n return self.entrata\n <mask token>\n <mask...
[ 2, 8, 10, 11, 12 ]
<|reserved_special_token_0|> class INDENT_STACK: <|reserved_special_token_0|> def __init__(self): self.my_stack = [{'physical': 0, 'logical': 0, 'type': 'none'}] def init_indent(self): del self.my_stack self.my_stack = [{'physical': 0, 'logical': 0, 'type': 'none'}] <|reserve...
flexible
{ "blob_id": "e6010ec05ec24dcd2a44e54ce1b1f11000e775ce", "index": 8399, "step-1": "<mask token>\n\n\nclass INDENT_STACK:\n <mask token>\n\n def __init__(self):\n self.my_stack = [{'physical': 0, 'logical': 0, 'type': 'none'}]\n\n def init_indent(self):\n del self.my_stack\n self.my_s...
[ 7, 10, 11, 17, 19 ]
import bnn #get #!wget http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz #!wget http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz #unzip #!gzip -d t10k-images-idx3-ubyte.gz #!gzip -d t10k-labels-idx1-ubyte.gz #read labels print("Reading labels") labels = [] with open("/home/xilinx/jupyter_notebooks/...
normal
{ "blob_id": "da34eb25ec08c8311fa839a0cdcd164eff036a5d", "index": 942, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Reading labels')\n<mask token>\nwith open('/home/xilinx/jupyter_notebooks/bnn/t10k-labels-idx1-ubyte', 'rb'\n ) as lbl_file:\n magicNum = int.from_bytes(lbl_file.read(4), byte...
[ 0, 1, 2, 3, 4 ]
from django.urls import path, include from rest_framework.routers import SimpleRouter from board_api.views import PostViewSet, UpvoteView, CommentViewSet router = SimpleRouter() router.register(r"post", PostViewSet) router.register(r"post_upvote", UpvoteView) router.register(r"comment", CommentViewSet) urlpatterns ...
normal
{ "blob_id": "db309283137383cd698f235e7326c6e5c50f6cf3", "index": 6671, "step-1": "<mask token>\n", "step-2": "<mask token>\nrouter.register('post', PostViewSet)\nrouter.register('post_upvote', UpvoteView)\nrouter.register('comment', CommentViewSet)\n<mask token>\n", "step-3": "<mask token>\nrouter = SimpleRo...
[ 0, 1, 2, 3, 4 ]
# Ömer Malik Kalembaşı 150180112 import numpy as np import matplotlib.pyplot as plt fig = plt.figure() img = plt.imread("clown.bmp") u, s, v = np.linalg.svd(img) zeros = np.zeros((200, 320)) for i in range(200): zeros[i, i] = s[i] for n in range(1, 7): r = 2**i p = np.dot(u, zeros[:...
normal
{ "blob_id": "b76b188dc77077ae70f320d01e9410d44b171974", "index": 1903, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(200):\n zeros[i, i] = s[i]\nfor n in range(1, 7):\n r = 2 ** i\n p = np.dot(u, zeros[:, :r])\n svd = np.dot(p, v[:r, :])\n fig.add_subplot(3, 2, n)\n plt....
[ 0, 1, 2, 3, 4 ]
name = ['zhangsan'] def func(n): name = n print(name) def func1(): nonlocal name name = 'xiaohong' print(name) func1() print(name) func('lisi')
normal
{ "blob_id": "b04aef64dc0485d9112a40e00d178042833a9ddd", "index": 4294, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef func(n):\n name = n\n print(name)\n\n def func1():\n nonlocal name\n name = 'xiaohong'\n print(name)\n func1()\n print(name)\n\n\n<mask token>\...
[ 0, 1, 2, 3 ]
#!/usr/bin/python # -*- coding: utf-8 -*- import optparse import logging from pyspark import SparkContext from pyspark import SparkConf logger = logging.getLogger(__name__) def create_context(appName): """ Creates Spark HiveContext """ logger.info("Creating Spark context - may take some while") ...
normal
{ "blob_id": "d4b432735a112ccb293bf2f40929846b4ce34cd0", "index": 9348, "step-1": "<mask token>\n\n\ndef create_context(appName):\n \"\"\"\n Creates Spark HiveContext\n \"\"\"\n logger.info('Creating Spark context - may take some while')\n conf = SparkConf()\n conf.set('spark.hadoop.validateOutp...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def create_gecko_driver(): home_dir = os.getenv('HOME') return Firefox(executable_path=os.path.join(home_dir, 'bin', 'geckodriver') ) @pytest.fixture def driver(request): firefox = create_gecko_driver() ...
flexible
{ "blob_id": "b6e28f29edd0c4659ab992b45861c4c31a57e7fd", "index": 8920, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef create_gecko_driver():\n home_dir = os.getenv('HOME')\n return Firefox(executable_path=os.path.join(home_dir, 'bin', 'geckodriver')\n )\n\n\n@pytest.fixture\ndef driv...
[ 0, 2, 3, 4, 5 ]
import time import datetime from pushover import init, Client from scraper import * from config import * # Get the current time timeNow = time.strftime("%a %b %d, %I:%M %p").lstrip("0").replace(" 0", " ") # Initialise Pushover for notifications client = Client(user_key, api_token=api_token) # Loop for times of ISS ...
normal
{ "blob_id": "a573c6870392024ec2e84571ccb0bad3f5c4033a", "index": 4261, "step-1": "<mask token>\n\n\ndef issCheck():\n for i in column.keys():\n for x in column[i]:\n if i == 'Date':\n issNow = x\n if issNow == timeNow:\n client.send_message('I...
[ 1, 2, 3, 4, 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": "1cf5ce11b965d65426ed421ef369954c59d7eba9", "index": 3199, "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', '000...
[ 0, 1, 2, 3, 4 ]
from datetime import datetime import time from os import system import RPi.GPIO as GPIO import firebase_admin from firebase_admin import credentials from firebase_admin import db GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(21, GPIO.OUT) # este pin es de salida carro GPIO.setup(26, GPIO.OUT) # este pin es...
normal
{ "blob_id": "0972bd1241ad91f54f8dfde6327ee226c27bf2ca", "index": 9747, "step-1": "<mask token>\n", "step-2": "<mask token>\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(21, GPIO.OUT)\nGPIO.setup(26, GPIO.OUT)\nGPIO.setup(19, GPIO.OUT)\nGPIO.setup(13, GPIO.OUT)\nGPIO.setup(6, GPIO.OUT)\nGPIO.setu...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Dato: <|reserved_special_token_0|> <|reserved_special_token_0|> def setId(self, id): self.__id = id <|reserved_special_token_0|> def setDato(self, dato): self.__dato = dato <|reserved_special_token_0|> def setTipo(self, tipo): s...
flexible
{ "blob_id": "95256390e1e7e9227b96dccce33082de9d2cddd3", "index": 5158, "step-1": "<mask token>\n\n\nclass Dato:\n <mask token>\n <mask token>\n\n def setId(self, id):\n self.__id = id\n <mask token>\n\n def setDato(self, dato):\n self.__dato = dato\n <mask token>\n\n def setTip...
[ 6, 7, 9, 10, 12 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def run(): dataDir = 'Data/' personalStorage = PersonalStorage.from_file(dataDir + 'Outlook.pst') for folder in personalStorage.root_folder.get_sub_folders(): for messageInfo in folder.enumerate_messages(): ...
flexible
{ "blob_id": "8a6028aa477f697946ab75411b667f559e87141c", "index": 7072, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run():\n dataDir = 'Data/'\n personalStorage = PersonalStorage.from_file(dataDir + 'Outlook.pst')\n for folder in personalStorage.root_folder.get_sub_folders():\n ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- import pytest class TestMark: @pytest.mark.demo1 def test_case1(self): print("testcase1") @pytest.mark.demo1 def test_case2(self): print("testcase1") @pytest.mark.demo2 def test_case3(self): print("testcase1") @pytest...
normal
{ "blob_id": "f49c15dca26d987e1d578790e077501a504e560b", "index": 5814, "step-1": "<mask token>\n\n\nclass TestMark:\n\n @pytest.mark.demo1\n def test_case1(self):\n print('testcase1')\n\n @pytest.mark.demo1\n def test_case2(self):\n print('testcase1')\n <mask token>\n\n @pytest.ma...
[ 4, 5, 6, 7, 8 ]
#!/usr/bin/python import os import sys import csv import json from time import sleep from datetime import datetime ShowProgress = False ConvertTime = False def print_welcome(): print(""" [*******************************************************************************************************] ...
normal
{ "blob_id": "dace25428f48da633ee571b51565d15650782649", "index": 1237, "step-1": "#!/usr/bin/python\nimport os\nimport sys\nimport csv\nimport json\nfrom time import sleep\nfrom datetime import datetime\n\nShowProgress = False\nConvertTime = False\n\n\ndef print_welcome():\n print(\"\"\"\n[*******************...
[ 0 ]
#!/usr/bin/env python # pylama:ignore=E221,E251 from setuptools import find_packages, setup setup( name = 'coding_exercises', version = '1.0', description = 'Coding Exercises in Python', author = 'Gustavo Gama', author_email = 'gustavo.gama@gmail.com', url = 'https...
normal
{ "blob_id": "5f4abc7e9397034737ee214b0d0aae39ebf1548b", "index": 8098, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='coding_exercises', version='1.0', description=\n 'Coding Exercises in Python', author='Gustavo Gama', author_email=\n 'gustavo.gama@gmail.com', url='https://gama.igenesi...
[ 0, 1, 2, 3 ]
import netCDF4 as nc import numpy as np import os def RangeExtender(filename,directory): fileNC=nc.Dataset(directory+filename,'r') nu=fileNC['nu'][:] filename,ext=os.path.splitext(filename) fileOut=nc.Dataset(directory+filename+"_50000cm-1.nc",'w') nu_orig_length=len(nu) step=abs(nu[1]...
normal
{ "blob_id": "f3527185117fd7205f55f47f2f08448a7d7b0100", "index": 8143, "step-1": "<mask token>\n\n\ndef RangeExtender(filename, directory):\n fileNC = nc.Dataset(directory + filename, 'r')\n nu = fileNC['nu'][:]\n filename, ext = os.path.splitext(filename)\n fileOut = nc.Dataset(directory + filename ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def lambda_handler(event, context): sts_client = boto3.client('sts') assumerole = sts_client.assume_role(RoleArn='arn:aws:iam::' + accountnumber + ':role/' + rolename, RoleSessionName=rolesession) credentials...
flexible
{ "blob_id": "539431649e54469ddbe44fdbd17031b4449abdd9", "index": 5867, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lambda_handler(event, context):\n sts_client = boto3.client('sts')\n assumerole = sts_client.assume_role(RoleArn='arn:aws:iam::' +\n accountnumber + ':role/' + rolena...
[ 0, 1, 2, 3, 4 ]
import sys def solution(input): k = 1 for v in sorted(input): if v >= k: k += 1 return k - 1 testcase = sys.stdin.readline() for i in range(int(testcase)): sys.stdin.readline() line1 = sys.stdin.readline().rstrip('\n') line2 = sys.stdin.readline().rstrip('\n') ans = sol...
normal
{ "blob_id": "a89724be31b4ccc1a3d83305509d9624da364a0c", "index": 6004, "step-1": "<mask token>\n\n\ndef solution(input):\n k = 1\n for v in sorted(input):\n if v >= k:\n k += 1\n return k - 1\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef solution(input):\n k = 1\n for ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class APInfoTest(unittest.TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def test_init_no_ip(self): """Test the __init__ method when parameter 'ip' is None. Since the field is optional, it should pass. ...
flexible
{ "blob_id": "ae5dfa7fa6a0d7349d6ae29aeac819903facb48f", "index": 3518, "step-1": "<mask token>\n\n\nclass APInfoTest(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def test_init_no_ip(self):\n \"\"\"Test the __init__ method when parameter 'ip' is None.\n Since the ...
[ 10, 11, 13, 14, 16 ]
# Square-Root of Trinomials import math print("Έχουμε ένα τριώνυμο ax²+bx+c. Δώστε μία θετική ή αρνητική τιμή σε κάθε σταθερά!") a=int(input("a:")) b=int(input("b:")) c=int(input("c:")) D= b**2-4*a*c print("Η Διακρίνουσα ειναι: " + str(D)) if D>0: x1=(-b+math.sqrt(D))/(2*a) print("Η πρώτη ρίζα ειναι: " + s...
normal
{ "blob_id": "b80deec4d3d3ab4568f37cc59e098f1d4af5504c", "index": 6503, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\n 'Έχουμε ένα τριώνυμο ax²+bx+c. Δώστε μία θετική ή αρνητική τιμή σε κάθε σταθερά!'\n )\n<mask token>\nprint('Η Διακρίνουσα ειναι: ' + str(D))\nif D > 0:\n x1 = (-b + math...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(os.name) print(os.environ.get('PATH')) print(os.path.abspath('.')) os.path.join(os.path.abspath('.'), 'testdir') os.mkdir(os.path.abspath('.')) <|reserved_special_token_1|> import os print(os.name) print(os.environ.get('P...
flexible
{ "blob_id": "fd059ae6e5eb3f7dc18dff6f9ed206002cea5fb2", "index": 9788, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(os.name)\nprint(os.environ.get('PATH'))\nprint(os.path.abspath('.'))\nos.path.join(os.path.abspath('.'), 'testdir')\nos.mkdir(os.path.abspath('.'))\n", "step-3": "import os\nprint...
[ 0, 1, 2, 3 ]
import cv2 as cv img = cv.imread('images/gradient.png', 0) _,th1 = cv.threshold(img, 127,255, cv.THRESH_BINARY) _,th2 = cv.threshold(img, 127, 255, cv.THRESH_BINARY_INV) _,th3 = cv.threshold(img, 127, 255, cv.THRESH_TRUNC) #freeze the pixel color after the threshold _,th4 = cv.threshold(img, 127, 255, cv.THRESH_TOZERO...
normal
{ "blob_id": "6f356840944e11f52a280262697d7e33b3cca650", "index": 2319, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv.imshow('Threshold Trunc', th3)\ncv.imshow('Threshold2', th2)\ncv.imshow('Threshold', th1)\ncv.imshow('Image', img)\ncv.imshow('th4', th4)\ncv.imshow('th5', th5)\ncv.waitKey(0)\ncv.dest...
[ 0, 1, 2, 3, 4 ]
import threading import time g_num = 0 def work1(num): global g_num for i in range(num): g_num += 1 print("__in work1: g_num is {}".format(g_num)) def work2(num): global g_num for i in range(num): g_num += 1 print("__in work2: g_num is {}".format(g_num)) def main(): ...
normal
{ "blob_id": "60079005c2091d2dc0b76fb71739671873f0e0f1", "index": 9534, "step-1": "<mask token>\n\n\ndef work1(num):\n global g_num\n for i in range(num):\n g_num += 1\n print('__in work1: g_num is {}'.format(g_num))\n\n\ndef work2(num):\n global g_num\n for i in range(num):\n g_num +...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python import numpy as np import cv2 # Creat a Image with Pixel 512x512 RGB image = np.zeros((512, 512, 3), np.uint8) # Pt Definition # x0y0, x1y0, x2 y0 # x0y1 , x1y1, x2y1 # Draw a Line in the Middle of the image # Start Co-ordinate end Co-ordinate While Color and Line Width cv2.line(image, (0, 0),...
normal
{ "blob_id": "f6c5c2180a1a4b05b3f103c330b455e7387713a6", "index": 8125, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.line(image, (0, 0), (512, 0), (255, 255, 255), 5)\ncv2.line(image, (0, 50), (512, 50), (255, 255, 255), 5)\ncv2.rectangle(image, (256, 0), (400, 256), (0, 255, 0), 3)\n<mask token>\nc...
[ 0, 1, 2, 3, 4 ]
#Homework 2 PyPoll #The total number of votes cast #A complete list of candidates who received votes #The percentage of votes each candidate won #The total number of votes each candidate won #The winner of the election based on popular vote. #First we'll import the os module # This will allow us to create file pat...
normal
{ "blob_id": "800d87a879987c47f1a66b729932279fc8d4fa38", "index": 7314, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('election_data.csv') as csvfile:\n csvreader = csv.reader(csvfile, delimiter=',')\n print(csvreader)\n", "step-3": "<mask token>\ncsvpath = os.path.join('election_data.c...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.2.2 on 2021-05-11 09:49 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('meeting', '0004_auto_20210511_0947'), ] operations = [ migrations.AlterField( model_name='event', name='end', ...
normal
{ "blob_id": "1c1cd0eeea4dbf446aa4582f42ef1f3b5a4e8875", "index": 7452, "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 = [('meeting', '...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(21, GPIO.OUT) GPIO.setup(26, GPIO.OUT) GPIO.setup(19, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(6, GPIO.OUT) GPIO.setup(5, GPIO.OUT) GPIO.setup(11, GPIO.OUT) GPIO.setup...
flexible
{ "blob_id": "0972bd1241ad91f54f8dfde6327ee226c27bf2ca", "index": 9747, "step-1": "<mask token>\n", "step-2": "<mask token>\nGPIO.setwarnings(False)\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(21, GPIO.OUT)\nGPIO.setup(26, GPIO.OUT)\nGPIO.setup(19, GPIO.OUT)\nGPIO.setup(13, GPIO.OUT)\nGPIO.setup(6, GPIO.OUT)\nGPIO.setu...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def plot(ax, ls_batch, ls_dev, its, title): ax.plot(range(len(ls_batch)), ls_batch, label='Batch') ax.plot(range(len(ls_dev)), ls_dev, label='Dev') ax.text(0.3, 0.93, 'Batch: {:.3f}'.format(ls_batch[-1]), transform=ax. transAxes) ax.text(0.3, 0.86, 'Dev: {:.3f}'.fo...
flexible
{ "blob_id": "2f6e5ed4e2d52190551dec2ac18441b8355699b5", "index": 7096, "step-1": "<mask token>\n\n\ndef plot(ax, ls_batch, ls_dev, its, title):\n ax.plot(range(len(ls_batch)), ls_batch, label='Batch')\n ax.plot(range(len(ls_dev)), ls_dev, label='Dev')\n ax.text(0.3, 0.93, 'Batch: {:.3f}'.format(ls_batch...
[ 1, 2, 3, 4, 5 ]
__doc__ def fizz_buzz(num1, num2, end_range): if not ( isinstance(num1, int) and isinstance(num2, int) and isinstance(end_range, int) ) or (num1 < 0 or num2 < 0 or end_range < 0): return "Input should be a positive integer" # I'm storing the result to test the returned value aka a list of...
normal
{ "blob_id": "d00873c3ee72b55cb5b74f78a98de61a25b3cc21", "index": 7227, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_answer():\n import sys\n answer1 = None\n answer2 = None\n answer3 = None\n try:\n answer1 = fizz_buzz(3, 5, 16)\n answer2 = fizz_buzz(2, 7, 20)\...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- """Script to view and manage OPenn repositories. Use this script to list and update OPenn primary repositories, to view repository details, and to list documents in each repository. """ import os import sys import argparse import logging sys.path.insert(0, os.path.abspa...
normal
{ "blob_id": "e3071643548bb3a4e8d0a5710820ad39b8a6b04b", "index": 5057, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Script to view and manage OPenn repositories. Use this script to list and\nupdate OPenn primary repositories, to view repository details, and to list\ndocuments in each reposi...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): """ 公共参数: store: 商城或书店名称(小米|文泉), browser: 浏览器(目前只支持Chrome), version: 浏览器版本号, quit: 运行完后是否退出浏览器(默认不退出), hidden: 是否启用界面(默认启用), 商城抢购: url: 抢购商城地址, addr_nth: 收货地址(选择第几个收货地址,默认第一个), 书店扒书(...
flexible
{ "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|> def search_way(adjacency_list, points): use = [(False) for i in range(points.__len__())] way = [(0) for i in range(points.__len__())] cost = [(100000) for i in range(points.__len__())] cost[0] = 0 checkVar = 0 test = True while tes...
flexible
{ "blob_id": "1e4d21998b9f8915167166e5965b0c8c87fcf61d", "index": 3060, "step-1": "<mask token>\n", "step-2": "def search_way(adjacency_list, points):\n use = [(False) for i in range(points.__len__())]\n way = [(0) for i in range(points.__len__())]\n cost = [(100000) for i in range(points.__len__())]\n...
[ 0, 1, 2 ]