code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
<|reserved_special_token_0|> def ph_transform_2B(Gamma, bas2B, idx2B, basph2B, idxph2B): dim = len(basph2B) Gamma_ph = np.zeros((dim, dim)) for i1, (a, b) in enumerate(basph2B): for i2, (c, d) in enumerate(basph2B): Gamma_ph[i1, i2] -= Gamma[idx2B[a, d], idx2B[c, b]] return Gamma_p...
flexible
{ "blob_id": "0eb86fc64b74c79cace838e2d71ed92533123229", "index": 9910, "step-1": "<mask token>\n\n\ndef ph_transform_2B(Gamma, bas2B, idx2B, basph2B, idxph2B):\n dim = len(basph2B)\n Gamma_ph = np.zeros((dim, dim))\n for i1, (a, b) in enumerate(basph2B):\n for i2, (c, d) in enumerate(basph2B):\n ...
[ 17, 18, 20, 21, 29 ]
import numpy as np class EdgeListError(ValueError): pass def check_edge_list(src_nodes, dst_nodes, edge_weights): """Checks that the input edge list is valid.""" if len(src_nodes) != len(dst_nodes): raise EdgeListError("src_nodes and dst_nodes must be of same length.") if edge_weights is N...
normal
{ "blob_id": "cdbc7d703da69adaef593e6a505be25d78beb7ce", "index": 7815, "step-1": "<mask token>\n\n\nclass EdgeListError(ValueError):\n pass\n\n\n<mask token>\n\n\nclass AdjacencyMatrixError(ValueError):\n pass\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass EdgeListError(ValueError):\n pass\n...
[ 2, 4, 5, 6, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def extendedEuclid(a, b): """ Preconditions - a and b are both positive integers. Posconditions - The equation for ax+by=gcd(a,b) has been returned where x and y are solved. Input - a : int, b : int Output - ax+by=gcd(a...
flexible
{ "blob_id": "36e5b0f40b8016f39120f839766db0ac518c9bed", "index": 4712, "step-1": "<mask token>\n", "step-2": "def extendedEuclid(a, b):\n \"\"\"\n Preconditions - a and b are both positive integers.\n Posconditions - The equation for ax+by=gcd(a,b) has been returned where\n x and y ...
[ 0, 1, 2 ]
"""Config flow for Philips TV integration.""" from __future__ import annotations from collections.abc import Mapping import platform from typing import Any from haphilipsjs import ConnectionFailure, PairingFailure, PhilipsTV import voluptuous as vol from homeassistant import config_entries, core from homeassistant.c...
normal
{ "blob_id": "515967656feea176e966de89207f043f9cc20c61", "index": 6716, "step-1": "<mask token>\n\n\nclass ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):\n <mask token>\n <mask token>\n\n def __init__(self) ->None:\n \"\"\"Initialize flow.\"\"\"\n super().__init__()\n self._cu...
[ 6, 9, 10, 11, 12 ]
import os from flask import Flask # from flask_login import LoginManager from flask_sqlalchemy import SQLAlchemy # from flask_bcrypt import Bcrypt from flask_wtf.csrf import CSRFProtect app = Flask(__name__) csrf = CSRFProtect(app) # bcrypt = Bcrypt(app) app.config['SECRET_KEY'] = 'v\xf9\xf7\x11\x13\x18\xfaMYp\xed_\x...
normal
{ "blob_id": "24c9b562411a63f0d3f2ee509bb60dafe7fbecd1", "index": 373, "step-1": "<mask token>\n", "step-2": "<mask token>\napp.config.from_object(__name__)\n<mask token>\n", "step-3": "<mask token>\napp = Flask(__name__)\ncsrf = CSRFProtect(app)\napp.config['SECRET_KEY'] = 'vù÷\\x11\\x13\\x18úMYpí_èÉw\\x06\\...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Leaky_Relu(Layer): def forward(self, x): self.x = x.copy() return np.maximum(x, self.x * 0.01) def backprop(self, back_grad): grad = back_grad.copy() grad[self.x < 0] = grad[self.x < 0] * 0.01 return grad class Tanh(Layer): de...
flexible
{ "blob_id": "a5a764586faabb5af58f4649cdd20b6b18236a99", "index": 6080, "step-1": "<mask token>\n\n\nclass Leaky_Relu(Layer):\n\n def forward(self, x):\n self.x = x.copy()\n return np.maximum(x, self.x * 0.01)\n\n def backprop(self, back_grad):\n grad = back_grad.copy()\n grad[se...
[ 19, 29, 32, 34, 38 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(bots.split('\n')) botnet.close() <|reserved_special_token_1|> botnet = open('bots.txt', 'r') bots = botnet.read() print(bots.split('\n')) botnet.close() <|reserved_special_token_1|> botnet = open("bots.txt","r") bots =...
flexible
{ "blob_id": "ea876d903263c907f63b2f37a81f2576345dae62", "index": 7692, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(bots.split('\\n'))\nbotnet.close()\n", "step-3": "botnet = open('bots.txt', 'r')\nbots = botnet.read()\nprint(bots.split('\\n'))\nbotnet.close()\n", "step-4": "botnet = open(\"b...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for _ in range(num_down): img_color = cv2.pyrDown(img_color) for _ in range(num_bilateral): img_color = cv2.bilateralFilter(img_color, d=9, sigmaColor=9, sigmaSpace=7) for _ in range(num_down): img_color = cv2.pyrUp(im...
flexible
{ "blob_id": "16db443642746af4ae45862627baaa9eca54a165", "index": 3138, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(num_down):\n img_color = cv2.pyrDown(img_color)\nfor _ in range(num_bilateral):\n img_color = cv2.bilateralFilter(img_color, d=9, sigmaColor=9, sigmaSpace=7)\nfor _ i...
[ 0, 1, 2, 3, 4 ]
import requests # url="http://www.google.com" # response=requests.get(url) # print(response.status_code) url = "http://icanhazdadjoke.com/" response = requests.get(url, headers={"Accept": "application/json"}) data = response.text print(type(data)) data = response.json() print(data)
normal
{ "blob_id": "f94894e5d3e6a0ff367911c72f4d863ac32c8baa", "index": 1435, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(type(data))\n<mask token>\nprint(data)\n", "step-3": "<mask token>\nurl = 'http://icanhazdadjoke.com/'\nresponse = requests.get(url, headers={'Accept': 'application/json'})\ndata ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def f(A): if len(A) == 1: return 0 else: rightStart = len(A) // 2 leftArray = A[0:rightStart] righArray = A[rightStart:] B, b = count_and_sort(leftArray) C, c = count_and_sort(righArray) D, d = count_and_sort_split(B, C) ...
flexible
{ "blob_id": "b5611c668a40e1735c92d6d00867885023ad713f", "index": 248, "step-1": "<mask token>\n\n\ndef f(A):\n if len(A) == 1:\n return 0\n else:\n rightStart = len(A) // 2\n leftArray = A[0:rightStart]\n righArray = A[rightStart:]\n B, b = count_and_sort(leftArray)\n ...
[ 2, 3, 4, 5 ]
# Copyright (c) 2021 Koichi Sakata from pylib_sakata import init as init # uncomment the follows when the file is executed in a Python console. # init.close_all() # init.clear_all() import os import shutil import numpy as np from control import matlab from pylib_sakata import ctrl from pylib_sakata import plot prin...
normal
{ "blob_id": "ad1aa69f92f104ac8b82aca3c0a64ce3de48b36d", "index": 3847, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Start simulation!')\n<mask token>\nif os.path.exists(figurefolderName):\n shutil.rmtree(figurefolderName)\nos.makedirs(figurefolderName)\n<mask token>\nprint('Common parameters ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class BaseModelApi(TemplateView, ModelFormMixin): def get_template_names(self): prefix = self.request.method if prefix in ['PUT', 'PATCH', 'POST']: prefix = 'form' name = self.model return [f'{name}/{name}_{prefix}.html'] <|reserved_spe...
flexible
{ "blob_id": "a63e5186c0eb8b5ae8510b473168db3461166513", "index": 7784, "step-1": "<mask token>\n\n\nclass BaseModelApi(TemplateView, ModelFormMixin):\n\n def get_template_names(self):\n prefix = self.request.method\n if prefix in ['PUT', 'PATCH', 'POST']:\n prefix = 'form'\n na...
[ 14, 15, 21, 25, 26 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> after_process.head(5) after_process.to_csv(path_or_buf= 'E:\\Thesis Content\\ukdale CSV\\Without Noise\\Tvday.csv', sep=',', index_label='date') <|reserved_special_token_1|> <|reserved_special_token_0|> data = pd.read_c...
flexible
{ "blob_id": "19c0c3156488ce99316ce40f32e84e476b7afdac", "index": 2754, "step-1": "<mask token>\n", "step-2": "<mask token>\nafter_process.head(5)\nafter_process.to_csv(path_or_buf=\n 'E:\\\\Thesis Content\\\\ukdale CSV\\\\Without Noise\\\\Tvday.csv', sep=',',\n index_label='date')\n", "step-3": "<mask ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def main(): print('##############################') response = requests.get( 'http://www.muenchen.de/rathaus/Serviceangebote/familie/kinderbetreuung/corona.html#geschlossene-kitas-oder-kitagruppen-_6' , headers=headers) soup = BeautifulSoup(response.text, 'lxml...
flexible
{ "blob_id": "5a4a014d07cf312f148e089ea43484f663ce32bc", "index": 8586, "step-1": "<mask token>\n\n\ndef main():\n print('##############################')\n response = requests.get(\n 'http://www.muenchen.de/rathaus/Serviceangebote/familie/kinderbetreuung/corona.html#geschlossene-kitas-oder-kitagrupp...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class OneCycleScheduler(Callback): <|reserved_special_token_0|> def __init__(self, lr_max, steps, mom_min=0.85, mom_max=0.95, phase_1_pct=0.3, div_factor=25.0): super(OneCycleScheduler, self).__init__() lr_min = lr_max / div_factor final_lr = lr_ma...
flexible
{ "blob_id": "056235f8f65a3d6a310ee8a8742c1369b5398f28", "index": 7749, "step-1": "<mask token>\n\n\nclass OneCycleScheduler(Callback):\n <mask token>\n\n def __init__(self, lr_max, steps, mom_min=0.85, mom_max=0.95,\n phase_1_pct=0.3, div_factor=25.0):\n super(OneCycleScheduler, self).__init_...
[ 7, 11, 15, 16, 19 ]
# -*- coding: utf-8 -*- """ :Author: Dominic Hunt """ import numpy as np import logging import itertools import copy import types import utils class FitSubsetError(Exception): pass class ActionError(Exception): pass class StimuliError(Exception): pass class FitSim(object)...
normal
{ "blob_id": "1d5db3db319e67e050036e718bbe0c538365d229", "index": 1976, "step-1": "<mask token>\n\n\nclass FitSim(object):\n <mask token>\n\n def __init__(self, participant_choice_property='Actions',\n participant_reward_property='Rewards', model_fitting_variable=\n 'ActionProb', task_stimuli_...
[ 12, 15, 16, 17, 19 ]
<|reserved_special_token_0|> @pytest.fixture(scope='session', autouse=True) def stop(request): global fixture def finalizer(): fixture.session.ensure_logout() fixture.destroy() request.addfinalizer(finalizer) return fixture <|reserved_special_token_0|> def pytest_generate_tests(me...
flexible
{ "blob_id": "0c0fb3bfb81be5ef6a60584eafeefec61f171679", "index": 9124, "step-1": "<mask token>\n\n\n@pytest.fixture(scope='session', autouse=True)\ndef stop(request):\n global fixture\n\n def finalizer():\n fixture.session.ensure_logout()\n fixture.destroy()\n request.addfinalizer(finalize...
[ 4, 5, 6, 7, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if word[0].islower(): print('{}{}'.format(word[0].upper(), word[1:])) sys.exit() else: print(word) sys.exit() <|reserved_special_token_1|> <|reserved_special_token_0|> word = input() if word[0].islower(): pr...
flexible
{ "blob_id": "227e78312b5bad85df562b6ba360de352c305e7b", "index": 3913, "step-1": "<mask token>\n", "step-2": "<mask token>\nif word[0].islower():\n print('{}{}'.format(word[0].upper(), word[1:]))\n sys.exit()\nelse:\n print(word)\n sys.exit()\n", "step-3": "<mask token>\nword = input()\nif word[0...
[ 0, 1, 2, 3 ]
from django import forms from .models import BlogPost class BlogPostForm(forms.ModelForm): class Meta: model = BlogPost fields = '__all__'
normal
{ "blob_id": "c4624425f57211e583b5fbaec3943539ce6fea6f", "index": 88, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BlogPostForm(forms.ModelForm):\n\n\n class Meta:\n model = BlogPost\n fields = '__all__'\n", "step-3": "from django import forms\nfrom .models import BlogPost\n...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def send(user_id, input_text, api_key=None): if not api_key: api_key = default_api_key msg = {'reqType': 0, 'perception': {'inputText': {'text': input_text}, 'selfInfo': {'location': {'city': '北京', 'province': '北京'}}}, 'userInfo': {'apiKey': api_key, 'userI...
flexible
{ "blob_id": "15539d824490b7ae4724e7c11949aa1db25ecab2", "index": 5112, "step-1": "<mask token>\n\n\ndef send(user_id, input_text, api_key=None):\n if not api_key:\n api_key = default_api_key\n msg = {'reqType': 0, 'perception': {'inputText': {'text': input_text},\n 'selfInfo': {'location': {'...
[ 2, 3, 4, 5, 6 ]
import os from logzero import logger as log from extract import data_generator from transform import create_dataframe def bigquery( datafile, dataset=os.environ["BQDATASET"], project=os.environ["GCPPROJECT"], schema=[ {"name": "conversation", "type": "STRING"}, {"name": "id", "type": ...
normal
{ "blob_id": "d6046217308745b85455aed78734700b9622782c", "index": 7559, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef bigquery(datafile, dataset=os.environ['BQDATASET'], project=os.environ[\n 'GCPPROJECT'], schema=[{'name': 'conversation', 'type': 'STRING'}, {\n 'name': 'id', 'type': 'INTEG...
[ 0, 1, 2, 3 ]
import jiml.cli def write_file(path, text): path.write_text(text) return path def test_argparse(tmp_path): tmpl = write_file(tmp_path / 't.yaml', 'key: {{ var }}') inp = write_file(tmp_path / 'i.json', '{"var": "Hello!"}') out = tmp_path / 'o.json' jiml.cli.main(jiml.cli.parse_args( ...
normal
{ "blob_id": "700d35f9e941fe9325821a377ec1ca1c245ddaec", "index": 176, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef write_file(path, text):\n path.write_text(text)\n return path\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef write_file(path, text):\n path.write_text(text)\n ...
[ 0, 1, 2, 3, 4 ]
import constants from auth.storage import Storage from utils import create_error_with_status from flask import jsonify, request, current_app def register_user(): try: email = request.json["email"] password = request.json["password"] except KeyError: status = constants.statuses["user"...
normal
{ "blob_id": "73a4b3497952f90029ba24b73b835de53fc687ec", "index": 3349, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef register_user():\n try:\n email = request.json['email']\n password = request.json['password']\n except KeyError:\n status = constants.statuses['user']['...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class KdTree: <|reserved_special_token_0|> def __init__(self): self.root = None def create(self, X, dimensions=None): """ create a kd-tree on data X. :param X: shape is (n_samples, n_features). :param dimensions: the max number of feat...
flexible
{ "blob_id": "2f16c74e51789dd06bfc1fe1c6173fa5b0ac38cd", "index": 4747, "step-1": "<mask token>\n\n\nclass KdTree:\n <mask token>\n\n def __init__(self):\n self.root = None\n\n def create(self, X, dimensions=None):\n \"\"\"\n create a kd-tree on data X.\n :param X: shape is (n...
[ 6, 7, 10, 12, 13 ]
from django.utils.html import strip_tags from rest_framework import serializers from home.models import * class SliderSerializer(serializers.ModelSerializer): class Meta: model = Slider fields = "__all__" class CategorySerializer(serializers.ModelSerializer): class Meta: model = Cate...
normal
{ "blob_id": "b8fa36ed3587511e0c64f0ffc87ea6e7857725d7", "index": 4595, "step-1": "<mask token>\n\n\nclass ProductSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Product\n fields = '__all__'\n\n def to_representation(self, instance):\n data = super().to_representati...
[ 5, 6, 8, 9, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SignupAliasForm(forms.Form): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SignupAliasForm(forms.Form): alias = forms.CharField(m...
flexible
{ "blob_id": "953186a330ae9dff15c037b556746590d748c7ad", "index": 4974, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SignupAliasForm(forms.Form):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass SignupAliasForm(forms.Form):\n alias = forms.CharField(max_length=20...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def parse_file(file_in, file_out): ptrFile_in = open(file_in, 'r') ptrFile_out = open(file_out, 'w', encoding='utf-8') cleanLines = [] for line in ptrFile_in: cleanLine = {} line = line.rstrip() if line != '': try: decode...
flexible
{ "blob_id": "e3afaabc1f7f64b9189fc88dd478ed75e81f35e1", "index": 4564, "step-1": "<mask token>\n\n\ndef parse_file(file_in, file_out):\n ptrFile_in = open(file_in, 'r')\n ptrFile_out = open(file_out, 'w', encoding='utf-8')\n cleanLines = []\n for line in ptrFile_in:\n cleanLine = {}\n l...
[ 1, 2, 3, 4, 5 ]
from base.SpellingDictionary import SpellingDictionary from datastructure.trie import NeedMore class WordFinder: def __init__(self): self.spellingDictionary = SpellingDictionary() #self.dictionary.add(["toad", "to", "do", "dot"]) self.spellingDictionary.populateDictionary() pr...
normal
{ "blob_id": "3be3edbecfbb602d4c4a853f006a3a6f4b992fd3", "index": 1728, "step-1": "from base.SpellingDictionary import SpellingDictionary\r\nfrom datastructure.trie import NeedMore\r\nclass WordFinder:\r\n def __init__(self):\r\n self.spellingDictionary = SpellingDictionary()\r\n #self.dictionary...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for r, d, files in os.walk(root): if files != []: for i in files: fp = os.path.join(r, i) label = i.split('_')[0] dst = os.path.join(save_path, label) if not os.path.exis...
flexible
{ "blob_id": "cc19ff829cc4a11c3dc873353fa2194ec9a87718", "index": 8584, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor r, d, files in os.walk(root):\n if files != []:\n for i in files:\n fp = os.path.join(r, i)\n label = i.split('_')[0]\n dst = os.path.join(s...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def setParser(htmlParser='html5lib'): global _html_parser _html_parser = htmlParser def discoverEndpoint(domain, endpoint, content=None, look_in={'name': 'link'}, test_urls=True, validateCerts=True): """Find the given endpoint for the given domain. Only scan html ele...
flexible
{ "blob_id": "1bb82a24faed6079ec161d95eff22aa122295c13", "index": 3982, "step-1": "<mask token>\n\n\ndef setParser(htmlParser='html5lib'):\n global _html_parser\n _html_parser = htmlParser\n\n\ndef discoverEndpoint(domain, endpoint, content=None, look_in={'name':\n 'link'}, test_urls=True, validateCerts=...
[ 2, 5, 6, 7, 8 ]
<|reserved_special_token_0|> class DataSet(object): <|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_token_0|> ...
flexible
{ "blob_id": "c931d1ac5c2d003a8eaac3c6d777ce408df57117", "index": 8534, "step-1": "<mask token>\n\n\nclass DataSet(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def genera_datos(self) ->None:\n ...
[ 3, 4, 6, 8, 9 ]
<|reserved_special_token_0|> class Parser: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def get_description(self, id_str, headers): link = ('https://api.joom.com/1.1/products/' + id_str + '?language=ru-RU&currency=RUB') res = reque...
flexible
{ "blob_id": "00c6899b9d49cbbd0f1980eada77ad91562211a0", "index": 4471, "step-1": "<mask token>\n\n\nclass Parser:\n <mask token>\n <mask token>\n <mask token>\n\n def get_description(self, id_str, headers):\n link = ('https://api.joom.com/1.1/products/' + id_str +\n '?language=ru-RU...
[ 2, 3, 4, 5, 6 ]
# coding: utf-8 import sys from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand from flask_assets import ManageAssets from app import app from assets import assets from db import db from .changepassword import ChangePassword from .create_superuser import SuperUserCommand from ....
normal
{ "blob_id": "c331802cf5a09bc8db8ddbfa37636a01cf73684e", "index": 2626, "step-1": "<mask token>\n\n\nclass MyMan(Manager):\n\n def run(self, commands=None, default_command=None):\n \"\"\"\n Prepares manager to receive command line input. Usually run\n inside \"if __name__ == \"__main__\" b...
[ 2, 3, 4, 5, 6 ]
# Generated by Django 2.2.7 on 2019-11-22 21:09 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('Product', '0003_productimage'), ] operations = [ migrations.RemoveField( model_name='productimage', name='comm...
normal
{ "blob_id": "a3382c3e6e04ccb87b1d55f072ce959b137f9fdd", "index": 5722, "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 = [('Product', '...
[ 0, 1, 2, 3, 4 ]
import datetime now = datetime.datetime.now() print(now.year, now.month, now.day, now.hour, now.minute, now.second)
normal
{ "blob_id": "3af91de0b25f575ec9d981d7711c710a7e9695e4", "index": 6819, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(now.year, now.month, now.day, now.hour, now.minute, now.second)\n", "step-3": "<mask token>\nnow = datetime.datetime.now()\nprint(now.year, now.month, now.day, now.hour, now.minut...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def f(w, b, x): return 1.0 / (1.0 + np.exp(-(w * x + b))) def error(w, b): err = 0.0 for x, y in zip(X, Y): fx = f(w, b, x) err += 0.5 * (fx - y) ** 2 return err def grad_b(w, b, x, y): fx = f(w, b, x) return (fx - y) * fx * (1 - fx) def grad_...
flexible
{ "blob_id": "2387856757ad1c3ff911cf2a7537ca6df7786997", "index": 9244, "step-1": "<mask token>\n\n\ndef f(w, b, x):\n return 1.0 / (1.0 + np.exp(-(w * x + b)))\n\n\ndef error(w, b):\n err = 0.0\n for x, y in zip(X, Y):\n fx = f(w, b, x)\n err += 0.5 * (fx - y) ** 2\n return err\n\n\ndef...
[ 5, 6, 7, 8, 9 ]
from django.db import models from django.utils.text import slugify # Create your models here. class SponsorType(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name class Sponsor(models.Model): type = models.ForeignKey(SponsorType, on_delete=models.CASCADE, ...
normal
{ "blob_id": "81f0119f6f348f6d33e8d22f588fc8c2e0593d3c", "index": 1536, "step-1": "<mask token>\n\n\nclass SponsorType(models.Model):\n <mask token>\n <mask token>\n\n\nclass Sponsor(models.Model):\n type = models.ForeignKey(SponsorType, on_delete=models.CASCADE, null=True)\n id = models.AutoField(pri...
[ 5, 6, 7, 8, 9 ]
import sys N = int(input()) card = [int(x+1) for x in range(N)] trash = [] while len(card)>1: topCard = card.pop(0) trash.append(topCard) card.append(card.pop(0)) outputStr = "" for i in range(len(trash)): outputStr += str(trash[i]) + " " outputStr += str(card[0]) print(outputStr)
normal
{ "blob_id": "90e475dfd128689dd4e1a5375ced6e4cbfb73c07", "index": 7860, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile len(card) > 1:\n topCard = card.pop(0)\n trash.append(topCard)\n card.append(card.pop(0))\n<mask token>\nfor i in range(len(trash)):\n outputStr += str(trash[i]) + ' '\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @app.route('/') def index(): return render_template('login.html') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.route('/') def index(): return render_template('login.html') @app.route('/login', methods=['POST', 'GET']) def log...
flexible
{ "blob_id": "82f8bfd95fea3025bed2b4583c20526b0bd5484f", "index": 3535, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('login.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('login.html')\n\n\n@app.route(...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def parse_args(): """ Parse input arguments. :return: """ parser = argparse.ArgumentParser(description='以图搜图API测试') parser.add_argument('--ak', dest='access_key', help= 'access_key for qiniu accou...
flexible
{ "blob_id": "c7147741784b37b42200869002d4df5ddc900675", "index": 2001, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_args():\n \"\"\"\n Parse input arguments.\n :return:\n \"\"\"\n parser = argparse.ArgumentParser(description='以图搜图API测试')\n parser.add_argument('--ak', des...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> RAVEN_CONFIG = {} ALLOWED_HOSTS = ['*'] <|reserved_special_token_1|> from .base import * RAVEN_CONFIG = {} ALLOWED_HOSTS = ['*']
flexible
{ "blob_id": "eee60a6f46549ededfbc7b0b294ab723e2e73f7e", "index": 4490, "step-1": "<mask token>\n", "step-2": "<mask token>\nRAVEN_CONFIG = {}\nALLOWED_HOSTS = ['*']\n", "step-3": "from .base import *\nRAVEN_CONFIG = {}\nALLOWED_HOSTS = ['*']\n", "step-4": null, "step-5": null, "step-ids": [ 0, ...
[ 0, 1, 2 ]
from sense_hat import SenseHat import time import random #Set game_mode to True for single roll returning value #False for demonstration purposes class ElectronicDie: def __init__(self, mode): self.game_mode = mode sense = SenseHat() #Colours O = (0,0,0) B = (0, 0, 255) #Settings #...
normal
{ "blob_id": "edfad88c837ddd3bf7cceeb2f0b1b7a5356c1cf7", "index": 8998, "step-1": "<mask token>\n\n\nclass ElectronicDie:\n\n def __init__(self, mode):\n self.game_mode = mode\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ...
[ 4, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- from datetime import datetime, timedelta import math import re import copy from lcs import lcs # Create your models here. keywords=["int","long","for","while","if","else","break","continue","return","true","false","double","do","signed","unsigned"] symbol=["[","]","{","}","(",")","&","|","^",...
normal
{ "blob_id": "ebd510bcd0caded03c5bcc36a11945710d5e644b", "index": 5591, "step-1": "# -*- coding: utf-8 -*-\n\nfrom datetime import datetime, timedelta\nimport math\nimport re\nimport copy\nfrom lcs import lcs\n# Create your models here.\n\n\nkeywords=[\"int\",\"long\",\"for\",\"while\",\"if\",\"else\",\"break\",\...
[ 0 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __copyright__ = """ This code is licensed under the MIT license. Copyright University Innsbruck, Institute for General, Inorganic, and Theoretical Chemistry, Podewitz Group See LICENSE for details """ from scipy.signal import argrelextrema from typing import List, Tuple i...
normal
{ "blob_id": "8c42e06fd92f0110b3ba8c4e7cc0ac45b9e44378", "index": 3150, "step-1": "<mask token>\n\n\nclass ButtonActions(object):\n <mask token>\n\n def plot_rdf(self, display):\n matplotlib.rcParams.update({'font.size': 10})\n self.fig = plt.figure(figsize=(display.width, display.height))\n ...
[ 3, 8, 9, 10, 11 ]
from collections import OrderedDict import copy import numpy as np from scipy.optimize import curve_fit from ... import Operation as opmod from ...Operation import Operation from ....tools import saxstools class SpectrumFit(Operation): """ Use a measured SAXS spectrum (I(q) vs. q), to optimize the param...
normal
{ "blob_id": "7b5713c9a5afa911df1c2939751de30412162f15", "index": 446, "step-1": "<mask token>\n\n\nclass SpectrumFit(Operation):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass SpectrumFit(Operation):\n <mask token>\n\n def __init__(self):\n input_names...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class GetPlanningSceneResponse(genpy.Message): _md5sum = '285525c9abe002fbafa99af84a14b4cb' _type = 'arm_navigation_msgs/GetPlanningSceneResponse' _has_header = False _full_text = """ PlanningScene planning_scene ======================================================...
flexible
{ "blob_id": "b8e18877af990c533c642d4937354198a4676419", "index": 5194, "step-1": "<mask token>\n\n\nclass GetPlanningSceneResponse(genpy.Message):\n _md5sum = '285525c9abe002fbafa99af84a14b4cb'\n _type = 'arm_navigation_msgs/GetPlanningSceneResponse'\n _has_header = False\n _full_text = \"\"\"\n\nPla...
[ 10, 14, 18, 20, 21 ]
<|reserved_special_token_0|> class PresentationAdmin(admin.ModelAdmin): <|reserved_special_token_0|> model = Presentation actions = [export_scholars] raw_id_fields = 'user', 'updated_by', 'leader' list_max_show_all = 500 list_per_page = 500 list_display = ('title', 'reviewer', 'last_name',...
flexible
{ "blob_id": "1ae69eaaa08a0045faad13281a6a3de8f7529c7a", "index": 9761, "step-1": "<mask token>\n\n\nclass PresentationAdmin(admin.ModelAdmin):\n <mask token>\n model = Presentation\n actions = [export_scholars]\n raw_id_fields = 'user', 'updated_by', 'leader'\n list_max_show_all = 500\n list_pe...
[ 7, 9, 11, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> #!/usr/bin/python # -*- coding: utf-8 -*- """ @project= Life_is_short_you_need_python @file= judgement @author= wubingyu @create_time= 2017/12/21 下午2:58 """ #a if condition else b #(falseValue,trueValue)[test] #(falseValue,trueValue)[test==True] #(falseValue...
flexible
{ "blob_id": "73e23b3560294ca24428e7dd4cc995b97767335c", "index": 4202, "step-1": "<mask token>\n", "step-2": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\"\"\"\n@project= Life_is_short_you_need_python\n@file= judgement\n@author= wubingyu\n@create_time= 2017/12/21 下午2:58\n\"\"\"\n\n#a if condition else b\n#(fa...
[ 0, 1 ]
def add(a, b): print "ADDING %d + %d" % (a, b) return a + b def subtract(a, b): print "SUBTRACTING %d - %d" %(a, b) return a - b def multipy(a, b): print "MULTIPLYING %d * %d" % (a, b) return a * b def divide(a, b): print "DIVIDING %d / %d" % (a, b) return a / b print "Let's do some...
normal
{ "blob_id": "b4b80e40d12486881e37dd7ddeeef9c76417ebd9", "index": 5906, "step-1": "def add(a, b):\n print \"ADDING %d + %d\" % (a, b)\n return a + b\n\ndef subtract(a, b):\n print \"SUBTRACTING %d - %d\" %(a, b)\n return a - b\n\ndef multipy(a, b):\n print \"MULTIPLYING %d * %d\" % (a, b)\n retu...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def _preserve_tag_on_taxes(cr, registry): preserve_existing_tags_on_taxes(cr, registry, 'l10n_lb') env = api.Environment(cr, SUPERUSER_ID, {}) accounts = env['account.account'].search([('code', 'in', ['5301', ...
flexible
{ "blob_id": "74b38599dd793282612a468a760f6301b9f039d6", "index": 9878, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef _preserve_tag_on_taxes(cr, registry):\n preserve_existing_tags_on_taxes(cr, registry, 'l10n_lb')\n env = api.Environment(cr, SUPERUSER_ID, {})\n accounts = env['account.a...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def maximization(X, g): """ Returns: pi, m, S, or None, None, None on failure """ if type(X) is not np.ndarray or len(X.shape) != 2: return None, None, None if type(g) is not np.ndarray or len(g.shape...
flexible
{ "blob_id": "a55daebd85002640db5e08c2cf6d3e937b883f01", "index": 1611, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef maximization(X, g):\n \"\"\"\n Returns: pi, m, S, or None, None, None on failure\n \"\"\"\n if type(X) is not np.ndarray or len(X.shape) != 2:\n return None, No...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def filter_lines(in_filename, in_filename2, out_filename): """Read records from in_filename and write records to out_filename if the beginning of the line (taken up to the first comma at or after position 11) is found in keys (which must be a set ...
flexible
{ "blob_id": "502e0f0c6376617dc094fcdd47bea9773d011864", "index": 900, "step-1": "<mask token>\n", "step-2": "def filter_lines(in_filename, in_filename2, out_filename):\n \"\"\"Read records from in_filename and write records to out_filename if\n the beginning of the line (taken up to the first comma at or...
[ 0, 1, 2, 3, 4 ]
import boto3 import jinja2 import markdown # Instantiate S3 client s3_client = boto3.client('s3') # HTML style template TEMPLATE = """<!DOCTYPE html> <html> <head> <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css" rel="stylesheet"> <style> body { ...
normal
{ "blob_id": "3df57059539e5e3579c6dbee6be288e04b5f93b5", "index": 3400, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lambda_handler(event, context):\n for record in event['Records']:\n bucket = record['s3']['bucket']['name']\n key = record['s3']['object']['key']\n output_...
[ 0, 1, 2, 3, 4 ]
a=[[*map(int,input().split())]for _ in range(int(input()))] a.sort() s=0 l0,h0=a[0] for l,h in a: if h0<h:s+=(l-l0)*h0;l0,h0=l,h l1,h1=a[-1] for l,h in a[::-1]: if h>h1:s+=(l1-l)*h1;l1,h1=l,h s+=(l1-l0+1)*h1 print(s)
normal
{ "blob_id": "62dab85b7ab5fdae8117827b2f56bccf99615cb7", "index": 7341, "step-1": "<mask token>\n", "step-2": "<mask token>\na.sort()\n<mask token>\nfor l, h in a:\n if h0 < h:\n s += (l - l0) * h0\n l0, h0 = l, h\n<mask token>\nfor l, h in a[::-1]:\n if h > h1:\n s += (l1 - l) * h1\n...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Testing(unittest.TestCase): def test_creation(self): x = userinput.UserInput() self.assertNotEqual(x, None) def test_charset_initialization(self): x = userinput.UserInput() self.assertEqual(x.character_set, userinput.CHARACTERS) def tes...
flexible
{ "blob_id": "4745d81558130440d35d277b586572f5d3f85c06", "index": 7366, "step-1": "<mask token>\n\n\nclass Testing(unittest.TestCase):\n\n def test_creation(self):\n x = userinput.UserInput()\n self.assertNotEqual(x, None)\n\n def test_charset_initialization(self):\n x = userinput.UserI...
[ 4, 5, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> django.version <|reserved_special_token_1|> import django django.version <|reserved_special_token_1|> # Mezzanine Django Framework createdb error on Max OSX 10.9.2 import django django.version
flexible
{ "blob_id": "56afde2a31ad9dddee35e84609dff2eb0fc6fe1a", "index": 9438, "step-1": "<mask token>\n", "step-2": "<mask token>\ndjango.version\n", "step-3": "import django\ndjango.version\n", "step-4": "# Mezzanine Django Framework createdb error on Max OSX 10.9.2\nimport django\ndjango.version\n", "step-5":...
[ 0, 1, 2, 3 ]
import pytest import numpy as np from dwave_qbsolv import QBSolv from src.quantumrouting.solvers import partitionqubo from src.quantumrouting.types import CVRPProblem from src.quantumrouting.wrappers.qubo import wrap_vrp_qubo_problem @pytest.fixture def cvrp_problem(): max_num_vehicles = 1 coords = [[-15.6570...
normal
{ "blob_id": "f61e9e8069a0e90506c2f03a0cc4a25a16d71b85", "index": 3732, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.fixture\ndef cvrp_problem():\n max_num_vehicles = 1\n coords = [[-15.6570138544452, -47.802664728268745], [-15.65879313293694,\n -47.7496622016347], [-15.65144038...
[ 0, 1, 2, 3 ]
# Generated by Django 3.2.1 on 2021-05-17 18:02 import django.contrib.auth.models from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ('auth', '0012_alter_user_first_name_max_length'), ] operations...
normal
{ "blob_id": "7ce471b3a6966c1a60ae2e2f3ec42369fe3d0f9c", "index": 6377, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
import cv2 import numpy as np from matplotlib import pyplot as plt import glob def des_match(des_l,des_q): bf=cv2.BFMatcher(cv2.NORM_L2,crossCheck=True) matches=bf.match(des_l,des_q) matches = sorted(matches,key=lambda x:x.distance) return matches def check_match(matches,threshold,txt): count=0 if (matches...
normal
{ "blob_id": "4bc61ae2fe6453819a5bbf9cf05976f7800fa7c1", "index": 4420, "step-1": "import cv2\nimport numpy as np \nfrom matplotlib import pyplot as plt\nimport glob\n\n\n\n\ndef des_match(des_l,des_q):\n\tbf=cv2.BFMatcher(cv2.NORM_L2,crossCheck=True)\n\tmatches=bf.match(des_l,des_q)\n\tmatches = sorted(matches,k...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def main(): date_column = 'date of last vet visit' target = 'age at death' export_file_dir = './output/' export_model_dir = './model/xgb_model.dat' import_ = Import() print( """ To predict how lon...
flexible
{ "blob_id": "696b9db78cc7f6002eb39b640e0e5b2b53e52e91", "index": 8448, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n date_column = 'date of last vet visit'\n target = 'age at death'\n export_file_dir = './output/'\n export_model_dir = './model/xgb_model.dat'\n import_ = ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if alien_color == 'green': print('you earned 5 points') <|reserved_special_token_0|> if alien_color2 == 'green': print('your earned 5 points') if alien_color2 == 'yellow': print('Right answer') <|reserved_special_token...
flexible
{ "blob_id": "30e4c4c5ef944b0cd2d36b2fe5f7eee39dff1d16", "index": 6511, "step-1": "<mask token>\n", "step-2": "<mask token>\nif alien_color == 'green':\n print('you earned 5 points')\n<mask token>\nif alien_color2 == 'green':\n print('your earned 5 points')\nif alien_color2 == 'yellow':\n print('Right ...
[ 0, 1, 2, 3 ]
from rest_framework import viewsets from recruitment.serializers.LocationSerializer import LocationSerializer from recruitment.models.Location import Location import django_filters class LocationViewSet(viewsets.ModelViewSet): queryset = Location.objects.all().filter(deleted=0) serializer_class = LocationSer...
normal
{ "blob_id": "aef45cb8ea9fcaeffcca147da7637536bcc4b226", "index": 6217, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LocationViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LocationViewSet(viewsets.ModelViewSet):\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def adding(user_list): sumnum = 0 for item in user_list: sumnum += item return sumnum def subtraction(user_list): subtractnum = user_list[0] for item in user_list[1:]: subtractnum -= item return subtractnum def powering(user_list): pownum = ...
flexible
{ "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 ]
#!/usr/bin/env python3 # Written by jack @ nyi # Licensed under FreeBSD's 3 clause BSD license. see LICENSE '''This class calls the system's "ping" command and stores the results''' class sys_ping: '''this class is a python wrapper for UNIX system ping command, subclass ping does the work, last stores data from t...
normal
{ "blob_id": "44dee207ffa4f78293484126234a3b606e79915b", "index": 5056, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass sys_ping:\n <mask token>\n <mask token>\n\n\n class last:\n \"\"\"This class stores data from last sys_ping.ping()\"\"\"\n min_time, avg_time, max_time, m...
[ 0, 1, 2, 3, 4 ]
from kafka import KafkaConsumer import csv users = set() # returns string of title given a ConsumerRecord def parse_cr(cr): binary = cr.value string = binary.decode('utf-8') # [time, user id, GET request] return string.split(',') # returns string of title given a ConsumerRecord in name+name+year for...
normal
{ "blob_id": "374fbb986524f28cc86f6e579f504eeb8ddc9701", "index": 1122, "step-1": "<mask token>\n\n\ndef parse_cr(cr):\n binary = cr.value\n string = binary.decode('utf-8')\n return string.split(',')\n\n\ndef get_title(cr):\n get = parse_cr(cr)[2]\n head = get[5:9]\n if head == 'data':\n ...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> parser.read('sim.conf') print(parser.get('config', 'option1')) print(parser.get('config', 'option2')) print(parser.get('config', 'option3')) <|reserved_special_token_1|> <|reserved_special_token_0|> parser = configparser.Config...
flexible
{ "blob_id": "cf5ab10ce743aa261867501e93f498022e5908fe", "index": 7360, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.read('sim.conf')\nprint(parser.get('config', 'option1'))\nprint(parser.get('config', 'option2'))\nprint(parser.get('config', 'option3'))\n", "step-3": "<mask token>\nparser = con...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> @login_required def index(request): grup = request.user.grup birim = request.user.birim emirler = Emir.objects.filter(durum='Aktif') l = list() for e in emirler.values(): data = dict() data['is_emri'] = e['is_emri'] data['valfmontaj'] = Valf.obj...
flexible
{ "blob_id": "74dd9151195fef41862c2793621172518f1f486d", "index": 5248, "step-1": "<mask token>\n\n\n@login_required\ndef index(request):\n grup = request.user.grup\n birim = request.user.birim\n emirler = Emir.objects.filter(durum='Aktif')\n l = list()\n for e in emirler.values():\n data = ...
[ 10, 25, 26, 33, 35 ]
from classifier import classifier from get_input_args import get_input_args from os import listdir #!/usr/bin/env python3 # -*- coding: utf-8 -*- # */AIPND-revision/intropyproject-classify-pet-images/calculates_results_stats_hints.py # # PRO...
normal
{ "blob_id": "f96c9753f3cbb0e554f9f05591e23943009c8955", "index": 2371, "step-1": "<mask token>\n\n\ndef calculates_results_stats(results_dic):\n \"\"\"\n Calculates statistics of the results of the program run using classifier's model \n architecture to classifying pet images. Then puts the results stat...
[ 3, 4, 7, 8, 9 ]
""" 《Engineering a Compiler》 即《编译器设计第二版》 https://www.clear.rice.edu/comp412/ """ # 《parsing-techniques》 讲前端 ## http://parsing-techniques.duguying.net/ebook/2/1/3.html """ 前端看Parsing Techniques,后端看鲸书,都是最好的。 """ # 《essential of programming language》 # sicp """ 如果对编程语言设计方面感兴趣,想对编程语言和编译器设计有大概的概念,可以看看PLP。 想快速实践可以看《自制脚本语...
normal
{ "blob_id": "5663ded291405bcf0d410041485487bb17560223", "index": 3106, "step-1": "<mask token>\n", "step-2": "\n\"\"\"\n《Engineering a Compiler》\n即《编译器设计第二版》\nhttps://www.clear.rice.edu/comp412/\n\"\"\"\n# 《parsing-techniques》 讲前端\n## http://parsing-techniques.duguying.net/ebook/2/1/3.html\n\n\"\"\"\n前端看Parsin...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> seed(1) <|reserved_special_token_0|> set_random_seed(2) print('\x1b[91m Lectura de datos \x1b[0m') <|reserved_special_token_0|> model.add(Conv1D(64, 32, input_shape=(x_train.shape[1], 1), activation='elu')) model.add(Flatten()) mo...
flexible
{ "blob_id": "bfb52a5ee6d88d63c4ef89dae26bb8cbecb091c6", "index": 4200, "step-1": "<mask token>\n", "step-2": "<mask token>\nseed(1)\n<mask token>\nset_random_seed(2)\nprint('\\x1b[91m Lectura de datos \\x1b[0m')\n<mask token>\nmodel.add(Conv1D(64, 32, input_shape=(x_train.shape[1], 1), activation='elu'))\nmode...
[ 0, 1, 2, 3, 4 ]
#' % Computational Biology Lab 3 #' % Alois Klink #' % 18 May 2017 #' # Converting Reaction Equations to a ODE #' To convert many reaction equations to one ODE, one must first find the propensity #' and the changes of each reaction. #' The Reaction class takes a lambda function of the propensity and the change matri...
normal
{ "blob_id": "87a1624707e4a113a35d975518e432277c851e41", "index": 9962, "step-1": "<mask token>\n", "step-2": "<mask token>\nsystem.trajectories()\n<mask token>\nprint('r is ' + str(r))\nsystem.gillespieConcentrations(50000 * r)\nsystem.gillespieTrajectories([[0, 0], [4, 23]], 10000 * r)\n<mask token>\nsystem.g...
[ 0, 1, 2, 3, 4 ]
from flask import Blueprint, current_app logging = Blueprint("logging", __name__) @logging.route("/debug/") def debug(): current_app.logger.debug("some debug message") return "" @logging.route("/warning/") def warning(): current_app.logger.warning("some warning message") return "" @logging.ro...
normal
{ "blob_id": "7c2d57a8368eb8d1699364c60e98766e66f01569", "index": 4659, "step-1": "<mask token>\n\n\n@logging.route('/debug/')\ndef debug():\n current_app.logger.debug('some debug message')\n return ''\n\n\n<mask token>\n\n\n@logging.route('/error/')\ndef error():\n current_app.logger.error('some error m...
[ 2, 3, 4, 5, 6 ]
from django.contrib import admin from .models import User, UserProfile, Lead, Agent, Category admin.site.register(User) admin.site.register(UserProfile) admin.site.register(Lead) admin.site.register(Agent) admin.site.register(Category)
normal
{ "blob_id": "55d184a9342b40fe027913e46933325bb00e33a6", "index": 5386, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(User)\nadmin.site.register(UserProfile)\nadmin.site.register(Lead)\nadmin.site.register(Agent)\nadmin.site.register(Category)\n", "step-3": "from django.contrib impo...
[ 0, 1, 2 ]
from day19.rules import Rule, CharacterMatch, OrRule, ListRule def parse_rule(rules: dict, rule_str: str=None) ->Rule: if rule_str is None: rule_str: str = rules[0] if '"' in rule_str: return CharacterMatch(rule_str.strip('"')) elif '|' in rule_str: or_rules = [parse_rule(rules, pa...
normal
{ "blob_id": "4d4f7db6d5b4ed7eac3ced73aca76d3c952c84f4", "index": 1456, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_rule(rules: dict, rule_str: str=None) ->Rule:\n if rule_str is None:\n rule_str: str = rules[0]\n if '\"' in rule_str:\n return CharacterMatch(rule_str.s...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def need_owner(view_func): def _wrapped_view(request, *args, **kwargs): rc = request.rc rc.project = q_get(Project, name=kwargs['name'], status=consts. PROJECT_ENABLE) rc.project_name = kwargs['name'] if rc.project == None: rais...
flexible
{ "blob_id": "bacd0c729193f064b21ab8e01e98dfc276094458", "index": 7853, "step-1": "<mask token>\n\n\ndef need_owner(view_func):\n\n def _wrapped_view(request, *args, **kwargs):\n rc = request.rc\n rc.project = q_get(Project, name=kwargs['name'], status=consts.\n PROJECT_ENABLE)\n ...
[ 7, 14, 16, 17, 18 ]
<|reserved_special_token_0|> class UserNotAllowedError(Exception): """Raised when the user is recognized but forbidden from entering.""" class _Credentials(object): email = None security_token_is_stale = False <|reserved_special_token_0|> def _parse_security_token(token): """Parse a CHIRP securi...
flexible
{ "blob_id": "d077f32061b87a4bfd6a0ac226730957a4000804", "index": 5859, "step-1": "<mask token>\n\n\nclass UserNotAllowedError(Exception):\n \"\"\"Raised when the user is recognized but forbidden from entering.\"\"\"\n\n\nclass _Credentials(object):\n email = None\n security_token_is_stale = False\n\n\n<...
[ 10, 11, 12, 13, 16 ]
<|reserved_special_token_0|> def calculates_results_stats(results_dic): """ Calculates statistics of the results of the program run using classifier's model architecture to classifying pet images. Then puts the results statistics in a dictionary (results_stats_dic) so that it's returned for printing...
flexible
{ "blob_id": "f96c9753f3cbb0e554f9f05591e23943009c8955", "index": 2371, "step-1": "<mask token>\n\n\ndef calculates_results_stats(results_dic):\n \"\"\"\n Calculates statistics of the results of the program run using classifier's model \n architecture to classifying pet images. Then puts the results stat...
[ 3, 4, 7, 8, 9 ]
import subprocess import datetime def ping_address(host,n): ping = subprocess.Popen( ["ping","-c",str(n),host], stdout = subprocess.PIPE, stderr = subprocess.PIPE) out,error = ping.communicate() return out, error def ping_address_windows(host,n): ping = subprocess.Popen( ["...
normal
{ "blob_id": "3f2221f5f3a699020dd5986acb793e3083976dff", "index": 7176, "step-1": "<mask token>\n\n\ndef parse_msg(msg):\n line_org = msg.split('\\n')\n N = len(line_org) - 2\n line = line_org[N]\n return line\n\n\ndef get_vals(msg):\n rhs = msg.split('=')\n try:\n nums = rhs[1].split('/'...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> @workflow_class class FlyteDJOLoadTestWorkflow(object): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @workflow_class class FlyteDJOLoadTestWorkflow(object): tasks_count = Input(Types.Integer) dj = ...
flexible
{ "blob_id": "c30b0db220bdacd31ab23aa1227ce88affb79daa", "index": 2322, "step-1": "<mask token>\n\n\n@workflow_class\nclass FlyteDJOLoadTestWorkflow(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\n@workflow_class\nclass FlyteDJOLoadTestWorkflow(object):\n tasks_count = Input(Typ...
[ 1, 2, 4, 5, 6 ]
# Author: Cristian Steib # # # -*- encoding: utf-8 -*- import pilasengine class consoleColors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' class BotonComando(): ''' ...
normal
{ "blob_id": "266b8958b761ee7266a8098aeaecb8b6c2a24a2a", "index": 1757, "step-1": "<mask token>\n\n\nclass BotonComando:\n <mask token>\n\n def __init__(self, *args, **kwargs):\n self.pilas = args[0] if len(args) and type(args[0]\n ) is pilasengine.Pilas else kwargs['pilas'] if kwargs.get(...
[ 10, 12, 13, 14, 19 ]
# Required python libraries for attack.py import socket import os import sys from termcolor import colored import StringIO import time # need to find Python equivalent libraries for these import stdio import stdlib import unistd # need to find Python equivalent libraries for these import includes import killer impor...
normal
{ "blob_id": "6d25b0fedf0d5081a3a0a93ddacc49748464d9d0", "index": 405, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef checksum_tcp_udp(ip_header, buffer_name, data_length, lenth):\n return sum_checksum_tcp_udp\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef checksum_tcp_udp(ip_header, ...
[ 0, 1, 2, 3, 4 ]
import datetime def days_count(year, month, hour): point = datetime.datetime(year, month, hour, 0, 0, 0, 000000) now = datetime.datetime.now() interval_day = point - now return interval_day.days messages = { '猫钰钰 五月有砖搬': '距离 猫钰钰 上岗还有 {} 天'.format(days_count(2019, 6, 1)), # 6.1 上岗 'AD Zh': '...
normal
{ "blob_id": "82ce6304977d468945526824ade1500e10d25d09", "index": 2872, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef days_count(year, month, hour):\n point = datetime.datetime(year, month, hour, 0, 0, 0, 0)\n now = datetime.datetime.now()\n interval_day = point - now\n return interva...
[ 0, 1, 2, 3, 4 ]
# aylat # This program will calculate an individual's body mass index (BMI), # based on their height and their weight # Prompt user to input information Name = input('Enter your full name: ') Weight = float(input('Enter your weight in pounds: ')) Height = float(input('Enter your height in inches: ')) # Perform BMI ...
normal
{ "blob_id": "8b009451e9f65ef12e5db1321a9d5347ef7fd756", "index": 9593, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('\\n')\nif BMI < 18.5:\n print(Name, ', your BMI calculation is ', format(BMI, '.1f'),\n ', which indicates your weight category is underweight.', sep='')\nelif BMI < 24.9...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> for i in range(0, 20): if i % 20 == 0: print('Stop It') else: print('The For Loop Failed')
flexible
{ "blob_id": "bfb2d7b811fd450b53493375fa130649349d308f", "index": 174, "step-1": "<mask token>\n", "step-2": "for i in range(0, 20):\n if i % 20 == 0:\n print('Stop It')\nelse:\n print('The For Loop Failed')\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] ...
[ 0, 1 ]
# Generated by Django 3.1 on 2020-09-09 15:58 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('orders', '0001_initial'), ] operations = [ migrations.RenameField( model_name='orderproduct', old_name='products', ...
normal
{ "blob_id": "0e73153d004137d374637abf70faffabf0bab1fb", "index": 9762, "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 = [('orders', '0...
[ 0, 1, 2, 3, 4 ]
import DB as db import os from Chart import Chart import matplotlib.pyplot as plt import numpy as np table = db.get_researcher_copy() chart_path = '../charts/discipline ' def get_discipline_with_more_female(): docs = table.aggregate([ {'$match':{'gender':{'$exists':1}}}, {'$unwind':'$labels'}, {'$group':{'_id'...
normal
{ "blob_id": "c585b1439217fff42945eeb9e02512d73f8ba19f", "index": 5805, "step-1": "<mask token>\n\n\ndef get_discipline_with_more_female():\n docs = table.aggregate([{'$match': {'gender': {'$exists': 1}}}, {\n '$unwind': '$labels'}, {'$group': {'_id': {'label': '$labels',\n 'gender': '$gender'}, ...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def index(request): notes = Note.objects.all().order_by('-created_at') context = {'notes': notes} return render(request, 'notes/index.html', context) def add(request): if request.method == 'POST': errors = Note.objects.validate(request.POST) if errors: ...
flexible
{ "blob_id": "e983db4b99e73929c02eb84fab1ee56138048052", "index": 8221, "step-1": "<mask token>\n\n\ndef index(request):\n notes = Note.objects.all().order_by('-created_at')\n context = {'notes': notes}\n return render(request, 'notes/index.html', context)\n\n\ndef add(request):\n if request.method ==...
[ 2, 3, 4, 5, 6 ]
casosteste = int(input()) for testes in range(casosteste): num_instru = int(input()) lista = [] for intru in range(num_instru): p = input().upper() if p == 'LEFT': lista.append(-1) elif p == 'RIGHT': lista.append(+1) elif p.startswith('SAME AS'): ...
normal
{ "blob_id": "a14a6c015ed3063015973b5376a1351a70808dc0", "index": 8420, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor testes in range(casosteste):\n num_instru = int(input())\n lista = []\n for intru in range(num_instru):\n p = input().upper()\n if p == 'LEFT':\n lis...
[ 0, 1, 2 ]
#!/usr/bin/python # -*- coding: utf-8 -*- from tp_global import * from cgibase import cgibase from tp_mongodb import * import json import requests class Ccase_model(cgibase): def __init__(self): return cgibase.__init__(self) def onInit(self): cgibase.SetNoCheckCookie(self) opr = cgiba...
normal
{ "blob_id": "5282e9a9e87fd7fd6053f816048f371fbe190046", "index": 5650, "step-1": "<mask token>\n\n\nclass Ccase_model(cgibase):\n\n def __init__(self):\n return cgibase.__init__(self)\n <mask token>\n\n def cmadd(self):\n self.log.debug('cmadd in.')\n req = self.input['input']\n ...
[ 6, 9, 10, 11, 13 ]
from datetime import datetime from unittest import mock import pytest from freezegun import freeze_time from datahub.ingestion.api.common import PipelineContext from src.datahub.ingestion.source.aws.s3_util import make_s3_urn FROZEN_TIME = "2020-04-14 07:00:00" @pytest.mark.integration def test_athena_config_query...
normal
{ "blob_id": "1304b6373edeca394070b8a3d144608cf07172e3", "index": 9448, "step-1": "<mask token>\n\n\n@pytest.mark.integration\ndef test_athena_config_query_location_old_plus_new_value_not_allowed():\n from datahub.ingestion.source.sql.athena import AthenaConfig\n with pytest.raises(ValueError):\n Ath...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def start_simulation(sumo, scenario, network, begin, end, interval, output): logging.debug('Finding unused port') unused_port_lock = UnusedPortLock() unused_port_lock.__enter__() remote_port = find_unused_port() logging.debug('Port %d was ...
flexible
{ "blob_id": "4775bef3623497e9bbe79ca2d4e9e9da0422c450", "index": 401, "step-1": "<mask token>\n", "step-2": "def start_simulation(sumo, scenario, network, begin, end, interval, output):\n logging.debug('Finding unused port')\n unused_port_lock = UnusedPortLock()\n unused_port_lock.__enter__()\n rem...
[ 0, 1, 2 ]
<|reserved_special_token_0|> def setLoggingFile(): """ This function will setup a logger and logfile """ try: dirPath = os.path.dirname(os.path.realpath(__file__)) dirFiles = os.listdir(dirPath) for itemNr in range(len(dirFiles)): nameOfFile = 'data0' + str(itemNr +...
flexible
{ "blob_id": "05e468c2f64e33d6b390f681314ed7961bd4def7", "index": 2684, "step-1": "<mask token>\n\n\ndef setLoggingFile():\n \"\"\"\n This function will setup a logger and logfile\n \"\"\"\n try:\n dirPath = os.path.dirname(os.path.realpath(__file__))\n dirFiles = os.listdir(dirPath)\n ...
[ 10, 12, 14, 15, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SearchConfig(AppConfig): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SearchConfig(AppConfig): name = 'search' verbose_name ...
flexible
{ "blob_id": "f47e4d6ff079b6ac2320467d87b34ae82face032", "index": 4506, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SearchConfig(AppConfig):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass SearchConfig(AppConfig):\n name = 'search'\n verbose_name = _('Search...
[ 0, 1, 2, 3, 4 ]
import os basedir = os.path.abspath(os.path.dirname(__file__)) class FlaskConfig(object): SECRET_KEY = os.environ.get('FLASK_SECRET_KEY') or 'TuLAsWbcoKr5YhDE' BOOTSTRAP_SERVE_LOCAL = os.environ.get('FLASK_BOOTSTRAP_SERVE_LOCAL') or True APPLICATION_ROOT = os.environ.get('FLASK_APPLICATION_ROOT') or '' ...
normal
{ "blob_id": "a0349abb3a56ff4bc1700dbf0fa5a1fc2e3453ce", "index": 6469, "step-1": "<mask token>\n\n\nclass FlaskConfig(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass FlaskConfig(object):\n SECRET_KEY = os.environ.get('FLASK_SECRET_KEY') or 'TuLAsWbcoKr5Y...
[ 1, 2, 3, 4, 5 ]
import numpy as np from ARA import * from State import * def theta_given_s(theta, q): """ Probability of an random event theta given current state s. Args: theta: Random event s = [q, r, w]: State Returns: Unnormalized probability of the random event. """ if q == 0: ...
normal
{ "blob_id": "87f3885b4357d66a745932f3c79804e6c15a57fa", "index": 3162, "step-1": "<mask token>\n\n\ndef new_w(w, d):\n \"\"\"\n Multi-period commitments in the next epoch.\n Args:\n d: Defender's actions\n m: Number of non multi-period commitments. (i.e. The first m defender's actions are ...
[ 3, 4, 5, 6, 7 ]
__author__ = 'jacek gruzewski' #!/user/bin/python3.4 """ To do: throw exceptions rather than calling sys.exit(1) """ ############################################################ # IMPORTS ############################################################ # Python's libraries import time import sys import logging imp...
normal
{ "blob_id": "dc928da92dc7e8a37a7f32dd4a579fd09b89eb01", "index": 4955, "step-1": "<mask token>\n\n\ndef swap_dns(live_alias, future_value, alias_dns_name, zone, records):\n \"\"\"\n :description: Changes alias (blue.<domain> or green.<domain>) that is behind live url.\n :param\n live_alias: Your ...
[ 1, 10, 14, 15, 23 ]
# !/usr/bin/env python # -*- coding:utf-8 -*- # Author: sx import string def reverse(text): """将字符串翻转""" return text[::-1] def is_palindrome(text): print(e for e in text if e.isalnum()) # 去掉标点空格 m = ''.join(e for e in text if e.isalnum()) print(m) """是否是回文数""" return m == revers...
normal
{ "blob_id": "03a1f9f533f7550db32fa25578ef2f7f4c741510", "index": 8583, "step-1": "<mask token>\n\n\ndef reverse(text):\n \"\"\"将字符串翻转\"\"\"\n return text[::-1]\n\n\ndef is_palindrome(text):\n print(e for e in text if e.isalnum())\n m = ''.join(e for e in text if e.isalnum())\n print(m)\n \"\"\"...
[ 2, 3, 4, 5, 6 ]
from __future__ import unicode_literals import abc import logging import six import semantic_version from lymph.utils import observables, hash_id from lymph.core.versioning import compatible, serialize_version logger = logging.getLogger(__name__) # Event types propagated by Service when instances change. ADDED = '...
normal
{ "blob_id": "ba41f2a564f46032dbf72f7d17b2ea6deaa81b10", "index": 4332, "step-1": "<mask token>\n\n\nclass Service(InstanceSet):\n <mask token>\n\n def __str__(self):\n return self.name\n\n def __iter__(self):\n return six.itervalues(self.instances)\n\n def __len__(self):\n return...
[ 12, 18, 20, 22, 26 ]
from django.shortcuts import render from django.contrib import messages from django.contrib.auth import logout from django.contrib.auth.decorators import login_required # Create your views here. # def login(request): # return render(request, 'login.html') # def validar_login(request): # usuario= request.POST['...
normal
{ "blob_id": "08712e050bd90408ed9d22bba9f62fafacd64d99", "index": 9671, "step-1": "<mask token>\n\n\n@login_required\ndef Lojanisima(request):\n return render(request, 'lojanisima/ruta_lojanisima.html')\n\n\n@login_required\ndef Identiarte(request):\n return render(request, 'identiarte/ruta_identiarte.html'...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class BoletoGerenciaNetConfig(AppConfig): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class BoletoGerenciaNetConfig(AppConfig): name = 'boletogerencianet' <|reserved_spec...
flexible
{ "blob_id": "c2069113f322c97e953fba6b9d21b90a8b13a066", "index": 2308, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BoletoGerenciaNetConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass BoletoGerenciaNetConfig(AppConfig):\n name = 'boletogerencianet'\n", "step-4"...
[ 0, 1, 2, 3 ]