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|> def area(a, b): resultado = a * b return resultado <|reserved_special_token_0|> <|reserved_special_token_1|> def area(a, b): resultado = a * b return resultado def main(): num1 = float(input('INTRODUCE LA BASE: ')) num2 = float(...
flexible
{ "blob_id": "282dbdb3a8d9ed914e8ca5c7fa74d2873920e18c", "index": 7308, "step-1": "<mask token>\n", "step-2": "def area(a, b):\n resultado = a * b\n return resultado\n\n\n<mask token>\n", "step-3": "def area(a, b):\n resultado = a * b\n return resultado\n\n\ndef main():\n num1 = float(input('IN...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class TestKOrderStatistic(unittest.TestCase): def test_find(self): for a, k, ans in test_case_find: self.assertEqual(k_order_statistic(a, k), ans) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestKOrderStati...
flexible
{ "blob_id": "b93cd5ad957da37b1a4cca1d465a67723110e926", "index": 2813, "step-1": "<mask token>\n\n\nclass TestKOrderStatistic(unittest.TestCase):\n\n def test_find(self):\n for a, k, ans in test_case_find:\n self.assertEqual(k_order_statistic(a, k), ans)\n <mask token>\n", "step-2": "<m...
[ 2, 3, 4, 5 ]
# Named Entity Recognition on Medical Data (BIO Tagging) # Bio-Word2Vec Embeddings Source and Reference: https://github.com/ncbi-nlp/BioWordVec import os import re import torch import pickle from torch import nn from torch import optim import torch.nn.functional as F import numpy as np import random from DNC.dnc imp...
normal
{ "blob_id": "eb99def75404bc3b674bcb633714009149f2d50d", "index": 5097, "step-1": "<mask token>\n\n\nclass task_NER:\n\n def __init__(self):\n self.name = 'NER_task_bio'\n self.controller_size = 128\n self.controller_layers = 1\n self.num_read_heads = 1\n self.num_write_heads...
[ 12, 20, 26, 27, 29 ]
__author__ = 'matthias' from tcp import * from data import * #SERVER = "131.225.237.31" #PORT = 33487 data = LaserData() #server = TCP(SERVER, PORT) server = TCP() server.start_server() for i in range(100): data = server.recv_server() print data
normal
{ "blob_id": "1e4d18909b72ceef729efdd7b2ab996ace45f1bd", "index": 6367, "step-1": "__author__ = 'matthias'\n\nfrom tcp import *\nfrom data import *\n\n#SERVER = \"131.225.237.31\"\n#PORT = 33487\n\ndata = LaserData()\n#server = TCP(SERVER, PORT)\nserver = TCP()\nserver.start_server()\nfor i in range(100):\n da...
[ 0 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # This file is part of CbM (https://github.com/ec-jrc/cbm). # Author : Konstantinos Anastasakis # Credits : GTCAP Team # Copyright : 2021 European Commission, Joint Research Centre # License : 3-Clause BSD from ipywidgets import (Text, VBox, HBox, Label, Password...
normal
{ "blob_id": "22afc6b9df87ef1eba284da20a807366278c24d4", "index": 1343, "step-1": "<mask token>\n\n\ndef rest_api(mode=None):\n \"\"\"\"\"\"\n values = config.read()\n wt_url = Text(value=values['api']['url'], placeholder='Add URL',\n description='API URL:', disabled=False)\n wt_user = Text(val...
[ 2, 3, 4, 5, 6 ]
import unittest import shapely.geometry as gm from alphaBetaLab.abRectangularGridBuilder import abRectangularGridBuilder class testAbRectangularGridBuilder(unittest.TestCase): def getMockHiResAlphaMtxAndCstCellDet(self, posCellCentroids = None): class _mockClass: def __init__(self, posCellCentroids): ...
normal
{ "blob_id": "6175ce6534d44d703df6cdef94fc2b1285e25f49", "index": 2202, "step-1": "<mask token>\n\n\nclass testAbRectangularGridBuilder(unittest.TestCase):\n\n def getMockHiResAlphaMtxAndCstCellDet(self, posCellCentroids=None):\n\n\n class _mockClass:\n\n def __init__(self, posCellCentroids):...
[ 6, 7, 8, 9, 10 ]
from flask import Flask, request, jsonify import sqlite3 from database import Database app = Flask(__name__) db = Database() @app.route('/') def homepage(): argslist = request.args faciltype = argslist.get('facil') facils = [] try: facils = db.getFacilitiesFromFacilityType(facilty...
normal
{ "blob_id": "2424d667e1bb4ee75b5053eb6f9b002787a5317f", "index": 6391, "step-1": "<mask token>\n\n\n@app.route('/')\ndef homepage():\n argslist = request.args\n faciltype = argslist.get('facil')\n facils = []\n try:\n facils = db.getFacilitiesFromFacilityType(faciltype)\n facils = map(l...
[ 2, 6, 7, 8, 9 ]
#n-repeated element class Solution: def repeatedNTimes(self, A): freq = {} for i in A: if i in freq.keys(): freq[i] += 1 else: freq[i] = 1 key = list(freq.keys()) val = list(freq.values()) m = max(val) return key...
normal
{ "blob_id": "d50618f7784e69b46cb665ec1a9c56f7a2867785", "index": 5033, "step-1": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Solution:\n\n def repeatedNTimes(self, A):\n freq = {}\n for i in A:\n if i in freq.keys():\n freq[i] += 1\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> scheme = 'http' hostname = 'localhost' port = 9000 routes = ['/available/2', '/available/4'] <|reserved_special_token_1|> # -*- coding: utf-8 -*- scheme = 'http' hostname = 'localhost' port = 9000 routes = [ '/available/2', '/available/4' ]
flexible
{ "blob_id": "d1402469232b5e3c3b09339849f6899e009fd74b", "index": 3323, "step-1": "<mask token>\n", "step-2": "scheme = 'http'\nhostname = 'localhost'\nport = 9000\nroutes = ['/available/2', '/available/4']\n", "step-3": "# -*- coding: utf-8 -*-\n\n\nscheme = 'http'\n\nhostname = 'localhost'\n\nport = 9000\n\...
[ 0, 1, 2 ]
data = " Ramya , Deepa,LIRIL ,amma, dad, Kiran, 12321 , Suresh, Jayesh, Ramesh,Balu" lst = data.split(",") for name in lst: name = name.strip().upper() rname = name[::-1] if name == rname: print(name) girlsdata = "Tanvi,Dhatri,Haadya,Deepthi,Deepa,Ramya" # Name which start with DEE get those name...
normal
{ "blob_id": "622b388beb56eba85bbb08510c2bcea55f23da9a", "index": 721, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor name in lst:\n name = name.strip().upper()\n rname = name[::-1]\n if name == rname:\n print(name)\n<mask token>\nprint('-' * 20)\n<mask token>\nfor name in names:\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def import_csv_from_aws(): client = boto3.client('s3', aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY) client.download_file('ergast-csv', 'filtered_laptimes.csv', 'filter...
flexible
{ "blob_id": "b573db8ea0845fb947636b8d82ed462904c6005d", "index": 5519, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef import_csv_from_aws():\n client = boto3.client('s3', aws_access_key_id=AWS_ACCESS_KEY_ID,\n aws_secret_access_key=AWS_SECRET_ACCESS_KEY)\n client.download_file('ergas...
[ 0, 1, 2, 3 ]
"""Ex026 Faça um programa que leia uma frase pelo teclado e mostre: Quantas vezes aparece a letra "A". Em que posição ela aparece a primeira vez. Em que posição ela aparece pela última vez.""" frase = str(input('Digite uma frase: ')).strip().lower() n_a = frase.count('a') f_a = frase.find('a')+1 l_a= frase.rfind('a')-1...
normal
{ "blob_id": "58f3b8c5470c765c81f27d39d9c28751a8c2b719", "index": 277, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f'Sua frase tem {n_a} letras a')\nprint(f'A letra A aparece pela primeira vez na {f_a}° posição')\nprint(f'A letra A apaerece pela ultima vez na {l_a}° posição')\n", "step-3": "<ma...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json import codecs import Levenshtein import logging import random from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import cross_val_score import time from sklearn.model_selection import KFold import numpy as np import s...
normal
{ "blob_id": "37804c92b69d366cc1774335b6a2295dfd5b98f3", "index": 6592, "step-1": "<mask token>\n\n\ndef gen_label(uid1, uid2):\n if same_line_dict[uid1].__contains__(uid2) and same_line_dict[uid2\n ].__contains__(uid1):\n return '1'\n else:\n return '-1'\n\n\n<mask token>\n\n\ndef gen_...
[ 2, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def generatetest(n=100, filename='test_data'): ids = [] names_list = [] for _ in range(n): ids.append(''.join(random.choices(string.ascii_letters + string. digits, k=9))) names_list.append...
flexible
{ "blob_id": "aa913fd40a710cfd7288fd59c4039c4b6a5745cc", "index": 4569, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generatetest(n=100, filename='test_data'):\n ids = []\n names_list = []\n for _ in range(n):\n ids.append(''.join(random.choices(string.ascii_letters + string.\n ...
[ 0, 1, 2, 3, 4 ]
import math from historia.utils import unique_id, position_in_range from historia.pops.models.inventory import Inventory from historia.economy.enums.resource import Good, NaturalResource from historia.economy.enums.order_type import OrderType from historia.economy.models.price_range import PriceRange from historia.econ...
normal
{ "blob_id": "887a39f1eeb81e6472938c2451e57866d3ac4a45", "index": 661, "step-1": "<mask token>\n\n\nclass Pop(object):\n <mask token>\n\n def __init__(self, province, pop_job, population):\n \"\"\"\n Creates a new Pop.\n manager (Historia)\n province (SecondaryDivision)\n ...
[ 15, 26, 28, 32, 33 ]
# import necessary modules import cv2 import xlsxwriter import statistics from matplotlib import pyplot as plt import math import tqdm import numpy as np import datetime def getDepths(imgs, img_names, intersectionCoords, stakeValidity, templateIntersections, upperBorder, tensors, actualTensors, intersectionDist, b...
normal
{ "blob_id": "24a538dcc885b37eb0147a1ee089189f11b20f8a", "index": 7945, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getDepths(imgs, img_names, intersectionCoords, stakeValidity,\n templateIntersections, upperBorder, tensors, actualTensors,\n intersectionDist, blobDistTemplate, debug, debu...
[ 0, 1, 2, 3 ]
import discord class Leveling: __slots__ = ('sid', 'channelID', 'message', 'noxpchannelIDs', 'noxproleID', 'remove', 'bot', 'roles') sid: int channelID: int message: str noxpchannelIDs: list[int] noxproleID: int remove: bool roles: list[list] def __init__(self, bot, sid, r...
normal
{ "blob_id": "346df9706dc222f43a77928964cd54e7d999a585", "index": 8052, "step-1": "<mask token>\n\n\nclass Leveling:\n <mask token>\n sid: int\n channelID: int\n message: str\n noxpchannelIDs: list[int]\n noxproleID: int\n remove: bool\n roles: list[list]\n <mask token>\n\n @property...
[ 2, 3, 4, 5 ]
#!/usr/local/bin/python3 from sys import stdin import argparse # Default values alignment = 'l' border = 'none' stretch_factor = '1.0' toprule = '' # Default options custom_header = False standalone = False stretch = False booktabs = False # Parsing command-line options parser = argparse.ArgumentParser('<stdin> | cs...
normal
{ "blob_id": "591ac07e735e08bcafa8274eb1a1547a01261f55", "index": 8430, "step-1": "<mask token>\n\n\ndef rule(type):\n if booktabs:\n if type == 'top':\n return '\\\\toprule'\n if type == 'mid':\n return '\\\\midrule'\n if type == 'bottom':\n return '\\\\bo...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class Individual: <|reserved_special_token_0|> @property def dir(self): """Get the unitary vector of direction. Returns: numpy.ndarray: The unitary vector of direction. """ return unit_vector(normalize_angle(self.angle)) <|res...
flexible
{ "blob_id": "386e491f6b10ca27f513d678c632571c29093ad2", "index": 5825, "step-1": "<mask token>\n\n\nclass Individual:\n <mask token>\n\n @property\n def dir(self):\n \"\"\"Get the unitary vector of direction.\n\n Returns:\n numpy.ndarray: The unitary vector of direction.\n\n ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for line in f: line = line.strip() if len(line) == 0: continue name, *marks = line.split(',') if len(marks) == 0: continue marks = filter(str.isdigit, marks) total = sum(map(int, marks)) ...
flexible
{ "blob_id": "00587de133ee68415f31649f147fbff7e9bf65d5", "index": 3337, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in f:\n line = line.strip()\n if len(line) == 0:\n continue\n name, *marks = line.split(',')\n if len(marks) == 0:\n continue\n marks = filter(str.is...
[ 0, 1, 2, 3 ]
# Python program to count number of digits in a number. # print len(str(input('Enter No.: '))) num = input("Enter no.: ") i = 1 while num / 10: num = num / 10 i += 1 if num < 10: break print i
normal
{ "blob_id": "37748e3dd17f2bdf05bb28b4dfded12de97e37e4", "index": 9619, "step-1": "# Python program to count number of digits in a number.\n\n# print len(str(input('Enter No.: ')))\n\nnum = input(\"Enter no.: \")\n\ni = 1\nwhile num / 10:\n num = num / 10\n i += 1\n if num < 10:\n break\nprint i\n...
[ 0 ]
import requests import tkinter as tk from tkinter.font import Font from time import strptime class Window(tk.Tk): def __init__(self): super().__init__() #取得網路上的資料 res = requests.get('https://flask-robert.herokuapp.com/youbike') jsonObj = res.json() areas = jsonObj['areas'] ...
normal
{ "blob_id": "f9becdb48583423e7bd3730d1cd74a6a016663dc", "index": 1768, "step-1": "<mask token>\n\n\nclass Window(tk.Tk):\n\n def __init__(self):\n super().__init__()\n res = requests.get('https://flask-robert.herokuapp.com/youbike')\n jsonObj = res.json()\n areas = jsonObj['areas']...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def print_all_models(): return models.Sample.objects.all() @sync_to_async def _create_record(name): return models.Sample.objects.create(name=name) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> os.environ.setdefault('DJANGO_SETTINGS_M...
flexible
{ "blob_id": "4afb556ceca89eb90ba800db4f383afad1cd42a5", "index": 3765, "step-1": "<mask token>\n\n\ndef print_all_models():\n return models.Sample.objects.all()\n\n\n@sync_to_async\ndef _create_record(name):\n return models.Sample.objects.create(name=name)\n\n\n<mask token>\n", "step-2": "<mask token>\no...
[ 2, 3, 4, 5, 6 ]
def test_corr_callable_method(self, datetime_series): my_corr = (lambda a, b: (1.0 if (a == b).all() else 0.0)) s1 = Series([1, 2, 3, 4, 5]) s2 = Series([5, 4, 3, 2, 1]) expected = 0 tm.assert_almost_equal(s1.corr(s2, method=my_corr), expected) tm.assert_almost_equal(datetime_series.corr(datetim...
normal
{ "blob_id": "5e68233fde741c0d2a94bf099afb6a91c08e2a29", "index": 6071, "step-1": "<mask token>\n", "step-2": "def test_corr_callable_method(self, datetime_series):\n my_corr = lambda a, b: 1.0 if (a == b).all() else 0.0\n s1 = Series([1, 2, 3, 4, 5])\n s2 = Series([5, 4, 3, 2, 1])\n expected = 0\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [url('^$', SprintListView.as_view(), name='sprint_list'), path('create/', view=CreateSprintView.as_view(), name='create_sprint'), path('modificar/<int:sprint_pk>/', view=UpdateSprintView.as_view(), name='...
flexible
{ "blob_id": "2b1ec422a42af59a048c708f86b686eb0564b51f", "index": 2456, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^$', SprintListView.as_view(), name='sprint_list'),\n path('create/', view=CreateSprintView.as_view(), name='create_sprint'),\n path('modificar/<int:sprint_pk>/'...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class FlowerIdentify(tornado.web.RequestHandler): def get(self): self.render('flower_identify.html') class IdentifyHandler(tornado.websocket.WebSocketHandler): def post(self): dataUrl = self.get_body_argument('image') Orientation = self.get_body_argumen...
flexible
{ "blob_id": "1c3b1776f14a085bec90be11028c87dc47f00293", "index": 1722, "step-1": "<mask token>\n\n\nclass FlowerIdentify(tornado.web.RequestHandler):\n\n def get(self):\n self.render('flower_identify.html')\n\n\nclass IdentifyHandler(tornado.websocket.WebSocketHandler):\n\n def post(self):\n ...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class GenomicArray: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def __init__(self, data_table: Optional[Union[Sequence, pd.DataFrame]], meta_dict: Optional[Mapping]=None): if data_table is None or isinstance(data_...
flexible
{ "blob_id": "0b833276ca10118f2d60e229ff03400b03915958", "index": 2429, "step-1": "<mask token>\n\n\nclass GenomicArray:\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, data_table: Optional[Union[Sequence, pd.DataFrame]],\n meta_dict: Optional[Mapping]=None):\n if dat...
[ 36, 38, 48, 49, 55 ]
from flask import logging from flask_sqlalchemy import SQLAlchemy from passlib.apps import custom_app_context as pwd_context logger = logging.getLogger(__name__) db = SQLAlchemy() # flask-sqlalchemy class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db...
normal
{ "blob_id": "e976f7e423d75f7fc8a3d5cd597bdd9358ae317e", "index": 5243, "step-1": "<mask token>\n\n\nclass User(db.Model):\n __tablename__ = 'users'\n id = db.Column(db.Integer, primary_key=True)\n username = db.Column(db.String(32), index=True)\n password_hash = db.Column(db.String(128))\n\n def h...
[ 11, 13, 15, 16, 17 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> warnings.filterwarnings('ignore') <|reserved_special_token_0|> os.chdir(lib_path) <|reserved_special_token_0|> print(res.summary()) <|reserved_special_token_0|> X0 <|reserved_special_token_0|> b <|reserved_special_token_0|> covid_...
flexible
{ "blob_id": "2060f57cfd910a308d60ad35ebbbf9ffd5678b9c", "index": 3519, "step-1": "<mask token>\n", "step-2": "<mask token>\nwarnings.filterwarnings('ignore')\n<mask token>\nos.chdir(lib_path)\n<mask token>\nprint(res.summary())\n<mask token>\nX0\n<mask token>\nb\n<mask token>\ncovid_actual.loc[:, 'Date':'human...
[ 0, 1, 2, 3, 4 ]
from django.db.models import manager from django.shortcuts import render from django.http import JsonResponse from rest_framework.response import Response from rest_framework.utils import serializer_helpers from rest_framework.views import APIView from rest_framework.pagination import PageNumberPagination from rest_fr...
normal
{ "blob_id": "34536e3112c8791c8f8d48bb6ffd059c1af38e2f", "index": 8978, "step-1": "<mask token>\n\n\nclass StockPagination(PageNumberPagination):\n page_size = 20\n page_size_query_param = 'page_size'\n max_page_size = 500\n\n\nclass StockView(APIView):\n\n def get(self, request, *args, **kwargs):\n ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> @service_marker class TestTrainingDebuggerJob: def _wait_sagemaker_training_rule_eval_status(self, training_job_name, rule_type: str, expected_status: str, wait_periods: int=30, period_length: int=30): return wait_for_status(expected_status, wait_periods, peri...
flexible
{ "blob_id": "6f107d0d0328c2445c0e1d0dd10e51227da58129", "index": 3900, "step-1": "<mask token>\n\n\n@service_marker\nclass TestTrainingDebuggerJob:\n\n def _wait_sagemaker_training_rule_eval_status(self, training_job_name,\n rule_type: str, expected_status: str, wait_periods: int=30,\n period_le...
[ 4, 7, 8, 9, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestComparisonExpression: <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TestComparisonExpression: def test_cmp(self): assert exp.parse('CMP(1, 2)') == {'...
flexible
{ "blob_id": "91959f6621f05b1b814a025f0b95c55cf683ded3", "index": 5856, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestComparisonExpression:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TestComparisonExpression:\n\n def test_cmp(self):\n assert exp.parse('CMP(1, 2)') ...
[ 0, 1, 2, 3 ]
from tensorflow import keras class SkippableSeq(keras.utils.Sequence): def __init__(self, seq): super(SkippableSeq, self).__init__() self.start = 0 self.seq = seq def __iter__(self): return self def __next__(self): res = self.seq[self.start] self.start = (self.start + 1) % len(self) ...
normal
{ "blob_id": "2417dd4f3787742832fec53fec4592165d0fccfc", "index": 9513, "step-1": "<mask token>\n\n\nclass SkippableSeq(keras.utils.Sequence):\n\n def __init__(self, seq):\n super(SkippableSeq, self).__init__()\n self.start = 0\n self.seq = seq\n\n def __iter__(self):\n return se...
[ 9, 10, 11, 12, 13 ]
def find_max(a, b): if a > b: return a return b def find_max_three(a, b, c): return find_max(a, find_max(b, c))
normal
{ "blob_id": "71dc429033b159f6ed806358f2286b4315e842d9", "index": 9617, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_max_three(a, b, c):\n return find_max(a, find_max(b, c))\n", "step-3": "def find_max(a, b):\n if a > b:\n return a\n return b\n\n\ndef find_max_three(a, b, ...
[ 0, 1, 2 ]
# binary search # iterative def Iter_BinarySearch(array,b,e,value): while(b<=e):#pay attention to the judgement! mid=(b+e)/2#floor if (array[mid]<value):#value in [mid,e] b=mid+1 elif (array[mid]>value):#value in [b,mid] e=mid-1 else: print "find ...
normal
{ "blob_id": "f2d7f0b0d27bd43223d0eb6a6279b67968461dad", "index": 9499, "step-1": "# binary search\n\n# iterative\ndef Iter_BinarySearch(array,b,e,value):\n while(b<=e):#pay attention to the judgement!\n mid=(b+e)/2#floor\n if (array[mid]<value):#value in [mid,e]\n b=mid+1\n eli...
[ 0 ]
variable_1 = 100 variable_2 = 500 variable_3 = 222.5 variable_4 = 'Hello' variable_5 = 'world' print(variable_1, variable_2, variable_3, sep=', ') print(variable_4, variable_5, sep=', ', end='!\n') user_age = input('Введите ваш возраст: ') user_name = input('Введите ваше имя: ') print(variable_4 + ', ' + user_name + '!...
normal
{ "blob_id": "12ca9a81574d34d1004ac9ebcb2ee4b31d7171e2", "index": 5623, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(variable_1, variable_2, variable_3, sep=', ')\nprint(variable_4, variable_5, sep=', ', end='!\\n')\n<mask token>\nprint(variable_4 + ', ' + user_name + '! ' + 'Ваш возраст: ' + user...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class CopoChunkedUploadCompleteView(ChunkedUploadCompleteView): do_md5_check = False def get_response_data(self, chunked_upload, request): """ Data for the response. Should return a dictionary-like object. Called *only* if POST is successful. """ ...
flexible
{ "blob_id": "2b7415d86f9157ae55228efdd61c9a9e9920bc5c", "index": 7716, "step-1": "<mask token>\n\n\nclass CopoChunkedUploadCompleteView(ChunkedUploadCompleteView):\n do_md5_check = False\n\n def get_response_data(self, chunked_upload, request):\n \"\"\"\n Data for the response. Should return ...
[ 12, 13, 14, 15, 18 ]
#!/usr/bin/python # encoding: utf-8 # # In case of reuse of this source code please do not remove this copyright. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the Licen...
normal
{ "blob_id": "a7218971b831e2cfda9a035eddb350ecf1cdf938", "index": 17, "step-1": "#!/usr/bin/python\n# encoding: utf-8\n#\n# In case of reuse of this source code please do not remove this copyright.\n#\n#\tThis program is free software: you can redistribute it and/or modify\n#\tit under the terms of the GNU Gener...
[ 0 ]
import unittest import json import os import copy from nested.nested_dict import NestedDict from pprint import pprint class TestNestedDict(unittest.TestCase): @classmethod def setUpClass(cls): path = os.path.dirname(__file__) cls.afile = os.path.join(path, '../nested/data/food_nested_dict.jso...
normal
{ "blob_id": "f9a255a464b5f48a1a8be2e2887db721a92e7f4e", "index": 1474, "step-1": "<mask token>\n\n\nclass TestNestedDict(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_dfood(self):\n self.assertEqual(self.dfood.keys(), [u'0001', u'0002', u'0003'])\n <mask token>\n <mask toke...
[ 3, 6, 8, 10, 12 ]
from collections import namedtuple from os import getenv from pathlib import Path TMP = getenv("TMP", "/tmp") PYBITES_FAKER_DIR = Path(getenv("PYBITES_FAKER_DIR", TMP)) CACHE_FILENAME = "pybites-fake-data.pkl" FAKE_DATA_CACHE = PYBITES_FAKER_DIR / CACHE_FILENAME BITE_FEED = "https://codechalleng.es/api/bites/" BLOG_FE...
normal
{ "blob_id": "7336b8dec95d23cbcebbff2a813bbbd5575ba58f", "index": 2327, "step-1": "<mask token>\n", "step-2": "<mask token>\nTMP = getenv('TMP', '/tmp')\nPYBITES_FAKER_DIR = Path(getenv('PYBITES_FAKER_DIR', TMP))\nCACHE_FILENAME = 'pybites-fake-data.pkl'\nFAKE_DATA_CACHE = PYBITES_FAKER_DIR / CACHE_FILENAME\nBI...
[ 0, 1, 2, 3 ]
v1=int(input("Introdu virsta primei persoane")) v2=int(input("Introdu virsta persoanei a doua")) v3=int(input("Introdu virsta persoanei a treia")) if ((v1>18)and(v1<60)): print(v1) elif((v2>18)and(v2<60)): print(v2) elif((v3>18)and(v3<60)): print(v3)
normal
{ "blob_id": "b8c749052af0061373808addea3ad419c35e1a29", "index": 3324, "step-1": "<mask token>\n", "step-2": "<mask token>\nif v1 > 18 and v1 < 60:\n print(v1)\nelif v2 > 18 and v2 < 60:\n print(v2)\nelif v3 > 18 and v3 < 60:\n print(v3)\n", "step-3": "v1 = int(input('Introdu virsta primei persoane'...
[ 0, 1, 2, 3 ]
from .personal_questions import * from .survey_questions import *
normal
{ "blob_id": "a8f2d527e9824d3986f4bb49c3cc75fd0d999bf7", "index": 3290, "step-1": "<mask token>\n", "step-2": "from .personal_questions import *\nfrom .survey_questions import *\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> def load_norm_file(fname): """Parse the norm file and return the mean system norms""" try: with open(fname, 'r') as fh: lines = fh.readlines() norms = [float(ll.strip().split()[0]) for ll in lines] return norms except: return...
flexible
{ "blob_id": "d03669924233edf33fcb6645f5ed7ab118f54a95", "index": 7610, "step-1": "<mask token>\n\n\ndef load_norm_file(fname):\n \"\"\"Parse the norm file and return the mean system norms\"\"\"\n try:\n with open(fname, 'r') as fh:\n lines = fh.readlines()\n norms = [float(ll.s...
[ 5, 6, 7, 8, 9 ]
import random import numpy as np import torch from utils import print_result, set_random_seed, get_dataset, get_extra_args from cogdl.tasks import build_task from cogdl.datasets import build_dataset from cogdl.utils import build_args_from_dict DATASET_REGISTRY = {} def build_default_args_for_node_classification(da...
normal
{ "blob_id": "2396f7acab95260253c367c62002392760157705", "index": 1236, "step-1": "<mask token>\n\n\ndef build_default_args_for_node_classification(dataset):\n cpu = not torch.cuda.is_available()\n args = {'lr': 0.01, 'weight_decay': 0.0005, 'max_epoch': 1000,\n 'max_epochs': 1000, 'patience': 100, '...
[ 5, 6, 7, 8, 10 ]
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import tempfile from functools import partial import numpy as np import torch from ax.benchmark.benchmark_pr...
normal
{ "blob_id": "52eec56f7f5da8356f61301994f846ef7769f73b", "index": 6189, "step-1": "<mask token>\n\n\nclass JSONStoreTest(TestCase):\n\n def setUp(self):\n self.experiment = get_experiment_with_batch_and_single_trial()\n\n def testJSONEncodeFailure(self):\n self.assertRaises(JSONEncodeError, ob...
[ 7, 10, 12, 14, 18 ]
<|reserved_special_token_0|> def get_datas(): filename = None while True: filename = input('Please enter filename:') if not filename.strip(): print('Filename is empty!') continue if not os.path.exists(filename): print('File is not exists!') ...
flexible
{ "blob_id": "6829f7bcbc1b12500795eec19829ff077502e270", "index": 3260, "step-1": "<mask token>\n\n\ndef get_datas():\n filename = None\n while True:\n filename = input('Please enter filename:')\n if not filename.strip():\n print('Filename is empty!')\n continue\n ...
[ 6, 7, 8, 10, 12 ]
<|reserved_special_token_0|> class RoomView(View): def get(self, request, room_id): try: room = Room.objects.get(id=room_id) rating_list = [field.name for field in Review._meta.get_fields( ) if field.name not in ['id', 'review_user', 'review_room', ...
flexible
{ "blob_id": "cc5b22a0246fcc9feaed6a0663095a6003e6cef1", "index": 6685, "step-1": "<mask token>\n\n\nclass RoomView(View):\n\n def get(self, request, room_id):\n try:\n room = Room.objects.get(id=room_id)\n rating_list = [field.name for field in Review._meta.get_fields(\n ...
[ 6, 7, 8, 9, 10 ]
import sqlalchemy from sqlalchemy.ext.automap import automap_base from sqlalchemy.orm import Session from sqlalchemy import create_engine, func, inspect from flask import Flask, jsonify, render_template, redirect from flask_pymongo import PyMongo from config import mongo_password, mongo_username, sql_username, sql_pass...
normal
{ "blob_id": "15e1ce95398ff155fe594c3b39936d82d71ab9e2", "index": 5015, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n pokemon_data = mongo.db.pokemon.find_one()\n return render_template('index.html', pokemon_data=pokemon_data)\n\n\n@app.route('/stats')\ndef stats():\n session = Session(eng...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2015 RAPP # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at #http://www.apache.org/licenses/LICENSE-2.0 # Unless required by app...
normal
{ "blob_id": "f4e287f5fce05e039c54f1108f6e73020b8d3d8f", "index": 9346, "step-1": "<mask token>\n\n\nclass AsyncHandler(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass AsyncHandler(object):\n <mask token>\n\n def __init__(self, future...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class ncbDB(Pconfig): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def ncb_getQuery(self, querySQL): result = [] try: with self.connect_...
flexible
{ "blob_id": "257a4d0b0c713624ea8452dbfd6c5a96c9a426ad", "index": 8344, "step-1": "<mask token>\n\n\nclass ncbDB(Pconfig):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def ncb_getQuery(self, querySQL):\n result = []\n try:\n with self.co...
[ 4, 7, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> sys.path.append('./Pytorch-UNet/') <|reserved_special_token_0|> if __name__ == '__main__': logger = Logger() torch.backends.cudnn.benchmark = True args = parse_args() logger.update_args(args) if not os.path.exi...
flexible
{ "blob_id": "fbd5c7fa335d6bde112e41a55d15aee31e3ebaf7", "index": 2759, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('./Pytorch-UNet/')\n<mask token>\nif __name__ == '__main__':\n logger = Logger()\n torch.backends.cudnn.benchmark = True\n args = parse_args()\n logger.update_...
[ 0, 1, 2, 3 ]
import sys from collections import deque t = int(sys.stdin.readline().rstrip()) for _ in range(t): n, m = map(int, sys.stdin.readline().split()) q = deque(map(int, sys.stdin.readline().split())) count = 0 while q: highest = max(q) doc = q.popleft() m -= 1 if doc != highes...
normal
{ "blob_id": "a571abd88184c8d8bb05245e9c3ce2e4dabb4c09", "index": 615, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(t):\n n, m = map(int, sys.stdin.readline().split())\n q = deque(map(int, sys.stdin.readline().split()))\n count = 0\n while q:\n highest = max(q)\n ...
[ 0, 1, 2, 3 ]
from platypush.message.response import Response class CameraResponse(Response): pass # vim:sw=4:ts=4:et:
normal
{ "blob_id": "4c38d0487f99cdc91cbce50079906f7336e51482", "index": 5462, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CameraResponse(Response):\n pass\n", "step-3": "from platypush.message.response import Response\n\n\nclass CameraResponse(Response):\n pass\n", "step-4": "from platypu...
[ 0, 1, 2, 3 ]
from core.models import Atom from core.models.vector3d import cVector3D from fractions import Fraction class SpaceGroup(object): def __init__(self, index=None, name=None, lattice_system=None, lattice_centering=None, inversion=Non...
normal
{ "blob_id": "88731049227629ed84ff56922d7ac11d4a137984", "index": 5376, "step-1": "<mask token>\n\n\nclass Centering(object):\n\n def __init__(self, letter, additional_lattice_points):\n self.letter = letter\n self.additional_lattice_points = additional_lattice_points\n\n def transform(self, o...
[ 15, 28, 33, 34, 44 ]
import os import h5py import numpy as np import torch from datasets.hdf5 import get_test_datasets from unet3d import utils from unet3d.config import load_config from unet3d.model import get_model logger = utils.get_logger('UNet3DPredictor') def predict(model, hdf5_dataset, config): """ Return prediction ma...
normal
{ "blob_id": "6fba773025268d724283e510a03d0592282adb0a", "index": 1780, "step-1": "<mask token>\n\n\ndef save_predictions(prediction_maps, output_file, dataset_names):\n \"\"\"\n Saving probability maps to a given output H5 file. If 'average_channels'\n is set to True average the probability_maps across ...
[ 2, 6, 7, 8, 9 ]
<|reserved_special_token_0|> class CompanyInfo(object): def __init__(self): self._alter_list = None self._basic_info = None self._case_info_list = None self._entinv_list = None self._fr_position_list = None self._frinv_list = None self._person_list = None ...
flexible
{ "blob_id": "6743a4f3c9118e790e52b586a36d71a735101702", "index": 1901, "step-1": "<mask token>\n\n\nclass CompanyInfo(object):\n\n def __init__(self):\n self._alter_list = None\n self._basic_info = None\n self._case_info_list = None\n self._entinv_list = None\n self._fr_posi...
[ 14, 18, 19, 20, 22 ]
import pandas as pd import csv import numpy as np import matplotlib.pyplot as plt #import csv file with recorded left, right servo angles and their corresponding roll and pitch values df = pd.read_csv('C:/Users/yuyan.shi/Desktop/work/head-neck/kinematics/tabblepeggy reference tables/mid_servo_angle_2deg_3.csv') ...
normal
{ "blob_id": "fd7961d3a94b53ae791da696bb2024165db8b8fc", "index": 5354, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.scatter(df['left_rel_angle'], df['right_rel_angle'])\nplt.xlabel('Left servo angle(deg)')\nplt.ylabel('Right servo angle(deg)')\nplt.title('Plot of left and right servo values')\nplt....
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class HomePageView(TemplateView): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class HomePageView(TemplateView): template_name = 'base.html' <|reserved_special_token_1|> <|reserved_special_token_0|> def index(request): contex...
flexible
{ "blob_id": "f0a54feaa165a393c4e87cbac2a38347633acf5a", "index": 1425, "step-1": "<mask token>\n\n\nclass HomePageView(TemplateView):\n <mask token>\n", "step-2": "<mask token>\n\n\nclass HomePageView(TemplateView):\n template_name = 'base.html'\n", "step-3": "<mask token>\n\n\ndef index(request):\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('app.root_path===', app.root_path) print('app.static_url_path===', app.static_url_path) app.secret_key('uaremyhero') <|reserved_special_token_0|> Session(app) app.register_blueprint(login.login) app.register_blueprint() <|...
flexible
{ "blob_id": "9d2fdf47b5c4b56cc0177a9c0a86b1ed57c88d49", "index": 4151, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('app.root_path===', app.root_path)\nprint('app.static_url_path===', app.static_url_path)\napp.secret_key('uaremyhero')\n<mask token>\nSession(app)\napp.register_blueprint(login.logi...
[ 0, 1, 2, 3, 4 ]
from page_parsing import get_item_info_from,url_list,item_info,get_links_from # ================================================= < <链接去重 > > ===================================================== # 设计思路: # 1.分两个数据库,第一个用于只用于存放抓取下来的 url (ulr_list);第二个则储存 url 对应的物品详情信息(item_info) # 2.在抓取过程中在第二个数据库中写...
normal
{ "blob_id": "4f2017632d905c80c35fbaead83ecb7e1ac95760", "index": 9868, "step-1": " from page_parsing import get_item_info_from,url_list,item_info,get_links_from\n\n\n # ================================================= < <链接去重 > > =====================================================\n\n # 设计思路:\n # ...
[ 0 ]
import pymongo client = pymongo.MongoClient("mongodb://localhost:27017/") # Database Name db = client["Test"] # Collection Name col = db["C100"] x = col.find_one() print(x)
normal
{ "blob_id": "7d10fb58aa5213516c656c05966fcaad6868ae81", "index": 1548, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(x)\n", "step-3": "<mask token>\nclient = pymongo.MongoClient('mongodb://localhost:27017/')\ndb = client['Test']\ncol = db['C100']\nx = col.find_one()\nprint(x)\n", "step-4": "im...
[ 0, 1, 2, 3, 4 ]
# Databricks notebook source #import and create sparksession object from pyspark.sql import SparkSession spark=SparkSession.builder.appName('rc').getOrCreate() # COMMAND ---------- #import the required functions and libraries from pyspark.sql.functions import * # COMMAND ---------- # Convert csv file to Spark Data...
normal
{ "blob_id": "d22ebe24605065452ae35c44367ee21a726ae7a1", "index": 1892, "step-1": "<mask token>\n\n\ndef loadDataFrame(fileName, fileSchema):\n return spark.read.format('csv').schema(fileSchema).option('header', 'true'\n ).option('mode', 'DROPMALFORMED').csv('/FileStore/tables/%s' % fileName\n )\...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for group in groups: allananswers = set(list('abcdefghijklmnopqrstuvwxyz')) answers = set() people = group.split('\n') for person in people: allananswers = allananswers & set(list(person)) for answe...
flexible
{ "blob_id": "8f1ec65ca60605747f46f596e0b5848922bcd0b5", "index": 2127, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor group in groups:\n allananswers = set(list('abcdefghijklmnopqrstuvwxyz'))\n answers = set()\n people = group.split('\\n')\n for person in people:\n allananswers = a...
[ 0, 1, 2, 3, 4 ]
import os import io import yaml from collections import OrderedDict from rich.console import Console from malwarebazaar.platform import get_config_path, get_config_dir class Config(OrderedDict): instance = None def __init__(self): ec = Console(stderr=True, style="bold red") Config.ensure_pa...
normal
{ "blob_id": "5a9e0b220d2c94aea7e3d67338771cf48c3aec8f", "index": 6439, "step-1": "<mask token>\n\n\nclass Config(OrderedDict):\n <mask token>\n\n def __init__(self):\n ec = Console(stderr=True, style='bold red')\n Config.ensure_path(ec)\n config_file = get_config_path()\n if not...
[ 4, 5, 6, 7, 8 ]
from .ctoybox import Game, State as FrameState, Input import numpy as np from PIL import Image import json from typing import Dict, Any, List, Tuple, Union, Optional def json_str(js: Union[Dict[str, Any], Input, str]) -> str: """ Turn an object into a JSON string -- handles dictionaries, the Input class, and...
normal
{ "blob_id": "c77e320cee90e8210e4c13d854649b15f6e24180", "index": 2798, "step-1": "<mask token>\n\n\nclass Toybox(object):\n <mask token>\n\n def __init__(self, game_name: str, grayscale: bool=True, frameskip: int\n =0, seed: Optional[int]=None, withstate: Optional[dict]=None):\n \"\"\"\n ...
[ 27, 30, 39, 59, 65 ]
import requests url = 'https://item.jd.com/100008348550.html' try: r = requests.get(url) r.raise_for_status() print(r.encoding) r.encoding = r.apparent_encoding print(r.text[:1000]) print(r.apparent_encoding) except: print('error')
normal
{ "blob_id": "0271c45a21047b948946dd76f147692bb16b8bcf", "index": 5378, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n r = requests.get(url)\n r.raise_for_status()\n print(r.encoding)\n r.encoding = r.apparent_encoding\n print(r.text[:1000])\n print(r.apparent_encoding)\nexcept:\n...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> os.chdir(main_dir) <|reserved_special_token_0|> for col in loan_seller_cols: cmbs.drop(columns=col, axis=1, inplace=True) <|reserved_special_token_0|> for key, value in regex_dict.items(): cmbs.columns = [re.sub(key, value...
flexible
{ "blob_id": "eb890c68885cbab032ce9d6f3be3fd7013a2788b", "index": 2140, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.chdir(main_dir)\n<mask token>\nfor col in loan_seller_cols:\n cmbs.drop(columns=col, axis=1, inplace=True)\n<mask token>\nfor key, value in regex_dict.items():\n cmbs.columns = [...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def aitoff_projection(theta, phi): import numpy as np theta = theta - np.pi cos_phi = np.cos(phi) denom = np.sqrt(1 + cos_phi * np.cos(theta / 2)) x = 180 * cos_phi * np.sin(theta / 2) / denom x = x + 180 y = 90 * np.sin(phi) / den...
flexible
{ "blob_id": "0dcf90514543a1ca801e82cd402b3e1002b1f5d0", "index": 9262, "step-1": "<mask token>\n", "step-2": "def aitoff_projection(theta, phi):\n import numpy as np\n theta = theta - np.pi\n cos_phi = np.cos(phi)\n denom = np.sqrt(1 + cos_phi * np.cos(theta / 2))\n x = 180 * cos_phi * np.sin(th...
[ 0, 1, 2 ]
from django.shortcuts import redirect, render from users.models import CustomUser from .models import Profile def profile_page_view(request, username): current_user = request.user user = CustomUser.objects.get(username=username) profile = Profile.objects.get(user=user) if current_user in profile.follow...
normal
{ "blob_id": "3caaa455cda0567b79ae063c777846157839d64f", "index": 8548, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef profile_page_view(request, username):\n current_user = request.user\n user = CustomUser.objects.get(username=username)\n profile = Profile.objects.get(user=user)\n if ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class event_ticket(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_t...
flexible
{ "blob_id": "bddba2fd710829db17c6419878ce535df0aba01c", "index": 2760, "step-1": "<mask token>\n\n\nclass event_ticket(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>...
[ 7, 12, 14, 19, 20 ]
<|reserved_special_token_0|> def mutate_operator(root, nodes, path): candidates = [node for node in nodes.keys() if type(node) in OP_TYPES. keys() and _check_parent_type(node, nodes, OP_PARENT_TYPES)] if len(candidates) == 0: return -1 mut_node = random.choice(candidates) type_idx = OP...
flexible
{ "blob_id": "c0524301a79788aa34a039fc46799021fb45362c", "index": 7141, "step-1": "<mask token>\n\n\ndef mutate_operator(root, nodes, path):\n candidates = [node for node in nodes.keys() if type(node) in OP_TYPES.\n keys() and _check_parent_type(node, nodes, OP_PARENT_TYPES)]\n if len(candidates) == ...
[ 3, 4, 5, 6, 7 ]
__author__ = 'asistente' #from __future__ import absolute_import from unittest import TestCase from selenium import webdriver from selenium.webdriver.common.by import By class FunctionalTest(TestCase): def setUp(self): self.browser = webdriver.Chrome("C:\\chromedriver\\chromedriver.exe") self.b...
normal
{ "blob_id": "fc4cf800c663abf20bfba7fcc1032e09a992641b", "index": 5334, "step-1": "<mask token>\n\n\nclass FunctionalTest(TestCase):\n\n def setUp(self):\n self.browser = webdriver.Chrome('C:\\\\chromedriver\\\\chromedriver.exe')\n self.browser.implicitly_wait(2)\n\n def tearDown(self):\n ...
[ 6, 7, 9, 13, 14 ]
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QGraphicsOpacityEffect, \ QPushButton from PyQt5.QtCore import Qt class ToolBar(QWidget): """ Window for entering parameters """ def __init__(self, parent): super().__init__(parent) self._main_wnd = parent self.setAttribut...
normal
{ "blob_id": "772e2e0a442c1b63330e9b526b76d767646b0c7c", "index": 7819, "step-1": "<mask token>\n\n\nclass ToolBar(QWidget):\n <mask token>\n\n def __init__(self, parent):\n super().__init__(parent)\n self._main_wnd = parent\n self.setAttribute(Qt.WA_StyledBackground, True)\n sel...
[ 3, 5, 6, 9, 10 ]
config_prefix = "<" config_suported_types = ["PNG", "GIF", "JPEG"] config_pattern = "^[A-Za-z0-9_]*$" config_max_storage = int(1E9) config_max_name_length = 20 config_message_by_line = 2 config_max_message_length = 2000 config_max_emote_length = 8*int(1E6) config_pong = """ ,;;;!!!!!;;. :!!!!!!!!!!!!!!; ...
normal
{ "blob_id": "dc2deb7d4c9cc126a6d80435fe9dbc16d6ac8941", "index": 9397, "step-1": "<mask token>\n", "step-2": "config_prefix = '<'\nconfig_suported_types = ['PNG', 'GIF', 'JPEG']\nconfig_pattern = '^[A-Za-z0-9_]*$'\nconfig_max_storage = int(1000000000.0)\nconfig_max_name_length = 20\nconfig_message_by_line = 2\...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): with open('./src/test/predictions.json', 'r') as f: data = json.load(f) total = len(data['label']) google = 0 sphinx = 0 for i in range(len(data['label'])): label = data['label'][i...
flexible
{ "blob_id": "9fc184fe3aa498138138403bef719c59b85b3a80", "index": 4392, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n with open('./src/test/predictions.json', 'r') as f:\n data = json.load(f)\n total = len(data['label'])\n google = 0\n sphinx = 0\n for i in range(l...
[ 0, 1, 2, 3, 4 ]
# Задание 1 # Выучите основные стандартные исключения, которые перечислены в данном уроке. # Задание 2 # Напишите программу-калькулятор, которая поддерживает следующие операции: сложение, вычитание, # умножение, деление и возведение в степень. Программа должна выдавать сообщения об ошибке и # продолжать работу при ввод...
normal
{ "blob_id": "a8341bf422a4d31a83ff412c6aac75e5cb8c5e0f", "index": 5876, "step-1": "<mask token>\n\n\ndef adding(user_list):\n sumnum = 0\n for item in user_list:\n sumnum += item\n return sumnum\n\n\ndef subtraction(user_list):\n subtractnum = user_list[0]\n for item in user_list[1:]:\n ...
[ 3, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> urlpatterns = [path('', views.artifact, name='artifacts'), path( '<int:artifact_id>', views.detail, name='detail'), path('register/', views.register, name='register')] <|reserved_special_token_1|> from django.contrib im...
flexible
{ "blob_id": "9b73037e8af7d4f91261cebf895b68650182fcd5", "index": 2780, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.artifact, name='artifacts'), path(\n '<int:artifact_id>', views.detail, name='detail'), path('register/',\n views.register, name='register')]\n", "st...
[ 0, 1, 2, 3 ]
from xgboost import XGBRegressor from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score import pandas as pd import numpy as np from ghg import GHGPredictor predictor = GHGPredictor() dataset_df = pd.read_csv("db-wheat.csv", index_col=0) # print(dataset_df.iloc[1]) dataset_d...
normal
{ "blob_id": "0ebd3ca5fd29b0f2f2149dd162b37f39668f1c58", "index": 7397, "step-1": "<mask token>\n\n\ndef predict(model, row):\n preds = []\n for perc in range(-10, 11):\n new_row = row.copy()\n row_copy = row.copy()\n new_row = new_row.drop(labels=['Area', 'Year', 'Crop',\n '...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> api_id = '2168275' api_hash = 'e011a9cb95b7e7e153aa5840985fc883' <|reserved_special_token_1|> api_id = "2168275" api_hash = "e011a9cb95b7e7e153aa5840985fc883"
flexible
{ "blob_id": "c6d6fcc242e1b63104a3f3eb788880635257ff4c", "index": 7503, "step-1": "<mask token>\n", "step-2": "api_id = '2168275'\napi_hash = 'e011a9cb95b7e7e153aa5840985fc883'\n", "step-3": "api_id = \"2168275\"\napi_hash = \"e011a9cb95b7e7e153aa5840985fc883\"\n", "step-4": null, "step-5": null, "step-...
[ 0, 1, 2 ]
while True: print("Light Levels:" + input.light_level()) if input.light_level() < 6: light.set_all(light.rgb(255, 0, 255)) elif input.light_level() < 13: light.set_all(light.rgb(255, 0, 0)) else: light.clear()
normal
{ "blob_id": "7277b045f85d58383f26ab0d3299feb166f45e36", "index": 2575, "step-1": "<mask token>\n", "step-2": "while True:\n print('Light Levels:' + input.light_level())\n if input.light_level() < 6:\n light.set_all(light.rgb(255, 0, 255))\n elif input.light_level() < 13:\n light.set_all(...
[ 0, 1, 2 ]
"""empty message Revision ID: 3e4ee9eaaeaa Revises: 6d58871d74a0 Create Date: 2016-07-25 15:30:38.008238 """ # revision identifiers, used by Alembic. revision = '3e4ee9eaaeaa' down_revision = '6d58871d74a0' from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - ...
normal
{ "blob_id": "db49313d2bc8b9f0be0dfd48c6065ea0ab3294cb", "index": 4032, "step-1": "<mask token>\n\n\ndef downgrade():\n op.drop_index(op.f('ix_account_sub_int'), table_name='account')\n op.drop_index(op.f('ix_account_mac'), table_name='account')\n op.drop_index(op.f('ix_account_interface'), table_name='a...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # @Time : 2019/3/5 上午9:55 # @Author : yidxue from src.handler.base.base_handler import BaseHandler from src.utils.tools import read_model from tornado.options import options import os module_path = os.path.abspath(os.path.join(os.curdir)) model_path = os.path.join(module_path, 'model') cl...
normal
{ "blob_id": "a8ae59bb525c52ef852655f0ef1e32d96c8914d6", "index": 1356, "step-1": "<mask token>\n\n\nclass ReloadModelHandler(BaseHandler):\n\n def __init__(self, application, request, **kwargs):\n super(ReloadModelHandler, self).__init__(application, request, **kwargs\n )\n <mask token>\n...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def process_resources(_res_iter): for rows in _res_iter: def process_rows(_rows): for row in _rows: for column in columns: if column in row: del row[column] yield row yield process...
flexible
{ "blob_id": "17b3fb44d9e7a09fe3b807b47bdc0248b6960634", "index": 4022, "step-1": "<mask token>\n\n\ndef process_resources(_res_iter):\n for rows in _res_iter:\n\n def process_rows(_rows):\n for row in _rows:\n for column in columns:\n if column in row:\n ...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> def partition_benthic(reach, runoff, runoff_mass, erosion_mass): from .parameters import soil, stream_channel, benthic try: reach = self.region.flow_file.fetch(reach) q, v, l = reach.q, reach.v, reach.l except AttributeError: return None, None, (None, N...
flexible
{ "blob_id": "5890525b16b42578ac06e7ab2170c5613feea0a5", "index": 6494, "step-1": "<mask token>\n\n\ndef partition_benthic(reach, runoff, runoff_mass, erosion_mass):\n from .parameters import soil, stream_channel, benthic\n try:\n reach = self.region.flow_file.fetch(reach)\n q, v, l = reach.q,...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class TestComponents(unittest.TestCase): def setUp(self): self.cpu = CPU(cycles=5) self.disk = DiskIO(cycles=5) self.network = Network(cycles=5) def test_cpu_length(self): cpu_data = self.cpu.get_data(start=0, stop=1, noise=0.01) self.asse...
flexible
{ "blob_id": "4f54f3e306df3b861124adb4fe544089446e8021", "index": 3453, "step-1": "<mask token>\n\n\nclass TestComponents(unittest.TestCase):\n\n def setUp(self):\n self.cpu = CPU(cycles=5)\n self.disk = DiskIO(cycles=5)\n self.network = Network(cycles=5)\n\n def test_cpu_length(self):\...
[ 4, 5, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def density(arr, ax=None, logx=False, logy=False, bins=25, mode='density', extent=None, contours=[], percentiles=True, relim=True, cmap= DEFAULT_CONT_COLORMAP, shading='auto', vmin=0.0, colorbar=False, **kwargs): """...
flexible
{ "blob_id": "ae475dc95c6a099270cf65d4b471b4b430f02303", "index": 8840, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef density(arr, ax=None, logx=False, logy=False, bins=25, mode='density',\n extent=None, contours=[], percentiles=True, relim=True, cmap=\n DEFAULT_CONT_COLORMAP, shading='auto...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class DynamicVPTree: <|reserved_special_token_0|> def __init__(self, dist_fn, min_tree_size=4): """ :param dist_fn: Metric distance function used for vp-trees :param min_tree_size: Minimum number of nodes to form a tree (extra nodes are stored in a pool un...
flexible
{ "blob_id": "22e6616fb98ecfb256587c3767c7c289decc6bf6", "index": 3049, "step-1": "<mask token>\n\n\nclass DynamicVPTree:\n <mask token>\n\n def __init__(self, dist_fn, min_tree_size=4):\n \"\"\"\n :param dist_fn: Metric distance function used for vp-trees\n :param min_tree_size: Minimu...
[ 4, 6, 9, 11, 12 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def IsContinuous(numbers): if not numbers or len(numbers) < 1: return False numbers.sort() number_of_zero = 0 number_of_gap = 0 for i in range(len(numbers)): if numbers[i] == 0: number_of_zero += 1 small = n...
flexible
{ "blob_id": "68a776d7fccc8d8496a944baff51d2a862fc7d31", "index": 1259, "step-1": "<mask token>\n", "step-2": "def IsContinuous(numbers):\n if not numbers or len(numbers) < 1:\n return False\n numbers.sort()\n number_of_zero = 0\n number_of_gap = 0\n for i in range(len(numbers)):\n ...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def merge(p, n): global vet global aux if n <= 1: return 0 c = merge(p, n // 2) + merge(p + n // 2, n - n // 2) d, a, b = 0, 0, n // 2 while d < n: if a != n // 2 and (b == n or vet[p + a]...
flexible
{ "blob_id": "fe081a422db6b7f10c89179beab852c6b74ec687", "index": 2795, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef merge(p, n):\n global vet\n global aux\n if n <= 1:\n return 0\n c = merge(p, n // 2) + merge(p + n // 2, n - n // 2)\n d, a, b = 0, 0, n // 2\n while d <...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def readimg(dirs, imgname): img = cv2.imread(dirs + imgname) img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) return img def readimg_color(dirs, imgname): img = cv2.imread(dirs + imgname) img = cv2.normalize(img.astype('float'), None, 0.0, 1.0, cv2.NORM_MINMAX) return...
flexible
{ "blob_id": "e08ab06be0957e5e173df798742abc493eac84d0", "index": 6006, "step-1": "<mask token>\n\n\ndef readimg(dirs, imgname):\n img = cv2.imread(dirs + imgname)\n img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)\n return img\n\n\ndef readimg_color(dirs, imgname):\n img = cv2.imread(dirs + imgname)\n ...
[ 9, 11, 14, 15, 16 ]
import pickle import time DECAY = 0.95 DEPTH = 2 def init_cache(g): ''' Initialize simrank cache for graph g ''' g.cache = {} def return_and_cache(g, element, val): ''' Code (and function name) is pretty self explainatory here ''' g.cache[element] = val return val def simrank_impl(g, node1, node2, t, is_wei...
normal
{ "blob_id": "535ee547475fbc2e1c0ee59e3e300beda1489d47", "index": 4215, "step-1": "import pickle\nimport time\nDECAY = 0.95\nDEPTH = 2\n\ndef init_cache(g):\n\t'''\n\tInitialize simrank cache for graph g\n\t'''\n\tg.cache = {}\n\ndef return_and_cache(g, element, val):\n\t'''\n\tCode (and function name) is pretty ...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def make_single_prediction(wav_file, model, is_game): """ Predictions with model that is locally saved :param wav_file: wav-file we want to predict :param model: Trained model for our predictions :return: None "...
flexible
{ "blob_id": "a17c448b068b28881f9d0c89be6037503eca3974", "index": 5700, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef make_single_prediction(wav_file, model, is_game):\n \"\"\" Predictions with model that is locally saved\n\n :param wav_file: wav-file we want to predict\n :param model: T...
[ 0, 1, 2, 3, 4 ]
print("2 + 3 * 4 =") print(2 + 3 * 4) print("2 + (3 * 4) = ") print(2 + (3 * 4))
normal
{ "blob_id": "58d137d614a0d5c11bf4325c1ade13f4f4f89f52", "index": 3184, "step-1": "<mask token>\n", "step-2": "print('2 + 3 * 4 =')\nprint(2 + 3 * 4)\nprint('2 + (3 * 4) = ')\nprint(2 + 3 * 4)\n", "step-3": "print(\"2 + 3 * 4 =\")\nprint(2 + 3 * 4)\n\nprint(\"2 + (3 * 4) = \")\nprint(2 + (3 * 4))\n", "step-...
[ 0, 1, 2 ]
from opengever.propertysheets.assignment import get_document_assignment_slots from opengever.propertysheets.assignment import get_dossier_assignment_slots from opengever.propertysheets.storage import PropertySheetSchemaStorage from plone.restapi.services import Service LISTING_TO_SLOTS = { u'dossiers': get_dossie...
normal
{ "blob_id": "ab352c9431fda19bc21a9f7ffa075303641cca45", "index": 155, "step-1": "<mask token>\n\n\nclass ListingCustomFieldsGet(Service):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ListingCustomFieldsGet(Service):\n <mask token>\n\n def reply(self):\n solr_fields = ...
[ 1, 2, 3, 5, 6 ]
class Pinnwand: def __init__(self): self.__zettel = [] def hefteAn(self, notiz): prio = notiz.count('!') self.__zettel.append((prio, notiz)) <|reserved_special_token_0|> def __str__(self): ausgabe = 'Notizen\n' zettelListe = self.__zettel[:] zettelListe...
flexible
{ "blob_id": "382a3b8bcd07c7098cecf2b770e46dfff50eeb98", "index": 2695, "step-1": "class Pinnwand:\n\n def __init__(self):\n self.__zettel = []\n\n def hefteAn(self, notiz):\n prio = notiz.count('!')\n self.__zettel.append((prio, notiz))\n <mask token>\n\n def __str__(self):\n ...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def parse(query): print('parsing the query...') query = dnf_converter.convert(query) cp_clause_list = [] clause_list = [] for cp in query['$or']: clauses = [] if '$and' in cp: for ...
flexible
{ "blob_id": "999de0965efa3c1fe021142a105dcf28184cd5ba", "index": 43, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse(query):\n print('parsing the query...')\n query = dnf_converter.convert(query)\n cp_clause_list = []\n clause_list = []\n for cp in query['$or']:\n claus...
[ 0, 1, 2, 3 ]
#!/usr/bin/python import serial import time import sys senderId="\x01" receiverId="\x00" #openSerial just opens the serial connection def openSerial(port): #Some configuration for the serial port ser = serial.Serial() ser.baudrate = 300 ser.port = port ser.bytesize = 8 ser.stopbits = 2 ser.open() return ser ...
normal
{ "blob_id": "bf1d54015a9ae529f4fda4fa9b9f7c874ec3b240", "index": 4514, "step-1": "#!/usr/bin/python\n\nimport serial\nimport time\nimport sys\n\nsenderId=\"\\x01\"\nreceiverId=\"\\x00\"\n\n#openSerial just opens the serial connection\ndef openSerial(port):\n\t#Some configuration for the serial port\n\tser = seri...
[ 0 ]
<|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": "ab12468b1da20c896e3578091fd9ba245dcfa0a4", "index": 1350, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('core', '000...
[ 0, 1, 2, 3, 4 ]
# Copyright (c) 2021, Omid Erfanmanesh, All rights reserved. import math import numpy as np import pandas as pd from data.based.based_dataset import BasedDataset from data.based.file_types import FileTypes class DengueInfection(BasedDataset): def __init__(self, cfg, development): super(DengueInfectio...
normal
{ "blob_id": "93ac8a1f795f7809a3e88b56ce90bf1d31706554", "index": 1139, "step-1": "<mask token>\n\n\nclass DengueInfection(BasedDataset):\n <mask token>\n\n def cyclic_encoder(self, col, max_val):\n self.df[col + '_sin'] = np.sin(2 * np.pi * self.df[col] / max_val)\n self.df[col + '_cos'] = np...
[ 16, 18, 22, 25, 33 ]
#!/usr/bin/env python import rospy import numpy as np import time import RPi.GPIO as GPIO from ccn_raspicar_ros.msg import RaspiCarWheel from ccn_raspicar_ros.msg import RaspiCarWheelControl from ccn_raspicar_ros.srv import RaspiCarMotorControl class MotorControl(object): def __init__(self, control_pin=[16, 18,...
normal
{ "blob_id": "2985360c1e2d03c619ea2994c609fdf8c033bebd", "index": 9177, "step-1": "<mask token>\n\n\nclass MotorControl(object):\n <mask token>\n <mask token>\n\n def forward(self, speed=1.0, t=None):\n self.pwm_r1.ChangeDutyCycle(self.r_level * speed)\n self.pwm_r2.ChangeDutyCycle(0)\n ...
[ 5, 11, 13, 15, 18 ]